Re: [Numpy-discussion] Advanced selection, duplicate indices, and augmented assignment

2007-01-06 Thread Robert Kern
Sean R. Lynch wrote: x = zeros((3,)) x[array([0, 1, 1])] += array([1, 1, 1]) x > array([ 1., 1., 0.]) > > If this worked the way I was hoping, the output would be [1 2 0] because > it would add to element 1 twice due to its duplication in the advanced > selection array. > > Is t

[Numpy-discussion] Advanced selection, duplicate indices, and augmented assignment

2007-01-06 Thread Sean R. Lynch
I have an array of vertices and an array of indices that make a list of triangles. I'd like to calculate the normals for each vertex as a (pseudo-)average of the normals of each triangle that contains it, so I get smooth lighting in OpenGL. I'd also like to avoid looping in Python because the verte