Skip to content
fn

eig

→Tensor
eig(input: Tensor)

Implementing kernel

C++ engine symbols that back this Python API.

Eigenvalue decomposition of a general square matrix.

For a general (not necessarily symmetric) square matrix AA returns eigenvalues λi\lambda_i and right eigenvectors viv_i such that

Avi = λi vi,A = V Λ V−1.A v_i \,=\, \lambda_i\, v_i, \qquad A \,=\, V\,\Lambda\,V^{-1}.

For matrices with complex eigenvalues, the result is in general complex-valued. When AA is known to be symmetric / Hermitian prefer eigh — it is faster, more stable, and produces real eigenvalues with orthogonal eigenvectors.

Parameters

inputTensor
Square matrix of shape (*, n, n).

Returns

Tensor

Tensor of shape (*, n). Real for real-spectrum matrices, complex otherwise.

Notes

Backed by LAPACK geev. Cost is O(n3)O(n^3). 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.+0.j), (3.+0.j)], dtype=lucid.complex64)