svd.nipals: singular valude decomposition using NIPALS algorithm

Description Usage Arguments Value See Also Examples

View source: R/svd.nipals.R

Description

The function may be faster when x is a sparseMatrix object and a few components need to be calculated. In addition, NA values could be presented in x.

Usage

1
svd.nipals(x, nf, ...)

Arguments

x

a numeric matrix whose SVD decomposition is to be computed

nf

the number of singular vectors want to computed

...

other parameters passed to nipals, except the following argument: center (=FALSE), scale (=FALSE), gramschmidt (=FALSE)#'

Value

the same as svd, list of three components, d, u, v

See Also

svd

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# small matrix
m <- matrix(rnorm(200), 20, 10)
s <- svd.nipals(m)

# large sparse matrix
## Not run: 
library(Matrix)
m <- matrix(sample(c(rnorm(10000), rep(0, 9990000))), 10000, 1000)
ms <- Matrix(m, sparse=TRUE)
system.time(
  s1 <- svd(m)
)
system.time(
  s2 <- svd.nipals(ms, nf = 1)
) 

## End(Not run)

mengchen18/mogsa documentation built on June 7, 2020, 6:05 p.m.