Hello everyone,
Here is what I want to do. I've got two arrays :
- rotation_matrices that contains 50 two dimensional rotation matrices. Each rotation matrix is shaped as (2,2). Thus, rotation_matrices is shaped as (2,2,50).
- vectors that contains 50 two dimensional vectors. Thus, it is shaped as (2,50).
I want (if it exists) a one-line numpy operation that gives me the (2,50) array that contains the rotated vectors, let's call it rotated_vectors. What I mean is that the k-ith element of rotated_vectors contains the product of the k-ith rotation matrix with the k-ith vector.
For the moment, I have come up with the loop that follows :
for ind,elt in enumerate(np.arange(nb_of_vectors)):
rotated_vector[ind] = np.dot( rotation_matrices[:,:,ind], vectors[:,ind] )
I think there is room for improvement. If you have any suggestion, you are welcome.
Thank you for your time.
Jagaral