sparseLRMatrix-class: Sparse plus low rank matrix

Description Details Slots Examples

Description

Eventually this class will subclass Matrix objects, but for now this is a basic implementation that essentially only supports singular value decomposition.

Details

To learn more about S4 classes, please see https://adv-r.hadley.nz/s4.html.

Slots

sparse

sparseMatrix.

U

Matrix.

V

Matrix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)

# construct the matrix, which represents A + U %*% t(V)
X <- sparseLRMatrix(sparse = A, U = U, V = V)

dim(X)

s <- svds(X, 5)  # efficient

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