PCL
pcl::GenericChebyshevFit< Tx, Ty > Class Template Reference

Approximation of vector-valued functions by Chebyshev polynomial expansions. More...

#include <ChebyshevFit.h>

+ Inheritance diagram for pcl::GenericChebyshevFit< Tx, Ty >:

Public Types

typedef GenericMultiVector< Ty > coefficient_series
 
typedef GenericVector< Ty > coefficients
 
typedef GenericVector< Ty > function_value
 
typedef GenericMultiVector< Ty > function_values
 

Public Member Functions

template<class F >
 GenericChebyshevFit (F f, Tx x1, Tx x2, int N, int n)
 
 GenericChebyshevFit (const coefficient_series &ck, Tx x1, Tx x2)
 
 GenericChebyshevFit ()=default
 
 GenericChebyshevFit (const GenericChebyshevFit &)=default
 
 GenericChebyshevFit (GenericChebyshevFit &&)=default
 
const coefficient_seriesCoefficients () const
 
GenericChebyshevFit Derivative () const
 
function_value Evaluate (Tx x) const
 
GenericChebyshevFit Integral () const
 
bool IsTruncated (int i=-1) const
 
bool IsValid () const
 
int Length (int i=0) const
 
Tx LowerBound () const
 
int NumberOfCoefficients () const
 
int NumberOfComponents () const
 
int NumberOfTruncatedCoefficients () const
 
function_value operator() (Tx x) const
 
GenericChebyshevFitoperator= (const GenericChebyshevFit &)=default
 
GenericChebyshevFitoperator= (GenericChebyshevFit &&)=default
 
bool Truncate (Ty e)
 
int TruncatedLength (int i=-1) const
 
Ty TruncationError (int i=-1) const
 
Tx UpperBound () const
 

Detailed Description

template<typename Tx, typename Ty>
class pcl::GenericChebyshevFit< Tx, Ty >

GenericChebyshevFit approximates a smooth, vector-valued function f(x) in a given interval [a,b] by expansion with a set of truncated series of Chebyshev polynomials. As is well known, the Chebyshev expansion:

T(x) = Sum_i( ci*Ti(x) ),

where i belongs to [0,∞), Ti(x) is the Chebyshev polynomial of the ith degree, and the ci's are polynomial coefficients, is very close to the optimal approximating polynomial that minimizes the error |T(x) - f(x)|, where x varies over the fitting interval [a,b].

For functions converging strongly after a given series length n, one can truncate the Chebyshev series to a smaller length m < n to obtain an approximating polynomial with a maximum error close to |Tm+1(x)|.

In addition to Chebyshev expansion, truncation and approximation, this class also implements generation of Chebyshev polynomials to approximate the first derivative and indefinite integral of the fitted function.

The template argument Tx represents the type of the independent variable, or the type of the argument x of the fitted function y = f(x). The template argument Ty represents the type of a component of the value y of the fitted function.

Definition at line 101 of file ChebyshevFit.h.

Member Typedef Documentation

◆ coefficient_series

template<typename Tx, typename Ty>
typedef GenericMultiVector<Ty> pcl::GenericChebyshevFit< Tx, Ty >::coefficient_series

Represents a set of ordered lists of Chebyshev polynomial coefficients.

Definition at line 113 of file ChebyshevFit.h.

◆ coefficients

template<typename Tx, typename Ty>
typedef GenericVector<Ty> pcl::GenericChebyshevFit< Tx, Ty >::coefficients

Represents an ordered list of Chebyshev polynomial coefficients.

Definition at line 108 of file ChebyshevFit.h.

◆ function_value

template<typename Tx, typename Ty>
typedef GenericVector<Ty> pcl::GenericChebyshevFit< Tx, Ty >::function_value

Represents a function value.

Definition at line 118 of file ChebyshevFit.h.

◆ function_values

template<typename Tx, typename Ty>
typedef GenericMultiVector<Ty> pcl::GenericChebyshevFit< Tx, Ty >::function_values

Represents a set of function values.

Definition at line 123 of file ChebyshevFit.h.

Constructor & Destructor Documentation

◆ GenericChebyshevFit() [1/5]

template<typename Tx, typename Ty>
template<class F >
pcl::GenericChebyshevFit< Tx, Ty >::GenericChebyshevFit ( f,
Tx  x1,
Tx  x2,
int  N,
int  n 
)
inline

Constructs a truncated Chebyshev polynomial expansion with n coefficients to approximate the specified N-dimensional, vector-valued function f in the interval [x1,x2] of the independent variable.

The function f will be called n times and should have the following prototype (or equivalent by means of suitable type conversions and/or default arguments):

GenericVector<Ty> f( Tx )

where the length of a returned vector must be equal to N.

The expansion process will compute n^2 + n cosines, which may dominate the complexity of the process if the function f is comparatively fast.

The interval [x1,x2] must not be empty or insignificant with respect to the machine epsilon. If that happens, this constructor will throw an appropriate Error exception. The interval bounds can be specified in any order, that is, x2 can legally be < x1; in such case the bounds will be implicitly swapped by this constructor.

The interval [x1,x2] will be also the valid range of evaluation for this object, which can be retrieved with LowerBound() and UpperBound(). See also the Evaluate() member function.

The length n of the polynomial coefficient series should be ≥ 2. If n ≤ 1, the specified value will be ignored and n = 2 will be forced. Typically, a relatively large series length should be used, say between 30 and 100 coefficients, depending on the rate and amplitude of function variations within the fitting interval. The polynomial expansion can be further truncated to approximate the function to the desired error bound. See the Truncate() and Evaluate() member functions for details.

Definition at line 160 of file ChebyshevFit.h.

◆ GenericChebyshevFit() [2/5]

template<typename Tx, typename Ty>
pcl::GenericChebyshevFit< Tx, Ty >::GenericChebyshevFit ( const coefficient_series ck,
Tx  x1,
Tx  x2 
)
inline

Constructs a truncated Chebyshev polynomial expansion from the specified coefficient series ck to approximate a vector-valued function in the interval [x1,x2] of the independent variable. The dimension of the approximated function and the coefficient series lengths are acquired from the specified container ck.

This constructor performs basic coherence and structural integrity checks on the specified parameters, and throws the appropriate Error exception if it detects any problem. However, the validity of polynomial expansion coefficients cannot be verified; ensuring it is the responsibility of the caller.

Definition at line 200 of file ChebyshevFit.h.

◆ GenericChebyshevFit() [3/5]

template<typename Tx, typename Ty>
pcl::GenericChebyshevFit< Tx, Ty >::GenericChebyshevFit ( )
default

Default constructor.

Constructs an invalid, uninitialized object that cannot be used to perform function evaluations. A default-constructed GenericChebyshevFit object should be assigned with an already initialized instance in order to become operative.

See also
IsValid()

◆ GenericChebyshevFit() [4/5]

template<typename Tx, typename Ty>
pcl::GenericChebyshevFit< Tx, Ty >::GenericChebyshevFit ( const GenericChebyshevFit< Tx, Ty > &  )
default

Copy constructor.

◆ GenericChebyshevFit() [5/5]

template<typename Tx, typename Ty>
pcl::GenericChebyshevFit< Tx, Ty >::GenericChebyshevFit ( GenericChebyshevFit< Tx, Ty > &&  )
default

Move constructor.

Member Function Documentation

◆ Coefficients()

template<typename Tx, typename Ty>
const coefficient_series& pcl::GenericChebyshevFit< Tx, Ty >::Coefficients ( ) const
inline

Returns a reference to the immutable set of Chebyshev polynomial expansion coefficients in this object.

Definition at line 449 of file ChebyshevFit.h.

◆ Derivative()

template<typename Tx, typename Ty>
GenericChebyshevFit pcl::GenericChebyshevFit< Tx, Ty >::Derivative ( ) const
inline

Returns a GenericChebyshevFit object that approximates the derivative of the function fitted by this object.

The returned object can be used to evaluate the derivative within the fitting interval of this object, defined by LowerBound() and UpperBound().

The returned object will always own Chebyshev polynomials with the length of the originally fitted series, not of the current truncated lengths, if the polynomial expansions have been truncated.

See also
Integral()

Definition at line 517 of file ChebyshevFit.h.

Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::Derivative().

◆ Evaluate()

template<typename Tx, typename Ty>
function_value pcl::GenericChebyshevFit< Tx, Ty >::Evaluate ( Tx  x) const
inline

Evaluates the truncated Chebyshev polynomial expansion for the specified value x of the independent variable, and returns the approximated function value.

The specified evaluation point x must lie within the fitting interval, given by LowerBound() and UpperBound(), which was specified as the x1 and x2 arguments when the function was initially fitted by the class constructor. For performance reasons, this precondition is not verified by this member function. If an out-of-range evaluation point is specified, this function will return an unpredictable result.

If the polynomial series has been truncated by calling Truncate(), this function evaluates the current truncated Chebyshev expansions instead of the original ones.

See also
operator ()()

Definition at line 472 of file ChebyshevFit.h.

References pcl::Array< T, A >::At(), pcl::GenericVector< T >::Length(), pcl::GenericChebyshevFit< Tx, Ty >::LowerBound(), pcl::GenericChebyshevFit< Tx, Ty >::NumberOfComponents(), and pcl::GenericChebyshevFit< Tx, Ty >::UpperBound().

Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::Evaluate(), pcl::GenericChebyshevFit< Tx, Ty >::operator()(), and pcl::GenericScalarChebyshevFit< Tx, Ty >::operator()().

◆ Integral()

template<typename Tx, typename Ty>
GenericChebyshevFit pcl::GenericChebyshevFit< Tx, Ty >::Integral ( ) const
inline

Returns a GenericChebyshevFit object that approximates the indefinite integral of the function fitted by this object.

The returned object can be used to evaluate the integral within the fitting interval of this object, as defined by LowerBound() and UpperBound(). The constant of integration is set to a value such that the integral is zero at the lower fitting bound.

The returned object will always own Chebyshev polynomials with the length of the originally fitted series, not of the current truncated lengths, if the polynomial expansions have been truncated.

See also
Derivative()

Definition at line 559 of file ChebyshevFit.h.

Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::Integral().

◆ IsTruncated()

template<typename Tx, typename Ty>
bool pcl::GenericChebyshevFit< Tx, Ty >::IsTruncated ( int  i = -1) const
inline

Returns true iff the Chebyshev polynomial expansion has been truncated for the specified zero-based vector component index i.

If i < 0, returns true iff the expansions have been truncated for all vector components.

See also
Truncate(), TruncatedLength()

Definition at line 359 of file ChebyshevFit.h.

References pcl::Array< T, A >::Length(), pcl::GenericChebyshevFit< Tx, Ty >::Length(), and pcl::GenericChebyshevFit< Tx, Ty >::NumberOfComponents().

Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::IsTruncated().

◆ IsValid()

template<typename Tx, typename Ty>
bool pcl::GenericChebyshevFit< Tx, Ty >::IsValid ( ) const
inline

Returns true if this object has been correctly initialized and can be used to perform function evaluations. Returns false if this is an uninitialized, default-constructed object

Definition at line 252 of file ChebyshevFit.h.

References pcl::Array< T, A >::IsEmpty().

◆ Length()

template<typename Tx, typename Ty>
int pcl::GenericChebyshevFit< Tx, Ty >::Length ( int  i = 0) const
inline

Returns the number of coefficients in the generated Chebyshev polynomial expansion for the specified zero-based vector component index i. This is the number of coefficients that was specified or acquired in a class constructor.

See also
TruncatedLength()

Definition at line 301 of file ChebyshevFit.h.

References pcl::Array< T, A >::Length(), and pcl::GenericChebyshevFit< Tx, Ty >::NumberOfComponents().

Referenced by pcl::GenericChebyshevFit< Tx, Ty >::IsTruncated().

◆ LowerBound()

template<typename Tx, typename Ty>
Tx pcl::GenericChebyshevFit< Tx, Ty >::LowerBound ( ) const
inline

Returns the lower bound of this Chebyshev fit. This is the smallest value of the independent variable for which the function has been fitted, and hence the smallest value for which this object can be legally evaluated for function approximation.

See also
UpperBound()

Definition at line 265 of file ChebyshevFit.h.

Referenced by pcl::GenericChebyshevFit< Tx, Ty >::Evaluate().

◆ NumberOfCoefficients()

template<typename Tx, typename Ty>
int pcl::GenericChebyshevFit< Tx, Ty >::NumberOfCoefficients ( ) const
inline

Returns the total number of coefficients in this Chebyshev polynomial expansion, or the sum of computed coefficients for all vector components.

See also
NumberOfTruncatedCoefficients()

Definition at line 330 of file ChebyshevFit.h.

◆ NumberOfComponents()

template<typename Tx, typename Ty>
int pcl::GenericChebyshevFit< Tx, Ty >::NumberOfComponents ( ) const
inline

Returns the number of components in the (vector-valued) dependent variable. This is the number of vector components in a fitted or approximated function value.

Definition at line 288 of file ChebyshevFit.h.

Referenced by pcl::GenericChebyshevFit< Tx, Ty >::Evaluate(), pcl::GenericChebyshevFit< Tx, Ty >::IsTruncated(), pcl::GenericChebyshevFit< Tx, Ty >::Length(), pcl::GenericChebyshevFit< Tx, Ty >::TruncatedLength(), and pcl::GenericChebyshevFit< Tx, Ty >::TruncationError().

◆ NumberOfTruncatedCoefficients()

template<typename Tx, typename Ty>
int pcl::GenericChebyshevFit< Tx, Ty >::NumberOfTruncatedCoefficients ( ) const
inline

Returns the total number of coefficients in the truncated Chebyshev polynomial expansion, or the sum of the lengths of the truncated coefficients series for all vector components.

See also
NumberOfCoefficients()

Definition at line 345 of file ChebyshevFit.h.

◆ operator()()

template<typename Tx, typename Ty>
function_value pcl::GenericChebyshevFit< Tx, Ty >::operator() ( Tx  x) const
inline

A synonym for Evaluate().

Definition at line 498 of file ChebyshevFit.h.

References pcl::GenericChebyshevFit< Tx, Ty >::Evaluate().

◆ operator=() [1/2]

template<typename Tx, typename Ty>
GenericChebyshevFit& pcl::GenericChebyshevFit< Tx, Ty >::operator= ( const GenericChebyshevFit< Tx, Ty > &  )
default

Copy assignment operator. Returns a reference to this object.

◆ operator=() [2/2]

template<typename Tx, typename Ty>
GenericChebyshevFit& pcl::GenericChebyshevFit< Tx, Ty >::operator= ( GenericChebyshevFit< Tx, Ty > &&  )
default

Move assignment operator. Returns a reference to this object.

◆ Truncate()

template<typename Tx, typename Ty>
bool pcl::GenericChebyshevFit< Tx, Ty >::Truncate ( Ty  e)
inline

Attempts to truncate the Chebyshev polynomial expansion for the specified maximum error e. Returns true iff the expansion could be truncated successfully for all vector components of the fitted function.

If n is the length of a fitted polynomial series, this function finds a truncated length 1 < m ≤ n such that:

Sum_i( |ci| ) < e

where ci is a polynomial coefficient and the zero-based subindex i is in the interval [m,n-1].

The truncated Chebyshev expansion will approximate the fitted function component with a maximum error close to ±|e| within the fitting interval.

This member function does not remove any polynomial coefficients, so the original polynomial expansion remains intact. This means that the fitted polynomials can be truncated successively to achieve different error bounds, as required.

If the polynomial series cannot be truncated to achieve the required tolerance in all function components (that is, if either all coefficients for a given component are larger than e in absolute value, or n = 2), this function forces m = n for the components where the requested truncation is not feasible, yielding the original, untruncated Chebyshev polynomials for those components. In such case this function returns false.

Definition at line 428 of file ChebyshevFit.h.

References pcl::Abs().

◆ TruncatedLength()

template<typename Tx, typename Ty>
int pcl::GenericChebyshevFit< Tx, Ty >::TruncatedLength ( int  i = -1) const
inline

Returns the number of coefficients in the truncated Chebyshev polynomial expansion for the specified zero-based vector component index i.

If i < 0, returns the largest number of polynomial coefficients among all vector components.

See also
Truncate(), Length()

Definition at line 316 of file ChebyshevFit.h.

References pcl::GenericChebyshevFit< Tx, Ty >::NumberOfComponents().

Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::TruncatedLength().

◆ TruncationError()

template<typename Tx, typename Ty>
Ty pcl::GenericChebyshevFit< Tx, Ty >::TruncationError ( int  i = -1) const
inline

Returns an estimate of the maximum error in the truncated Chebyshev polynomial expansion for the specified zero-based vector component index i.

If i < 0, returns the largest expansion error estimate among all vector components.

See also
Truncate()

Definition at line 377 of file ChebyshevFit.h.

References pcl::GenericChebyshevFit< Tx, Ty >::NumberOfComponents().

Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::TruncationError().

◆ UpperBound()

template<typename Tx, typename Ty>
Tx pcl::GenericChebyshevFit< Tx, Ty >::UpperBound ( ) const
inline

Returns the upper bound of this Chebyshev fit. This is the largest value of the independent variable for which the function has been fitted, and hence the largest value for which this object can be legally evaluated for function approximation.

See also
LowerBound()

Definition at line 278 of file ChebyshevFit.h.

Referenced by pcl::GenericChebyshevFit< Tx, Ty >::Evaluate().


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