42 _tol(2.2204460492503131e-16)
45 oocoutE(nullptr,Eval) <<
"RooBrentRootFinder:: cannot find roots for function of dimension "
46 << _function->getDimension() << std::endl;
65 double fa= (*_function)(&
a) - value;
66 double fb= (*_function)(&
b) - value;
68 oocxcoutD((
TObject*)
nullptr,Eval) <<
"RooBrentRootFinder::findRoot(" <<
_function->getName() <<
"): initial interval does not bracket a root: ("
69 <<
a <<
"," <<
b <<
"), value = " << value <<
" f[xlo] = " << fa <<
" f[xhi] = " << fb << std::endl;
80 if ((fb < 0 && fc < 0) || (fb > 0 && fc > 0)) {
89 if (std::abs(fc) < std::abs(fb)) {
99 double tol = 0.5 *
_tol * std::abs(
b);
100 double m = 0.5 * (
c -
b);
103 if (fb == 0 || std::abs(
m) <= tol) {
110 if (std::abs(
e) < tol || std::abs(fa) <= std::abs(fb)) {
129 p = s * (2 *
m *
q * (
q -
r) - (
b -
a) * (
r - 1));
130 q = (
q - 1) * (
r - 1) * (s - 1);
140 double min1= 3 *
m *
q - std::abs(tol *
q);
141 double min2= std::abs(
e *
q);
142 if (2 * p < (min1 < min2 ? min1 : min2)) {
157 if (std::abs(
d) > tol) {
161 b += (
m > 0 ? +tol : -tol);
163 fb= (*_function)(&
b) - value;
167 oocoutE(
nullptr,Eval) <<
"RooBrentRootFinder::findRoot(" <<
_function->getName() <<
"): maximum iterations exceeded." << std::endl;
int Int_t
Signed integer 4 bytes (int).
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
const RooAbsFunc * _function
Pointer to input function.
bool findRoot(double &result, double xlo, double xhi, double value=0) const
Do the root finding using the Brent-Decker method.
static constexpr int MaxIterations
RooBrentRootFinder(const RooAbsFunc &function)
Constructor taking function binding as input.
bool _valid
True if current state is valid.
Mother of all ROOT objects.