[Numpy-discussion] nested loops too slow
Thu Aug 9 03:01:31 CDT 2012
Using for-loops for numerical calculations is often problematic for
numerical calculations. I don't understand the fancy stuff with the
indexing of the arrays. Can you provide a working example script
and/or a brief description of the calculation you are performing
(including equations)? How does the array look like?
On Wed, Aug 8, 2012 at 3:47 PM, nicolas aunai <email@example.com> wrote:
> 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 ?
> Thanks much
> NumPy-Discussion mailing list
More information about the NumPy-Discussion