|
NumericAL
A header-only C++20 lexer built on REAL
|
The singular value decomposition A = U Σ Vᴴ of an m × n matrix.
More...
#include <decomposition.hpp>
Public Member Functions | |
| svd_decomposition (const matrix< T > &a, svd_method method=svd_method::divide_and_conquer, bool full=false) | |
Decomposes a. | |
| const vector< double > & | singular_values () const noexcept |
| The singular values, descending. | |
| const matrix< T > & | u () const &noexcept |
The left singular vectors U (columns): m × k, or m × m full. | |
| matrix< T > | u () && |
U, moved out of an expiring decomposition (v and the singular values stay). | |
| const matrix< T > & | v () const &noexcept |
The right singular vectors V (columns): n × k, or n × n full. | |
| matrix< T > | vh () const |
Vᴴ (k × n, or n × n full), so that A = U Σ Vᴴ reads u() * diag(singular_values()) * vh() (full, Σ padded with zeros to m × n). | |
Private Member Functions | |
| void | factor (const matrix< T > &a, svd_method method, bool full) |
Decomposes an m × n a with m ≥ n into u_, singular_values_ and v_, U square when full. | |
Static Private Member Functions | |
| static matrix< T > | left_vectors (buffer< T > q, buffer< T > left, std::size_t rows, std::size_t cols, std::size_t width) |
U from the Householder q (rows × width) and the left vectors left of R (cols × cols): Q times them, and when Q is complete (width = rows) its columns past cols after them. | |
| static void | orthogonalise (buffer< T > &x, const buffer< T > &basis, std::size_t n, std::size_t count) |
Removes from x its components along the first count columns of the n × n basis. | |
Private Attributes | |
| vector< double > | singular_values_ |
| Singular values, descending. | |
| matrix< T > | u_ |
| m×k left singular vectors. | |
| matrix< T > | v_ |
| n×k right singular vectors. | |
The singular value decomposition A = U Σ Vᴴ of an m × n matrix.
| T | The scalar element type (double or std::complex<double>). |
With k = min(m, n): the k singular values, descending; U (m × k) and V (n × k) with orthonormal columns, also where A is rank-deficient. Computed after a Householder QR of A (of Aᴴ when m < n): by default R is reduced to bidiagonal form and the bidiagonal decomposed by divide and conquer (svd_method::divide_and_conquer), the method of LAPACK's dgesdd, most of its work in matrix products, or by implicit-shift QR (svd_method::bidiagonal_qr, dgesvd's); either way each singular value to an absolute accuracy of the largest times the machine epsilon. One-sided Jacobi on R (svd_method::jacobi) gives every singular value to high relative accuracy — the small ones of a graded matrix too — at several times the cost. vh is Vᴴ, the third factor NumPy's svd returns. Full (full true, NumPy's full_matrices=True), U is m × m and V n × n: the columns past k are an orthonormal basis of the complement, the rest of the complete Householder Q of the larger side.
Definition at line 6017 of file decomposition.hpp.
|
inlineexplicit |
Decomposes a.
| [in] | a | The matrix. |
| [in] | method | The algorithm for R. |
| [in] | full | Whether U and V are square (m × m, n × n), as NumPy's full_matrices=True. |
| non_finite_error | If an entry is infinite or NaN. |
| convergence_error | If the iteration does not converge within its bound (not observed). |
Definition at line 6029 of file decomposition.hpp.
|
inlineprivate |
Decomposes an m × n a with m ≥ n into u_, singular_values_ and v_, U square when full.
Definition at line 6101 of file decomposition.hpp.
|
inlinestaticprivate |
U from the Householder q (rows × width) and the left vectors left of R (cols × cols): Q times them, and when Q is complete (width = rows) its columns past cols after them.
Definition at line 6080 of file decomposition.hpp.
|
inlinestaticprivate |
Removes from x its components along the first count columns of the n × n basis.
Definition at line 6227 of file decomposition.hpp.
|
inlinenoexcept |
The singular values, descending.
Definition at line 6044 of file decomposition.hpp.
U, moved out of an expiring decomposition (v and the singular values stay).
Definition at line 6056 of file decomposition.hpp.
|
inlinenoexcept |
The left singular vectors U (columns): m × k, or m × m full.
Definition at line 6050 of file decomposition.hpp.
|
inlinenoexcept |
The right singular vectors V (columns): n × k, or n × n full.
Definition at line 6062 of file decomposition.hpp.
Vᴴ (k × n, or n × n full), so that A = U Σ Vᴴ reads u() * diag(singular_values()) * vh() (full, Σ padded with zeros to m × n).
Definition at line 6069 of file decomposition.hpp.
Singular values, descending.
Definition at line 6243 of file decomposition.hpp.
m×k left singular vectors.
Definition at line 6244 of file decomposition.hpp.
n×k right singular vectors.
Definition at line 6245 of file decomposition.hpp.