|
|
|||
File indexing completed on 2026-06-02 08:17:14
0001 // 0002 // APFEL++ 2017 0003 // 0004 // Author: Valerio Bertone: valerio.bertone@cern.ch 0005 // 0006 0007 #pragma once 0008 0009 #include <vector> 0010 #include <tuple> 0011 #include <iostream> 0012 #include <functional> 0013 0014 namespace apfel 0015 { 0016 /** 0017 * @brief The template class QGrids is a mother class for the 0018 * interpolation in Q. This class also implements methods for the 0019 * subgrid interpolation relevant for example in a VFNS evolution. 0020 */ 0021 template<class T> 0022 class QGrid 0023 { 0024 public: 0025 /** 0026 * @name Constructors 0027 * List of constructors. 0028 */ 0029 ///@{ 0030 QGrid() = delete; 0031 0032 /** 0033 * @brief The QGrid constructor. 0034 * @param nQ: the number of grid intervals in Q 0035 * @param QMin: the lower edge of the grid in Q 0036 * @param QMax: the upper edge of the grid in Q 0037 * @param InterDegree: the interpolation degree 0038 * @param Thresholds: the fixed point of the grid over which interpolation is forbidden 0039 * @param TabFunc: the function used to tabulate the grid in Q 0040 * @param InvTabFunc: the inverse function of TabFunc (an analytic expression is necessary) 0041 */ 0042 QGrid(int const& nQ, 0043 double const& QMin, 0044 double const& QMax, 0045 int const& InterDegree, 0046 std::vector<double> const& Thresholds, 0047 std::function<double(double const&)> const& TabFunc, 0048 std::function<double(double const&)> const& InvTabFunc); 0049 0050 /** 0051 * @brief The QGrid constructor. 0052 * @param nQ: the number of grid intervals in Q 0053 * @param QMin: the lower edge of the grid in Q 0054 * @param QMax: the upper edge of the grid in Q 0055 * @param InterDegree: the interpolation degree 0056 * @param Thresholds: the fixed point of the grid over which interpolation is forbidden 0057 * @param Lambda: the parameter of the function log(log(Q/Lambda)) used for the tabulation on the grid in Q 0058 */ 0059 QGrid(int const& nQ, 0060 double const& QMin, 0061 double const& QMax, 0062 int const& InterDegree, 0063 std::vector<double> const& Thresholds, 0064 double const& Lambda = 0.25); 0065 0066 /** 0067 * @brief The QGrid constructor. 0068 * @param Qg: the user-defined interpolation grid 0069 * @param InterDegree: the interpolation degree 0070 * @note This constructor assumes that the function used to 0071 * compute the interpolating functions is linear. In addition, the 0072 * input vector 'Qg' is assumed to be ordered and 0073 * 'well-behaved'. To be used with care. 0074 */ 0075 QGrid(std::vector<double> const& Qg, 0076 int const& InterDegree); 0077 0078 /** 0079 * @brief The QGrid copy constructor. 0080 * @param qg: the object to be copied 0081 */ 0082 QGrid(QGrid const& qg); 0083 ///@} 0084 0085 /** 0086 * @brief Function that interpolates on the grid in Q. 0087 * @param Q: the value of the required interpolation 0088 * @return the interpolated value 0089 */ 0090 T Evaluate(double const& Q) const; 0091 0092 /** 0093 * @brief Function that derives on the grid in Q. 0094 * @param Q: the value of the required interpolation 0095 * @return the interpolated derivative 0096 */ 0097 T Derive(double const& Q) const; 0098 0099 /** 0100 * @brief Function that integrates on the grid in Q. 0101 * @param Qa: the lower integration bound 0102 * @param Qb: the upper integration bound 0103 * @return the interpolated integral 0104 */ 0105 T Integrate(double const& Qa, double const& Qb) const; 0106 0107 /** 0108 * @name Comparison operators 0109 * Collection of operators for comparing QGrid objects 0110 */ 0111 ///@{ 0112 bool operator == (QGrid const& sg) const; 0113 bool operator != (QGrid const& sg) const; 0114 ///@} 0115 0116 /** 0117 * @name Binary operators 0118 */ 0119 ///@{ 0120 QGrid<T>& operator = (QGrid<T> const& qg); //!< this = QGrid<T> 0121 QGrid<T>& operator *= (double const& s); //!< this *= Scalar 0122 QGrid<T>& operator /= (double const& s); //!< this /= Scalar 0123 QGrid<T>& operator += (QGrid<T> const& qg); //!< this += QGrid<T> 0124 QGrid<T>& operator -= (QGrid<T> const& qg); //!< this -= QGrid<T> 0125 ///@} 0126 0127 /** 0128 * @name Getters 0129 */ 0130 ///@{ 0131 int nQ() const { return _nQ; } //!< return the number of Q interval 0132 int InterDegree() const { return _InterDegree; } //!< return the interpolation degree 0133 double QMin() const { return _QMin; } //!< return the minimum node value 0134 double QMax() const { return _QMax; } //!< return the maximum node value 0135 std::function<double(double const&)> const& TabFunc() const { return _TabFunc; } //!< return the tabulation function 0136 std::vector<double> const& GetThresholds() const { return _Thresholds;} //!< return the heavy quark thresholds 0137 std::vector<double> const& GetQGrid() const { return _Qg; } //!< return the grid in Q 0138 std::vector<double> const& GetFQGrid() const { return _fQg; } //!< return the grid in _TabFunc(Q) 0139 std::vector<int> const& GetThesholdIndices() const { return _nQg; } //!< return the indices of the thresholds on the grid 0140 std::vector<T> const& GetQGridValues() const { return _GridValues; } //!< return the tabulated objects on the grid. 0141 ///@} 0142 0143 /** 0144 * @brief Interpolation functions on QGrid. 0145 * @param tQ: interpolation control parameter 0146 * @param tau: the grid index 0147 * @param fq: the value of _TabFunc(Q) of the required interpolation 0148 * @return the interpolation weights 0149 */ 0150 double Interpolant(int const& tQ, int const& tau, double const& fq) const; 0151 0152 /** 0153 * @brief Derivative of the interpolation functions on QGrid. 0154 * @param tQ: interpolation control parameter 0155 * @param tau: the grid index 0156 * @param Q: the value of Q of the required interpolation 0157 * @return the derivarive of the interpolation weights 0158 */ 0159 double DerInterpolant(int const& tQ, int const& tau, double const& Q) const; 0160 0161 /** 0162 * @brief Derivative of the interpolation functions on QGrid. 0163 * @param tQ: interpolation control parameter 0164 * @param tau: the grid index 0165 * @param Qa: the value of the lower integration bound 0166 * @param Qb: the value of the upper integration bound 0167 * @return the integral of interpolation weights 0168 */ 0169 double IntInterpolant(int const& tQ, int const& tau, double const& Qa, double const& Qb) const; 0170 0171 /** 0172 * @brief Computes the control parameter of the interpolant, the 0173 * lower and upper bounds over which the sum is limited. 0174 * @param Q: the value of the required interpolation 0175 * @return the lower and upper bounds of tau 0176 */ 0177 std::tuple<int, int, int> SumBounds(double const& Q) const; 0178 0179 /** 0180 * @brief Print the QGrid object 0181 */ 0182 void Print() const { std::cout << *this << std::endl; } 0183 0184 protected: 0185 int _nQ; //!< Number intervals 0186 double _QMin; //!< Minumim value of Q 0187 double _QMax; //!< Maximum value of Q 0188 int _InterDegree; //!< Interpolation degree 0189 std::vector<double> _Thresholds; //!< Thresholds 0190 std::function<double(double const&)> _TabFunc; //!< Function whose constant step is used for the tabulation 0191 std::vector<double> _Qg; //!< Grid in Q 0192 std::vector<double> _fQg; //!< Grid in _TabFunc(Q) 0193 std::vector<int> _nQg; //!< Indices of the nodes on which there is either a bound or a threshold 0194 std::vector<T> _GridValues; //!< Vector of values to be interpolated on the grid 0195 0196 template<class U> 0197 friend std::ostream& operator << (std::ostream& os, QGrid<U> const& dt); 0198 }; 0199 0200 /** 0201 * @name Ternary operators 0202 */ 0203 ///@{ 0204 template<class T> 0205 QGrid<T> operator * (double const& s, QGrid<T> rhs); //!< Scalar*QGrid<T> 0206 template<class T> 0207 QGrid<T> operator * (QGrid<T> lhs, double const& s); //!< QGrid<T>*Scalar 0208 template<class T> 0209 QGrid<T> operator / (QGrid<T> lhs, double const& s); //!< QGrid<T>/Scalar 0210 template<class T> 0211 QGrid<T> operator + (QGrid<T> lhs, QGrid<T> const& rhs); //!< QGrid<T>+QGrid<T> 0212 template<class T> 0213 QGrid<T> operator - (QGrid<T> lhs, QGrid<T> const& rhs); //!< QGrid<T>-QGrid<T> 0214 ///@} 0215 0216 /** 0217 * @brief Method that prints QGrid with cout <<. 0218 */ 0219 template<class T> 0220 inline std::ostream& operator << (std::ostream& os, QGrid<T> const& Qg) 0221 { 0222 os << "QGrid: " << &Qg << "\n"; 0223 os << "nQ = " << Qg._nQ << "\n"; 0224 os << "QMin = " << Qg._QMin << "\n"; 0225 os << "QMax = " << Qg._QMax << "\n"; 0226 os << "InterDegree = " << Qg._InterDegree << "\n"; 0227 os << "Thresholds = "; 0228 for (const auto &v: Qg._Thresholds) os << v << " "; 0229 os << "\n"; 0230 os << "Threshold indices = "; 0231 for (const auto &v: Qg._nQg) os << v << " "; 0232 os << "\n"; 0233 os << "Qg = "; 0234 for (const auto &v: Qg._Qg) os << v << " "; 0235 os << "\n"; 0236 return os; 0237 } 0238 }
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|