<div>Hello, </div><div><br></div><div>If you increment an array using advanced indexing and have repeated indexes, the array doesn't get repeatedly incremented, <a href="http://comments.gmane.org/gmane.comp.python.numeric.general/50291">http://comments.gmane.org/gmane.comp.python.numeric.general/50291</a>. I wrote a C function that does incrementing with repeated indexes correctly. The branch is here (<a href="https://github.com/jsalvatier/numpy">https://github.com/jsalvatier/numpy</a> see the last two commits). Would a patch with a cleaned up version of a function like this be accepted into numpy? I'm not experienced writing numpy C code so I'm sure it still needs improvement.</div>
<div><br></div><div>If you compile and install that branch, you can test the code using: </div><div><br></div><div><div>from numpy import * </div><div>from numpy.core.multiarray import index_increment</div><div><br></div>
<div>a = arange(12).reshape((3,4))</div><div>index = ([1,1,2,0], [0,0,2,3])</div><div>vals = [50,50., 30.,16]</div><div><br></div><div>b = index_increment(a, index, vals)</div><div><br></div><div>print b</div></div><div><br>
</div><div>"""</div><div>should print out:</div><div> [[   0.    1.    2.   19.]</div><div> [ 104.    5.    6.    7.]</div><div> [   8.    9.   40.   11.]]</div><div>"""</div><div><br></div><div>
Cheers,</div><div>John</div><div><br></div><div><br></div>