eigen2 {sanic} | R Documentation |
Spectral Decomposition
Description
Solvers for eigenproblems around the matrix A
. Compute eigenvalues
\lambda
and eigenvectors v
of A
, such that
Av = \lambda v
.
Usage
eigen2(a, symmetric, vectors = TRUE)
Arguments
a |
Square numeric matrix. |
symmetric |
Logical scalar indicating whether 'a' is symmetric. By default symmetry is checked up to machine precision, which may take a long time for symmetric matrices. |
vectors |
Logical scalar indicating whether eigenvectors should be computed and returned. |
Value
Solves the eigenproblem and returns a list with eigenvalues in
the "values"
slot and, if requested, eigenvectors in the slot
"vectors"
.
Examples
set.seed(42)
# Compute eigenvalues and eigenvectors for a square matrix
A <- matrix(rnorm(9), nrow = 3, ncol = 3)
ev <- eigen2(A, symmetric = FALSE)
# Compute eigenvalues and eigenvectors for a symmetric matrix
A <- crossprod(matrix(rnorm(9), nrow = 3, ncol = 3))
ev <- eigen2(A, symmetric = TRUE)
# Check reconstruction
norm(A %*% ev$vectors - ev$vectors %*% diag(ev$values))
[Package sanic version 0.0.2 Index]