Dense row-major matrix with optional GPU storage.
Thin wrappers around C++17 <cmath> and <numeric> with readable names.
SVDResult svd_truncated(const Matrix &A, idx k, Backend backend=default_backend, idx oversampling=10, Rng *rng=nullptr)
Randomized truncated SVD – top-k singular triplets.
Backend
Selects which backend handles a linalg operation.
@ seq
Naive textbook loops – always available.
constexpr T ipow(T x) noexcept
Compute x^N at compile time via repeated squaring.
SVDResult svd(const Matrix &A, Backend backend=Backend::seq, real tol=1e-12, idx max_sweeps=100)
Full SVD of an mxn matrix via one-sided Jacobi.
constexpr Backend default_backend
Backend enum for linear algebra operations.
QR factorization via Householder reflections.
Seeded pseudo-random number generator (Mersenne Twister). Pass a pointer to rng_* functions to draw s...
Result of a Singular Value Decomposition: A = U * diag(S) * Vᵀ
Matrix Vt
rxn right singular vectors (rows orthonormal)
Matrix U
mxr left singular vectors (columns orthonormal)
Vector S
r singular values in descending order
bool converged
Whether Jacobi converged (always true for randomized)
idx sweeps
Jacobi sweeps (full SVD only; 0 for randomized)