svds.sparseLRMatrix: Truncated singular value decomposition of a matrix

Description Usage Arguments Value Examples

View source: R/object.R

Description

A thin wrapper around RSpectra::svds(), please see more detailed documentation there. In particular, this function leverages the function interface.

Usage

1
2
## S3 method for class 'sparseLRMatrix'
svds(A, k, nu = k, nv = k, opts = list(), ...)

Arguments

A

Matrix to decompose.

k

Number of singular values to estimate.

nu

Number of left singular vectors to estimate.

nv

Number of right singular vectors to estimate.

opts

Passed to RSpectra::svds().

...

Passed to RSpectra::svds().

Value

A list with the following components:

d

A vector of the computed singular values.

u

An m by nu matrix whose columns contain the left singular vectors. If nu == 0, NULL will be returned.

v

An n by nv matrix whose columns contain the right singular vectors. If nv == 0, NULL will be returned.

nconv

Number of converged singular values.

niter

Number of iterations used.

nops

Number of matrix-vector multiplications used.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
set.seed(528491)

n <- 50
m <- 40
k <- 3

A <- rsparsematrix(n, m, 0.1)

U <- Matrix(rnorm(n * k), nrow = n, ncol = k)
V <- Matrix(rnorm(m * k), nrow = m, ncol = k)

X <- sparseLRMatrix(sparse = A, U = U, V = V)

svds(X, 5)

sparseLRMatrix documentation built on March 2, 2021, 5:08 p.m.