26namespace BrentMethods {
 
   45   double xxmin = (logStep) ? std::exp(
xmin) : 
xmin;
 
   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;
 
   67      if (logStep) 
x = std::exp(
x);
 
   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);
 
  158      fv = fw = fx = std::fabs((*function)(
x)-fy);
 
  160   for (
int i=0; i<itermax; i++){
 
  162      tol = epsrel*(std::fabs(
x))+epsabs;
 
  165      if (std::fabs(
x-
m) <= (t2-0.5*(
b-
a))) {
 
  177      if (std::fabs(
e)>tol){
 
  191         if (std::fabs(
p) >= std::fabs(0.5*
q*
r) || 
p <= 
q*(
a-
x) || 
p >= 
q*(
b-
x)) {
 
  199            if (u-
a < t2 || 
b-u < t2)
 
  201               d=(
m-
x >= 0) ? std::fabs(tol) : -std::fabs(tol);
 
  207      u = (std::fabs(
d)>=tol ? 
x+
d : 
x+ ((
d >= 0) ? std::fabs(tol) : -std::fabs(tol)) );
 
  211         fu = -(*function)(u);
 
  213         fu = std::fabs((*function)(u)-fy);
 
  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...
 
winID h TVirtualViewer3D TVirtualGLPainter p
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
 
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.
 
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.