[Numpy-discussion] Taking a large number of dot products at once

Sturla Molden sturla at molden.no
Fri Mar 4 09:01:49 EST 2011


Den 04.03.2011 14:55, skrev Sturla Molden:
>
> We can do this with Python lists of NumPy arrays as well, avoiding 
> stacking the arrays in a 2D structure:
>
>    [np.dot(u,v.T) for u,v in zip(U,V)]
>
  Damn it, bad style. Inner product, not outer...

    [np.dot(u.T,v) for u,v in zip(U,V)]

or just

    [np.dot(u,v) for u,v in zip(U,V)]

While it does not matter for 1D vectors, it would for rank 1 x n matrices.


Sturla


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110304/8e336d5c/attachment.html>


More information about the NumPy-Discussion mailing list