trunc_svd: Truncated singular value decomposition

View source: R/trunc_svd.R

trunc_svdR Documentation

Truncated singular value decomposition

Description

Truncated SVD

Usage

trunc_svd(
  A,
  d,
  adjust = 3,
  tol = .Machine$double.eps,
  override = FALSE,
  force = FALSE,
  maxit = 1000
)

Arguments

A

matrix to decompose

d

number of singular vectors

adjust

extra singular vectors to calculate for accuracy

tol

convergence criterion

override

TRUE means we use corpcor::fast.svd() instead of the iterative algorithm (useful for small data or very high d).

force

If TRUE, forces the Lanczos algorithm to be used on all datasets (usually corpcor::fast.svd() is used on small datasets or large d)

maxit

Maximum number of iterations

Details

Performs singular value decomposition but only returns the first d singular vectors/values. The truncated SVD utilizes Lanczos bidiagonalization. See references.

This function was modified from the package irlba 1.0.1 under GPL. Replacing the crossprod() calls with the C wrapper to dgemv is a dramatic difference in larger datasets. Since the wrapper is technically not a matrix multiplication function, it seemed wise to make a copy of the function.

Value

list with singular value decomposition. Has elements 'd', 'u', 'v', and 'iter'

Examples

obj <- trunc_svd( hgdp_subset, 4 )
obj$d
obj$u
obj$v
obj$iter

StoreyLab/lfa documentation built on March 7, 2024, 9:59 p.m.