0

I am currently doing calculation with 7 parameters, each parameter set corresponding to a value. And I store the data in the format as a list of rule, like following

{{100, 7, 1, 1, 1, 1/5, 0} -> 0.00720852, {100, 7, 1, 2, 1, 1/5, 0} ->
   0.00456272, {100, 7, 1, 3, 1, 1/5, 0} -> 0.00363628, {100, 7, 1, 4, 1, 1/5, 0} -> 
  0.0034754, {100, 7, 1, 5, 1, 1/5, 0} ->0.00343746, {100, 7, 1, 6, 1, 1/5, 0} -> 
  0.00342957, {100, 7, 1, 7, 1, 1/5, 0} -> 0.0034},........}

I put all my calculated data into a single rule list, I name it generaldata

when I want to extract data from the generaldata used for plotting, I would write the following code for example

extractdata = Table[Table[{100, 7, line, distance, 1, 1/5, delta}, {line, 1, long + 1}, {distance, 1, 12}], {delta, 0, 1, 1/50}] /. generaldata

currently, my generaldata's length is 88000, and it took me 40 seconds to accomplish the rule replacement. It is quite slow. I also tried Parallel it

data = ParallelMap[Replace[#, generaldata] &, 
    Table[Table[{100, 7, line, distance, 1, 1/5, delta}, {line, 1, long + 1}, {distance, 1, 12}], {delta, 0, 1, 1/50}], {3}]; // AbsoluteTiming

and this took even longer about 200 seconds on an 8 core machine.

What's more, I only calculated a small part of the data I wanted. So I can foresee, if I don't improve the method, the time cost will be much more.

So I am asking here for a better quicker method.

matheorem
  • 17,132
  • 8
  • 45
  • 115

0 Answers0