18 #ifndef ROOT_Math_Error 27 namespace BrentMethods {
46 if (npx < 2)
return 0.5*(xmax-
xmin);
47 double dx = (xmax-
xmin)/(npx-1);
51 yymin = (*function)(xxmin);
53 yymin = -(*function)(xxmin);
57 for (
int i=1; i<=npx-1; i++) {
58 double x = xmin + i*dx;
79 xmin = std::max(xmin,xxmin-dx);
80 xmax = std::min(xmax,xxmin+dx);
82 return std::min(xxmin, xmax);
85 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)
101 const double c = 3.81966011250105097e-01;
102 double u,
v, w,
x, fv, fu, fw, fx,
e, p,
q,
r, t2, d=0,
m,
tol;
109 fv = fw = fx = (*function)(
x);
111 fv = fw = fx = -(*function)(
x);
113 fv = fw = fx =
std::fabs((*
function)(x)-fy);
115 for (
int i=0; i<itermax; i++){
136 p = (x-
v)*q - (x-w)*
r;
148 e=(x>=
m ? a-
x : b-
x);
154 if (u-a < t2 || b-u < t2)
159 e=(x>=
m ? a-
x : b-
x);
166 fu = -(*function)(u);
173 v=w; fv=fw; w=
x; fw=fx; x=u; fx=fu;
178 v=w; fv=fw; w=u; fw=fu;
180 else if (fu<=fv || v==x || v==w){
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
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...
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Namespace for new Math classes and functions.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b