       Any idea how to parallelize this small code construct

• To: mathgroup at smc.vnet.net
• Subject: [mg110835] Any idea how to parallelize this small code construct
• From: pratip <pratip.chakraborty at gmail.com>
• Date: Thu, 8 Jul 2010 03:14:39 -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-4000) we will significantly get help if we can
parallize the code.

Best regards,

Pratip

```

• Prev by Date: Re: plot colored ellipsoid
• Next by Date: Displaying cylinders
• Previous by thread: Re: Pattern: x_List with conditions on elements
• Next by thread: Re: Any idea how to parallelize this small code construct