# Using parallel computing to build a matrix recursively

I am trying to compute the product of a sequence of matrices using the command ParallelDo. Of course, if I use the simpler command Do, I am able to do the computation. In order to set my current problem, I've considered my Table of Matrices (with another less trivial values):

R = ParallelTable[i*IdentityMatrix[2], {i, 0, n}]


And now, I would like to compute something like:

g = IdentityMatrix[2];
Do[g = R[[i]].g, {i, 1, n}]


To reduce the computing time, I would like to use ParallelDo. Can someone help me please?

-
It's impossible because next iteration of Do depends on previous iteration – molekyla777 May 21 '14 at 7:41

Dot can be Parallelize'd, but it will be slower than a sequential evaluation unless the expression is quite large. For example:

ClearAll[n, R, g];
n = 4000;
R = ParallelTable[i*RandomInteger[100, {10, 10}], {i, n}];
Rg = Append[Riffle[R, g], g] /. g -> RandomInteger[100, {10, 10}];
CloseKernels[];
LaunchKernels[ks = 4];
ParallelTable[{$KernelID,$IterationLimit = \[Infinity]}, {ks}]

a = Dot @@ Rg // AbsoluteTiming;
a // First


19.081809

b = Parallelize[Dot @@ Rg] // AbsoluteTiming;
b // First


17.003070

-