fn

eigvalsh

Tensor
eigvalsh(x: Tensor, UPLO: str = 'L')
source

Eigenvalues of a Hermitian / symmetric matrix.

Returns only the real eigenvalues λ1λn\lambda_1 \le \cdots \le \lambda_n of a symmetric (real) or Hermitian (complex) matrix without forming the eigenvectors. Equivalent to eigh(A)[0] but skips eigenvector assembly when no gradients are requested.

Parameters

xTensor
Symmetric / Hermitian matrix of shape (*, n, n).
UPLOstr= 'L'
"L" reads the lower triangle (default), "U" the upper.

Returns

Tensor

Eigenvalues in ascending order, shape (*, n).

Notes

When x.requires_grad is true the call routes through eigh so that backward via the Loewner formula remains available. Otherwise the engine kernel is invoked directly.

Examples

>>> import lucid
>>> from lucid.linalg import eigvalsh
>>> eigvalsh(lucid.tensor([[2.0, 1.0], [1.0, 3.0]]))
Tensor([1.3820, 3.6180])