My code involves diagonalizing a matrix of size 128×128. The matrix is very nearly hermitian and depends on some initial conditions. When I call scipy.linalg.eigh, it sometimes works normally. Other times, it churns for a while and then terminates the whole Python code without raising any errors.
I tried to run eigh with significantly non-Hermitian matrices of the same size. It sometimes does the same thing as described above and sometimes runs normally, obviously giving a wrong diagonalization. I manually hermitized the matrix as $1/2(A+A^dag)$ but the problem remains. What’s worst is that is seems quite random. Since Python doesn’t raise any errors, I am a bit lost in what to do. Help much appreciated.
I also tried numpy.linalg.eigh and it works fine for the same matrices.
lsls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.