splr: create a 'SparseplusLowRank' object

Description Usage Arguments Value Author(s) See Also Examples

View source: R/Methods_splr.R

Description

create an object of class SparseplusLowRank which can be efficiently stored and for which efficient linear algebra operations are possible.

Usage

1
splr(x, a = NULL, b = NULL)

Arguments

x

sparse matrix with dimension say m x n

a

matrix with m rows and number of columns r less than min(dim(x))

b

matrix with n rows and number of columns r less than min(dim(x))

Value

an object of S4 class SparseplusLowRank is returned with slots x, a and b

Author(s)

Trevor Hastie

See Also

SparseplusLowRank-class, softImpute

Examples

1
2
3
4
5
6
x=matrix(sample(c(3,0),15,replace=TRUE),5,3)
x=as(x,"sparseMatrix")
a=matrix(rnorm(10),5,2)
b=matrix(rnorm(6),3,2)
new("SparseplusLowRank",x=x,a=a,b=b)
splr(x,a,b)

Example output

Loading required package: Matrix
Loaded softImpute 1.4

An object of class "SparseplusLowRank"
Slot "x":
5 x 3 sparse Matrix of class "dgCMatrix"
          
[1,] 3 . 3
[2,] . 3 .
[3,] . . .
[4,] 3 . 3
[5,] . . 3

Slot "a":
           [,1]       [,2]
[1,]  0.4368339  1.3791281
[2,]  0.8201539  0.3603063
[3,] -0.7106896  0.4938978
[4,] -1.9355163  0.6626788
[5,]  2.1920066 -0.6061937

Slot "b":
           [,1]       [,2]
[1,] -1.2612477 -1.9298740
[2,] -0.8199872  0.7065309
[3,] -1.1710449  0.8309296

An object of class "SparseplusLowRank"
Slot "x":
5 x 3 sparse Matrix of class "dgCMatrix"
          
[1,] 3 . 3
[2,] . 3 .
[3,] . . .
[4,] 3 . 3
[5,] . . 3

Slot "a":
           [,1]       [,2]
[1,]  0.4368339  1.3791281
[2,]  0.8201539  0.3603063
[3,] -0.7106896  0.4938978
[4,] -1.9355163  0.6626788
[5,]  2.1920066 -0.6061937

Slot "b":
           [,1]       [,2]
[1,] -1.2612477 -1.9298740
[2,] -0.8199872  0.7065309
[3,] -1.1710449  0.8309296

softImpute documentation built on May 9, 2021, 9:07 a.m.