[Numpy-discussion] Sum of the product of three or more arrays
Fri Oct 19 14:48:41 CDT 2007
On 10/18/07, Robert Kern <firstname.lastname@example.org> wrote:
> Geoffrey Zhu wrote:
> > Hi All,
> > Given three vectors of the same lengths, X, Y, and Z, I am looking for
> > an efficient way to calculate the following:
> > sum(x[i]*y[i]*z[i], for i=1..n )
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless enigma
> that is made terrible by our own mad attempt to interpret it as though it had
> an underlying truth."
> -- Umberto Eco
> Numpy-discussion mailing list
(x*y*z).sum() is probably faster than sum(x*y*z).
More information about the Numpy-discussion