<br><br><div class="gmail_quote">On Tue, Jun 9, 2009 at 12:56 PM, bruno Piguet <span dir="ltr"><<a href="mailto:bruno.piguet@gmail.com">bruno.piguet@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Dear all,<br><br>   Can someone point me to a doc on dot product vectorisation ?<br><br>Here is what I try to do : <br><br>I've got a rotation function which looks like : <br><br>def rotat_scal(phi, V):<br>    s = math.sin(phi)<br>

    c = math.cos(phi)<br>    M = np.zeros((3, 3))<br>    M[2, 2] = M[1, 1] = c<br>    M[1, 2] = -s<br>    M[2, 1] = s<br>    M[0, 0] = 1<br>    return np.dot(M, V)<br><br>(where phi is a scalar, and V and array of size (3,1))<br>

<br>Now, I want to apply it to a time series of phi and V, in a vectorised way.<br>So, I tried to simply add a first dimension :<br>Phi is now of size(n) and V (n, 3).<br>(I really whish to have this shape, for direct correspondance to file).<br>

</blockquote><div><br>Well, in this case you can use complex multiplication and either work with just the x,y components or use two complex components, i.e., [x + 1j*y, z]. In the first case you can then do the rotation as V*exp(1j*phi). If you want more general rotations, a ufunc for quaternions would do the trick.<br>
<br>Chuck <br></div><br></div><br>