title: Fast inverse and transpose matrix in Python
body: <p>I have a large matrix <code>A</code> of shape <code>(n, n, 3, 3)</code> with <code>n</code> is about <code>5000</code>. Now I want find the inverse and transpose of matrix <code>A</code>:</p>
  
  <pre><code>import numpy as np
  A = np.random.rand(1000, 1000, 3, 3)
  identity = np.identity(3, dtype=A.dtype)
  Ainv = np.zeros_like(A)
  Atrans = np.zeros_like(A)
  for i in range(1000):
      for j in range(1000):
          Ainv[i, j] = np.linalg.solve(A[i, j], identity)
          Atrans[i, j] = np.transpose(A[i, j])
  </code></pre>
  
  <p>Is there a faster, more efficient way to do this?</p>