TRIQS/nda 1.3.0
Multi-dimensional array library for C++
|
#include <nda/lapack/gelss_worker.hpp>
Worker class for solving linear least square problems.
Solving a linear least squares problem means finding the minimum norm solution \( \mathbf{x} \) of a linear system of equations, i.e.
\[ \min_x | \mathbf{b} - \mathbf{A x} |_2 \; , \]
where \( \mathbf{A} \) is a given matrix and \( \mathbf{b} \) is a given vector (although it can also be a matrix, in this case one gets a solution matrix \( \mathbf{X} \)).
See https://math.stackexchange.com/questions/772039/how-does-the-svd-solve-the-least-squares-problem for the notation used in this file.
T | Value type of the given problem. |
Definition at line 68 of file gelss_worker.hpp.
Public Member Functions | |
gelss_worker (matrix< T > A_) | |
Construct a new worker object for a given matrix \( \mathbf{A} \) . | |
int | n_var () const |
Get the number of variables of the given problem. | |
std::pair< matrix< T >, double > | operator() (matrix_const_view< T > B, std::optional< long >={}) const |
Solve the least-square problem for a given right hand side matrix \( \mathbf{B} \). | |
std::pair< vector< T >, double > | operator() (vector_const_view< T > b, std::optional< long >={}) const |
Solve the least-square problem for a given right hand side vector \( \mathbf{b} \). | |
array< double, 1 > const & | S_vec () const |
Get the singular value array. | |
|
inline |
Construct a new worker object for a given matrix \( \mathbf{A} \) .
It performs the SVD decomposition of the given matrix \( \mathbf{A} \) and calculates the (pseudo) inverse of \( \mathbf{A} \). Furthermore, it sets the null space term which determines the error of the least square problem.
A_ | Matrix to be decomposed by SVD. |
Definition at line 107 of file gelss_worker.hpp.
|
inline |
Get the number of variables of the given problem.
Definition at line 90 of file gelss_worker.hpp.
|
inline |
Solve the least-square problem for a given right hand side matrix \( \mathbf{B} \).
B | Right hand side matrix. |
Definition at line 134 of file gelss_worker.hpp.
|
inline |
Solve the least-square problem for a given right hand side vector \( \mathbf{b} \).
b | Right hand side vector. |
Definition at line 151 of file gelss_worker.hpp.
|
inlinenodiscard |
Get the singular value array.
Definition at line 96 of file gelss_worker.hpp.