|
From: Graeme O'K. <gj...@ne...> - 2005-07-14 05:31:56
|
Hi, I know this really belongs on the sourceforge.net:numarray list, but it is a very inactive list. I have noted the following with numarray: >>> x = numarray.zeros([3,3], numarray.Int16) >>> i = [0,1,2,0,1,2] >>> j = [0,1,2,0,1,2] >>> x[i, j] += 1 >>> print x [[1, 0, 0] [0, 1, 0] [0, 0, 1]] I was expecting (hoping) [[2, 0, 0] [0, 2, 0] [0, 0, 2]] which is what you obviously get if you: for n in range(len(i)) : x[i[n], j[n]] += 1 This is the sort of operation one does all the time when histogramming data-streams. Is there a way to achieve this without looping over i/j. cheers, Graeme |