linalg_eigh {torch} | R Documentation |
Computes the eigenvalue decomposition of a complex Hermitian or real symmetric matrix.
Description
Letting \mathbb{K}
be \mathbb{R}
or \mathbb{C}
,
the eigenvalue decomposition of a complex Hermitian or real symmetric matrix
A \in \mathbb{K}^{n \times n}
is defined as
Usage
linalg_eigh(A, UPLO = "L")
Arguments
A |
(Tensor): tensor of shape |
UPLO |
('L', 'U', optional): controls whether to use the upper or lower triangular part
of |
Details
Math could not be displayed. Please visit the package website.
where Q^{H}
is the conjugate transpose when Q
is complex, and the transpose when Q
is real-valued.
Q
is orthogonal in the real case and unitary in the complex case.
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
is assumed to be Hermitian (resp. symmetric), but this is not checked internally, instead:
If
UPLO
\= 'L'
(default), only the lower triangular part of the matrix is used in the computation.If
UPLO
\= 'U'
, only the upper triangular part of the matrix is used. The eigenvalues are returned in ascending order.
Value
A list (eigenvalues, eigenvectors)
which corresponds to \Lambda
and Q
above.
eigenvalues
will always be real-valued, even when A
is complex.
It will also be ordered in ascending order.
eigenvectors
will have the same dtype as A
and will contain the eigenvectors as its columns.
Warning
The eigenvectors of a symmetric 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-1
in the real case or bye^{i \phi}, \phi \in \mathbb{R}
in the complex case produces another set of valid eigenvectors of the matrix. This non-uniqueness problem is even worse when the matrix has repeated eigenvalues. In this case, one may multiply the associated eigenvectors spanning the subspace by a rotation matrix and the resulting eigenvectors will be valid eigenvectors.Gradients computed using the
eigenvectors
tensor will only be finite whenA
has unique eigenvalues. Furthermore, if the distance between any two eigvalues 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}
.
Note
The eigenvalues of real symmetric or complex Hermitian matrices are always real.
See Also
-
linalg_eigvalsh()
computes only the eigenvalues values of a Hermitian matrix. Unlikelinalg_eigh()
, the gradients oflinalg_eigvalsh()
are always numerically stable. -
linalg_cholesky()
for a different decomposition of a Hermitian matrix. The Cholesky decomposition gives less information about the matrix but is much faster to compute than the eigenvalue decomposition. -
linalg_eig()
for a (slower) function that computes the eigenvalue decomposition of a not necessarily Hermitian square matrix. -
linalg_svd()
for a (slower) function that computes the more general SVD decomposition of matrices of any shape. -
linalg_qr()
for another (much faster) decomposition that works on general matrices.
Other linalg:
linalg_cholesky_ex()
,
linalg_cholesky()
,
linalg_det()
,
linalg_eigvalsh()
,
linalg_eigvals()
,
linalg_eig()
,
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()
Examples
if (torch_is_installed()) {
a <- torch_randn(2, 2)
linalg_eigh(a)
}