[Numpy-discussion] linalg.eigh orders eigenvalues/eigenvectors differently than linalg.eig
Zachary Pincus
zpincus@stanford....
Mon Feb 19 04:56:34 CST 2007
Hello all,
It seems that the 'eigh' routine from numpy.linalg does not follow
the same convention as numpy.linalg.eig in terms of the order of the
returned eigenvalues. (And thus eigenvectors as well...)
Specifically, eig returns eigenvalues in order from largest to
smallest, while eigh returns them from smallest to largest.
Example:
>>> a = numpy.array([[21, 28, 35],[28, 38, 48],[35, 48, 61]])
>>> numpy.linalg.eigh(a)
(array([ -1.02825542e-14, 7.04131679e-01, 1.19295868e+02]),
array([[ 0.40824829, -0.81314396, -0.41488581],
[-0.81649658, -0.12200588, -0.56431188],
[ 0.40824829, 0.56913221, -0.71373795]]))
>>> numpy.linalg.eig(a)
(array([ 1.19295868e+02, 7.04131679e-01, 4.62814557e-15]),
array([[-0.41488581, -0.81314396, 0.40824829],
[-0.56431188, -0.12200588, -0.81649658],
[-0.71373795, 0.56913221, 0.40824829]]))
Is this a bug? If it is, though, fixing it now might break code that
depends on this 'wrong' order. (This is also present in
scipy.linalg.) If not a bug, or not-fixable-now, then at least some
documentation as to the convention regarding ordering of eigenvalues
is probably worthwhile...
Any thoughts?
Zach
More information about the Numpy-discussion
mailing list