35#define INCLXX_IN_GEANT4_MODE 1
55 const G4double IFunction1D::integrationCoefficients[] = {
84 nIntervals =
G4int(interval/step);
87 G4int remainder = nIntervals % 9;
89 nIntervals += 9 - remainder;
91 nIntervals = std::max(nIntervals, 9);
94 const G4double dx = interval/nIntervals;
96 for(
G4int j = 1; j<nIntervals; ++j) {
98 const unsigned index = j%9;
99 result +=
operator()(x) * integrationCoefficients[index];
102 return result*dx*sign;
119 } *thePrimitive =
new Primitive(
this);
130 normalisation(1./theFunction->integrate(xMin,xMax))
134 return std::min(1., normalisation * theFunction->integrate(xMin,x));
139 } *theInverseCDF =
new InverseCDF(
this);
142 delete theInverseCDF;
Functor for 1-dimensional mathematical functions.
Simple interpolation table for the inverse of a IFunction1D functor.
virtual G4double operator()(const G4double x) const =0
Compute the value of the function.
virtual G4double getXMaximum() const
Return the maximum allowed value of the independent variable.
G4double xMin
Minimum value of the independent variable.
IFunction1D * primitive() const
Return a pointer to the (numerical) primitive to this function.
G4double xMax
Maximum value of the independent variable.
virtual G4double integrate(const G4double x0, const G4double x1, const G4double step=-1.) const
Integrate the function between two values.
virtual G4double getXMinimum() const
Return the minimum allowed value of the independent variable.
InverseInterpolationTable * inverseCDFTable(const G4int nNodes=60) const
Return a pointer to the inverse of the CDF of this function.
Class for interpolating the inverse of a 1-dimensional function.