APFEL 4.8.0
A PDF evolution library in C++
Loading...
Searching...
No Matches
distribution_test.cc
//
// APFEL++ 2017
//
// Author: Valerio Bertone: valerio.bertone@cern.ch
//
#include <apfel/apfelxx.h>
#include <cmath>
// Class to define the analytical expression of LO splitting function P0qq
class p0qq: public apfel::Expression
{
public:
p0qq(): Expression() {}
double Regular(double const& x) const
{
return - 2 * apfel::CF * ( 1 + x );
}
double Singular(double const& x) const
{
return 4 * apfel::CF / ( 1 - x );
}
double Local(double const& x) const
{
return 4 * apfel::CF * log(1 - x) + 3 * apfel::CF;
}
};
// Class to define the analytical expression of the squared LO splitting function P0qq
class p0qq2: public apfel::Expression
{
public:
p0qq2(): Expression() {}
double Regular(double const& x) const
{
return 4 * apfel::CF * apfel::CF * ( - 4 * log(x) / ( 1 - x ) - 4 * ( 1 + x ) * log(1 - x) + 3 * ( 1 + x ) * log(x) - ( x + 5 ) );
}
double Singular(double const& x) const
{
return 4 * apfel::CF * apfel::CF * ( 8 * log(1 - x) + 6 ) / ( 1 - x );
}
double Local(double const& x) const
{
return 4 * apfel::CF * apfel::CF * ( 4 * pow(log(1 - x),2) + 6 * log(1 - x) + 9. / 4. - 4 * pow(M_PI,2) / 6. ) ;
}
};
int main()
{
// Grid
const apfel::Grid g{{{100, 1e-5, 3}, {100, 1e-1, 3}, {40, 8e-1, 3}}};
// Distribution
const apfel::Distribution d{g, [&] (double const& x) -> double{ return 1 - x; }};
// Print distribution
std::cout << d;
// Expression
const p0qq p;
// Operator
std::cout << "\nInitialization ..." << std::endl;
t.start();
const apfel::Operator O{g, p};
t.stop();
// Multiply operator by the distribution to create a new distribution
std::cout << "\nConvolution between operator and distribution (O * d) ..." << std::endl;
t.start();
const apfel::Distribution Od = O * d;
t.stop();
// Multiply operator by itself to create a new operator
std::cout << "\nConvolution between two operators (O * O) ..." << std::endl;
t.start();
const apfel::Operator OO = O * O;
t.stop();
// Tabulation parameters
const int nx = 100;
const double xmin = 1e-5;
const double xmax = 0.999;
const double xstp = exp( log(xmax / xmin) / ( nx - 1 ) );
// Check the numerical accuracy of "Od" by comparing with the analytical result
std::cout << "\nChecking the numerical accuracy of O * d ... " << std::endl;
std::cout << std::scientific;
for (double x = xmin; x < xmax * 1.000001; x *= xstp)
{
// Analytic result for x \int_x^1 dy Pqq(y) ( 1 - x / y )
const double Ix = apfel::CF * ( - 2 * ( 3. / 2. - x - pow(x,2) / 2. ) + 4 * ( 1 - x ) * log(1 - x) + 3 * ( 1 - x ) + 2 * x * ( log(x) + 1 - x ) );
const double Odx = Od.Evaluate(x);
const double Oxd = InnerProduct(O.Evaluate(x), d);
std::cout << x << "\t\t" << Odx << "\t\t" << Oxd << "\t\t" << Ix << "\t\t" << Odx / Ix << "\t\t" << Oxd / Ix << std::endl;
}
// Check the numerical accuracy of "Od" by comparing with the analytical result
// Analytical expression of P0qq \otimes P0qq
const p0qq2 p2;
const apfel::Operator O2{g, p2};
// Now convolute both "OO" and "O2" with the test distribution "d" and check the result
const apfel::Distribution OOd = OO * d;
const apfel::Distribution O2d = O2 * d;
std::cout << "\nChecking the numerical accuracy of O * O ... " << std::endl;
for (double x = xmin; x < xmax * 1.000001; x *= xstp)
std::cout << x << "\t\t" << OOd.Evaluate(x) << "\t\t" << O2d.Evaluate(x) << "\t\t" << OOd.Evaluate(x) / O2d.Evaluate(x) << std::endl;
// Now define a double object with O and d and print it.
std::cout << DObj << std::endl;
return 0;
}
The Distribution class defines one of the basic objects of APFEL++. This is essentially the discretis...
Definition distribution.h:22
The DoubleObject class is a collection of pairs of single objects (Distributions or Operators) accomp...
Definition doubleobject.h:37
The Expression class encapsulates in a proper form a given analytic expression in such a way that it ...
Definition expression.h:17
virtual double Local(double const &) const
Virtual local term.
Definition expression.h:55
Expression(double const &eta=1)
The "Expression" constructor.
virtual double Singular(double const &) const
Virtual singular term.
Definition expression.h:49
virtual double Regular(double const &) const
Virtual regular term.
Definition expression.h:43
The Grid class defines ab object that is essentially a collection of "SubGrid" objects plus other glo...
Definition grid.h:22
double Evaluate(double const &x) const
Function that evaluates the interpolated function on the joint grid.
The Operator class defines the basic object "Operator" which is essentially the convolution on the gr...
Definition operator.h:22
The Timer class computes the time elapsed between start and stop.
Definition timer.h:20
void stop(bool const &ForceDisplay=false)
This function stops the timer and reports the elapsed time in seconds since the last time the timer w...
Definition timer.h:36
void start()
This function starts the timer.
Definition timer.h:30
const double CF
Definition constants.h:148
double InnerProduct(Distribution const &d1, Distribution const &d2, double const &offset=0)
Function that computes the scala product bewteen two distributions. The product is computed using the...