fn
eigh
→Tensoreigh(x: Tensor, UPLO: str = 'L')Eigendecomposition of a Hermitian / symmetric matrix.
Returns the eigenvalues and orthonormal eigenvectors of a real symmetric (or complex Hermitian) matrix . Eigenvalues are returned in ascending order and eigenvectors form an orthogonal matrix such that
where with .
Parameters
xTensorSquare Hermitian / symmetric matrix of shape
(*, n, n).UPLOstr= 'L'"L" (default) reads only the lower triangle of x;
"U" reads only the upper triangle. The other triangle is
ignored, so a non-Hermitian input is accepted as long as the
chosen triangle holds the correct values.Returns
TensorReal-valued tensor of shape (*, n) in ascending order.
Notes
Prefer this over eig whenever A is symmetric / Hermitian
— it is faster, numerically more stable, and guarantees real
eigenvalues with orthogonal eigenvectors ().
Backward uses the Loewner-matrix formula :
symmetrised to enforce the symmetry of . Gradients blow up near repeated eigenvalues.
Implementation: LAPACK syevd on the CPU stream (via Apple
Accelerate); MLX on the GPU stream. Both run in .
Examples
>>> import lucid
>>> from lucid.linalg import eigh
>>> A = lucid.tensor([[2.0, 1.0], [1.0, 3.0]])
>>> w, V = eigh(A)
>>> w
Tensor([1.3820, 3.6180])