[Numpy-discussion] How to remove fortran-like loops with numpy?

David Goldsmith d_l_goldsmith at yahoo.com
Mon Jun 8 19:01:41 EDT 2009


--- On Mon, 6/8/09, Anne Archibald <peridot.faceted at gmail.com> wrote:

> > You can't, really. What you can do is just keep
> iterating with the
> > whole data set and ignore the parts that have already
> converged. Here
> > is an example:
> 
> Well, yes and no. This is only worth doing if the number of
> problem
> points that require many iterations is small - not the case
> here
> without some sort of periodicity detection - but you can
> keep an array
> of not-yet-converged points, which you iterate. When some
> converge,
> you store them in a results array (with fancy indexing) and
> remove
> them from your still-converging array.

Thanks, Anne.  This is the way I had anticipated implementing it myself eventually, but the "fancy-indexing" requirement has caused me to keep postponing it, waiting for some time when I'll have a hefty block of time to figure it out and then, inevitably, debug it. :(  Also, the transfer of points from un-converged to converged - when that's a large number, might that not be a large time-suck compared to Rob's method?  (Too bad this wasn't posted a couple weeks ago: I'd've had time then to implement your method and "race" it against Rob's, but alas, now I have this doc editing job...but that's a good thing, as my fractals are not yet making me any real money.) :-) 

> It's also worth remembering that the overhead of for loops
> is large
> but not enormous, so you can often remove only the inner
> for loop, in
> this case perhaps iterating over the image a line at a
> time.

Yes, definitely well worth remembering - thanks for reminding us!

Thanks again,

DG

> 
> Anne
> 



      



More information about the NumPy-Discussion mailing list