I've the following problem I cannot solve.
I allocate an empty matrix, v, of size n x m. Then I want to do a Parallel loop (ex. ParallelDo), and do some operations (described by a function operation[j,y] of two arguements) that as a result gives a numerical output. I want to "store" the i-th output in the i-th element of the list.
If I use a Parallel loop with inside a For loop, there is no way to in fact store the output in the list, and at the end of the loop, v, is empty. If I do the same thing with a regular loop (ex. Do), then it works.
Here I report a generic expample:
v = Table[{}, {j, 1, m}, {i, 1, n}];
ParallelDo[For[j = 1, j < n+1, j++, v[[j,i]] = operation[j,i]], {i, 1, m}]
But in this case, no matter of what the operation function is, V is still an empty matrix. If I use Do, instead of ParallelDo, then it works.
All DistributeDefinitions and related stuff I think are taken care correctly.
Thanks!
Nis a Mathematica function and can't be used as a variable. Also, you have syntax errors: what isi? – bill s Jan 24 '14 at 21:51SetSharedVariable@V;ParallelDo[V[[x,y]] = operation[x,y]], {y, 1, Y},{x,1,X}]. Although this is probably really inefficient. – Ajasja Jan 24 '14 at 22:08