[Numpy-discussion] nested loops too slow

nicolas aunai nicolas.aunai at gmail.com
Wed Aug 8 09:47:15 EDT 2012


Hi,

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 :


http://bpaste.net/show/cAkMBd3sUmhDXq0sIpZ5/


'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 ?


Thanks much
Nico



More information about the NumPy-Discussion mailing list