linalg_eig {torch} | R Documentation |
Letting \mathbb{K}
be \mathbb{R}
or \mathbb{C}
,
the eigenvalue decomposition of a square matrix
A \in \mathbb{K}^{n \times n}
(if it exists) is defined as
linalg_eig(A)
A |
(Tensor): tensor of shape |
Math could not be displayed. Please visit the package website.
This decomposition exists if and only if A
is diagonalizable
_.
This is the case when all its eigenvalues are different.
Supports input of float, double, cfloat and cdouble dtypes.
Also supports batches of matrices, and if A
is a batch of matrices then
the output has the same batch dimensions.
A list (eigenvalues, eigenvectors)
which corresponds to \Lambda
and V
above.
eigenvalues
and eigenvectors
will always be complex-valued, even when A
is real. The eigenvectors
will be given by the columns of eigenvectors
.
This function assumes that A
is diagonalizable
_ (for example, when all the
eigenvalues are different). If it is not diagonalizable, the returned
eigenvalues will be correct but A \neq V \operatorname{diag}(\Lambda)V^{-1}
.
The eigenvectors of a matrix are not unique, nor are they continuous with respect to
A
. Due to this lack of uniqueness, different hardware and software may compute
different eigenvectors.
This non-uniqueness is caused by the fact that multiplying an eigenvector by a
non-zero number produces another set of valid eigenvectors of the matrix.
In this implmentation, the returned eigenvectors are normalized to have norm
1
and largest real component.
Gradients computed using V
will only be finite when A
does not have repeated eigenvalues.
Furthermore, if the distance between any two eigenvalues is close to zero,
the gradient will be numerically unstable, as it depends on the eigenvalues
\lambda_i
through the computation of
\frac{1}{\min_{i \neq j} \lambda_i - \lambda_j}
.
The eigenvalues and eigenvectors of a real matrix may be complex.
linalg_eigvals()
computes only the eigenvalues. Unlike linalg_eig()
, the gradients of
linalg_eigvals()
are always numerically stable.
linalg_eigh()
for a (faster) function that computes the eigenvalue decomposition
for Hermitian and symmetric matrices.
linalg_svd()
for a function that computes another type of spectral
decomposition that works on matrices of any shape.
linalg_qr()
for another (much faster) decomposition that works on matrices of
any shape.
Other linalg:
linalg_cholesky_ex()
,
linalg_cholesky()
,
linalg_det()
,
linalg_eigh()
,
linalg_eigvalsh()
,
linalg_eigvals()
,
linalg_householder_product()
,
linalg_inv_ex()
,
linalg_inv()
,
linalg_lstsq()
,
linalg_matrix_norm()
,
linalg_matrix_power()
,
linalg_matrix_rank()
,
linalg_multi_dot()
,
linalg_norm()
,
linalg_pinv()
,
linalg_qr()
,
linalg_slogdet()
,
linalg_solve_triangular()
,
linalg_solve()
,
linalg_svdvals()
,
linalg_svd()
,
linalg_tensorinv()
,
linalg_tensorsolve()
,
linalg_vector_norm()
if (torch_is_installed()) {
a <- torch_randn(2, 2)
wv <- linalg_eig(a)
}