22 const std::vector<Real> & y,
28 mooseError(
"PolynomialFit does not allow empty input vectors");
34 else if (
_x.size() <= order)
35 mooseError(
"PolynomialFit requires an order less than the size of the input vector");
43 unsigned int num_rows =
_x.size();
44 unsigned int num_cols =
_order + 1;
45 _matrix.resize(num_rows * num_cols);
47 for (
unsigned int col = 0; col < num_cols; ++col)
48 for (
unsigned int row = 0; row < num_rows; ++row)
55 unsigned int size =
_coeffs.size();
59 for (
unsigned int i = 0; i < size; ++i)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Base class for linear least squares fit method.
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.
std::vector< Real > _matrix
Basis functions evaluated at each independent variable (note: actually a vector)
bool _truncate_order
Flag to implement a truncated polynomial.
PolynomialFit(const std::vector< Real > &x, const std::vector< Real > &y, unsigned int order, bool truncate_order=false)
static int _file_number
File number.
unsigned int _order
Order of the polynomial.
virtual Real sample(Real x) override
This function will take an independent variable input and will return the dependent variable based on...
virtual void fillMatrix() override
Helper function that creates the matrix necessary for the least squares algorithm.