33 #define INCLXX_IN_GEANT4_MODE 1
53 const G4double IFunction1D::integrationCoefficients[] = {
82 nIntervals =
G4int(interval/step);
85 G4int remainder = nIntervals % 9;
87 nIntervals += 9 - remainder;
89 nIntervals =
std::max(nIntervals, 9);
92 const G4double dx = interval/nIntervals;
94 for(
G4int j = 1; j<nIntervals; ++j) {
96 const unsigned index = j%9;
97 result +=
operator()(x) * integrationCoefficients[index];
100 return result*dx*
sign;
113 return theFunction->integrate(
xMin,x);
117 } *thePrimitive =
new Primitive(
this);
128 normalisation(1./theFunction->integrate(
xMin,
xMax))
132 return std::min(1., normalisation * theFunction->integrate(
xMin,x));
137 } *theInverseCDF =
new InverseCDF(
this);
140 delete theInverseCDF;
Simple interpolation table for the inverse of a IFunction1D functor.
IFunction1D * primitive() const
Return a pointer to the (numerical) primitive to this function.
G4double xMin
Minimum value of the independent variable.
virtual G4double operator()(const G4double x) const =0
Compute the value of the function.
G4double xMax
Maximum value of the independent variable.
InverseInterpolationTable * inverseCDFTable(const G4int nNodes=60) const
Return a pointer to the inverse of the CDF of this function.
void swap(shared_ptr< P > &, shared_ptr< P > &)
Class for interpolating the inverse of a 1-dimensional function.
virtual G4double integrate(const G4double x0, const G4double x1, const G4double step=-1.) const
Integrate the function between two values.
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
Functor for 1-dimensional mathematical functions.
virtual G4double getXMinimum() const
Return the minimum allowed value of the independent variable.
virtual G4double getXMaximum() const
Return the maximum allowed value of the independent variable.