TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
nda::lapack::gelss_worker< T >

#include <nda/lapack/gelss_worker.hpp>

Detailed Description

template<typename T>
class nda::lapack::gelss_worker< T >

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.

Template Parameters
TValue 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.
 

Constructor & Destructor Documentation

◆ gelss_worker()

template<typename T >
nda::lapack::gelss_worker< T >::gelss_worker ( matrix< T > A_)
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.

Parameters
A_Matrix to be decomposed by SVD.

Definition at line 107 of file gelss_worker.hpp.

Member Function Documentation

◆ n_var()

template<typename T >
int nda::lapack::gelss_worker< T >::n_var ( ) const
inline

Get the number of variables of the given problem.

Returns
Number of columns of the matrix \( \mathbf{A} \) .

Definition at line 90 of file gelss_worker.hpp.

◆ operator()() [1/2]

template<typename T >
std::pair< matrix< T >, double > nda::lapack::gelss_worker< T >::operator() ( matrix_const_view< T > B,
std::optional< long > = {} ) const
inline

Solve the least-square problem for a given right hand side matrix \( \mathbf{B} \).

Parameters
BRight hand side matrix.
Returns
A std::pair containing the solution matrix \( \mathbf{X} \) and the error of the least square problem.

Definition at line 134 of file gelss_worker.hpp.

◆ operator()() [2/2]

template<typename T >
std::pair< vector< T >, double > nda::lapack::gelss_worker< T >::operator() ( vector_const_view< T > b,
std::optional< long > = {} ) const
inline

Solve the least-square problem for a given right hand side vector \( \mathbf{b} \).

Parameters
bRight hand side vector.
Returns
A std::pair containing the solution vector \( \mathbf{x} \) and the error of the least square problem.

Definition at line 151 of file gelss_worker.hpp.

◆ S_vec()

template<typename T >
array< double, 1 > const & nda::lapack::gelss_worker< T >::S_vec ( ) const
inlinenodiscard

Get the singular value array.

Returns
1-dimensional array containing the singular values.

Definition at line 96 of file gelss_worker.hpp.


The documentation for this class was generated from the following file: