[Numpy-discussion] vectorizing histogram-like computation
Perry Greenfield
perry at stsci.edu
Mon Jun 20 12:32:15 EDT 2005
On Jun 20, 2005, at 3:09 PM, Piotr Luszczek wrote:
> All,
>
> I apologize if this is a dupe. I haven't seen it where I looked.
>
> There is numarray.numeric.histogram and numarray.mlab.histogram.
> What they do is this (more or less):
>
> for idx in arr:
> histogram[idx] += 1
>
> What I want to do is:
>
> for idx in arr:
> result[idx] ^= value
>
> Doing:
>
> result[arr] ^= value
>
> doesn't work. Which is not surprising because:
>
> histogram[arr] += 1
>
> doesn't work either.
>
> My question is whether there is a way to do it (the XOR example)
> without using a for loop.
>
> Thanks,
>
> Piotr
Not that I'm aware of. It suggests that there may be a need to expand
on the histogram-like functionality to handle this sort of thing,
though I wonder how often it would be used.
Perry Greenfield
More information about the NumPy-Discussion
mailing list