Question: Fastest way to apply a list of list of numbers to a function?

May 29 2014 teh_allchemist 35
Maple 17
1

Hi MaplePrimers,

I've written a function that needs to be evaluated at a bunch of different points.  Evaluating it in a loop works. I'm wondering if there was a faster way to do this because I'm evaluating a list of 400k+ sets of points.  

Right now I'm using a loop with the following code.

for i from 1 to 500000 do 
     Results(i):= f(L[i][])[1];
od;

 

If I have a function f, which has 5 arguements, f(y, w, x,y,z).

I also have a list of those arguements:  L = [[1,2,3,2,3],[4,5,6,2,3],[7,8,9,2,3]]

What would be the fastest way to get a list of results?  Also, is there a way that I could preallocate memory for this list?

Ideally, I would like to get the output as as list.  ie:

Results:= [[f(1,2,3,2,3)], [f(4,5,6,2,3)], [f(7,8,9,2,3)]]

 

Please Wait...