[Numpy-discussion] Numpy-discussion Digest, Vol 33, Issue 59
David Goldsmith
d_l_goldsmith@yahoo....
Wed Jun 10 12:55:58 CDT 2009
--- On Wed, 6/10/09, Juanjo Gomez Navarro <juanjo.gomeznavarro@gmail.com> wrote:
> The speed at which some points tend to infinite is huge.
> Some points, after 10 steps, reach a NaN. This is not
> problem in my Mac Book, but in the PC the speed is really
> poor when some infinities are reached (in the mac, the
> program takes 3 seconds to run, meanwhile in the PC it takes
> more than 1 minute). In order to solve this, I have added a
> line to set to 0 the points who have reached 2.0 (so they
> are already out of the Mandelbrot set):
Yeah, of course something like that should've been in the original code.
> On the other hand, the number of calculations that
> really need to be done (of points who have not yet
> been excluded from the Mandelbrot set) decreases rapidly. In
> the beginning, there are, in a given example, 250000 points,
> but in the final steps there are only 60000. Nevertheless,
> I'm calculating needlessly the 250000 points all
> the time, when only 10% of calculations should need to be
> done! It is a waste of time.
>
> Is there any way to save time in these useless
> calculations? The idea should be to perform the update of z
> only if certain conditions are met, in this case that
> abs(z)<2.
To do that you'd need to use the "fancy indexing" approach suggested by Anne, but of course, as Robert emphasized, figuring out the details of that implementation is much harder. I think the main thing to take away from all this (unless fractals, or an analogous algorithm, is what your ultimate goal is) is the use of implied for loops in the indexing as the Python replacement for explicit for loops in C and FORTRAN. This may be a tough adjustment at first if you've never encountered it in another context. (I'd venture to guess that many (most?) numpy users first encountered it in matlab, idl, Splus, or something like that, and thus came to numpy already familiar w/ the approach; in other words, numpy didn't invent this approach, it has a pretty long history.) Can anyone point Juanjo directly to that portion of a tutorial which goes over this?
DG
>
> Thanks.
>
>
> 2009/6/9 <numpy-discussion-request@scipy.org>
>
> ttp://mentat.za.net/numpy/intro/intro.html
>
>
>
> We never used it, but I still like the pretty pictures :-)
>
>
>
> Cheers
>
> St?fan
>
> --
> Juan José Gómez Navarro
>
> Edificio CIOyN, Campus de Espinardo, 30100
> Departamento de Física
> Universidad de Murcia
> Tfno. (+34) 968 398552
>
> Email: juanjo.gomeznavarro@gmail.com
>
> Web: http://ciclon.inf.um.es/Inicio.html
>
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the Numpy-discussion
mailing list