svds.sparseLRMatrix {sparseLRMatrix}R Documentation

Truncated singular value decomposition of a matrix

Description

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

Usage

## 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


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)


[Package sparseLRMatrix version 0.1.0 Index]