13#include "libmesh/int_range.h"
15#include "libmesh/ignore_warnings.h"
17#include "libmesh/restore_warnings.h"
37 mooseError(
"Empty variables in LeastSquaresFitBase. x and y must be set in the constructor or "
38 "using setVariables(x, y)");
49 typedef Eigen::Matrix<Real, Eigen::Dynamic, 1> SolveVec;
50 auto b = Eigen::Map<SolveVec, Eigen::Unaligned>(
_y.data(),
_y.size());
52 typedef Eigen::Matrix<Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor> SolveMatrix;
54 x = A.colPivHouseholderQr().solve(b);
63const std::vector<Real> &
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
virtual void generate()
Generate the fit.
virtual void fillMatrix()=0
Helper function that creates the matrix necessary for the least squares algorithm.
unsigned int getSampleSize()
Size of the array holding the points.
std::vector< Real > _x
Independent variable.
std::vector< Real > _coeffs
Vector of coefficients of the least squares fit.
unsigned int _num_coeff
The number of coefficients.
const std::vector< Real > & getCoefficients()
Const reference to the vector of coefficients of the least squares fit.
void doLeastSquares()
Wrapper for the LAPACK dgels function.
void setVariables(const std::vector< Real > &x, const std::vector< Real > &y)
std::vector< Real > _y
Dependent variable.
std::vector< Real > _matrix
Basis functions evaluated at each independent variable (note: actually a vector)