Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:17:15

0001 //
0002 // APFEL++ 2017
0003 //
0004 // Author: Valerio Bertone: valerio.bertone@cern.ch
0005 //
0006 
0007 #pragma once
0008 
0009 #include "apfel/qgrid.h"
0010 #include "apfel/matchedevolution.h"
0011 
0012 #include <map>
0013 
0014 namespace apfel
0015 {
0016   /**
0017    * @brief The template TabulateObject class is a derived of the
0018    * QGrid class that tabulates on object of type T (it can be a
0019    * double, a Distribution, an Operator, Set<Distribution>, a
0020    * Set<Operator>) over a grid in Q, taking into account the possible
0021    * presence of thresholds, and provides the method to evaluate the
0022    * tabulated object at any generic value of Q.
0023    */
0024   template<class T>
0025   class TabulateObject: public QGrid<T>
0026   {
0027   public:
0028     /**
0029      * @name Constructors
0030      * List of constructors.
0031      */
0032     ///@{
0033     /**
0034      * @brief The TabulateObject constructor for an "evolving"
0035      * object (MatchedEvolution).
0036      * @param Object: the MatchedEvolution type object to be tabulated in Q
0037      * @param nQ: the number of on nodes of the grid in Q
0038      * @param QMin: the lower bound of the grid in Q
0039      * @param QMax: the upper bound of the grid in Q
0040      * @param InterDegree: the interpolation degree on the grid in Q
0041      * @param Lambda: the value of the parameter in the function ln(ln(Q<SUP>2</SUP>/&Lambda;<SUP>2</SUP>)) used for the tabulation (default: 0.25)
0042      */
0043     TabulateObject(MatchedEvolution<T>      & Object,
0044                    int                 const& nQ,
0045                    double              const& QMin,
0046                    double              const& QMax,
0047                    int                 const& InterDegree,
0048                    double              const& Lambda = 0.25);
0049 
0050     /**
0051      * @brief The TabulateObject constructor for an "evolving"
0052      * object (MatchedEvolution) on a custom-spaced grid.
0053      * @param Object: the MatchedEvolution type object to be tabulated in Q
0054      * @param nQ: the number of on nodes of the grid in Q
0055      * @param QMin: the lower bound of the grid in Q
0056      * @param QMax: the upper bound of the grid in Q
0057      * @param InterDegree: the interpolation degree on the grid in Q
0058      * @param Thresholds: vector of quark thresholds
0059      * @param TabFunc: the function to be used for the tabulation in Q
0060      * @param InvTabFunc: the inverse function of TabFunc (it has to be provided analytically)
0061      */
0062     TabulateObject(MatchedEvolution<T>                       & Object,
0063                    int                                  const& nQ,
0064                    double                               const& QMin,
0065                    double                               const& QMax,
0066                    int                                  const& InterDegree,
0067                    std::vector<double>                  const& Thresholds,
0068                    std::function<double(double const&)> const& TabFunc,
0069                    std::function<double(double const&)> const& InvTabFunc);
0070 
0071     /**
0072      * @brief The TabulateObject constructor for a Q dependent
0073      * object.
0074      * @param Object: the T-valued function to be tabulated in Q
0075      * @param nQ: the number of on nodes of the grid in Q
0076      * @param QMin: the lower bound of the grid in Q
0077      * @param QMax: the upper bound of the grid in Q
0078      * @param InterDegree: the interpolation degree on the grid in Q
0079      * @param Thresholds: vector of quark thresholds
0080      * @param Lambda: the value of the parameter in the function ln(ln(Q<SUP>2</SUP>/&Lambda;<SUP>2</SUP>)) used for the tabulation (default: 0.25)
0081      */
0082     TabulateObject(std::function<T(double const&)> const& Object,
0083                    int                             const& nQ,
0084                    double                          const& QMin,
0085                    double                          const& QMax,
0086                    int                             const& InterDegree,
0087                    std::vector<double>             const& Thresholds,
0088                    double                          const& Lambda = 0.25);
0089 
0090     /**
0091      * @brief The TabulateObject constructor for a Q dependent
0092      * object tabulated on a user-defined distribution in Q.
0093      * @param Object: the T-valued function to be tabulated in Q
0094      * @param nQ: the number of on nodes of the grid in Q
0095      * @param QMin: the lower bound of the grid in Q
0096      * @param QMax: the upper bound of the grid in Q
0097      * @param InterDegree: the interpolation degree on the grid in Q
0098      * @param Thresholds: vector of quark thresholds
0099      * @param TabFunc: the function to be used for the tabulation in Q
0100      * @param InvTabFunc: the inverse function of TabFunc (it has to be provided analytically)
0101      */
0102     TabulateObject(std::function<T(double const&)>      const& Object,
0103                    int                                  const& nQ,
0104                    double                               const& QMin,
0105                    double                               const& QMax,
0106                    int                                  const& InterDegree,
0107                    std::vector<double>                  const& Thresholds,
0108                    std::function<double(double const&)> const& TabFunc,
0109                    std::function<double(double const&)> const& InvTabFunc);
0110 
0111     /**
0112      * @brief The TabulateObject constructor for a Q dependent
0113      * object tabulated on a user-defined grid.
0114      * @param Object: the T-valued function to be tabulated in Q
0115      * @param Qg: the user-defined interpolation grid
0116      * @param InterDegree: the interpolation degree on the grid in Q
0117      */
0118     TabulateObject(std::function<T(double const&)> const& Object,
0119                    std::vector<double>             const& Qg,
0120                    int                             const& InterDegree);
0121 
0122     /**
0123      * @brief The TabulateObject constructor for a pretabulated
0124      * object tabulated on a user-defined grid.
0125      * @param Object: the T-valued vector of the pre-tabulated object
0126      * @param Qg: the user-defined interpolation grid
0127      * @param InterDegree: the interpolation degree on the grid in Q
0128      */
0129     TabulateObject(std::vector<T>      const& Object,
0130                    std::vector<double> const& Qg,
0131                    int                 const& InterDegree);
0132 
0133     /**
0134      * @brief The TabulateObject copy constructor.
0135      */
0136     TabulateObject(const TabulateObject&) = default;
0137     ///@}
0138 
0139     /**
0140      * @name Binary operators
0141      */
0142     ///@{
0143     TabulateObject<T>& operator  = (TabulateObject<T> const& to);                         //!< this  = TabulateObject<T>
0144     TabulateObject<T>& operator *= (double const& s);                                     //!< this *= Scalar
0145     TabulateObject<T>& operator /= (double const& s);                                     //!< this /= Scalar
0146     TabulateObject<T>& operator += (TabulateObject<T> const& to);                         //!< this += TabulateObject<T>
0147     TabulateObject<T>& operator -= (TabulateObject<T> const& to);                         //!< this -= TabulateObject<T>
0148     ///@}
0149 
0150     /**
0151      * @name Evaluate functions
0152      * List of functions to interpolate the tabulated object.
0153      */
0154     ///@{
0155     /**
0156      * @brief This function interpolates in x and Q. It is used for T
0157      * = Distribution.
0158      */
0159     double EvaluatexQ(double const& x, double const& Q) const;
0160     /**
0161      * @brief This function interpolates in x and Q for a given
0162      * element i. It is used for T = Set<Distribution>.
0163      */
0164     double EvaluatexQ(int const& i, double const& x, double const& Q) const;
0165     /**
0166      * @brief This function interpolates in x, z, and Q. It is used
0167      * for T = DoubleOject<Distribution>.
0168      */
0169     double EvaluatexzQ(double const& x, double const& z, double const& Q) const;
0170     /**
0171      * @brief This function interpolates in x and Q and returns a
0172      * map. It is used for T = Set<Distribution>.
0173      */
0174     std::map<int, double> EvaluateMapxQ(double const& x, double const& Q) const;
0175     ///@}
0176   };
0177 
0178   /**
0179    * @name Ternary operators
0180    */
0181   ///@{
0182   template<class T>
0183   TabulateObject<T> operator * (double const& s, TabulateObject<T> rhs);                           //!< Scalar*TabulateObject<T>
0184   template<class T>
0185   TabulateObject<T> operator * (TabulateObject<T> lhs, double const& s);                           //!< TabulateObject<T>*Scalar
0186   template<class T>
0187   TabulateObject<T> operator / (TabulateObject<T> lhs, double const& s);                           //!< TabulateObject<T>/Scalar
0188   template<class T>
0189   TabulateObject<T> operator + (TabulateObject<T> lhs, TabulateObject<T> const& rhs);              //!< TabulateObject<T>+TabulateObject<T>
0190   template<class T>
0191   TabulateObject<T> operator - (TabulateObject<T> lhs, TabulateObject<T> const& rhs);              //!< TabulateObject<T>-TabulateObject<T>
0192   ///@}
0193 }