title: Multiplying 2D and 1D arrays NumPy
body: <p>I'm somewhat new to python and numpy, so maybe some of you can help me here.</p>
  <p>I have a 1D numpy array called z, and some 2D matrices called X0 , Y0, and SLM.</p>
  <p>I want to create a 3D array (a stack of 2D matrices), by doing this operation, trying to avoid a for loop:</p>
  <pre><code>for index in range(len(z)):
      3D_array[index] = SLM * np.exp( z[index] * (X0+Y0) )
  </code></pre>
  <p>So far I've tried:</p>
  <p><code>3D_array = SLM[np.newaxis, :] * np.exp( z[:, np.newaxis, np.newaxis] * (X0+Y0))</code></p>
  <p>This performs right, but its slow for my purposes.
  The arrays are big (z is size 200, and all 2D matrices are 1024x1024)</p>
  <p>Do you know any faster implementation for this?</p>