[Numpy-discussion] PutSum?

Robert Kern robert.kern at gmail.com
Fri Jun 11 23:08:24 EDT 2010


On Fri, Jun 11, 2010 at 22:06,  <jordan at math.ucsb.edu> wrote:
> Hi all,
>
> I recently needed to a simple array procedure that I assumed would be
> supported (and almost is) but was surprised to find some limitations.
>
> I've got two arrays, A and B, and some array of indices, I, and I want to
> perform the operation
>
> A[I] += B
>
> where I and B have the same dimensions.
>
> This works fine provided there are no repeated indices in I, but otherwise
> only the last of each repeated index is used. I've written a C function I
> call PutSum that does what I want, but I figured there must something
> already lying around. Is there?

numpy.bincount()

-- 
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



More information about the NumPy-Discussion mailing list