numerics 0.1.0
Loading...
Searching...
No Matches
svd.cpp File Reference

SVD dispatcher + randomized truncated SVD. More...

Go to the source code of this file.

Namespaces

namespace  num
 

Functions

SVDResult num::svd (const Matrix &A, Backend backend=lapack_backend, real tol=1e-12, idx max_sweeps=100)
 Full SVD of an mxn matrix.
 
SVDResult num::svd_truncated (const Matrix &A, idx k, Backend backend=default_backend, idx oversampling=10, Rng *rng=nullptr)
 Randomized truncated SVD – top-k singular triplets.
 

Detailed Description

SVD dispatcher + randomized truncated SVD.

One-sided Jacobi SVD

Apply Givens rotations G to the columns of A from the right until the columns are mutually orthogonal. Each rotation zeros (A^T*A)[p,q]:

Given col_p and col_q of the working matrix A: alpha = col_p * col_p, beta = col_q * col_q, gamma = col_p * col_q zeta = (beta - alpha) / (2gamma) t = sign(zeta) / (|zeta| + sqrt(1 + zeta^2)) c = 1/sqrt(1+t^2), s = c*t

Randomized SVD

Halko, Martinsson, Tropp (2011) "Finding Structure with Randomness".

Backend routing: Backend::lapack -> backends::lapack::svd (LAPACKE_dgesdd, divide-and-conquer) everything else -> backends::seq::svd (one-sided Jacobi)

Definition in file svd.cpp.