fn
eig
→Tensoreig(x: Tensor)Eigenvalue decomposition of a general square matrix.
For a general (not necessarily symmetric) square matrix returns eigenvalues and right eigenvectors such that
For matrices with complex eigenvalues, the result is in general
complex-valued. When is known to be symmetric / Hermitian
prefer eigh — it is faster, more stable, and produces real
eigenvalues with orthogonal eigenvectors.
Parameters
xTensorSquare matrix of shape
(*, n, n).Returns
TensorTensor of shape (*, n). Real for real-spectrum matrices,
complex otherwise.
Notes
Backed by LAPACK geev. Cost is . This op
currently has no autograd support — gradients through
eigendecomposition of a general matrix are notoriously unstable
near defective spectra and not implemented.
Examples
>>> import lucid
>>> from lucid.linalg import eig
>>> A = lucid.tensor([[2.0, 0.0], [0.0, 3.0]])
>>> w, V = eig(A)
>>> w
Tensor([2.0000, 3.0000])