# Most efficient library to diagonalize exactly large hermitian or unitary matrices

I am working on a physics problem which requires obtaining the exact eigenvalues and eigenvectors of Hermitian and Unitary matrices numerically. Naturally I would like to ask the experts what are the most efficient libraries to diagonalize the referred matrices. In particular, I would like to diagonalize efficiently matrices of size 12870*12870. I have been using Mathematica for convenience, but I am open to use any language you might suggest. I also have access to a HPC cluster in which the diagonalization of a unitary matrix of size 12870*12870 takes around 7000 seconds in Mathematica using 12 cores. Can this time be improved? Note: The matrices are numeric (not symbolic).

To be more precise, I diagonalized a random Hermitian matrix and a random Unitary matrix of size 12870 on the cluster using Mathematica. Here is the code I used:

With[{mat = RandomReal[1, 12870 {1, 1}]}, AbsoluteTiming[{vals, vecs} = Eigensystem[mat+Transpose[mat]];]]

With[{matu = Transpose[vecs].(Exp[I*vals]*Conjugate[vecs])}, AbsoluteTiming[Eigensystem[matu];]]


The results were:

In:= Out= {265.369827, Null}
In:= Out= {7042.662152, Null}


So the unitary matrix diagonalization takes a lot more time. Can this be improved using other languages?

• Something's wrong with the timings you cite. If you have a numerical matrix of that size, finding all eigenvalues with Mathematica should not take more than 5-10 minutes on a laptop. Post the specific Mathematica code you used. – Szabolcs Aug 16 '14 at 21:39
• Make sure that your matrix contains only machine precision floating point numbers. – Szabolcs Aug 16 '14 at 21:43
• @Szabolcs I acted with N function on the unitary matrix before applying Eigensystem to it. Are you sure it should take 5-10 minutes? Have you tried an example? Thanks for the suggestion. – lagoa Aug 17 '14 at 20:10
• Yes, I have tried with Eigenvalues. Eigensystem would take a little longer, see the extended comment I wrote in an answer. – Szabolcs Aug 17 '14 at 21:10
• Sorry, I was wrong. I'll get back to this later today. – Szabolcs Aug 19 '14 at 12:22