0.4.1
Loading...
Searching...
No Matches
NAV::PolynomialRegressor< Scalar > Class Template Reference

Polynomial Curve Fitting. More...

Public Types

enum class  Strategy : uint8_t {
  IncrementalLeastSquares ,
  LeastSquares ,
  HouseholderQR ,
  BDCSVD ,
  COD ,
  COUNT
}
 Possible Fit strategies. More...
 

Public Member Functions

Polynomial< Scalar > calcPolynomial () const
 Calculates the polynomial.
 
const ScrollingBuffer< std::pair< Scalar, Scalar > > & data () const
 Gets the underlying buffer.
 
bool empty () const
 Checks if the container has no elements.
 
 PolynomialRegressor (size_t polynomialDegree, size_t windowSize, Strategy strategy=Strategy::HouseholderQR)
 Constructor.
 
void push_back (const Scalar &x, const Scalar &y)
 Add a data point to the polynomial.
 
void push_back (const std::pair< Scalar, Scalar > &dataPoint)
 Add a data point to the polynomial.
 
void reset ()
 Reset the polynomial coefficients and saved data.
 
void setPolynomialDegree (size_t polynomialDegree)
 Set the Polynomial Degree and resets the data.
 
void setStrategy (Strategy strategy)
 Set the strategy for the fit and resets the data.
 
void setWindowSize (size_t windowSize)
 Sets the amount of points used for the fit (sliding window)
 
bool windowSizeReached () const
 Checks if the amount of data points equals the window size.
 

Private Member Functions

void pop_front ()
 Removes the first data point from the polynomial fit (sliding window)
 

Private Attributes

ScrollingBuffer< std::pair< Scalar, Scalar > > _data
 Values added to the fit.
 
IncrementalLeastSquares< Scalar > _incrementalLSQ
 Incremental LSQ Regressor.
 
size_t _polyDegree
 Polynomial degree to fit.
 
Strategy _strategy
 Strategy to use to fit the polynomial.
 
size_t _windowSize
 Amount of points to store.
 

Detailed Description

template<typename Scalar = double>
class NAV::PolynomialRegressor< Scalar >

Polynomial Curve Fitting.

Template Parameters
ScalarData type to store

Definition at line 38 of file PolynomialRegressor.hpp.

Member Enumeration Documentation

◆ Strategy

template<typename Scalar = double>
enum class NAV::PolynomialRegressor::Strategy : uint8_t
strong

Possible Fit strategies.

Enumerator
IncrementalLeastSquares 

Incremental Least Squares (only polynomials of order <= 2)

LeastSquares 

Least Squares (bas if even mildly ill-conditioned)

HouseholderQR 

Householder QR decomposition.

BDCSVD 

Bidiagonal Divide and Conquer SVD.

COD 

Complete Orthogonal Decomposition.

COUNT 

Amount of items in the enum.

Definition at line 42 of file PolynomialRegressor.hpp.

Constructor & Destructor Documentation

◆ PolynomialRegressor()

template<typename Scalar = double>
NAV::PolynomialRegressor< Scalar >::PolynomialRegressor ( size_t polynomialDegree,
size_t windowSize,
Strategy strategy = Strategy::HouseholderQR )
inline

Constructor.

Parameters
[in]polynomialDegreeDegree of the polynomial to fit
[in]windowSizeAmount of points to use for the fit (sliding window)
[in]strategyStrategy to use

Definition at line 56 of file PolynomialRegressor.hpp.

Member Function Documentation

◆ calcPolynomial()

template<typename Scalar = double>
Polynomial< Scalar > NAV::PolynomialRegressor< Scalar >::calcPolynomial ( ) const
inlinenodiscard

Calculates the polynomial.

Definition at line 143 of file PolynomialRegressor.hpp.

◆ data()

template<typename Scalar = double>
const ScrollingBuffer< std::pair< Scalar, Scalar > > & NAV::PolynomialRegressor< Scalar >::data ( ) const
inlinenodiscard

Gets the underlying buffer.

Definition at line 199 of file PolynomialRegressor.hpp.

◆ empty()

template<typename Scalar = double>
bool NAV::PolynomialRegressor< Scalar >::empty ( ) const
inlinenodiscard

Checks if the container has no elements.

Definition at line 196 of file PolynomialRegressor.hpp.

◆ pop_front()

template<typename Scalar = double>
void NAV::PolynomialRegressor< Scalar >::pop_front ( )
inlineprivate

Removes the first data point from the polynomial fit (sliding window)

Definition at line 214 of file PolynomialRegressor.hpp.

◆ push_back() [1/2]

template<typename Scalar = double>
void NAV::PolynomialRegressor< Scalar >::push_back ( const Scalar & x,
const Scalar & y )
inline

Add a data point to the polynomial.

Parameters
[in]xX Value
[in]yY Value

Definition at line 111 of file PolynomialRegressor.hpp.

◆ push_back() [2/2]

template<typename Scalar = double>
void NAV::PolynomialRegressor< Scalar >::push_back ( const std::pair< Scalar, Scalar > & dataPoint)
inline

Add a data point to the polynomial.

Parameters
[in]dataPointData point

Definition at line 103 of file PolynomialRegressor.hpp.

◆ reset()

template<typename Scalar = double>
void NAV::PolynomialRegressor< Scalar >::reset ( )
inline

Reset the polynomial coefficients and saved data.

Definition at line 136 of file PolynomialRegressor.hpp.

◆ setPolynomialDegree()

template<typename Scalar = double>
void NAV::PolynomialRegressor< Scalar >::setPolynomialDegree ( size_t polynomialDegree)
inline

Set the Polynomial Degree and resets the data.

Parameters
[in]polynomialDegreeDegree of the polynomial to fit

Definition at line 81 of file PolynomialRegressor.hpp.

◆ setStrategy()

template<typename Scalar = double>
void NAV::PolynomialRegressor< Scalar >::setStrategy ( Strategy strategy)
inline

Set the strategy for the fit and resets the data.

Parameters
strategyStrategy to use for fitting data

Definition at line 93 of file PolynomialRegressor.hpp.

◆ setWindowSize()

template<typename Scalar = double>
void NAV::PolynomialRegressor< Scalar >::setWindowSize ( size_t windowSize)
inline

Sets the amount of points used for the fit (sliding window)

Parameters
[in]windowSizeAmount of points to use for the fit

Definition at line 65 of file PolynomialRegressor.hpp.

◆ windowSizeReached()

template<typename Scalar = double>
bool NAV::PolynomialRegressor< Scalar >::windowSizeReached ( ) const
inlinenodiscard

Checks if the amount of data points equals the window size.

Definition at line 190 of file PolynomialRegressor.hpp.

Field Documentation

◆ _data

template<typename Scalar = double>
ScrollingBuffer<std::pair<Scalar, Scalar> > NAV::PolynomialRegressor< Scalar >::_data
private

Values added to the fit.

Definition at line 209 of file PolynomialRegressor.hpp.

◆ _incrementalLSQ

template<typename Scalar = double>
IncrementalLeastSquares<Scalar> NAV::PolynomialRegressor< Scalar >::_incrementalLSQ
private

Incremental LSQ Regressor.

Definition at line 211 of file PolynomialRegressor.hpp.

◆ _polyDegree

template<typename Scalar = double>
size_t NAV::PolynomialRegressor< Scalar >::_polyDegree
private

Polynomial degree to fit.

Definition at line 205 of file PolynomialRegressor.hpp.

◆ _strategy

template<typename Scalar = double>
Strategy NAV::PolynomialRegressor< Scalar >::_strategy
private

Strategy to use to fit the polynomial.

Definition at line 203 of file PolynomialRegressor.hpp.

◆ _windowSize

template<typename Scalar = double>
size_t NAV::PolynomialRegressor< Scalar >::_windowSize
private

Amount of points to store.

Definition at line 207 of file PolynomialRegressor.hpp.


The documentation for this class was generated from the following file: