1
$\begingroup$

My code contains the structure

Table[....,Table[....,{m1,1,N}],{m2,1,M}]

and I would like to use ParallelTable to improve timing. Empirically, I know that ParallelTable[...ParallelTable[...,{}],{}] does not work, so I use

ParallelTable[....,Table[....,{m1,1,N}],{m2,1,M}]

However, these two codes give different results and I do not know why.

$\endgroup$

1 Answer 1

2
$\begingroup$
i = 1;
Table[i++, {j, 1, 4}]

{1, 2, 3, 4}

h = 1;
ParallelTable[h++, {j, 1, 4}]

{1, 1, 1, 1}

$\endgroup$
1
  • $\begingroup$ SetSharedVariable[h], thx $\endgroup$ May 12, 2020 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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