22 static int gDefaultNpx = 100;
23 static int gDefaultNSearch = 10;
25 BrentRootFinder::BrentRootFinder() : fFunction(0),
26 fLogScan(false), fNIter(0),
28 fXMin(0), fXMax(0), fRoot(0)
34 void BrentRootFinder::SetDefaultNpx(
int n) { gDefaultNpx = n; }
36 void BrentRootFinder::SetDefaultNSearch(
int n) { gDefaultNSearch = n; }
39 bool BrentRootFinder::SetFunction(
const ROOT::Math::IGenFunction& f,
double xlow,
double xup)
59 const char* BrentRootFinder::Name()
const
60 {
return "BrentRootFinder"; }
63 bool BrentRootFinder::Solve(
int maxIter,
double absTol,
double relTol)
68 MATH_ERROR_MSG(
"BrentRootFinder::Solve",
"Function has not been set");
72 if (fLogScan && fXMin <= 0) {
73 MATH_ERROR_MSG(
"BrentRootFinder::Solve",
"xmin is <=0 and log scan is set - disable it");
86 int maxIter1 = gDefaultNSearch;
87 int maxIter2 = maxIter;
93 if (niter1 > maxIter1){
94 MATH_ERROR_MSG(
"BrentRootFinder::Solve",
"Search didn't converge");
98 double x = BrentMethods::MinimStep(fFunction, 4, xmin, xmax, fy, fNpx,fLogScan);
101 MATH_ERROR_MSG(
"BrentRootFinder",
"Interval does not contain a root");
104 x = BrentMethods::MinimBrent(fFunction, 4, xmin, xmax, x, fy, ok, niter2, absTol, relTol, maxIter2);