svd.HDF5Matrix: Singular Value Decomposition of an HDF5Matrix

View source: R/S3_decompositions.R

svd.HDF5MatrixR Documentation

Singular Value Decomposition of an HDF5Matrix

Description

Block-wise SVD entirely on disk. The matrix x is decomposed into x = u %*% diag(d) %*% t(v).

Usage

## S3 method for class 'HDF5Matrix'
svd(
  x,
  nu = min(dim(x)),
  nv = min(dim(x)),
  center = TRUE,
  scale = TRUE,
  k = 2L,
  q = 1L,
  method = "auto",
  rankthreshold = 0,
  overwrite = FALSE,
  threads = -1L,
  ...
)

Arguments

x

An HDF5Matrix object.

nu

Number of left singular vectors to compute (default = min(dim(x))).

nv

Number of right singular vectors to compute (default = min(dim(x))).

center

Logical. Center columns before decomposition (default TRUE).

scale

Logical. Scale columns before decomposition (default TRUE).

k

Number of local SVDs per incremental level (default 2).

q

Number of incremental levels (default 1).

method

Computation method: "auto" (default), "blocks", or "full".

rankthreshold

Numeric in [0, 0.1]. Rank approximation threshold (default 0).

overwrite

Logical. Overwrite existing SVD results (default FALSE).

threads

Integer. OpenMP threads (-1 = auto-detect).

...

Ignored (S3 compatibility).

Details

Singular values d are loaded into a plain numeric vector (they are always small: at most min(nrow(x), ncol(x)) values). u and v are returned as HDF5Matrix objects.

Value

Named list with:

d

Numeric vector of non-negative singular values, decreasing.

u

HDF5Matrix of left singular vectors, nrow(x) x nu.

v

HDF5Matrix of right singular vectors, ncol(x) x nv.

Examples


tmp <- tempfile(fileext = ".h5")
X   <- hdf5_create_matrix(tmp, "data/M", data = matrix(rnorm(500), 50, 10))
res <- svd(X)
length(res$d)   # 10  (min(50,10))
dim(res$u)      # 50 x 10
dim(res$v)      # 10 x 10
X$close()
res$u$close(); res$v$close()
unlink(tmp)



BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.