eigen {spam} | R Documentation |
Eigenvalues for Sparse Matrices
Description
Functions to calculate eigenvalues and eigenvectors of sparse
matrices.
It uses the value of spam.options("inefficiencywarning")
to dispatch between base::eigen()
or the Implicitly Restarted Arnoldi Process, using 'ARPACK'.
eigen.spam
is a wrapper function of eigen_approx
and transforms its output to base::eigen
like.
Usage
eigen.spam(x, nev = 10, symmetric, only.values = FALSE, control = list())
eigen_approx(x, nev, ncv, nitr, mode, only.values = FALSE, verbose = FALSE, f_routine)
Arguments
x |
a matrix of class |
nev |
number of eigenvalues to calculate. |
symmetric |
if TRUE, the matrix is assumed to be symmetric. |
only.values |
if TRUE, only |
control |
additional options, see ‘Details’. |
ncv |
see ‘Details’, use the |
nitr |
see ‘Details’, use the |
mode |
see ‘Details’, use the |
verbose |
see ‘Details’, use the |
f_routine |
only for |
Details
mode = " "
:-
there are different modes available for this function, each mode returns a different range of eigenvalues. Also the available modes are dependent, whether the input matrix is symmetric or not:
"LM"
:Eigenvalues with largest magnitude (sym, non sym), that is, largest eigenvalues in the Euclidean norm of complex numbers.
"SM"
:Eigenvalues with smallest magnitude (sym, non sym), that is, smallest eigenvalues in the Euclidean norm of complex numbers.
"LR"
:Eigenvalues with largest real part (non sym).
"SR"
:Eigenvalues with smallest real part (non sym).
"LI"
:Eigenvalues with largest imaginary part (non sym).
"SI"
:Eigenvalues with smallest imaginary part (non sym).
"LA"
:Eigenvalues with largest algebraic value (sym), that is, largest eigenvalues inclusive of any negative sign.
"SA"
:Eigenvalues with smallest algebraic value (syn), that is, smallest eigenvalues inclusive of any negative sign.
ncv
:-
the largest number of basis vectors that will be used in the Implicitly Restarted Arnoldi Process. Work per major iteration is proportional to x@dimension[1]*ncv*ncv. The default is set if
symmetric
to min(x@dimension[1] + 1, max(2 * nev + 1, 200)) or else to min(x@dimension[1] - 1, max(2 * nev + 1, 100)). Note, this value should not be chosen arbitrary large, but slightly larger thannev
. Otherwise it could lead to memory allocation problems. nitr
:-
the maximum number of iterations. The default is set to
ncv + 1000
spamflag = FALSE
:-
if TRUE, the Implicitly Restarted Arnoldi Process is used, independent of the dimension of the respective matrix (provided matrix is larger than 10x10).
verbose = FALSE
:-
print additional information.
cmplxeps
:-
threshold to determine whether a double value is zero, while transforming the ARPACK output to R class complex. The default is set to
.Machine$double.eps
.
Value
A vector of the length corresponding to the dimension of the input matrix.
Containing the required nev
eigenvalues.
If requested also the corresponding eigenvectors.
In the non symmetric case, the eigenvalues are returned in a matrix with a column containing the real parts and a column containing the imaginary parts of the eigenvalues.
The eigenvectors are then returned in two matrices.
Note
The user is advised to choose the control
options carefully, see ‘Details’ for more information.
Author(s)
Roman Flury, Reinhard Furrer
References
Lehoucq, R. B. and Sorensen, D. C. and Yang, C. (1997) ARPACK Users Guide: Solution of Large Scale Eigenvalue Problems by Implicitly Restarted Arnoldi Methods.
See Also
Option "inefficiencywarning"
in spam.options
and spam_random
.
Examples
set.seed(81)
rspam <- spam_random(42^2, density = .0001, spd = TRUE)
SPD <- eigen.spam(rspam, nev = 18, control = list(mode = "SM"),
only.values = TRUE)
any(SPD$values <= 0, na.rm = TRUE)
isSymmetric(rspam)
# hence the matrix is symmetric positiv definit
rspam2 <- spam_random(50^2, density = .0001, spd = FALSE, sym = TRUE,
distribution = rpois, lambda = 2)
SNPD <- eigen.spam(rspam2, nev = 18, control = list(mode = "SM"),
only.values = TRUE)
any(SNPD$values <= 0, na.rm = TRUE)
isSymmetric(rspam2)
# hence the matrix is symmetric but not positiv definit