Skip to main content

Module irlba

Module irlba 

Source
Expand description

Thick-restarted Lanczos bidiagonalization.

Golub–Kahan–Lanczos bidiagonalization with augmented thick restarts, following Baglama & Reichel (2005). This is the algorithm behind R’s irlba and, in spirit, scipy.sparse.linalg.svds.

§Why this rather than crate::lanczos

LAS2 keeps every Lanczos vector it generates, so its basis grows with the iteration count — unbounded in practice, since iterations defaults to min(rows, cols). Here the basis is fixed at work vectors (rank + 7 by default) no matter how many restarts are needed, so peak memory is known before the solve starts:

(work + 1) · cols + work · rows   scalars

For 200k × 30k at rank 50 that is about 95 MiB and it does not grow.

§Method

Each cycle extends the factorization

A·V  = U·B
Aᵀ·U = V·Bᵀ + β·v_next·eᵀ

to work columns, where B is small and bidiagonal, then takes the SVD of B. Its singular values are the Ritz estimates and |β · P[work-1, i]| is the residual for triplet i. Unconverged cycles restart from the rank best Ritz vectors plus the residual direction, which preserves the factorization’s structure — the restart costs one extra column in B rather than throwing the subspace away.

Structs§

IrlbaConfig
Configuration for svd_with.

Constants§

DEFAULT_EXTRA_WORK
Default extra basis vectors beyond the requested rank.
DEFAULT_MAX_RESTARTS
Default cap on restart cycles.
DEFAULT_TOL
Default relative residual tolerance.

Functions§

svd
rank largest singular triplets, defaults throughout.
svd_centered
PCA: rank largest singular triplets of the implicitly mean-centered matrix.
svd_seed
rank largest singular triplets with a fixed seed.
svd_with
Compute a decomposition with explicit configuration.