|
|
|||
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/distribution.h" 0010 #include "apfel/matrix.h" 0011 #include "apfel/lagrangeinterpolator.h" 0012 #include "apfel/doubleobject.h" 0013 0014 namespace apfel 0015 { 0016 /** 0017 * @brief The DoubleDistribution class defines one of the basic 0018 * objects that provides a discretisation of a two-dimensional 0019 * function and that can be used for convolutions. 0020 */ 0021 class DoubleDistribution 0022 { 0023 public: 0024 DoubleDistribution() = delete; 0025 0026 /** 0027 * @name Constructors 0028 * List of constructors. 0029 */ 0030 ///@{ 0031 /** 0032 * @brief The DoubleDistribution constructor 0033 * @param g1: the Grid object that defines the first interpolation grid 0034 * @param g2: the Grid object that defines the second interpolation grid 0035 * @param InDistFunc: the function of "x1" and "x2" to be tabulated 0036 */ 0037 DoubleDistribution(Grid const& g1, 0038 Grid const& g2, 0039 std::function<double(double const&, double const&)> const& InDistFunc = [] (double const&, double const&) -> double{ return 0; }); 0040 0041 /** 0042 * @brief The DoubleDistribution copy constructor 0043 * @param obj: the object to be copied 0044 */ 0045 DoubleDistribution(DoubleDistribution const& obj); 0046 0047 /** 0048 * @brief The DoubleDistribution constructor 0049 * @param d1: the first single distribution 0050 * @param d2: the second single distribution 0051 */ 0052 DoubleDistribution(Distribution const& d1, Distribution const& d2); 0053 0054 /** 0055 * @brief The DoubleDistribution constructor 0056 * @param g1: the Grid object that defines the first interpolation grid 0057 * @param g2: the Grid object that defines the second interpolation grid 0058 * @param distsubgrid: the distribution on the subgrids 0059 * @param distjointgrid: the distribution on the joint grid 0060 */ 0061 DoubleDistribution(Grid const& g1, 0062 Grid const& g2, 0063 std::vector<std::vector<matrix<double>>> const& distsubgrid, 0064 matrix<double> const& distjointgrid); 0065 0066 /** 0067 * @brief The DoubleDistribution constructor 0068 * @param DObj: the DoubleObject of distributions 0069 */ 0070 DoubleDistribution(DoubleObject<Distribution> const& DObj); 0071 ///@} 0072 0073 /** 0074 * @name Evaluate functions 0075 * List of functions that perform the interpolation on the x-space 0076 * grids. 0077 */ 0078 ///@{ 0079 /** 0080 * @brief Function that evaluates the interpolated function on the joint grids. 0081 * @param x1: the value in x1 to be interpolated 0082 * @param x2: the value in x2 to be interpolated 0083 * @return the interpolated result 0084 */ 0085 double Evaluate(double const& x1, double const& x2) const; 0086 0087 /** 0088 * @brief Function that evaluates the derivative of the 0089 * interpolated function on the joint grids. 0090 * @param x1: the value in x1 where the derivative has to be computed 0091 * @param x2: the value in x2 where the derivative has to be computed 0092 * @return the derivative of the interpolated function 0093 */ 0094 double Derive(double const& x1, double const& x2) const; 0095 0096 /** 0097 * @brief Function that evaluates the integral of the interpolated 0098 * function in the interval x1 in [a1,b1] and x2 in [a2,b2] on the 0099 * joint grids. 0100 * @param a1: the lower integration bound for the first variable 0101 * @param b1: the upper integration bound for the first variable 0102 * @param a2: the lower integration bound for the second variable 0103 * @param b2: the upper integration bound for the second variable 0104 * @return the integral of the interpolated function 0105 */ 0106 double Integrate(double const& a1, double const& b1, double const& a2, double const& b2) const; 0107 0108 /** 0109 * @brief Function that evaluates the DoubleDistribution in the 0110 * first variable leaving the second undetermined. This produces a 0111 * single distribution. 0112 * @param x1: the value of the first variable 0113 */ 0114 Distribution Evaluate1(double const& x1) const; 0115 0116 /** 0117 * @brief Function that evaluates the DoubleDistribution in the 0118 * second variable leaving the first undetermined. This produces a 0119 * single distribution. 0120 * @param x2: the value of the second variable 0121 */ 0122 Distribution Evaluate2(double const& x2) const; 0123 0124 /** 0125 * @brief Function that evaluates the derivative of a 0126 * DoubleDistribution in the first variable leaving the second 0127 * undetermined. This produces a single distribution. 0128 * @param x1: the value of the first variable 0129 */ 0130 Distribution Derive1(double const& x1) const; 0131 0132 /** 0133 * @brief Function that evaluates the derivative of a 0134 * DoubleDistribution in the second variable leaving the first 0135 * undetermined. This produces a single distribution. 0136 * @param x2: the value of the second variable 0137 */ 0138 Distribution Derive2(double const& x2) const; 0139 0140 /** 0141 * @brief Function that evaluates the integral of the interpolated 0142 * function in the interval [a1,b1] for the first variable leaving 0143 * the second undetermined. 0144 * @param a1: the lower integration bound for the first variable 0145 * @param b1: the upper integration bound for the first variable 0146 * @return the integral of the interpolated function 0147 */ 0148 Distribution Integrate1(double const& a1, double const& b1) const; 0149 0150 /** 0151 * @brief Function that evaluates the integral of the interpolated 0152 * function in the interval [a2,b2] for the second variable leaving 0153 * the first undetermined. 0154 * @param a2: the lower integration bound for the second variable 0155 * @param b2: the upper integration bound for the second variable 0156 * @return the integral of the interpolated function 0157 */ 0158 Distribution Integrate2(double const& a2, double const& b2) const; 0159 ///@} 0160 0161 /** 0162 * @brief Function that returns the derivative of the 0163 * DoubleDistribution in the form of a DoubleDistribution object. 0164 */ 0165 DoubleDistribution Derivative() const; 0166 0167 /** 0168 * @name Getters 0169 */ 0170 ///@{ 0171 Grid const& GetFirstGrid() const { return _g1; } 0172 Grid const& GetSecondGrid() const { return _g2; } 0173 LagrangeInterpolator const GetFirstInterpolator() const { return _li1; } 0174 LagrangeInterpolator const GetSecondInterpolator() const { return _li2; } 0175 std::vector<std::vector<matrix<double>>> const GetDistributionSubGrid() const { return _dDSubGrid; } 0176 matrix<double> const GetDistributionJointGrid() const { return _dDJointGrid; } 0177 ///@} 0178 0179 /** 0180 * @name Binary operators 0181 */ 0182 ///@{ 0183 DoubleDistribution& operator = (DoubleDistribution const& d); //!< this = Distribution 0184 DoubleDistribution& operator *= (double const& s); //!< this *= Scalar 0185 DoubleDistribution& operator *= (std::function<double(double const&, double const&)> const& f); //!< this *= Function of both the integration variables 0186 DoubleDistribution& operator *= (std::function<double(double const&)> const& f); //!< this *= Function of one variable used for both the integration variables 0187 DoubleDistribution& operator /= (double const& s); //!< this /= Scalar 0188 DoubleDistribution& operator *= (DoubleDistribution const& d); //!< this *= Distribution 0189 DoubleDistribution& operator += (DoubleDistribution const& d); //!< this += Distribution 0190 DoubleDistribution& operator -= (DoubleDistribution const& d); //!< this -= Distribution 0191 ///@} 0192 0193 /** 0194 * @brief Print the DoubleDistribution object 0195 */ 0196 void Print() const { std::cout << *this << std::endl; } 0197 0198 private: 0199 Grid const& _g1; //!< The first interpolation grid 0200 Grid const& _g2; //!< The second interpolation grid 0201 LagrangeInterpolator const _li1; //!< The first Lagrange interpolator 0202 LagrangeInterpolator const _li2; //!< The second Lagrange interpolator 0203 std::vector<std::vector<matrix<double>>> _dDSubGrid; //!< The array with the double distribution values on the subgrids 0204 matrix<double> _dDJointGrid; //!< The array with the double distribution values on the joint grids 0205 0206 friend std::ostream& operator << (std::ostream& os, DoubleDistribution const& sg); 0207 }; 0208 0209 /** 0210 * @name Ternary operators 0211 */ 0212 ///@{ 0213 DoubleDistribution operator * (double const& s, DoubleDistribution rhs); //!< Scalar*Distribution 0214 DoubleDistribution operator * (DoubleDistribution lhs, double const& s); //!< Distribution*Scalar 0215 DoubleDistribution operator * (std::function<double(double const&, double const&)> const& f, DoubleDistribution rhs); //!< Function*Distribution 0216 DoubleDistribution operator * (DoubleDistribution lhs, std::function<double(double const&, double const&)> const& f); //!< Distribution*Function 0217 DoubleDistribution operator * (std::function<double(double const&)> const& f, DoubleDistribution rhs); //!< Function*Distribution 0218 DoubleDistribution operator * (DoubleDistribution lhs, std::function<double(double const&)> const& f); //!< Distribution*Function 0219 DoubleDistribution operator / (DoubleDistribution lhs, double const& s); //!< Distribution/Scalar 0220 DoubleDistribution operator + (DoubleDistribution lhs, DoubleDistribution const& rhs); //!< Distribution+Distribution 0221 DoubleDistribution operator - (DoubleDistribution lhs, DoubleDistribution const& rhs); //!< Distribution-Distribution 0222 DoubleDistribution operator * (DoubleDistribution lhs, DoubleDistribution const& rhs); //!< Distribution*Distribution 0223 ///@} 0224 0225 /** 0226 * @brief Method which prints DoubleDistribution with cout <<. 0227 */ 0228 std::ostream& operator << (std::ostream& os, DoubleDistribution const& in); 0229 }
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|