sablib
Loading...
Searching...
No Matches
polyfit.h File Reference

Polynomial fitting using the least squares method (Gauss-Newton for linear models). More...

#include <stdexcept>
#include <Eigen/Eigen>

Go to the source code of this file.

Functions

template<typename Derived>
const Derived::PlainObject sablib::PolyFit (const Eigen::MatrixBase< Derived > &x, const Eigen::MatrixBase< Derived > &y, const unsigned int polyorder)
 Fits a polynomial of a specified order to the given data points.

Detailed Description

Polynomial fitting using the least squares method (Gauss-Newton for linear models).

Author
Izadori

Definition in file polyfit.h.

Function Documentation

◆ PolyFit()

template<typename Derived>
const Derived::PlainObject sablib::PolyFit ( const Eigen::MatrixBase< Derived > & x,
const Eigen::MatrixBase< Derived > & y,
const unsigned int polyorder )

Fits a polynomial of a specified order to the given data points.

This function uses the normal equations, which is the Gauss-Newton method applied to a linear model.

Template Parameters
DerivedThe derived type of the Eigen object.
Parameters
xThe x-coordinates of the data points.
yThe y-coordinates of the data points.
polyorderThe order of the polynomial to fit.
Returns
The coefficients of the fitted polynomial (from lowest to highest order).
Exceptions
std::invalid_argumentThrown if x and y sizes differ or if polyorder is too high.

Definition at line 29 of file polyfit.h.