47#ifndef G4FunctionSolver_h
48#define G4FunctionSolver_h 1
57 : maxIter(iterations), tolerance(tol), tF(ff) {};
71 { maxIter = iterations; }
78 aa = std::min(Limit1, Limit2);
79 bb = std::max(Limit1, Limit2);
89 x = std::min(std::max(x, a), b);
93 if (0.0 == fc) {
return true; }
101 if (std::abs(a - b) <= epsX)
114 x = (std::abs(fa) <= std::abs(fb)) ? a : b;
115 return (std::min(std::abs(fa), std::abs(fb)) < epsY);
121 for (
G4int i = 0; i < maxIter; ++i)
123 x = (a*fb - b*fa)/(fb - fa);
124 fc = tF->Function(x);
125 if (std::abs(fc) < epsY) {
return true; }
127 G4double delta = std::min((x - a), (b - x));
128 if (delta < epsX) {
return true; }
129 else if (fa*fc < 0.0) { b = x; fb = fc; }
130 else { a = x; fa = fc; }
G4double epsilon(G4double density, G4double temperature)
G4FunctionSolver(T_Function *ff, const G4int iterations, const G4double tol)
G4bool operator==(const G4FunctionSolver &right) const =delete
G4FunctionSolver & operator=(const G4FunctionSolver &right)=delete
void SetIntervalLimits(const G4double Limit1, const G4double Limit2)
G4bool FindRoot(G4double &x)
G4FunctionSolver(const G4FunctionSolver &right)=delete
G4bool operator!=(const G4FunctionSolver &right) const =delete
~G4FunctionSolver()=default
void SetTolerance(const G4double epsilon)
void SetMaxIterations(const G4int iterations)