Skip to main content
added 48 characters in body
Source Link
matheorem
  • 17.7k
  • 8
  • 53
  • 121

ParallelMap method has an apparent downside, that is it will eliminate the parameter names.

from this line of code

ParallelMap[f, Tuples[{Range[0,59], Range[1,10]}]] 

you won't know directly the meaning of first Range and second Range

But with the latest powerful feature of Inactivate and Activate of Mathematica 10.

We could improve this using the following code

ParallelMap[Activate,Flatten@Table[Inactivate@f[x, y], {y, 0, 59 }, {x, 1, 10 }] 

I think is more clear than Szabolcs's ParallelMap approach.

and you could also define a function

Clear[finestParallelTable] SetAttributes[finestParallelTable,HoldAll] finestParallelTable[expr_,parameter__]:= ParallelMap[Activate,Flatten@Table[Inactivate@expr,parameter]] 

Now

finestParallelTable[f[x, y], {y, 0, 59 }, {x, 1, 10 }] 

Looks exactly the same as the original ParallelTable.

Finally, of course the result is a flat list, you could reshape it later or directly add the reshape feature into the function finestParallelTable

ParallelMap method has an apparent downside, that is it will eliminate the parameter names.

from this line of code

ParallelMap[f, Tuples[{Range[0,59], Range[1,10]}]] 

you won't know directly the meaning of first Range and second Range

But with the latest powerful feature of Inactivate and Activate of Mathematica 10.

We could improve this using the following code

ParallelMap[Activate,Flatten@Table[Inactivate@f[x, y], {y, 0, 59 }, {x, 1, 10 }] 

I think is more clear than Szabolcs's ParallelMap approach.

and you could also define a function

Clear[finestParallelTable] finestParallelTable[expr_,parameter__]:= ParallelMap[Activate,Flatten@Table[Inactivate@expr,parameter]] 

Now

finestParallelTable[f[x, y], {y, 0, 59 }, {x, 1, 10 }] 

Looks exactly the same as the original ParallelTable.

Finally, of course the result is a flat list, you could reshape it later or directly add the reshape feature into the function finestParallelTable

ParallelMap method has an apparent downside, that is it will eliminate the parameter names.

from this line of code

ParallelMap[f, Tuples[{Range[0,59], Range[1,10]}]] 

you won't know directly the meaning of first Range and second Range

But with the latest powerful feature of Inactivate and Activate of Mathematica 10.

We could improve this using the following code

ParallelMap[Activate,Flatten@Table[Inactivate@f[x, y], {y, 0, 59 }, {x, 1, 10 }] 

I think is more clear than Szabolcs's ParallelMap approach.

and you could also define a function

Clear[finestParallelTable] SetAttributes[finestParallelTable,HoldAll] finestParallelTable[expr_,parameter__]:= ParallelMap[Activate,Flatten@Table[Inactivate@expr,parameter]] 

Now

finestParallelTable[f[x, y], {y, 0, 59 }, {x, 1, 10 }] 

Looks exactly the same as the original ParallelTable.

Finally, of course the result is a flat list, you could reshape it later or directly add the reshape feature into the function finestParallelTable

Source Link
matheorem
  • 17.7k
  • 8
  • 53
  • 121

ParallelMap method has an apparent downside, that is it will eliminate the parameter names.

from this line of code

ParallelMap[f, Tuples[{Range[0,59], Range[1,10]}]] 

you won't know directly the meaning of first Range and second Range

But with the latest powerful feature of Inactivate and Activate of Mathematica 10.

We could improve this using the following code

ParallelMap[Activate,Flatten@Table[Inactivate@f[x, y], {y, 0, 59 }, {x, 1, 10 }] 

I think is more clear than Szabolcs's ParallelMap approach.

and you could also define a function

Clear[finestParallelTable] finestParallelTable[expr_,parameter__]:= ParallelMap[Activate,Flatten@Table[Inactivate@expr,parameter]] 

Now

finestParallelTable[f[x, y], {y, 0, 59 }, {x, 1, 10 }] 

Looks exactly the same as the original ParallelTable.

Finally, of course the result is a flat list, you could reshape it later or directly add the reshape feature into the function finestParallelTable