|
|
|||
File indexing completed on 2026-06-02 08:17:12
0001 // 0002 // APFEL++ 2017 0003 // 0004 // Author: Valerio Bertone: valerio.bertone@cern.ch 0005 // 0006 0007 #pragma once 0008 0009 #include "apfel/lagrangeinterpolator.h" 0010 0011 #include <map> 0012 #include <functional> 0013 0014 namespace apfel 0015 { 0016 /** 0017 * @brief The Distribution class defines one of the basic objects 0018 * of APFEL++ that provides a discretisation of a function and that 0019 * can be conveniently used for convolutions. 0020 */ 0021 class Distribution: public LagrangeInterpolator 0022 { 0023 public: 0024 Distribution() = delete; 0025 0026 /** 0027 * @name Constructors 0028 * List of constructors. 0029 */ 0030 ///@{ 0031 /** 0032 * @brief The Distribution constructor 0033 * @param g: the Grid object that defines the interpolation grid 0034 */ 0035 Distribution(Grid const& g); 0036 0037 /** 0038 * @brief The Distribution constructor 0039 * @param obj: the reference distribution from wich the grid and the actual distributions are extracted 0040 */ 0041 Distribution(Distribution const& obj); 0042 0043 /** 0044 * @brief The Distribution constructor 0045 * @param obj: a reference distribution from wich the grid is extracted 0046 * @param distsubgrid: the vector of the distribution on the subgrids 0047 * @param distjointgrid: the vector of the distribution on the joint grid 0048 */ 0049 Distribution(Distribution const& obj, 0050 std::vector<std::vector<double>> const& distsubgrid, 0051 std::vector<double> const& distjointgrid); 0052 0053 /** 0054 * @brief The Distribution constructor 0055 * @param g: the Grid object that defines the interpolation grid 0056 * @param distsubgrid: the vector of the distribution on the subgrids 0057 * @param distjointgrid: the vector of the distribution on the joint grid 0058 */ 0059 Distribution(Grid const& g, 0060 std::vector<std::vector<double>> const& distsubgrid, 0061 std::vector<double> const& distjointgrid); 0062 0063 /** 0064 * @brief The Distribution constructor 0065 * @param g: the Grid object that defines the interpolation grid 0066 * @param InDistFunc: the function of "x" to be tabulated on the grid in x 0067 */ 0068 Distribution(Grid const& g, 0069 std::function<double(double const&)> const& InDistFunc); 0070 0071 /** 0072 * @brief The Distribution constructor 0073 * @param g: the Grid object that defines the interpolation grid 0074 * @param InDistFunc: the function of "x" and "Q" to be tabulated in "x" 0075 * @param Q: the value of "Q" at which InDistFunc is to be tabulated 0076 */ 0077 Distribution(Grid const& g, 0078 std::function<double(double const&, double const&)> const& InDistFunc, 0079 double const& Q); 0080 0081 /** 0082 * @brief The Distribution constructor 0083 * @param g: the Grid object that defines the interpolation grid 0084 * @param InDistFunc: the function of "ipdf" and "x" to be tabulated in x 0085 * @param ipdf: the value of "ipdf" at which InDistFunc is to be computed 0086 */ 0087 Distribution(Grid const& g, 0088 std::function<double(int const&, double const&)> const& InDistFunc, 0089 int const& ipdf); 0090 0091 /** 0092 * @brief The Distribution constructor 0093 * @param g: the Grid object that defines the interpolation grid 0094 * @param InDistFunc: the function of "ipdf", "x", and "Q" to be tabulated in x 0095 * @param ipdf: the value of "ipdf" at which InDistFunc is to be computed 0096 * @param Q: the value of "Q" at which InDistFunc is to be computed 0097 */ 0098 Distribution(Grid const& g, 0099 std::function<double(int const&, double const&, double const&)> const& InDistFunc, 0100 int const& ipdf, 0101 double const& Q); 0102 ///@} 0103 0104 /** 0105 * @brief Function that sets the values of the joint grid. 0106 * @param ix: the vector index 0107 * @param x: the value of of the distribution to set in the distribution vector on the joint grid 0108 */ 0109 void SetJointGrid(int const& ix, double const& x); 0110 0111 /** 0112 * @brief Function that sets the values of the subgrid. 0113 * @param ig: the subgrid index 0114 * @param ix: the vector index 0115 * @param x: value of of the distribution to set in the distribution vector on the ig-th subgrid 0116 */ 0117 void SetSubGrid(int const& ig, int const& ix, double const& x); 0118 0119 /** 0120 * @brief Function that sets the joint grid. 0121 * @param jg: the vector of the joint grid 0122 */ 0123 void SetJointGrid(std::vector<double> const& jg); 0124 0125 /** 0126 * @brief Function that sets the single subgrid. 0127 * @param ig: the subgrid index 0128 * @param sg: the vector of the subgrid 0129 */ 0130 void SetSubGrid(int const& ig, std::vector<double> const& sg); 0131 0132 /** 0133 * @brief Function that sets all of the subgrids at once. 0134 * @param sgs: the vector of vectors of the subgrids 0135 */ 0136 void SetSubGrids(std::vector<std::vector<double>> const& sgs); 0137 0138 /** 0139 * @brief Function that returns the derivative of the Distribution 0140 * in the form of a Distribution object. 0141 */ 0142 Distribution Derivative() const; 0143 0144 /** 0145 * @brief This function trasforms the the Distribution given a 0146 * functions. 0147 * @param TranformationFunc: set of transformation functions 0148 */ 0149 Distribution Transform(std::function<double(double const&)> const& TranformationFunc) const; 0150 0151 /** 0152 * @name Binary operators 0153 */ 0154 ///@{ 0155 Distribution& operator = (Distribution const& d); //!< this = Distribution 0156 Distribution& operator *= (double const& s); //!< this *= Scalar 0157 Distribution& operator *= (std::function<double(double const&)> const& f); //!< this *= Function of the integration variable 0158 Distribution& operator /= (double const& s); //!< this /= Scalar 0159 Distribution& operator *= (Distribution const& d); //!< this *= Distribution 0160 Distribution& operator += (Distribution const& d); //!< this += Distribution 0161 Distribution& operator -= (Distribution const& d); //!< this -= Distribution 0162 ///@} 0163 }; 0164 0165 /** 0166 * @name Ternary operators 0167 */ 0168 ///@{ 0169 Distribution operator * (double const& s, Distribution rhs); //!< Scalar*Distribution 0170 Distribution operator * (Distribution lhs, double const& s); //!< Distribution*Scalar 0171 Distribution operator * (std::function<double(double const&)> const& f, Distribution rhs); //!< Function*Distribution 0172 Distribution operator * (Distribution lhs, std::function<double(double const&)> const& f); //!< Distribution*Function 0173 Distribution operator / (Distribution lhs, double const& s); //!< Distribution/Scalar 0174 Distribution operator + (Distribution lhs, Distribution const& rhs); //!< Distribution+Distribution 0175 Distribution operator - (Distribution lhs, Distribution const& rhs); //!< Distribution-Distribution 0176 Distribution operator * (Distribution lhs, Distribution const& rhs); //!< Distribution*Distribution 0177 ///@} 0178 0179 /** 0180 * @name Maps of Distributions 0181 * Functions that return maps of Distribution objects. 0182 */ 0183 ///@{ 0184 /** 0185 * @brief Function that fills in a map of distributions from a 0186 * map-valued function. 0187 * @param g: the Grid object 0188 * @param InDistFunc: the map-valued function dependent on "x" and "Q" 0189 * @param Q: the value of "Q" at which InDistFunc is to be computed 0190 * @param skip: the vector of indices to be skipped in the tabulation (defalt: empty vector) 0191 */ 0192 std::map<int, Distribution> DistributionMap(Grid const& g, 0193 std::function<std::map<int, double>(double const&, double const&)> const& InDistFunc, 0194 double const& Q, 0195 std::vector<int> const& skip = {}); 0196 0197 /** 0198 * @brief Function that fills in a map of distributions from a 0199 * map-valued function. 0200 * @param g: the Grid object 0201 * @param InDistFunc: the map-valued function dependent on "x" 0202 * @param skip: the vector of indices to be skipped in the tabulation (defalt: empty vector) 0203 */ 0204 std::map<int, Distribution> DistributionMap(Grid const& g, 0205 std::function<std::map<int, double>(double const&)> const& InDistFunc, 0206 std::vector<int> const& skip = {}); 0207 0208 /** 0209 * @brief Function that fills in a map of distributions from a 0210 * vector-valued function. 0211 * @param g: the Grid object 0212 * @param InDistFunc: the vector-valued function dependent on "x" 0213 * @param NOutputs: number of outputs of the input function (default: 0, that is unknown) 0214 */ 0215 std::map<int, Distribution> DistributionMap(Grid const& g, 0216 std::function<std::vector<double>(double const&)> const& InDistFunc, 0217 int const& NOutputs = 0); 0218 0219 /** 0220 * @brief Function that sums the element of a 0221 * distribution. Specifically, it sums the elements of the joint 0222 * grid. Combined with the Distribution * Distribution operator, 0223 * this function is useful to compute scalar products. 0224 * @param InDist: the distribution to be summed 0225 */ 0226 double Sum(Distribution const& InDist); 0227 0228 /** 0229 * @brief Function that computes the scalar product bewteen two 0230 * Distribution objects. The product is computed using the joint 0231 * grids. 0232 * @param d1: the first input distribution 0233 * @param d2: the second input distribution 0234 * @param offset: offset applied to the inner product (default: 0) 0235 */ 0236 double InnerProduct(Distribution const& d1, Distribution const& d2, double const& offset = 0); 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 |
|