|
|
|||
File indexing completed on 2026-06-02 08:48:23
0001 /** 0002 * @file Chebyshev.h 0003 * @author Nabil Chouika (Irfu/SPhN - CEA Saclay) 0004 * @date 22 mars 2016 0005 * @version 1.0 0006 */ 0007 0008 #ifndef CHEBYSHEV_H_ 0009 #define CHEBYSHEV_H_ 0010 0011 #include "../linear_algebra/matrix/MatrixD.h" 0012 #include "../linear_algebra/vector/VectorD.h" 0013 0014 namespace NumA { 0015 0016 /** 0017 * @class Chebyshev 0018 * @brief Chebyshev expansion class. 0019 * 0020 * Interpolation \f$ f(x) = \sum_{i=0}^{N-1} c_i T_i \left( x \right) \f$ for \f$ x \in \left[ -1, 1 \right] \f$ , 0021 * where \f$ N \f$ is the order of the expansion. 0022 * 0023 * TODO: \f$ x \in \f$ any interval. 0024 */ 0025 0026 class Chebyshev { 0027 public: 0028 /** 0029 * Default Constructor with the order N of the expansion. 0030 * @param N Order of the expansion. 0031 */ 0032 Chebyshev(unsigned int N = 50); 0033 /** 0034 * Default destructor. 0035 */ 0036 virtual ~Chebyshev(); 0037 0038 /** 0039 * Get the order N of the expansion. 0040 * @return N unsigned int 0041 */ 0042 unsigned int getN() const; 0043 /** 0044 * Set the order N of the expansion/ 0045 * @param n unsigned int 0046 */ 0047 void setN(unsigned int n); 0048 0049 const NumA::VectorD& getRoots() const; 0050 0051 /** 0052 * Interpolation matrix. 0053 * @return Matrix which gives a vector of the coefficients for the expansion when applied to a vector of values on Chebyshev nodes. 0054 */ 0055 const NumA::MatrixD& getValuesToCoeffsMatrix() const; 0056 /** 0057 * 0058 * @return Matrix which gives a vector of the values on Chebyshev nodes when applied to a vector of coefficients for the expansion. 0059 */ 0060 const NumA::MatrixD& getCoeffsToValuesMatrix() const; 0061 0062 /** 0063 * 0064 * @param points Points where to evaluate the expansion. 0065 * @return Matrix which gives a vector of the values on given points when applied to a vector of coefficients for the expansion. 0066 */ 0067 NumA::MatrixD getCoeffsToValuesMatrix(const NumA::VectorD& points) const; 0068 /** 0069 * 0070 * @param x Point where the expansion is evaluated. 0071 * @return Vector which gives the Chebyshev expansion on x when a scalar product is taken with a vector of coefficients for the expansion. 0072 */ 0073 NumA::VectorD getCoeffsToValueVector(double x) const; 0074 0075 /** 0076 * Interpolation matrix. 0077 * @param points Points where to evaluate the expansion. 0078 * @return Matrix which gives a vector of values on given points when applied to a vector of values on Chebyshev nodes. 0079 */ 0080 NumA::MatrixD getValuesToValuesMatrix(const NumA::VectorD& points) const; 0081 /** 0082 * 0083 * @param x Point where the expansion is evaluated. 0084 * @return Vector which gives the Chebyshev expansion on x when a scalar product is taken with a vector of values on Chebyshev nodes. 0085 */ 0086 NumA::VectorD getValuesToValueVector(double x) const; 0087 0088 /** 0089 * Evaluate the Chebyshev expansion. 0090 * @param coeffs Coefficients \f$ c_i \f$ of the expansion. 0091 * @param x Point where the expansion is evaluated. 0092 * @return Chebyshev expansion: \sum_{i=0}^{N-1} c_i T_i \left( x \right) \f$. 0093 */ 0094 double evaluateExpansion(const NumA::VectorD& coeffs, double x) const; 0095 0096 static double T(unsigned int i, double x); ///< \f$ T_i \left( x \right) = \cos \left( i \arccos \left( x \right) \right) \f$. 0097 0098 private: 0099 unsigned int m_N; ///< Order of the expansion. 0100 NumA::VectorD m_roots; ///< Roots of T_N, i.e. the nodes of the expansion. 0101 NumA::MatrixD m_valuesToCoeffsMatrix; ///< Transformation matrix from the values on nodes to the coefficients of the expansion. 0102 NumA::MatrixD m_coeffsToValuesMatrix; ///< Transformation matrix from the coefficients of the expansion to the values on nodes. 0103 0104 void initRoots(); ///< Initialize the roots. 0105 void initValuesToCoeffsMatrix(); ///< Initialize the interpolation matrix. 0106 }; 0107 0108 } /* namespace NumA */ 0109 0110 #endif /* CHEBYSHEV_H_ */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|