# Solvers for Large-Scale Eigenvalue and SVD Problems

R interface to the 'Spectra' library < https://spectralib.org/> for large-scale eigenvalue and SVD problems. It is typically used to compute a few eigenvalues/vectors of an n by n matrix, e.g., the k largest eigenvalues, which is usually more efficient than eigen() if k << n. This package provides the 'eigs()' function that does the similar job as in 'Matlab', 'Octave', 'Python SciPy' and 'Julia'. It also provides the 'svds()' function to calculate the largest k singular values and corresponding singular vectors of a real matrix. The matrix to be computed on can be dense, sparse, or in the form of an operator defined by the user.

### Introduction

RSpectra is an R interface to the Spectra library. It is typically used to compute a few eigenvalues/vectors of an n by n matrix, e.g., the k largest eigen values, which is usually more efficient than eigen() if k << n.

Currently this package provides function eigs() for eigenvalue/eigenvector problems, and svds() for truncated SVD. Different matrix types in R, including sparse matrices, are supported. Below is a list of implemented ones:

• matrix (defined in base R)
• dgeMatrix (defined in Matrix package, for general matrices)
• dsyMatrix (defined in Matrix package, for symmetric matrices)
• dgCMatrix (defined in Matrix package, for column oriented sparse matrices)
• dgRMatrix (defined in Matrix package, for row oriented sparse matrices)
• function (implicitly specify the matrix by providing a function that calculates matrix product A %*% x)

### Example

We first generate some matrices:

General matrices have complex eigenvalues:

RSpectra also works on sparse matrices:

Function interface is also supported:

Symmetric matrices have real eigenvalues.

To find the smallest (in absolute value) k eigenvalues of A5, we have two approaches:

The results should be the same, but the latter method is far more stable on large matrices.

For SVD problems, you can specify the number of singular values (k), number of left singular vectors (nu) and number of right singular vectors(nv).

Similar to eigs(), svds() supports sparse matrices:

and function interface

# Reference manual

install.packages("RSpectra")

0.16-0 by Yixuan Qiu, a year ago

https://github.com/yixuan/RSpectra

Report a bug at https://github.com/yixuan/RSpectra/issues

Browse source code at https://github.com/cran/RSpectra

Authors: Yixuan Qiu [aut, cre] , Jiali Mei [aut] (Function interface of matrix operation) , Gael Guennebaud [ctb] (Eigenvalue solvers from the 'Eigen' library) , Jitse Niesen [ctb] (Eigenvalue solvers from the 'Eigen' library)

Documentation:   PDF Manual

Imports Matrix, Rcpp

Suggests knitr, rmarkdown, prettydoc