52 #ifndef __PCL_ChebyshevFit_h
53 #define __PCL_ChebyshevFit_h
69 template <
typename Tx,
typename Ty>
class GenericScalarChebyshevFit;
100 template <
typename Tx,
typename Ty>
161 : dx(
Abs( x2 - x1 ) )
163 , m(
Max( 2, n ),
Max( 1, N ) )
165 PCL_PRECONDITION( N > 0 )
166 PCL_PRECONDITION( n > 1 )
168 throw Error(
"GenericChebyshevFit: Empty or insignificant function evaluation interval." );
173 for (
int j = 0; j < n; ++j )
177 for (
int i = 0; i < N; ++i )
178 for (
int j = 0; j < n; ++j )
181 for (
int k = 0; k < n; ++k )
201 : dx(
Abs( x2 - x1 ) )
207 throw Error(
"GenericChebyshevFit: Empty or insignificant function evaluation interval." );
209 throw Error(
"GenericChebyshevFit: Empty polynomial expansion." );
210 for (
int i = 0; i < m.
Length(); ++i )
211 if ( (m[i] = c[i].
Length()) < 1 )
212 throw Error(
"GenericChebyshevFit: Invalid coefficient series for dimension " +
String( i ) +
'.' );
364 return m[i] < c[i].
Length();
384 for (
int j = 0; j < N; ++j )
388 if ( m[i] < c[i].
Length() )
391 for (
int j = c[i].
Length(); --j >= m[i]; )
439 mmin =
Max( 2, mmin );
442 for (
int i = 0; i < N; ++i )
445 for ( m[i] = c[i].
Length(); m[i] > mmin; --m[i] )
446 if ( (s +=
Abs( c[i][m[i]-1] )) >= e )
448 if ( m[i] < c[i].
Length() )
469 mmin =
Max( 2, mmin );
472 for (
int i = 0; i < N; ++i )
474 Ty e =
Abs( eps[i] );
476 for ( m[i] = c[i].
Length(); m[i] > mmin; --m[i] )
477 if ( (s +=
Abs( c[i][m[i]-1] )) >= e )
479 if ( m[i] < c[i].
Length() )
516 const Ty y0 = Ty( 2*(x - x0)/dx );
519 for (
int i = 0; i < y.
Length(); ++i )
523 const Ty* k = c[i].
At( m[i] );
524 for (
int j = m[i]; --j > 0; )
527 d1 = y2*d1 - d0 + *--k;
530 y[i] = y0*d1 - d0 + *--k/2;
565 for (
int i = 0; i < N; ++i )
572 ch1.c[i][n-1] = 2*n*c[i][n];
573 ch1.c[i][n-2] = 2*(n-1)*c[i][n-1];
574 for (
int j = n-3; j >= 0; --j )
575 ch1.c[i][j] = ch1.c[i][j+2] + 2*(j+1)*c[i][j+1];
576 ch1.c[i] *= Ty( 2 )/dx;
607 for (
int i = 0; i < N; ++i )
614 const Ty k = Ty( dx )/4;
617 for (
int j = 1; j < n-1; ++j, f = -f )
618 s += f*(ch.c[i][j] = k*(c[i][j-1] - c[i][j+1])/j);
619 ch.c[i][0] = 2*(s + f*(ch.c[i][n-1] = k*c[i][n-2]/(n-1)));
650 template <
typename Tx,
typename Ty>
798 #ifndef __PCL_NO_CHEBYSHEV_FIT_INSTANTIATE
bool IsEmpty() const noexcept
size_type Length() const noexcept
64-bit floating point Chebyshev function approximation.
Fundamental numeric constants.
64-bit floating point Chebyshev function approximation.
64-bit floating point scalar Chebyshev function approximation.
A simple exception with an associated error message.
32-bit floating point Chebyshev function approximation.
32-bit floating point scalar Chebyshev function approximation.
64-bit floating point Chebyshev function approximation.
64-bit floating point scalar Chebyshev function approximation.
80-bit extended precision floating point Chebyshev function approximation.
80-bit extended precision floating point scalar Chebyshev function approximation.
32-bit floating point Chebyshev function approximation.
32-bit floating point scalar Chebyshev function approximation.
Approximation of vector-valued functions by Chebyshev polynomial expansions.
int NumberOfCoefficients() const
GenericChebyshevFit Integral() const
const coefficient_series & Coefficients() const
int NumberOfTruncatedCoefficients() const
Ty TruncationError(int i=-1) const
GenericChebyshevFit Derivative() const
GenericChebyshevFit & operator=(const GenericChebyshevFit &)=default
function_value Evaluate(Tx x) const
function_value operator()(Tx x) const
GenericChebyshevFit(const GenericChebyshevFit &)=default
GenericChebyshevFit(GenericChebyshevFit &&)=default
GenericVector< Ty > coefficients
GenericChebyshevFit(const coefficient_series &ck, Tx x1, Tx x2)
bool IsTruncated(int i=-1) const
GenericChebyshevFit()=default
GenericMultiVector< Ty > coefficient_series
bool Truncate(const coefficients &eps, int mmin=2)
int TruncatedLength(int i=-1) const
int NumberOfComponents() const
int Length(int i=0) const
bool Truncate(Ty e, int mmin=2)
GenericChebyshevFit(F f, Tx x1, Tx x2, int N, int n)
Approximation of scalar-valued functions by Chebyshev polynomial expansion.
int TruncatedLength() const
GenericScalarChebyshevFit Derivative() const
Ty operator()(Tx x) const
GenericScalarChebyshevFit(F f, Tx x1, Tx x2, int n)
GenericScalarChebyshevFit & operator=(const GenericScalarChebyshevFit &)=default
GenericScalarChebyshevFit Integral() const
GenericScalarChebyshevFit(const GenericScalarChebyshevFit &)=default
Ty TruncationError() const
GenericScalarChebyshevFit()=default
GenericScalarChebyshevFit(GenericScalarChebyshevFit &&)=default
Generic vector of arbitrary length.
component MaxComponent() const noexcept
int Length() const noexcept
double Sum() const noexcept
80-bit extended precision floating point Chebyshev function approximation.
80-bit extended precision floating point scalar Chebyshev function approximation.
64-bit floating point scalar Chebyshev function approximation.
T Abs(const Complex< T > &c) noexcept
Complex< T > Cos(const Complex< T > &c) noexcept
constexpr const T & Max(const T &a, const T &b) noexcept