22 #ifndef CRNPolynomialRegression_HEADER
23 #define CRNPolynomialRegression_HEADER
55 data(std::distance(beg, en)),
56 coefficients(dim + 1),
61 if (data.size() < dimension)
64 for (Iter tmp = beg; tmp != en; ++tmp)
65 data[cnt++] = makePoint(*tmp);
81 virtual double operator[](
double x)
const override;
83 using Cartesian2DFunction::operator[];
88 const std::vector<crn::Point2DDouble>&
GetData() const noexcept {
return data; }
90 const std::vector<double>&
GetCoefficients() const noexcept {
return coefficients; }
100 template<
typename T,
typename Y> Point2DDouble makePoint(
const std::pair<T, Y> &p)
103 void computeCoeffs();
105 std::vector<double> coefficients;
106 std::vector<crn::Point2DDouble> data;
PolynomialRegression(Iter beg, Iter en, size_t dim)
Constructor from a list of points.
void TranslateY(int increment)
Translates the polynomial.
PolynomialRegression & operator=(const PolynomialRegression &)=default
const std::vector< crn::Point2DDouble > & GetData() const noexcept
Access to the sorted control point.
virtual double operator[](double x) const override
Gets ordinate at x (double)
Extrapolation
Extrapolation modes.
size_t GetDimension() const noexcept
Returns the dimension of the polynomial.
const std::vector< double > & GetCoefficients() const noexcept
Access to the coefficients of the polynomial.
virtual ~PolynomialRegression() override
Base class for 2D functions.
#define CRN_DECLARE_CLASS_CONSTRUCTOR(classname)
Declares a class constructor.
void SetExtrapolationMode(Extrapolation ex) noexcept
Sets the behaviour for points before the first control point and after the last control point...
CRN_ALIAS_SMART_PTR(ImageBW)