I'm using NumPy's linear algebra package to calculate the eigenvectors corresponding to the minimum eigenvalue of large Hermitian matrices. The linalg.eigh function claims to return the eigenvalues of a Hermitian matrix in ascending order, as well as the corresponding eigenvectors. This is precisely what I need. However, it seems that this function is failing even in the simple case of an already diagonal matrix. For example:
import numpy as np
H = np.diag([-0.4,-0.5, 0.4, 2.3, -0.5, -0.6, 0.3, 2.2, 0.4, 0.3, 1.2, 3.1, 2.3, 2.2, 3.1, 5.])
np.linalg.eigh(H)
The output is
(array([-0.6, -0.5, -0.5, -0.4, 0.3, 0.3, 0.4, 0.4, 1.2, 2.2, 2.2, 2.3, 2.3, 3.1, 3.1, 5. ]),
array([[ 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.],
[ 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.]]))
i.e. the function outputs [0,0,0,1,...] as the eigenvector corresponding to -0.6, which is clearly untrue. Can anybody tell me why this function is failing?