spam (version 2.5-1)

eigen: 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 spam whose nev eigenvalues and eigenvectors are to be computed.

nev

number of eigenvalues to calculate.

symmetric

if TRUE, the matrix is assumed to be symmetric.

only.values

if TRUE, only nev eigenvalues are computed and returned, otherwise nev eigenvalues and eigenvectors are returned.

control

additional options, see ‘Details’.

ncv

see ‘Details’, use the control option for eigen.spam.

nitr

see ‘Details’, use the control option for eigen.spam.

mode

see ‘Details’, use the control option for eigen.spam.

verbose

see ‘Details’, use the control option for eigen.spam.

f_routine

only for eigen_approx, to call the Fortran routine for symmetric matrices set this option to "ds_eigen_f" and for non symmetric to "dn_eigen_f".

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.

Details

mode = "LM":

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.

% item
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 than nev. 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.

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.

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

Run this code
# NOT RUN {
set.seed(81)
rspam <- spam_random(50^2, density = .0001, spd = TRUE)
SPD <- eigen.spam(rspam, nev = 20, control = list(mode = "SM"),
                  only.values = TRUE)

tail(SPD$values, 20)
isSymmetric(rspam)
# hence the matrix is symmetric positiv definit

rspam2 <- spam_random(50^2, density = .0001, spd = FALSE, sym = TRUE,
                      distribution = rpois, lambda = 2)
SNPDF <- eigen.spam(rspam2, nev = 20, control = list(mode = "SM"),
                    only.values = TRUE)

tail(SNPDF$values, 20)
isSymmetric(rspam2)
# hence the matrix is symmetric but not positiv definit
# }

Run the code above in your browser using DataCamp Workspace