On Wed, Apr 29, 2009 at 16:19, Dan Goodman <dg.gm...@thesamovar.net> wrote: > Robert Kern wrote: >> On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett <daniel.yarl...@gmail.com> >> wrote: >> >>> As you can see, Current is different in the two cases. Any ideas how I >>> can recreate the behavior of the iterative process in a more numpy- >>> friendly, vectorized (and hopefully quicker) way? >> >> Use bincount(). > > Neat. Is there a memory efficient way of doing it if the indices are > very large but there aren't many of them? e.g. if the indices were > I=[10000, 20000] then bincount would create a gigantic array of 20000 > elements for just two addition operations!
indices -= indices.min() -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion