34#define INCLXX_IN_GEANT4_MODE 1
55 namespace RootFinder {
88 return std::make_pair(x0,x1);
90 const G4double scaleFactorMinus1 = 1./scaleFactor;
95 INCL_DEBUG(
"Could not bracket the root." <<
'\n');
103 x0 *= scaleFactorMinus1;
111 return std::make_pair(x0,oldx0);
113 return std::make_pair(oldx1,x1);
126 std::pair<G4double,G4double> bracket =
bracketRoot(f,x0);
137 INCL_DEBUG(
"Root-finding algorithm could not bracket the root." <<
'\n');
153 G4int lastUpdated = 0;
158 INCL_DEBUG(
"Root-finding algorithm did not converge." <<
'\n');
164 x = (y1*x2-y2*x1)/(y1-y2);
173 if(lastUpdated==-1) y2 *= 0.5;
178 if(lastUpdated==1) y1 *= 0.5;
Static root-finder algorithm.
virtual void cleanUp(const G4bool success) const =0
std::pair< G4double, G4double > bracketRoot(RootFunctor const *const f, G4double x0)
Bracket the root of the function f.
const G4double toleranceY
Tolerance on the y value.
const G4int maxIterations
Maximum number of iterations for convergence.
Solution solve(RootFunctor const *const f, const G4double x0)
Numerically solve a one-dimensional equation.