title: Python - Numpy : 3D matrix * 2D vector fast calculation
body: <p>Hello everyone,</p>
  
  <p>Here is what I want to do. I've got two arrays :</p>
  
  <ul>
  <li><em>rotation_matrices</em> that contains 50 two dimensional rotation matrices. Each rotation matrix is shaped as (2,2). Thus, <em>rotation_matrices</em> is shaped as (2,2,50).</li>
  <li><em>vectors</em> that contains 50 two dimensional vectors. Thus, it is shaped as (2,50).</li>
  </ul>
  
  <p>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 <i>rotated_vectors</i>. What I mean is that the k-ith element of <i>rotated_vectors</i> contains the product of the k-ith rotation matrix with the k-ith vector.</p>
  
  <p>For the moment, I have come up with the loop that follows :</p>
  
  <pre><code>for ind,elt in enumerate(np.arange(nb_of_vectors)):
              rotated_vector[ind] = np.dot( rotation_matrices[:,:,ind], vectors[:,ind] )
  </code></pre>
  
  <p>I think there is room for improvement. If you have any suggestion, you are welcome.</p>
  
  <p>Thank you for your time.</p>
  
  <p>Jagaral</p>