Represents a factorization of a system of equations with no exact solution such that the Cholesky method of least squares can be used. More...
#include <rw/lapack/lsch.h>
Public Member Functions | |
RWLeastSqCh () | |
RWLeastSqCh (const RWGenMat< TypeT > &A) | |
unsigned | cols () const |
void | factor (const RWGenMat< TypeT > &A) |
bool | fail () const |
bool | good () const |
unsigned | rank () const |
RWMathVec< TypeT > | residual (const RWMathVec< TypeT > &b) const |
rw_numeric_traits< TypeT >::norm_type | residualNorm (const RWMathVec< TypeT > &b) const |
unsigned | rows () const |
RWMathVec< TypeT > | solve (const RWMathVec< TypeT > &b) const |
A linear system of equations has the form \( Ax = b \), where A contains more rows than columns and generally has no exact solution; it is overdetermined. The best that we can do is to find a solution vector x such that the norm of the residual vector, \( Ax-b \), is made as small as possible. The vector x is then a solution in the least squares sense, and this sort of problem is called a least squares problem.
There are three classes in the Linear Algebra Module for solving least squares problems. The approach is to construct a factorization of the matrix A that can be used to solve the problem. The classes RWLeastSqCh RWLeastSqQR and RWLeastSqSV encapsulate this factorization object. There are three methods provided:
Ch
QR
SV
.Which method you choose depends on the trade-off between speed and robustness that you want to make. As you move down the list, the methods decrease in speed, but increase in accuracy and robustness.
A system of equations \( Ax = b \) is underdetermined if the columns of A are linearly dependent. In this case, there are infinitely many solutions. Often, the one that is desired is the one with minimum norm. The classes RWLeastSqQR and RWLeastSqSV allow you to compute this solution.
Note that the classes RWLeastSqQR and RWLeastSqSV are publicly derived from their underlying decomposition types, so that advanced users can manipulate the underlying decomposition directly.
RWLeastSqCh< TypeT >::RWLeastSqCh | ( | ) |
Default constructor. Builds an empty decomposition. The decomposition is filled in using the factor function.
RWLeastSqCh< TypeT >::RWLeastSqCh | ( | const RWGenMat< TypeT > & | A | ) |
Constructs a factorization representing the given matrix.
|
inline |
Returns the number of columns in the matrix represented by this factorization.
void RWLeastSqCh< TypeT >::factor | ( | const RWGenMat< TypeT > & | A | ) |
Replaces the current factorization with a factorization representing the given matrix. The current factorization is lost.
|
inline |
Indicates whether the construction of the factorization is successful. The factorization can fail if the system matrix is not of full rank.
|
inline |
Indicates whether the construction of the factorization is successful. The factorization can fail if the system matrix is not of full rank.
|
inline |
Returns the rank the matrix represented by this factorization.
RWMathVec<TypeT> RWLeastSqCh< TypeT >::residual | ( | const RWMathVec< TypeT > & | b | ) | const |
Returns the residual vector, \( b-Ax \), associated with the right-hand side vector b and the corresponding least squares solution vector x
.
rw_numeric_traits<TypeT>::norm_type RWLeastSqCh< TypeT >::residualNorm | ( | const RWMathVec< TypeT > & | b | ) | const |
Returns the norm of the residual vector, \( (b-Ax)'(b-Ax) \), associated with the right-hand side vector b and the corresponding least squares solution vector x
.
|
inline |
Returns the number of rows in the matrix represented by this factorization.
RWMathVec<TypeT> RWLeastSqCh< TypeT >::solve | ( | const RWMathVec< TypeT > & | b | ) | const |
Returns the solution to the least squares problem for the given right-hand-side vector b. If the system matrix is overdetermined, this is the vector that minimizes the norm of the residual vector. If the system matrix is not overdetermined, this is the minimum norm vector that satisfies the system equations.
Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |