13 #include "libmesh/int_range.h" 15 #include "libmesh/ignore_warnings.h" 16 #include <Eigen/Dense> 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);
63 const std::vector<Real> &
void doLeastSquares()
Wrapper for the LAPACK dgels function.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
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.
unsigned int _num_coeff
The number of coefficients.
std::vector< Real > _y
Dependent variable.
virtual void generate()
Generate the fit.
std::vector< Real > _x
Independent variable.
void setVariables(const std::vector< Real > &x, const std::vector< Real > &y)
const std::vector< Real > & getCoefficients()
Const reference to the vector of coefficients of the least squares fit.
std::vector< Real > _coeffs
Vector of coefficients of the least squares fit.
std::vector< Real > _matrix
Basis functions evaluated at each independent variable (note: actually a vector)