[Numpy-discussion] numpy.linalg: eig versus eigh?

Piotr Luszczek luszczek at cs.utk.edu
Wed Mar 29 19:26:03 CST 2006


On Wednesday 29 March 2006 19:03, Zachary Pincus wrote:
> Can anyone tell me what the difference between numpy.linalg.eig and
> numpy.linalg.eigh is? (Ditto for eigvals and eigvalsh.)
>
> Thanks,
>
> Zach

eig() is for nonsymmetric matrices and eigh() is for symmetric
(or hermitian matrices).

The former most likely will return complex eigen values. The latter
always returns real eigen values.

eig() is slower and numerically less reliable (it calls LAPACK's DGEEV
and ZGEEV). Even for symmetric matrices it can produce complex
eigen pairs due to numerical round-off.

eigh() can be called with an optional parameter UPLO that tells the 
routine which triangle of the matrix it should operate on. That triangle
is destroyed and the other triangle is left untouched.

Piotr




More information about the Numpy-discussion mailing list