title: Repeat numpy vector-matrix-vector multiplication
body: <p>I have a set of vectors (n), another set of vectors (s) and a set of 3x3 2D arrays (T).</p>
  
  <pre><code>n = np.array([
      [[1, 2, 3]],
      [[2, 2, 3]],
      [[3, 2, 3]],
      [[4, 2, 3]],
      [[5, 2, 3]],
      [[6, 2, 3]]
  ])
  s = np.array([
      [[1, 1, 5]],
      [[2, 2, 5]],
      [[3, 3, 5]],
      [[4, 4, 5]],
      [[5, 5, 5]],
      [[6, 6, 5]]
  ])
  
  T = np.array([
      [[1, 2, 3],
       [1, 2, 3],
       [2, 2, 3]],
  
      [[2, 2, 3],
       [3, 2, 3],
       [4, 2, 3]],
  
      [[3, 2, 3],
       [5, 2, 3],
       [6, 2, 3]],
  
      [[4, 2, 3],
       [7, 2, 3],
       [8, 2, 3]]
  ])
  </code></pre>
  
  <p>Right now, my current code loops through n, s, and then T:</p>
  
  <pre><code>result = np.array(n.shape[0], s.shape[0], T.shape[0])
  
  for i in range(n.shape[0]):
      for j in range(s.shape[0]):
          for k in range(T.shape[0]):
              result[i][j][k] = np.sum(n[i] * T[k] * s[j].T)
  </code></pre>
  
  <p>I tried to use np.apply_along_axis but it requires a 1D array to operate on.  Ideally, I'm trying to work out a solution that doesn't require any for loops.</p>
  
  <p>I tried to get <code>np.tensordot()</code> working (and do this in two operations), but so far no success.</p>
  
  <p>Anyone have ideas on a more 'numpy-ish' way to do this?</p>