[Numpy-discussion] Easy way to vectorize a loop?
Mon Mar 2 00:58:27 CST 2009
On Mon, Mar 2, 2009 at 00:50, Stephen Simmons <email@example.com> wrote:
> 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] = vals
"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
More information about the Numpy-discussion