[Numpy-discussion] Any idea to run the dot-product on many arrays

Pascal pascal22p at parois.net
Thu Jan 13 11:13:24 EST 2011

On 01/13/2011 05:04 PM, EMMEL Thomas wrote:
> Hi,
> I need to rotate many vectors (x,y,z) with a given rotation matrix (3x3).
> I can always do
> for v in vectors:
>     tv += np.dot(mat, v)
> where mat is my fixed matrix (or array of arrays) and v is a single array.
> Is there any efficient way to use an array of vectors to do the 
> transfomation
> for all of these vectors at once?

numpy.dot(rotationmatrix , coordinates.T).T

Where coordinates is a n*3 matrix of n stacked vectors in rows. It works 
with vectors stacked in column without the the two transpose.

It's even possible to apply a symmetry operation to a bunch of second 
rank tensors in one go.


More information about the NumPy-Discussion mailing list