title: Does anyone see any possible way to slice this? (python)
body: <p>I've been trying to speed up some numpy arrays in Python and I know for loops are really bad so you should slice them but I just can't see anyway to slice this. Maybe there's some smart trick? I am pretty inexperienced in this so would appreciate any help!</p>
  <pre><code>    def propind(in1, in2):
          return in1+M*in2
       
      for ind1 in range(M):
          for ind2 in range(N):
              for ind3 in range(M):
                  for ind4 in range(N):
                      ret[propind(ind1,ind2), propind(ind3,ind4)] = tempH0s[ind1,ind2,ind4]*(ind1==ind3)
  </code></pre>
  <p>tempH0s is a MxNxN matrix and ret is a (MxN)x(MxN) matrix.</p>