MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

I am posting the problem once more

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110876] I am posting the problem once more
  • From: pratip <pratip.chakraborty at gmail.com>
  • Date: Sat, 10 Jul 2010 03:58:43 -0400 (EDT)

Dear Group,

Here is a simple code to solve linear systems. It is motivated from
Fullerton University numerics example. Now if someone can suggest how
to parallelize this code.

SORmethod[A0_, B0_, P0_, omega_, max_] :=
 Module[{A = N[A0], B = N[B0], i, j, k = 0, n = Length[P0], P = P0,
   oldP = P0},
  While[ k < max,
   Do[P[[i]] = (1 - omega) oldP[[i]] +
      omega/A[[i,
        i]] (B[[i]] - Sum[A[[i, j]] P[[j]], {j, 1, i - 1}] -
         Sum[A[[i, j]] oldP[[j]], {j, 1 + i, n}]) , {i, 1, n}];
   oldP = P;
   k = k + 1; ];
  Return[P] ]

To test the solver.

n = 10;
A = DiagonalMatrix[Table[2., {n}]];
For[i = 1, i <= n - 1, i++,
  A[[i, i + 1]] = A[[i + 1, i]] = 1.;];
B = Table[5. - Abs[i - 5], {i, 1, n}];
P = Table[1., {i, n}];
 X3 = SORmethod[A, B, P, 1.5, 200] // Chop

Check the above result with Mathematica LinearSolve

LinearSolve[A, B] // N

Straightforward ParallelDo or ParallelSum is not working. One can see
for large n (abt 400-14000) we will significantly get help if we can
parallize the code.

Best regards,

Pratip


  • Prev by Date: Re: image is not graphics
  • Next by Date: Re: replacement x->y except in Exp[x]
  • Previous by thread: Quantum Factorization Shor Algorithm in Mathematica
  • Next by thread: Re: Any idea how to parallelize this small code