MLSVD: SVD Solver

MLSVDR Documentation

SVD Solver

Description

Computes the top-M truncated SVD of a matrix. Dispatches internally between a direct (tall matrices), Gram (wide matrices), and randomized path based on the shape of X.

Details

Wraps the C++ MLSVD::compute(X, M) static method.

Methods

Public methods


MLSVD$new()

Initialize the solver with its dispatch thresholds.

Usage
MLSVD$new(min_dim_thresh = 10000, block_size = 1024, n_threads = NULL)
Arguments
min_dim_thresh

Integer (default 10000). The direct path (a Jacobi SVD that copies X and computes every singular triplet) is taken while min(n, p) is below it; above it, and when M < min(n, p) / 10, the randomized path runs two block-wise passes over X without a copy (the route for a large mmap_matrix). p > 2 n always takes the Gram path.

block_size

Integer (default 1024): the column block of the block-wise passes.

n_threads

Integer, the thread budget of the matrix products (NULL, the default: the library's default budget, trex_get_num_threads(), initially 1).


MLSVD$compute()

Compute top-M singular value decomposition of X.

Usage
MLSVD$compute(X, M)
Arguments
X

A numeric matrix (n x p), or an mmap_matrix (bound zero-copy; "readonly" suffices).

M

Integer, number of singular components to retain.

Returns

Named list with:

  • U Left singular vectors (n x M).

  • S Singular values (M).

  • V Right singular vectors (p x M).


MLSVD$clone()

The objects of this class are cloneable with this method.

Usage
MLSVD$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

G. Guennebaud, B. Jacob et al., Eigen v3, https://libeigen.gitlab.io/, 2010.

See Also

Other ML methods: MLElasticNet, MLElasticNetCV, MLLpNormScaler, MLPCA, MLRidge, MLRidgeCV, MLZScoreScaler, ml_agglomerative_cluster(), ml_cut_tree(), ml_distance_metric, ml_linkage_method

Examples

set.seed(42)
X <- matrix(rnorm(50 * 10), 50, 10)
solver <- MLSVD$new()
res <- solver$compute(X, M = 3)
dim(res$U)  # 50 x 3


TRexSelector documentation built on Nov. 20, 2026, 5:09 p.m.