RSpectra
R Interface to the Spectra Library for Large Scale Eigenvalue and SVD Problems
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.7%) to scientific vocabulary
Keywords
Repository
R Interface to the Spectra Library for Large Scale Eigenvalue and SVD Problems
Basic Info
- Host: GitHub
- Owner: yixuan
- Language: C++
- Default Branch: master
- Homepage: http://cran.r-project.org/package=RSpectra
- Size: 391 KB
Statistics
- Stars: 83
- Watchers: 8
- Forks: 12
- Open Issues: 8
- Releases: 0
Topics
Metadata Files
README.md
Solvers for Large Scale Eigenvalue and SVD Problems 
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 the 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)dgCMatrix(defined in Matrix package, for column oriented sparse matrices)dgRMatrix(defined in Matrix package, for row oriented sparse matrices)dsyMatrix(defined in Matrix package, for symmetric matrices)dsCMatrix(defined in Matrix package, for symmetric column oriented sparse matrices)dsRMatrix(defined in Matrix package, for symmetric row oriented sparse matrices)function(implicitly specify the matrix by providing a function that calculates matrix productA %*% x)
Examples
We first generate some matrices:
```r library(Matrix) n = 20 k = 5
set.seed(111) A1 = matrix(rnorm(n^2), n) ## class "matrix" A2 = Matrix(A1) ## class "dgeMatrix" ```
General matrices have complex eigenvalues:
r
eigs(A1, k)
eigs(A2, k, opts = list(retvec = FALSE)) ## eigenvalues only
RSpectra also works on sparse matrices:
```r A1[sample(n^2, n^2 / 2)] = 0 A3 = as(A1, "dgCMatrix") A4 = as(A1, "dgRMatrix")
eigs(A3, k) eigs(A4, k) ```
Function interface is also supported:
r
f = function(x, args)
{
as.numeric(args %*% x)
}
eigs(f, k, n = n, args = A3)
Symmetric matrices have real eigenvalues.
r
A5 = crossprod(A1)
eigs_sym(A5, k)
To find the smallest (in absolute value) k eigenvalues of A5,
we have two approaches:
r
eigs_sym(A5, k, which = "SM")
eigs_sym(A5, k, sigma = 0)
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).
```r m = 100 n = 20 k = 5 set.seed(111) A = matrix(rnorm(m * n), m)
svds(A, k) svds(t(A), k, nu = 0, nv = 3) ```
Similar to eigs(), svds() supports sparse matrices:
```r A[sample(m * n, m * n / 2)] = 0 Asp1 = as(A, "dgCMatrix") Asp2 = as(A, "dgRMatrix")
svds(Asp1, k) svds(Asp2, k, nu = 0, nv = 0) ```
and function interface
r
f = function(x, args)
{
as.numeric(args %*% x)
}
g = function(x, args)
{
as.numeric(crossprod(args, x))
}
svds(f, k, Atrans = g, dim = c(m, n), args = Asp1)
Owner
- Name: Yixuan Qiu
- Login: yixuan
- Kind: user
- Location: Shanghai
- Website: https://statr.me
- Repositories: 98
- Profile: https://github.com/yixuan
GitHub Events
Total
- Issues event: 2
- Watch event: 2
- Issue comment event: 1
- Push event: 1
Last Year
- Issues event: 2
- Watch event: 2
- Issue comment event: 1
- Push event: 1
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Yixuan Qiu | y****q@g****m | 96 |
| Philipp A | f****p@w****e | 2 |
| alex hayes | a****s@g****m | 1 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 24
- Total pull requests: 2
- Average time to close issues: 7 months
- Average time to close pull requests: 15 days
- Total issue authors: 19
- Total pull request authors: 2
- Average comments per issue: 4.38
- Average comments per pull request: 3.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 3
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 3
- Pull request authors: 0
- Average comments per issue: 1.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- privefl (3)
- alexpghayes (2)
- gdkrmr (2)
- flying-sheep (2)
- dswatson (1)
- DataStrategist (1)
- chuk-yong (1)
- xfim (1)
- boogiepenguin (1)
- slowkow (1)
- maelle (1)
- JohnCoene (1)
- Zilong-Li (1)
- bbuchsbaum (1)
- pcarbo (1)
Pull Request Authors
- flying-sheep (1)
- alexpghayes (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- cran 53,566 last-month
- Total docker downloads: 71,769
-
Total dependent packages: 125
(may contain duplicates) -
Total dependent repositories: 154
(may contain duplicates) - Total versions: 13
- Total maintainers: 1
cran.r-project.org: RSpectra
Solvers for Large-Scale Eigenvalue and SVD Problems
- Homepage: https://github.com/yixuan/RSpectra
- Documentation: http://cran.r-project.org/web/packages/RSpectra/RSpectra.pdf
- License: MPL (≥ 2)
-
Latest release: 0.16-2
published over 1 year ago
Rankings
Maintainers (1)
conda-forge.org: r-rspectra
- Homepage: https://github.com/yixuan/RSpectra
- License: MPL-2.0
-
Latest release: 0.12_0
published over 3 years ago
Rankings
Dependencies
- R >= 3.0.2 depends
- Matrix >= 1.1 imports
- Rcpp >= 0.11.5 imports
- knitr * suggests
- prettydoc * suggests
- rmarkdown * suggests