On 17/04/2008, Zachary Pincus wrote:
>  But even if indices = array, one still needs to do something like:
>  for index in indices: histogram[index] += 1
>
>  Which is slow in python and fast in C.
>

I haven't tried this, but if you want the sum in C you could do

for x in unique(indices):
    histogram[x] = (indices==x).sum()

Of course, this just replaces an O(N log N) algorithm by an O(N * M)
(M is the number of bins), which is only going to be worth for very
small M.

Peter
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to