linalg.eigvalsh
Description
Compute the eigenvalues of a complex Hermitian or real symmetric matrix.
Main difference from eigh: The eigenvectors are not computed.
Mandatory Input Parameters
Parameter |
Type |
Description |
|---|---|---|
a |
(…, M, M) array |
Hermitian or real symmetric matrices |
Optional Input Parameters
Parameter |
Type |
Default Value |
Description |
|---|---|---|---|
UPLO |
{'L', 'U'}, |
'L' |
Specifies whether the calculation is done with the lower triangular part ('L') or the upper triangular part ('U') of a. Irrespective of this value, only the real parts of the diagonal will be considered in the calculation to preserve the notion of a Hermitian matrix. It therefore follows that the imaginary part of the diagonal will always be treated as zero. |
Return Value
Parameter |
Type |
Description |
|---|---|---|
w |
(…, M) ndarray |
The eigenvalues in ascending order, each repeated according to its multiplicity. |
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | >>> import numpy as np >>> a = np.array([[1, -2j], [2j, 5]]) >>> np.linalg.eigvalsh(a) array([0.17157288, 5.82842712]) >>> >>> a = np.array([[5+2j, 9-2j], [0+2j, 2-1j]]) >>> a array([[5.+2.j, 9.-2.j], [0.+2.j, 2.-1.j]]) >>> b = np.array([[5.+0.j, 0.-2.j], [0.+2.j, 2.-0.j]]) >>> b array([[5.+0.j, 0.-2.j], [0.+2.j, 2.+0.j]]) >>> >>> wa = np.linalg.eigvalsh(a) >>> wa array([1., 6.]) >>> wb = np.linalg.eigvalsh(b) >>> wb array([1., 6.]) >>> wb = np.linalg.eigvals(b) >>> wb array([6.+0.j, 1.+0.j]) >>> |
Parent topic: Linear Algebra Functions