I have a large $2^N \times 2^N$ matrix. It is the exact Hamiltonian of a spin chain model which I have generated with code I wrote in Fortran. The code block diagonalizes the Hamiltonian into constant total-spin sectors and furthermore into blocks of definite momentum. I wish to diagonalize it (find the eigenvalues), however when I import it into Mathematica and apply Eigenvalues[]
to it, it takes a very long time. I assume that it would be much much faster to just compute the eigenvalues of each block individually (currently modifying my Fortran code to separate these blocks). For example, for $N=10$ the matrix is $1028\times 1028$, but the largest block is $25\times 25$ and there are (I think) N(N+1) = 110 blocks, most of which are maybe $5\times 5$. Is there a way to indicate to Mathematica that the matrix is block diagonal, or an efficient way to do this without actually putting each block in a separate file and importing and diagonalizing all of them separately?
Note that the matrix is Hermitian and may be complex.
SparseArray[]
when you import it? $\endgroup$SparseArray[]
before passing it toEigenvalues[]
but I got a message which said that it was being converted back into a normal matrix because it would be faster. I am currently modifying my code so that it can be stored as a sparse array since only around ~1% of the matrix elements are non-zero. $\endgroup$