PCL
|
Approximation of vector-valued functions by Chebyshev polynomial expansions. More...
#include <ChebyshevFit.h>
Public Types | |
using | coefficient_series = GenericMultiVector< Ty > |
using | coefficients = GenericVector< Ty > |
using | function_value = GenericVector< Ty > |
using | function_values = GenericMultiVector< 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.
using pcl::GenericChebyshevFit< Tx, Ty >::coefficient_series = GenericMultiVector<Ty> |
Represents a set of ordered lists of Chebyshev polynomial coefficients.
Definition at line 113 of file ChebyshevFit.h.
using pcl::GenericChebyshevFit< Tx, Ty >::coefficients = GenericVector<Ty> |
Represents an ordered list of Chebyshev polynomial coefficients.
Definition at line 108 of file ChebyshevFit.h.
using pcl::GenericChebyshevFit< Tx, Ty >::function_value = GenericVector<Ty> |
Represents a function value.
Definition at line 118 of file ChebyshevFit.h.
using pcl::GenericChebyshevFit< Tx, Ty >::function_values = GenericMultiVector<Ty> |
Represents a set of function values.
Definition at line 123 of file ChebyshevFit.h.
|
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.
|
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.
|
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.
|
default |
Copy constructor.
|
default |
Move constructor.
|
inline |
Returns a reference to the immutable set of Chebyshev polynomial expansion coefficients in this object.
Definition at line 489 of file ChebyshevFit.h.
|
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.
Definition at line 557 of file ChebyshevFit.h.
Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::Derivative().
|
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.
Definition at line 512 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(), and pcl::GenericChebyshevFit< Tx, Ty >::operator()().
|
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.
Definition at line 599 of file ChebyshevFit.h.
Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::Integral().
|
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.
Definition at line 359 of file ChebyshevFit.h.
References pcl::Array< T, A >::Length(), pcl::GenericChebyshevFit< Tx, Ty >::Length(), pcl::GenericVector< T >::MaxComponent(), and pcl::GenericChebyshevFit< Tx, Ty >::NumberOfComponents().
Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::IsTruncated().
|
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().
|
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.
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().
|
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.
Definition at line 265 of file ChebyshevFit.h.
Referenced by pcl::GenericChebyshevFit< Tx, Ty >::Evaluate().
|
inline |
Returns the total number of coefficients in this Chebyshev polynomial expansion, or the sum of computed coefficients for all vector components.
Definition at line 330 of file ChebyshevFit.h.
|
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.
References pcl::GenericVector< T >::Length().
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().
|
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.
Definition at line 345 of file ChebyshevFit.h.
References pcl::GenericVector< T >::Sum().
|
inline |
A synonym for Evaluate().
Definition at line 538 of file ChebyshevFit.h.
References pcl::GenericChebyshevFit< Tx, Ty >::Evaluate().
|
default |
Copy assignment operator. Returns a reference to this object.
|
default |
Move assignment operator. Returns a reference to this object.
|
inline |
Attempts to truncate the Chebyshev polynomial expansion for the specified vector of maximum truncation errors eps. Returns true
iff the expansion could be truncated successfully for all vector components of the fitted function.
This function is equivalent to Truncate( Ty, int ), but instead of a unique maximum truncation error applied to all vector components of the fitted function, it applies a specific maximum truncation error for each vector component.
Definition at line 467 of file ChebyshevFit.h.
References pcl::Max().
|
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.
The optional parameter mmin is the minimum allowed length of a coefficient series. The value of this parameter is 2 by default, which is the minimum number of Chebyshev coefficients in a series expansion. Specifying a value greater than 2 can be useful sometimes to impose stricter accuracy constraints on the truncated series.
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 436 of file ChebyshevFit.h.
References pcl::Abs(), and pcl::Max().
|
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.
Definition at line 316 of file ChebyshevFit.h.
References pcl::GenericVector< T >::MaxComponent(), and pcl::GenericChebyshevFit< Tx, Ty >::NumberOfComponents().
Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::TruncatedLength().
|
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.
Definition at line 377 of file ChebyshevFit.h.
References pcl::GenericChebyshevFit< Tx, Ty >::NumberOfComponents().
Referenced by pcl::GenericScalarChebyshevFit< Tx, Ty >::TruncationError().
|
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.
Definition at line 278 of file ChebyshevFit.h.
Referenced by pcl::GenericChebyshevFit< Tx, Ty >::Evaluate().