title: Numpy: stack duplicates of matrix in new dimension
body: <p>I have a 3x3 numpy array and I want to create a 3x3xC matrix where the new dimension consists of exact copies of the original 3x3 array. I am sure this is asked somewhere but I couldn't find the best way. I worked out how to do this for a simple 1 dimensional array x: </p>
  
  <pre><code>new_x = np.tile(np.array(x, (C, 1))
  </code></pre>
  
  <p>which repeats the array, then do: </p>
  
  <pre><code>np.transpose(np.expand_dims(new_x, axis=2),(2,1,0))
  </code></pre>
  
  <p>which expands the dimension and switches the axis so that the array is repeated in the 3rd dimension (although this works I'm not sure if this is the best way to do it either) - what is the most efficient way to do this for a general n x n numpy array? </p>