[Numpy-discussion] Fast vector multiplication
Mark Janikas
mjanikas at esri.com
Fri Jan 19 17:04:52 CST 2007
Doh!!! Nice call. Thanks for the input.
MJ
________________________________
From: numpy-discussion-bounces at scipy.org
[mailto:numpy-discussion-bounces at scipy.org] On Behalf Of Timothy
Hochberg
Sent: Friday, January 19, 2007 2:52 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] Fast vector multiplication
On 1/19/07, Mark Janikas <mjanikas at esri.com> wrote:
Hello all,
I am trying to figure out the most efficient way to get the sum of the
product of two vectors where id != id.
E.g.:
X = array([1,2,3])
Y = array([1,2,3])
Z = (1*2) + (1*3) + (2*1) + (2*3) + (3*1) + (3*2) = 22
I could obviously do this with loops, but I was wondering if there is a
version of multiply that could be used... or a form of vectorize. Any
ideas would be greatly appreciated.
Isn't this just equivalent to:
sum(X) * sum(Y) - dot(X, Y)
?
If so, I would just use that.
--
//=][=\\
tim.hochberg at ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070119/a97d9230/attachment.html
More information about the Numpy-discussion
mailing list