Public Member Functions | Private Member Functions | Private Attributes | List of all members
gnsstk::PolyFit< T > Class Template Reference

Detailed Description

template<class T>
class gnsstk::PolyFit< T >

Compute a polynomial fit of the form sum[X(i)*t**i] = d, that is solve for coefficients X given a set of data pairs (t,d). The dimension of X is n, the degree of the polynomial.

unsigned int i,n=4;
double dat[17]={...}, times[17]={...};
PolyFit<double> PF(n);
for(i=0; i<17; i++)
PF.Add(dat[i],times[i]);
cout << "Solution vector: " << PF.Solution() << endl;
cout << "Covariance matrix: " << PF.Covariance() << endl;
for(i=0; i<17; i++)
cout << times[i] << " " << dat[i] << " " << PF.Evaluate(times[i]) << endl;

Definition at line 73 of file PolyFit.hpp.

#include <PolyFit.hpp>

Public Member Functions

void Add (const std::vector< T > &d, const std::vector< T > &t)
 Add a std::vector of data to the estimation. More...
 
void Add (const Vector< T > &d, const Vector< T > &t)
 Add a gnsstk::Vector of data to the estimation. More...
 
void Add (T d, T t, T w=T(1))
 Add a single (optional: weighted) datum to the estimation. More...
 
Matrix< T > Covariance (void)
 get the covariance matrix More...
 
unsigned int Degree (void) const
 get the degree of the polynomial More...
 
Vector< T > Evaluate (const Vector< T > &Vt)
 
Evaluate (T t)
 
bool isSingular (void)
 is the problem singular? More...
 
unsigned int N (void) const
 get the number of data points processed More...
 
 PolyFit ()
 Empty constructor. More...
 
 PolyFit (unsigned int n)
 Constructor given an initial size. More...
 
void Reset (unsigned int n=0)
 
Vector< T > Solution (void)
 get the solution vector (coefficients) More...
 

Private Member Functions

void Solve (void)
 Invert the equation. More...
 

Private Attributes

Matrix< T > Cov
 Covariance matrix. More...
 
Vector< T > InfData
 information data = inverse(Cov)*X = sum[transpose(P)*data]. More...
 
Matrix< T > InfMatrix
 information matrix = inverse(Cov) = sum[transpose(P)*P], P=partials. More...
 
bool Inverted
 flag indicating problem has been inverted. More...
 
unsigned int n_
 degree of polynomial to be fit (dimension of state). More...
 
unsigned int Npts
 number of data points added to the estimation so far. More...
 
bool Singular
 flag indicating problem is singular. More...
 
Vector< T > X
 State vector (array of polynomial coefficients) of size n_. More...
 

Constructor & Destructor Documentation

◆ PolyFit() [1/2]

template<class T >
gnsstk::PolyFit< T >::PolyFit ( )
inline

Empty constructor.

Definition at line 77 of file PolyFit.hpp.

◆ PolyFit() [2/2]

template<class T >
gnsstk::PolyFit< T >::PolyFit ( unsigned int  n)
inline

Constructor given an initial size.

Definition at line 79 of file PolyFit.hpp.

Member Function Documentation

◆ Add() [1/3]

template<class T >
void gnsstk::PolyFit< T >::Add ( const std::vector< T > &  d,
const std::vector< T > &  t 
)
inline

Add a std::vector of data to the estimation.

Definition at line 152 of file PolyFit.hpp.

◆ Add() [2/3]

template<class T >
void gnsstk::PolyFit< T >::Add ( const Vector< T > &  d,
const Vector< T > &  t 
)
inline

Add a gnsstk::Vector of data to the estimation.

Definition at line 129 of file PolyFit.hpp.

◆ Add() [3/3]

template<class T >
void gnsstk::PolyFit< T >::Add ( d,
t,
w = T(1) 
)
inline

Add a single (optional: weighted) datum to the estimation.

Definition at line 110 of file PolyFit.hpp.

◆ Covariance()

template<class T >
Matrix<T> gnsstk::PolyFit< T >::Covariance ( void  )
inline

get the covariance matrix

Definition at line 220 of file PolyFit.hpp.

◆ Degree()

template<class T >
unsigned int gnsstk::PolyFit< T >::Degree ( void  ) const
inline

get the degree of the polynomial

Definition at line 222 of file PolyFit.hpp.

◆ Evaluate() [1/2]

template<class T >
Vector<T> gnsstk::PolyFit< T >::Evaluate ( const Vector< T > &  Vt)
inline

Evaluate the polynomial at a Vector of times; singular problems return an empty vector.

Definition at line 195 of file PolyFit.hpp.

◆ Evaluate() [2/2]

template<class T >
T gnsstk::PolyFit< T >::Evaluate ( t)
inline

Evaluate the polynomial at the given time; singular problems return zero.

Definition at line 177 of file PolyFit.hpp.

◆ isSingular()

template<class T >
bool gnsstk::PolyFit< T >::isSingular ( void  )
inline

is the problem singular?

Definition at line 216 of file PolyFit.hpp.

◆ N()

template<class T >
unsigned int gnsstk::PolyFit< T >::N ( void  ) const
inline

get the number of data points processed

Definition at line 224 of file PolyFit.hpp.

◆ Reset()

template<class T >
void gnsstk::PolyFit< T >::Reset ( unsigned int  n = 0)
inline

Reset the estimation, i.e. restart with new data, with new dimension. Default dimension is 0, meaning do not change dimension.

Definition at line 91 of file PolyFit.hpp.

◆ Solution()

template<class T >
Vector<T> gnsstk::PolyFit< T >::Solution ( void  )
inline

get the solution vector (coefficients)

Definition at line 218 of file PolyFit.hpp.

◆ Solve()

template<class T >
void gnsstk::PolyFit< T >::Solve ( void  )
inlineprivate

Invert the equation.

Definition at line 228 of file PolyFit.hpp.

Member Data Documentation

◆ Cov

template<class T >
Matrix<T> gnsstk::PolyFit< T >::Cov
private

Covariance matrix.

Definition at line 253 of file PolyFit.hpp.

◆ InfData

template<class T >
Vector<T> gnsstk::PolyFit< T >::InfData
private

information data = inverse(Cov)*X = sum[transpose(P)*data].

Definition at line 245 of file PolyFit.hpp.

◆ InfMatrix

template<class T >
Matrix<T> gnsstk::PolyFit< T >::InfMatrix
private

information matrix = inverse(Cov) = sum[transpose(P)*P], P=partials.

Definition at line 243 of file PolyFit.hpp.

◆ Inverted

template<class T >
bool gnsstk::PolyFit< T >::Inverted
private

flag indicating problem has been inverted.

Definition at line 247 of file PolyFit.hpp.

◆ n_

template<class T >
unsigned int gnsstk::PolyFit< T >::n_
private

degree of polynomial to be fit (dimension of state).

Definition at line 239 of file PolyFit.hpp.

◆ Npts

template<class T >
unsigned int gnsstk::PolyFit< T >::Npts
private

number of data points added to the estimation so far.

Definition at line 241 of file PolyFit.hpp.

◆ Singular

template<class T >
bool gnsstk::PolyFit< T >::Singular
private

flag indicating problem is singular.

Definition at line 249 of file PolyFit.hpp.

◆ X

template<class T >
Vector<T> gnsstk::PolyFit< T >::X
private

State vector (array of polynomial coefficients) of size n_.

Definition at line 251 of file PolyFit.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:45