title: numpy - tensor multiplication product
body: <p>I have a 4 x 4 matrix </p>
  
  <pre><code>import numpy as np
  c = np.random.rand((4,4))
  </code></pre>
  
  <p>I want to create an 100 x 4 x 4 x 100 tensor such that when the first an last index are equal, I get back my matrix else I get zeros.</p>
  
  <p>I can do this in a loop as</p>
  
  <pre><code>Z = np.zeros((100, 4, 4, 100))
  for i in range(100):
      Z[i, :, :, i] = c
  </code></pre>
  
  <p>is there a better way to do this? I tried looking at np.tensordot and np.einsum but could not figure it out.</p>
  
  <p>Thanks,
  Sahil</p>