26namespace BrentMethods {
50 bool foundInterval = (
type != 4);
52 yymin = (*function)(xxmin);
54 yymin = -(*function)(xxmin);
56 yymin = (*function)(xxmin)-fy;
65 for (
int i=1; i<=npx-1; i++) {
66 double x =
xmin + i*dx;
74 y = (*function)(
x)-fy;
76 if (
type < 4 &&
y < yymin) {
91 if (std::copysign(1.,
y)*std::copysign(1.,yymin) < 0 ) {
111 xmiddle = std::min(xxmin,
xmax);
115 if (!foundInterval) {
116 MATH_INFO_MSG(
"BrentMethods::MinimStep",
"Grid search failed to find a root in the interval ");
117 std::string msg =
"xmin = ";
119 msg += std::string(
" xmax = ");
121 msg += std::string(
" npts = ");
130 double MinimBrent(
const IGenFunction*
function,
int type,
double &
xmin,
double &
xmax,
double xmiddle,
double fy,
bool &ok,
int &niter,
double epsabs,
double epsrel,
int itermax)
146 const double c = 3.81966011250105097e-01;
147 double u,
v, w,
x, fv, fu, fw, fx,
e, p,
q,
r, t2,
d=0,
m, tol;
154 fv = fw = fx = (*function)(
x);
156 fv = fw = fx = -(*function)(
x);
160 for (
int i=0; i<itermax; i++){
181 p = (
x-
v)*
q - (
x-w)*
r;
199 if (u-
a < t2 ||
b-u < t2)
211 fu = -(*function)(u);
218 v=w; fv=fw; w=
x; fw=fx;
x=u; fx=fu;
223 v=w; fv=fw; w=u; fw=fu;
225 else if (fu<=fv ||
v==
x ||
v==w){
#define MATH_INFO_MSG(loc, str)
Pre-processor macro to report messages which can be configured to use ROOT error or simply an std::io...
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Namespace for new Math classes and functions.
double MinimStep(const IGenFunction *f, int type, double &xmin, double &xmax, double fy, int npx=100, bool useLog=false)
Grid search implementation, used to bracket the minimum and later use Brent's method with the bracket...
double MinimBrent(const IGenFunction *f, int type, double &xmin, double &xmax, double xmiddle, double fy, bool &ok, int &niter, double epsabs=1.E-8, double epsrel=1.E-10, int maxiter=100)
Finds a minimum of a function, if the function is unimodal between xmin and xmax This method uses a c...
std::string ToString(const T &val)
Utility function for conversion to strings.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...