It might make sense to do this:
vector_arr = np.concatenate([vector[np.newaxis, :] for vector in vectors], axis=0)
rotated_vector_arr = np.dot(vector_arr, rotation_matrix)
Then the lines rotated_vector_arrare what you want. You can view all this as one matrix product and loop through the C / Fortran BLAS library.
There is no need to use the matrix () class for matrix multiplication, arrays work fine. matrix () overloads the * operator, but I find that it just confuses things.
source
share