numerics 0.1.0
Loading...
Searching...
No Matches
svd.hpp
Go to the documentation of this file.
1/// @file svd/svd.hpp
2/// @brief Dense and randomized truncated SVD.
3#pragma once
4
5#include "core/matrix.hpp"
6#include "core/policy.hpp"
7#include "core/util/math.hpp"
8#include "core/vector.hpp"
10#include <algorithm>
11#include <cmath>
12#include <stdexcept>
13
14namespace num {
15
16struct SVDResult {
21 bool converged = false;
22};
23
24SVDResult svd(const Matrix& A,
25 Backend backend = lapack_backend,
26 real tol = 1e-12,
27 idx max_sweeps = 100);
28
30 idx k,
31 Backend backend = default_backend,
32 idx oversampling = 10,
33 Rng* rng = nullptr);
34
35} // namespace num
Backend enum and default backend selection.
Thin wrappers around <cmath> and <numeric> with readable names.
Dense row-major matrix templated over scalar type T.
SVDResult svd_truncated(const Matrix &A, idx k, Backend backend=default_backend, idx oversampling=10, Rng *rng=nullptr)
Definition svd.cpp:20
double real
Definition types.hpp:10
Backend
Definition policy.hpp:7
std::size_t idx
Definition types.hpp:11
SVDResult svd(const Matrix &A, Backend backend=lapack_backend, real tol=1e-12, idx max_sweeps=100)
Definition svd.cpp:11
constexpr Backend lapack_backend
Definition policy.hpp:66
constexpr real e
Definition math.hpp:44
constexpr Backend default_backend
Definition policy.hpp:53
QR factorization via Householder reflections.
Seeded pseudo-random number generator (Mersenne Twister). Pass a pointer to rng_* functions to draw s...
Definition math.hpp:281
Matrix Vt
Definition svd.hpp:19
Matrix U
Definition svd.hpp:17
Vector S
Definition svd.hpp:18
bool converged
Definition svd.hpp:21
Dense vector storage and operations.