Base class for linear least squares fit method. More...
#include <LeastSquaresFitBase.h>
Public Member Functions | |
LeastSquaresFitBase () | |
LeastSquaresFitBase (const std::vector< Real > &x, const std::vector< Real > &y) | |
virtual | ~LeastSquaresFitBase ()=default |
virtual void | generate () |
Generate the fit. More... | |
virtual Real | sample (Real x)=0 |
This function will take an independent variable input and will return the dependent variable based on the generated fit. More... | |
unsigned int | getSampleSize () |
Size of the array holding the points. More... | |
const std::vector< Real > & | getCoefficients () |
Const reference to the vector of coefficients of the least squares fit. More... | |
void | setVariables (const std::vector< Real > &x, const std::vector< Real > &y) |
Protected Member Functions | |
virtual void | fillMatrix ()=0 |
Helper function that creates the matrix necessary for the least squares algorithm. More... | |
void | doLeastSquares () |
Wrapper for the LAPACK dgels function. More... | |
Protected Attributes | |
std::vector< Real > | _x |
Independent variable. More... | |
std::vector< Real > | _y |
Dependent variable. More... | |
std::vector< Real > | _matrix |
Basis functions evaluated at each independent variable (note: actually a vector) More... | |
std::vector< Real > | _coeffs |
Vector of coefficients of the least squares fit. More... | |
unsigned int | _num_coeff |
The number of coefficients. More... | |
Base class for linear least squares fit method.
Derived classes must implement the fillMatrix() and sample() methods with the functional form of the fit.
Requires: LAPACK
Definition at line 23 of file LeastSquaresFitBase.h.
LeastSquaresFitBase::LeastSquaresFitBase | ( | ) |
Definition at line 19 of file LeastSquaresFitBase.C.
LeastSquaresFitBase::LeastSquaresFitBase | ( | const std::vector< Real > & | x, |
const std::vector< Real > & | y | ||
) |
Definition at line 21 of file LeastSquaresFitBase.C.
|
virtualdefault |
|
protected |
Wrapper for the LAPACK dgels function.
Called by generate() to perform the least squares fit
Definition at line 45 of file LeastSquaresFitBase.C.
Referenced by generate().
|
protectedpure virtual |
Helper function that creates the matrix necessary for the least squares algorithm.
Implemented in PolynomialFit.
Referenced by generate().
|
virtual |
Generate the fit.
This function must be called prior to using sample. Note: If you pass a vector that contains duplicate independent measures the call to LAPACK will fail
Definition at line 34 of file LeastSquaresFitBase.C.
Referenced by LeastSquaresFit::execute(), and LeastSquaresFitHistory::execute().
const std::vector< Real > & LeastSquaresFitBase::getCoefficients | ( | ) |
Const reference to the vector of coefficients of the least squares fit.
return | vector of coefficients |
Definition at line 64 of file LeastSquaresFitBase.C.
Referenced by LeastSquaresFit::execute(), and LeastSquaresFitHistory::execute().
unsigned int LeastSquaresFitBase::getSampleSize | ( | ) |
Size of the array holding the points.
Definition at line 58 of file LeastSquaresFitBase.C.
This function will take an independent variable input and will return the dependent variable based on the generated fit.
x | independent variable |
Implemented in PolynomialFit.
void LeastSquaresFitBase::setVariables | ( | const std::vector< Real > & | x, |
const std::vector< Real > & | y | ||
) |
Definition at line 27 of file LeastSquaresFitBase.C.
|
protected |
Vector of coefficients of the least squares fit.
Definition at line 79 of file LeastSquaresFitBase.h.
Referenced by doLeastSquares(), getCoefficients(), and PolynomialFit::sample().
|
protected |
Basis functions evaluated at each independent variable (note: actually a vector)
Definition at line 77 of file LeastSquaresFitBase.h.
Referenced by doLeastSquares(), and PolynomialFit::fillMatrix().
|
protected |
The number of coefficients.
Definition at line 81 of file LeastSquaresFitBase.h.
Referenced by doLeastSquares(), and PolynomialFit::PolynomialFit().
|
protected |
Independent variable.
Definition at line 73 of file LeastSquaresFitBase.h.
Referenced by PolynomialFit::fillMatrix(), generate(), getSampleSize(), PolynomialFit::PolynomialFit(), and setVariables().
|
protected |
Dependent variable.
Definition at line 75 of file LeastSquaresFitBase.h.
Referenced by doLeastSquares(), and setVariables().