Back to home page

EIC code displayed by LXR

 
 

    


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 "apfel/expression.h"
0010 #include "apfel/distribution.h"
0011 #include "apfel/matrix.h"
0012 
0013 namespace apfel
0014 {
0015   /**
0016    * @brief This class defines the basic object Operator which
0017    * essentially contains the convolution bewteen an "Expression"
0018    * object (e.g. a splitting function) and a set of interpolanting
0019    * functions defined on a grid.
0020    * @note Both the forward and the non-forward cases can be handled
0021    * by this class. They correspond respectively to inclusive
0022    * (DGLAP-like) and exclusive (GPD-like) processes.
0023    */
0024   class Operator
0025   {
0026   public:
0027     Operator() = delete;
0028     Operator(Operator const&) = default;
0029 
0030     /**
0031      * @brief The Operator constructor.
0032      * @param gr: the Grid object
0033      * @param expr: the expression to be convoluted
0034      * @param eps: relative accuracy of the numerical integrations (default: 10<SUP>-5</SUP>)
0035      * @param gpd: whether the operator has to computed for a GPD-like expression (default: false)
0036      * @param extended: whether the operator is to be extended (default: false)
0037      */
0038     Operator(Grid const& gr, Expression const& expr, double const& eps = 1e-5, bool const& gpd = false, bool const& extended = false);
0039 
0040     /**
0041      * @brief The Operator constructor from a raw operator.
0042      * @param gr: the Grid object
0043      * @param op: raw operator previously computed
0044      * @param gpd: whether the operator had to computed for a GPD-like expression (default: false)
0045      */
0046     Operator(Grid const& gr, std::vector<matrix<double>> const& op, bool const& gpd = false);
0047 
0048     /**
0049      * @brief The Operator constructor from another operator with rescaling.
0050      * @param op: raw operator previously computed
0051      * @param eta: rescaling factor
0052      * @note This constructor constructs a DGLAP-like extended
0053      * operator useful for massive coefficient functions.
0054      */
0055     Operator(Operator const& op, double const& eta);
0056 
0057     /**
0058      * @brief The Operator virtual destructor.
0059      */
0060     virtual ~Operator() {}
0061 
0062     /**
0063      * @name Binary operators
0064      */
0065     ///@{
0066     Distribution operator *= (Distribution const& d) const;         //!< this *= Distribution
0067     Operator& operator *= (Operator const& o);                      //!< this *= Operator
0068     Operator& operator  = (Operator const& o);                      //!< this  = Operator
0069     Operator& operator *= (double const& s);                        //!< this *= Scalar
0070     Operator& operator *= (std::function<double(double const&)> f); //!< This *= Function
0071     Operator& operator /= (double const& s);                        //!< this /= Scalar
0072     Operator& operator += (Operator const& o);                      //!< this += Operator
0073     Operator& operator -= (Operator const& o);                      //!< this -= Operator
0074     ///@}
0075 
0076     /**
0077      * @brief Function that interpolates the operator over the first
0078      * index and returns a Distribution object.
0079      * @param x: the value in x to be interpolated
0080      */
0081     Distribution Evaluate(double const& x) const;
0082 
0083     /**
0084      * @brief Function that inverts the current operator such that,
0085      * when multiplied by the original operator, it returns the unity.
0086      */
0087     void Invert();
0088 
0089     /**
0090      * @brief Function that extends the current operator by filling
0091      * the full square matrix using the known shift symmetry (only
0092      * effective for DGLAP-like operators).
0093      */
0094     void Extend();
0095 
0096     /**
0097      * @brief Function that returns the Grid object associated with
0098      * the operator.
0099      */
0100     Grid const& GetGrid() const { return _grid; }
0101 
0102     /**
0103      * @brief Function that returns the integration accuracy,
0104      */
0105     double const& GetIntegrationAccuracy() const { return _eps; }
0106 
0107     /**
0108      * @brief Function that returns the GPD switch,
0109      */
0110     bool const& IsGPD() const { return _gpd; }
0111 
0112     /**
0113      * @brief Function that returns whether the operato is extended,
0114      */
0115     bool const& IsExtended() const { return _extended; }
0116 
0117     /**
0118      * @brief Function that returns the Operator container.
0119      */
0120     std::vector<matrix<double>> GetOperator() const { return _Operator; }
0121 
0122     /**
0123      * @brief Function that prints the Operator object.
0124      */
0125     void Print() const { std::cout << *this << std::endl; }
0126 
0127   protected:
0128     Grid                 const& _grid;      //!< Grid on which to compute the operator
0129     double               const  _eps;       //!< Integration accuracy
0130     bool                 const  _gpd;       //!< GPD switch
0131     bool                        _extended;  //!< Whether the operator is extended
0132     std::vector<matrix<double>> _Operator;  //!< Operator values
0133 
0134     friend std::ostream& operator << (std::ostream& os, Operator const& op);
0135 
0136   private:
0137     /**
0138      * @brief Function that builds a DGLAP-like operator.
0139      */
0140     void BuildOperatorDGLAP(Expression const& expr);
0141 
0142     /**
0143      * @brief Function that builds a GPD-like operator.
0144      */
0145     void BuildOperatorGPD(Expression const& expr);
0146   };
0147 
0148   /**
0149    * @name Ternary operators
0150    */
0151   ///@{
0152   Distribution operator * (Operator lhs, Distribution const& rhs);                //!< Operator*Distribution
0153   Operator     operator * (Operator lhs, Operator const& rhs);                    //!< Operator*Operator
0154   Operator     operator * (double const& s, Operator rhs);                        //!< Scalar*Operator
0155   Operator     operator * (Operator lhs, double const& s);                        //!< Operator*Scalar
0156   Operator     operator * (std::function<double(double const&)> f, Operator rhs); //!< function*Operator
0157   Operator     operator * (Operator lhs, std::function<double(double const&)> f); //!< Operator*function
0158   Operator     operator / (Operator lhs, double const& s);                        //!< Operator/Scalar
0159   Operator     operator + (Operator lhs, Operator const& rhs);                    //!< Operator+Operator
0160   Operator     operator - (Operator lhs, Operator const& rhs);                    //!< Operator-Operator
0161   ///@}
0162 
0163   /**
0164    * @brief Method which prints Operator with std::cout <<.
0165    */
0166   std::ostream& operator << (std::ostream& os, Operator const& op);
0167 }