|
|
|||
File indexing completed on 2026-06-02 08:17:13
0001 // 0002 // APFEL++ 2017 0003 // 0004 // Author: Valerio Bertone: valerio.bertone@cern.ch 0005 // 0006 0007 #pragma once 0008 0009 #include "apfel/grid.h" 0010 0011 #include <array> 0012 0013 namespace apfel 0014 { 0015 /** 0016 * @brief The Interpolator class is a mother class for the x-space 0017 * interpolationand requires the implementation of a specialized 0018 * interpolation algorithm. The current version uses the joint grid 0019 * object stored allocated by the Grid class. 0020 */ 0021 class Interpolator 0022 { 0023 public: 0024 virtual ~Interpolator() = default; 0025 0026 /** 0027 * @brief The Interpolator constructor. 0028 * @param gr: the x-space grid object over which interpolation takes place 0029 */ 0030 Interpolator(Grid const& gr); 0031 0032 /** 0033 * @brief The Interpolator constructor. 0034 * @param gr: the x-space grid object over which interpolation takes place 0035 * @param distsubgrid: the vector of subgrids 0036 * @param distjointgrid: the joint subgrid 0037 * @note distjointgrid and distsubgrid are assumed to match the 0038 * structure of the grid gr. 0039 */ 0040 Interpolator(Grid const& gr, 0041 std::vector<std::vector<double>> const& distsubgrid, 0042 std::vector<double> const& distjointgrid); 0043 0044 /** 0045 * @name Evaluate functions 0046 * List of functions that perform the interpolation on the x-space 0047 * grid. These also include the derivative and the integral of the 0048 * interpolated function. 0049 */ 0050 ///@{ 0051 /** 0052 * @brief Function that evaluates the interpolated function on the joint grid. 0053 * @param x: the value in x to be interpolated 0054 * @return the interpolated result 0055 */ 0056 double Evaluate(double const& x) const; 0057 0058 /** 0059 * @brief Function that evaluates the interpolated function on a given subgrid. 0060 * @param x: the value in x to be interpolated 0061 * @param ig: the subgrid index 0062 * @return the interpolated result 0063 */ 0064 double Evaluate(double const& x, int const& ig) const; 0065 0066 /** 0067 * @brief Function that evaluates the derivative of the 0068 * interpolated function on the joint grid. 0069 * @param x: the value in x where the derivative has to be computed 0070 * @return the derivative of the interpolated function 0071 */ 0072 double Derive(double const& x) const; 0073 0074 /** 0075 * @brief Function that evaluates the integral of the interpolated 0076 * function in the interval [a,b] on the joint grid. 0077 * @param a: the lower integration bound 0078 * @param b: the upper integration bound 0079 * @return the integral of the interpolated function 0080 */ 0081 double Integrate(double const& a, double const& b) const; 0082 0083 /** 0084 * @brief Function that sums all entries of the distribution on 0085 * the joint grid. This function is meant to be used to compute 0086 * scalar products. 0087 * @return the squashed distribution 0088 */ 0089 double Squash() const; 0090 ///@} 0091 0092 /** 0093 * @brief Pure virtual method for the interpolating functions 0094 * polynomial in log(x). 0095 * @param beta: the x-space grid index 0096 * @param lnx: the value (of the log) of the interpolation point 0097 * @param sg: the SubGrid over which the interpolant is defined 0098 * @return the interpolation weights 0099 * @note This interpolant is polynomial in log(x) and is used when 0100 * computing operators on the grid. The reason is it's translation 0101 * invariance on a logarithmically spaced grid that reduces the 0102 * ammount of computations. 0103 */ 0104 virtual double InterpolantLog(int const& beta, double const& lnx, SubGrid const& sg) const = 0; 0105 0106 /** 0107 * @brief Pure virtual method for the interpolating functions. 0108 * @param beta: the x-space grid index 0109 * @param x: the value of the interpolation point 0110 * @param sg: the SubGrid over which the interpolant is defined 0111 * @return the interpolation weights 0112 */ 0113 virtual double Interpolant(int const& beta, double const& x, SubGrid const& sg) const = 0; 0114 0115 /** 0116 * @brief Virtual method for the derivative of the interpolating 0117 * functions. 0118 * @return the derivarive of the interpolation weights 0119 */ 0120 virtual double DerInterpolant(int const&, double const&, SubGrid const&) const { return 0; }; 0121 0122 /** 0123 * @brief Virtual method for the integral of the interpolating 0124 * functions. 0125 * @return the integral of the interpolation weights 0126 */ 0127 virtual double IntInterpolant(int const&, double const&, double const&, SubGrid const&) const { return 0; }; 0128 0129 /** 0130 * @brief This purely virtual function computes the lower and 0131 * upper bounds on which the the sum over interpolants is limited. 0132 * @param x: the value in x to be interpolated 0133 * @param sg: the SubGrid over which the interpolant is defined 0134 * @return the lower and upper bounds of the grid index 0135 */ 0136 virtual std::array<int, 2> SumBounds(double const& x, SubGrid const& sg) const = 0; 0137 0138 /** 0139 * @name Getters 0140 */ 0141 ///@{ 0142 Grid const& GetGrid() const { return _grid; } //!< The grid 0143 std::vector<std::vector<double>> const& GetDistributionSubGrid() const { return _distributionSubGrid; } //!< The distribution on the subgrids 0144 std::vector<double> const& GetDistributionJointGrid() const { return _distributionJointGrid; } //!< The distribution on the joint grid 0145 void Print() const { std::cout << *this << std::endl; } //!< Print the Interpolator object 0146 ///@} 0147 0148 protected: 0149 Grid const& _grid; //!< The stored grid reference 0150 std::vector<std::vector<double>> _distributionSubGrid; //!< The array with the distribution values on the subgrids. 0151 std::vector<double> _distributionJointGrid; //!< The array with the distribution values on the joint grid. 0152 0153 friend std::ostream& operator << (std::ostream& os, Interpolator const& sg); 0154 }; 0155 0156 /** 0157 * @brief Method which prints Interpolator with cout <<. 0158 */ 0159 std::ostream& operator << (std::ostream& os, Interpolator const& in); 0160 }
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|