Dear all, Can someone point me to a doc on dot product vectorisation ?
Here is what I try to do : I've got a rotation function which looks like : def rotat_scal(phi, V): s = math.sin(phi) c = math.cos(phi) M = np.zeros((3, 3)) M[2, 2] = M[1, 1] = c M[1, 2] = -s M[2, 1] = s M[0, 0] = 1 return np.dot(M, V) (where phi is a scalar, and V and array of size (3,1)) Now, I want to apply it to a time series of phi and V, in a vectorised way. So, I tried to simply add a first dimension : Phi is now of size(n) and V (n, 3). (I really whish to have this shape, for direct correspondance to file). The corresponding function looks like : def rotat_vect(phi, V): s = np.sin(phi) c = np.cos(phi) M = np.zeros((len(phi), 3, 3)) M[:, 2, 2] = M[:, 1, 1] = c M[:, 1, 2] = -s M[:, 2, 1] = s M[:, 0, 0] = np.ones (len(phi)) return np.dot(M, V) It was not really a surprise to see that it didn't work : > [...] > return np.dot(M, V) > ValueError: objects are not aligned Any hint ? Bruno.
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion