On Sun, Sep 28, 2008 at 4:15 PM, Geoffrey Irving <[EMAIL PROTECTED]> wrote:
>
> Thanks.  That works great.  A slightly cleaner version is
>
>    X += coo_matrix((Y, (K, zeros_like(K)))).sum(axis=1)
>
> The next question is: is there a similar way that generalizes to the
> case where X is n by 3 and Y is m by 3 (besides the obvious loop over
> range(3), that is)?
>

You could flatten the arrays and make a single matrix that implemented
the operation.  I'd stick with the loop over range(3) though, it's
more readable and likely to be as fast or faster than flattening the
arrays yourself.

-- 
Nathan Bell [EMAIL PROTECTED]
http://graphics.cs.uiuc.edu/~wnbell/
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to