RSpectra

R Interface to the Spectra Library for Large Scale Eigenvalue and SVD Problems

https://github.com/yixuan/rspectra

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

eigenvalues spectra svd
Last synced: 6 months ago · JSON representation

Repository

R Interface to the Spectra Library for Large Scale Eigenvalue and SVD Problems

Basic Info
Statistics
  • Stars: 83
  • Watchers: 8
  • Forks: 12
  • Open Issues: 8
  • Releases: 0
Topics
eigenvalues spectra svd
Created almost 10 years ago · Last pushed 6 months ago
Metadata Files
Readme

README.md

Solvers for Large Scale Eigenvalue and SVD Problems RSpectra

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 product A %*% 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

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

All Time
  • Total Commits: 99
  • Total Committers: 3
  • Avg Commits per committer: 33.0
  • Development Distribution Score (DDS): 0.03
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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

  • Versions: 8
  • Dependent Packages: 110
  • Dependent Repositories: 149
  • Downloads: 53,566 Last month
  • Docker Downloads: 71,769
Rankings
Dependent packages count: 0.9%
Dependent repos count: 1.6%
Downloads: 1.9%
Stargazers count: 4.7%
Average: 5.4%
Forks count: 5.5%
Docker downloads count: 17.6%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: r-rspectra
  • Versions: 5
  • Dependent Packages: 15
  • Dependent Repositories: 5
Rankings
Dependent packages count: 4.2%
Dependent repos count: 14.8%
Average: 24.2%
Stargazers count: 36.7%
Forks count: 41.0%
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.0.2 depends
  • Matrix >= 1.1 imports
  • Rcpp >= 0.11.5 imports
  • knitr * suggests
  • prettydoc * suggests
  • rmarkdown * suggests