numpy.linalg.eigvalsh(a, UPLO='L')[source]

Compute the eigenvalues of a Hermitian or real symmetric matrix.

Main difference from eigh: the eigenvectors are not computed.

Parameters :

a : (M, M) array_like

A complex- or real-valued matrix whose eigenvalues are to be computed.

UPLO : {‘L’, ‘U’}, optional

Specifies whether the calculation is done with the lower triangular part of a (‘L’, default) or the upper triangular part (‘U’).

Returns :

w : (M,) ndarray

The eigenvalues, not necessarily ordered, each repeated according to its multiplicity.

Raises :

LinAlgError :

If the eigenvalue computation does not converge.

See also

eigenvalues and eigenvectors of symmetric/Hermitian arrays.
eigenvalues of general real or complex arrays.
eigenvalues and right eigenvectors of general real or complex arrays.


This is a simple interface to the LAPACK routines dsyevd and zheevd that sets those routines’ flags to return only the eigenvalues of real symmetric and complex Hermitian arrays, respectively.


>>> from numpy import linalg as LA
>>> a = np.array([[1, -2j], [2j, 5]])
>>> LA.eigvalsh(a)
array([ 0.17157288+0.j,  5.82842712+0.j])

Previous topic


Next topic


This Page