[Numpy-discussion] nested loops too slow
Wed Aug 8 08:47:15 CDT 2012
I'm trying to write a code for doing a 2D integral. It works well when
I'm doing it with normal "for" loops, but requires two nested loops,
and is much too slow for my application. I would like to know if it is
possible to do it faster, for example with fancy indexing and the use
of numpy.cumsum(). I couln't find a solution, do you have an idea ?
The code is the following :
'flux2' is the result of the calculation with 'for' loops
implementation, and 'flux' is supposed to be the same result without
the loop. If I managed to do it for the single loops (line 23 is
identical to lines 20-21, and line 30 is identical to line 27,28) and
don't know how to do for the nested loops lines 33-35 (line 40 does
not give the same result).
Any idea ?
More information about the NumPy-Discussion