title: Faster calculation of multiple matrices' eigenvalues & eigenvectors
body: <p>I have several thousands of 3x3 matrices, which are stored as a numpy array Nx9, where N is a number of matrices, stored in rows. I want to calculate the eigenvalues &amp; eigenvectors for each of them (i.e. <code>e, v = np.linalg.eig(matrices[row_idx, :].reshape((3, 3))</code>, applied to each <code>row_idx</code> in <code>range(matrices.shape[0])</code>).</p>
  <p>So, the function would look as:</p>
  <pre><code>def compute_eigen(matrices):
      e_list, v_list = [], []
      for i in range(matrices.shape[0]):
          e, v = np.linalg.eig(matrices[row_idx, :].reshape((3, 3))
          v = -v
          e_list.append(e)
          v_list.append(v)
      return e_list, v_list
  </code></pre>
  <p>Now, how to make this run really fast? <code>np.apply_along_axis</code> is just a syntactic sugar for the for-loops, apparently, so it did not help much.</p>
  <p>I tried to look into Numba, and run the same function with <code>@jit(nopython=True)</code> decorator, which, indeed, dropped the execution time of this function from ~20s to ~2s for ~6000 matrices. However, is it possible to drop it under 1s? Is there some smart way to do it (assuming no usage of some very powerful hardware, GPUs etc)? Thanks.</p>