On Mon, Mar 2, 2009 at 00:50, Stephen Simmons <m...@stevesimmons.com> wrote: > Hi, > > Can anyone help me out with a simple way to vectorize this loop? > > # idx and vals are arrays with indexes and values used to update array data > # data = numpy.ndarray(shape=(100,100,100,100), dtype='f4') > flattened = data.ravel() > for i in range(len(vals)): > flattened[idx[i]]+=vals[i]
flattened[idx] = vals -- 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://projects.scipy.org/mailman/listinfo/numpy-discussion