STK++ 0.9.13
STK::ChebyshevCoefficients< Data, Coefs > Class Template Reference

ChebyshevCoefficients class allows to compute the coefficients of a sampled function using Chebyshev polynomials. More...

#include <STK_ChebyshevCoefficients.h>

Inheritance diagram for STK::ChebyshevCoefficients< Data, Coefs >:
Inheritance graph

Public Types

typedef IBasis< Data, CoefsBase
 
typedef Data::Type Type
 
- Public Types inherited from STK::IBasis< Data, Coefs >
typedef Data::Type Type
 

Public Member Functions

 ChebyshevCoefficients (Data const *p_data=0, int dim=1, bool useDataValues=true)
 default constructor
 
 ChebyshevCoefficients (Data const &data, int dim, bool useDataValues=true)
 constructor
 
 ChebyshevCoefficients (ChebyshevCoefficients const &coefs)
 copy constructor.
 
virtual ~ChebyshevCoefficients ()
 Destructor.
 
ChebyshevCoefficientsclone () const
 clone pattern implementation
 
virtual bool run ()
 run the computations.
 
- Public Member Functions inherited from STK::IBasis< Data, Coefs >
 IBasis ()
 default constructor
 
 IBasis (Data const *p_data, int dim, bool useDataValues=true)
 constructor
 
 IBasis (Data const &data, int dim, bool useDataValues=true)
 constructor
 
 IBasis (IBasis const &basis)
 copy constructor.
 
virtual ~IBasis ()
 destructor
 
int dim () const
 
Coefs constcoefficients () const
 
Type minValue () const
 
Type maxValue () const
 
void setData (Data const &data)
 Set the data set.
 
void setDim (int dim)
 
void setMinValue (Type const &minValue)
 
void setMaxValue (Type const &maxValue)
 
bool initializeStep ()
 Initialize the parameters minValue_ and maxValue_ using data set.
 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Public Attributes

Data constp_data_
 the input data set
 
Coefs coefficients_
 Array2D of the coefficients.
 
int dim_
 number of dimension to build
 
Type minValue_
 Minimal value of the data.
 
Type maxValue_
 Maximal value of the data.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IBasis< Data, Coefs >
virtual void update ()
 update IBasis if a parameter or a new data set is set, update the state of this runner.
 
- Protected Member Functions inherited from STK::IRunnerBase
 IRunnerBase ()
 default constructor
 
 IRunnerBase (IRunnerBase const &runner)
 copy constructor
 
virtual ~IRunnerBase ()
 destructor
 
- Protected Attributes inherited from STK::IBasis< Data, Coefs >
Data constp_data_
 the input data set
 
int dim_
 number of dimension to build
 
bool useDataValues_
 
Type minValue_
 Minimal value of the data.
 
Type maxValue_
 Maximal value of the data.
 
Coefs coefficients_
 Array2D of the coefficients.
 
- Protected Attributes inherited from STK::IRunnerBase
String msg_error_
 String with the last error message.
 
bool hasRun_
 true if run has been used, false otherwise
 

Detailed Description

template<class Data, class Coefs = ArrayXX>
class STK::ChebyshevCoefficients< Data, Coefs >

ChebyshevCoefficients class allows to compute the coefficients of a sampled function using Chebyshev polynomials.

Chebyshev polynomials are important in approximation theory because the roots of the Chebyshev polynomials of the first kind, which are also called Chebyshev nodes, are used as nodes in polynomial interpolation.

Definition at line 51 of file STK_ChebyshevCoefficients.h.

Member Typedef Documentation

◆ Base

template<class Data , class Coefs = ArrayXX>
typedef IBasis<Data, Coefs> STK::ChebyshevCoefficients< Data, Coefs >::Base

Definition at line 54 of file STK_ChebyshevCoefficients.h.

◆ Type

template<class Data , class Coefs = ArrayXX>
typedef Data::Type STK::ChebyshevCoefficients< Data, Coefs >::Type

Definition at line 55 of file STK_ChebyshevCoefficients.h.

Constructor & Destructor Documentation

◆ ChebyshevCoefficients() [1/3]

template<class Data , class Coefs = ArrayXX>
STK::ChebyshevCoefficients< Data, Coefs >::ChebyshevCoefficients ( Data const p_data = 0,
int  dim = 1,
bool  useDataValues = true 
)
inline

default constructor

Parameters
p_datapointer on the data set
dimnumber of basis to use
useDataValuesif true use data in order to find the minValue_ and maxValue_, use values set otherwise

Definition at line 71 of file STK_ChebyshevCoefficients.h.

72 : Base(p_data, dim, useDataValues){}
int dim() const
Definition STK_IBasis.h:77

◆ ChebyshevCoefficients() [2/3]

template<class Data , class Coefs = ArrayXX>
STK::ChebyshevCoefficients< Data, Coefs >::ChebyshevCoefficients ( Data const data,
int  dim,
bool  useDataValues = true 
)
inline

constructor

Parameters
datareference on the data set
dimnumber of basis to use
useDataValuesif true use data in order to find the minValue_ and maxValue_, use values set otherwise

Definition at line 79 of file STK_ChebyshevCoefficients.h.

80 : Base(data, dim, useDataValues){}

◆ ChebyshevCoefficients() [3/3]

template<class Data , class Coefs = ArrayXX>
STK::ChebyshevCoefficients< Data, Coefs >::ChebyshevCoefficients ( ChebyshevCoefficients< Data, Coefs > const coefs)
inline

copy constructor.

Parameters
coefsthe coefficients to copy

Definition at line 84 of file STK_ChebyshevCoefficients.h.

84: Base(coefs){}

◆ ~ChebyshevCoefficients()

template<class Data , class Coefs = ArrayXX>
virtual STK::ChebyshevCoefficients< Data, Coefs >::~ChebyshevCoefficients ( )
inlinevirtual

Destructor.

Definition at line 86 of file STK_ChebyshevCoefficients.h.

86{}

Member Function Documentation

◆ clone()

template<class Data , class Coefs = ArrayXX>
ChebyshevCoefficients * STK::ChebyshevCoefficients< Data, Coefs >::clone ( ) const
inline

clone pattern implementation

Definition at line 88 of file STK_ChebyshevCoefficients.h.

88{ return new ChebyshevCoefficients(*this);}
ChebyshevCoefficients(Data const *p_data=0, int dim=1, bool useDataValues=true)
default constructor

◆ run()

template<class Data , class Coefs >
bool STK::ChebyshevCoefficients< Data, Coefs >::run ( )
virtual

run the computations.

Implements STK::IRunnerBase.

Definition at line 95 of file STK_ChebyshevCoefficients.h.

96{
97 // check if data exists
98 if (!p_data_)
99 {
101 return false;
102 }
103 if (!this->initializeStep()) return false;
104 Data x = ( Type(2)* (*p_data_)-(minValue_+maxValue_))/(maxValue_-minValue_);
105 // resize and initialize coefficients
106 coefficients_.resize(p_data_->range(), Range(0, dim_)) =0;
107 if (dim_>1)
108 {
109 coefficients_.col(0) = Type(1);
110 if (dim_>2)
111 {
112 coefficients_.col(1) = x;
113 }
114 // compute T_{n+1}(x) = 2xT_n(x) - T_{n-1}(x)
115 for(int j=2; j<coefficients_.endCols(); ++j)
116 {
117 coefficients_.col(j) = 2. * x *coefficients_.col(j-1) - coefficients_.col(j-2); ;
118 }
119 }
120 // rescale
121 for(int d=1; d<coefficients_.endCols(); ++d)
122 {
124 }
125 this->hasRun_ = true;
126 return true;
127
128}
#define STKERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:49
Data const * p_data_
the input data set
Definition STK_IBasis.h:110
Type minValue_
Minimal value of the data.
Definition STK_IBasis.h:116
Type maxValue_
Maximal value of the data.
Definition STK_IBasis.h:118
int dim_
number of dimension to build
Definition STK_IBasis.h:112
Coefs coefficients_
Array2D of the coefficients.
Definition STK_IBasis.h:121
bool initializeStep()
Initialize the parameters minValue_ and maxValue_ using data set.
Definition STK_IBasis.h:181
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
bool hasRun_
true if run has been used, false otherwise
Definition STK_IRunner.h:98
virtual bool run()
run the computations.
TRange< UnknownSize > Range
Definition STK_Range.h:59

References STK::IRunnerBase::hasRun_, STK::IRegression< Array, Array, Weight >::initializeStep(), STK::IRunnerBase::msg_error_, STK::SinesCoefficients< Data, Coefs >::run(), and STKERROR_NO_ARG.

Member Data Documentation

◆ coefficients_

template<class Data , class Coefs = ArrayXX>
Coefs STK::IBasis< Data, Coefs >::coefficients_

Array2D of the coefficients.

Definition at line 121 of file STK_IBasis.h.

◆ dim_

template<class Data , class Coefs = ArrayXX>
int STK::IBasis< Data, Coefs >::dim_

number of dimension to build

Definition at line 112 of file STK_IBasis.h.

◆ maxValue_

template<class Data , class Coefs = ArrayXX>
Type STK::IBasis< Data, Coefs >::maxValue_

Maximal value of the data.

Definition at line 118 of file STK_IBasis.h.

◆ minValue_

template<class Data , class Coefs = ArrayXX>
Type STK::IBasis< Data, Coefs >::minValue_

Minimal value of the data.

Definition at line 116 of file STK_IBasis.h.

◆ p_data_

template<class Data , class Coefs = ArrayXX>
Data const* STK::IBasis< Data, Coefs >::p_data_

the input data set

Definition at line 110 of file STK_IBasis.h.


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