#include <iostream>
#include <cmath>
#include <iomanip>
int main()
{
const std::vector<double> Thrs{1.4, 6};
const auto xQdist = [&](double const& x, double const& Q) -> double{ return x * ( 1 - x ) / log(log(Q/0.2)) + (Q > Thrs[0] ? 0.1 : 0) + (Q > Thrs[1] ? 0.2 : 0); };
const auto dxQdist = [&](double const& x, double const& Q) -> double{ return - x * ( 1 - x ) / pow(log(log(Q/0.2)), 2) / Q / log(Q/0.2); };
const auto ixQdist = [&](double const& x, double const& Qa, double const& Qb) -> double
{
apfel::Integrator integrand{[=] (
double const& Q) ->
double{
return x * ( 1 - x ) / log(log(Q/0.2)) + (Q > Thrs[0] ? 0.1 : 0) + (Q > Thrs[1] ? 0.2 : 0); }};
return integrand.
integrate(Qa, Qb, Thrs, 1e-7);
};
std::cout << dist << std::endl;
double nx = 5;
double xmin = 1e-1;
double xmax = 9e-1;
double xstep = exp( log( xmax / xmin ) / ( nx - 1 ) );
double nQ = 20;
double Qmin = 1.1;
double Qmax = 100;
double Qstep = exp( log( Qmax / Qmin ) / ( nQ - 1 ) );
std::cout << "Accuracy test:" << std::endl;
std::cout << " Q "
<< " x "
<< "Interpolated "
<< " Direct "
<< " Ratio "
<< " Deriv. inter. "
<< " Deriv. dir. "
<< " Ratio "
<< "Integ. inter. "
<< " Integ. dir. "
<< " Ratio "
<< std::endl;
std::cout << std::scientific;
double Q = Qmin;
for (int iQ = 0; iQ < nQ; iQ++)
{
double x = xmin;
for (int ix = 0; ix < nx; ix++)
{
std::cout << Q << " " << x << " "
<< d.
Evaluate(x) <<
" " << xQdist(x, Q) <<
" " << d.
Evaluate(x) / xQdist(x, Q) <<
" "
<< dd.
Evaluate(x) <<
" " << dxQdist(x, Q) <<
" " << dd.
Evaluate(x) / dxQdist(x, Q) <<
" "
<< id.Evaluate(x) << " " << ixQdist(x, Q, 5) << " " << id.Evaluate(x) / ixQdist(x, Q, 5) << " "
<< std::endl;
x *= xstep;
}
Q *= Qstep;
}
nx = 1000;
xstep = exp( log( xmax / xmin ) / ( nx - 1 ) );
nQ = 1000;
Qstep = exp( log( Qmax / Qmin ) / ( nQ - 1 ) );
std::cout << "\nPerformance test:" << std::endl;
std::cout << "Interpolating " << nx << " x-space points for each of " << nQ << " Q-space points... ";
Q = Qmin;
for (int iQ = 0; iQ < nQ; iQ++)
{
double x = xmin;
for (int ix = 0; ix < nx; ix++)
{
x *= xstep;
}
Q *= Qstep;
}
return 0;
}
The Distribution class defines one of the basic objects of APFEL++. This is essentially the discretis...
Definition distribution.h:22
The Grid class defines ab object that is essentially a collection of "SubGrid" objects plus other glo...
Definition grid.h:22
The Integrator class performs unidimensional numerical integrations using the Guassian quadrature.
Definition integrator.h:19
double integrate(double const &xmin, double const &xmax, double const &eps) const
Function that integrates the integrand with a given relative accuracy using the method defined in the...
double Derive(double const &x) const
Function that evaluates the derivative of the interpolated function on the joint grid.
double Evaluate(double const &x) const
Function that evaluates the interpolated function on the joint grid.
double Integrate(double const &a, double const &b) const
Function that evaluates the integral of the interpolated function in the interval [a,...
Class for the x-space interpolation SubGrids.
Definition subgrid.h:23
The template TabulateObject class is a derived of the QGrid class that tabulates on object of type T ...
Definition tabulateobject.h:26
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