https://mooseframework.inl.gov
LeastSquaresFitBase.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include <vector>
13 #include <string>
14 
15 #include "Moose.h"
16 
24 {
25 public:
27  LeastSquaresFitBase(const std::vector<Real> & x, const std::vector<Real> & y);
28 
29  virtual ~LeastSquaresFitBase() = default;
30 
36  virtual void generate();
37 
44  virtual Real sample(Real x) = 0;
45 
50  unsigned int getSampleSize();
51 
56  const std::vector<Real> & getCoefficients();
57 
58  void setVariables(const std::vector<Real> & x, const std::vector<Real> & y);
59 
60 protected:
64  virtual void fillMatrix() = 0;
65 
70  void doLeastSquares();
71 
73  std::vector<Real> _x;
75  std::vector<Real> _y;
77  std::vector<Real> _matrix;
79  std::vector<Real> _coeffs;
81  unsigned int _num_coeff;
82 };
void doLeastSquares()
Wrapper for the LAPACK dgels function.
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.
Base class for linear least squares fit method.
std::vector< Real > _y
Dependent variable.
virtual ~LeastSquaresFitBase()=default
virtual void generate()
Generate the fit.
std::vector< Real > _x
Independent variable.
void setVariables(const std::vector< Real > &x, const std::vector< Real > &y)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real sample(Real x)=0
This function will take an independent variable input and will return the dependent variable based on...
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)