title: How to perform a stacked/element-wise matrix vector multiplication in numpy?
body: <p>Let's assume we have a bunch of 3 by 3 matrices along with a bunch of 3-dimensional vectors:</p>
  
  <pre><code>N = 100
  matrices = np.random.rand(N, 3, 3) # shape: (100, 3, 3)
  vectors = np.random.rand(N, 3)     # shape: (100, 3)
  </code></pre>
  
  <p>How can I perform an "element-wise" matrix/vector multiplication, so that e.g. <code>result[0]</code> is the 3-dimensional vector resulting from the matrix/vector multiplication of <code>matrices[0]</code> with <code>vector[0]</code>.</p>
  
  <p>Using <code>np.dot</code>, <code>np.matmul</code>, or <code>np.prod</code> directly fails due to the non-matching shapes. Is there a broadcasting trick to make this work?</p>