This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / linalg / eigvalsh

_ArrayFunctionDispatcher

numpy.linalg:eigvalsh

source: build-install/usr/lib/python3.14/site-packages/numpy/linalg/_linalg.py :1265

Signature

def   eigvalsh ( a UPLO = L )

Summary

Compute the eigenvalues of a complex Hermitian or real symmetric matrix.

Extended Summary

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'). Irrespective of this value only the real parts of the diagonal will be considered in the computation to preserve the notion of a Hermitian matrix. It therefore follows that the imaginary part of the diagonal will always be treated as zero.

Returns

w : (..., M,) ndarray

The eigenvalues in ascending order, each repeated according to its multiplicity.

Raises

: LinAlgError

If the eigenvalue computation does not converge.

Notes

Broadcasting rules apply, see the numpy.linalg documentation for details.

The eigenvalues are computed using LAPACK routines _syevd, _heevd.

Examples

import numpy as np
from numpy import linalg as LA
a = np.array([[1, -2j], [2j, 5]])
LA.eigvalsh(a)
a = np.array([[5+2j, 9-2j], [0+2j, 2-1j]])
a
b = np.array([[5.+0.j, 0.-2.j], [0.+2.j, 2.-0.j]])
b
wa = LA.eigvalsh(a)
wb = LA.eigvals(b)
wa
wb

See also

eig

eigenvalues and right eigenvectors of general real or complex arrays.

eigh

eigenvalues and eigenvectors of real symmetric or complex Hermitian (conjugate symmetric) arrays.

eigvals

eigenvalues of general real or complex arrays.

scipy.linalg.eigvalsh

Similar function in SciPy.

Aliases

  • numpy.linalg.eigvalsh