Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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}];
LaunchKernels[ks = 4];
ParallelTable[{$KernelID, $IterationLimit = \[Infinity]}, {ks}]

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


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


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.