17 #ifndef ROOT_Math_Error
26 namespace BrentMethods {
45 if (npx < 2)
return 0.5*(xmax-
xmin);
46 double dx = (xmax-
xmin)/(npx-1);
50 yymin = (*function)(xxmin);
52 yymin = -(*function)(xxmin);
56 for (
int i=1; i<=npx-1; i++) {
57 double x = xmin + i*dx;
84 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)
100 const double c = 3.81966011250105097e-01;
101 double u,
v, w,
x, fv,
fu, fw, fx, e, p,
q,
r, t2, d=0,
m,
tol;
108 fv = fw = fx = (*function)(
x);
110 fv = fw = fx = -(*function)(
x);
112 fv = fw = fx =
std::fabs((*
function)(x)-fy);
114 for (
int i=0; i<itermax; i++){
135 p = (x-
v)*q - (x-w)*
r;
147 e=(x>=
m ? a-x : b-
x);
153 if (u-a < t2 || b-u < t2)
158 e=(x>=
m ? a-x : b-
x);
165 fu = -(*function)(u);
172 v=w; fv=fw; w=
x; fw=fx; x=u; fx=
fu;
177 v=w; fv=fw; w=u; fw=
fu;
179 else if (fu<=fv || v==x || v==w){
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Namespace for new ROOT 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...
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Namespace for new Math classes and functions.