4 #include "RConfigure.h" 48 return 5.55680381022934800;
61 int pr = std::cout.precision(16);
62 std::cout <<
"Result: " << root << std::endl;
64 std::cout.precision(pr);
65 std::cout <<
" difference: " << difference << std::endl;
77 std::cout <<
"*************************************************************\n";
80 std::cout <<
"Test for simple function f(x) = x^2 - 5 \n" << std::endl;
82 std::cout <<
"\nTest for f(x) = gamma_cdf \n" << std::endl;
83 xmin = 3.955687382047723;
84 xmax = 9.3423159494328623;
101 root = f1->
GetX(0, xmin, xmax,tol,maxiter);
104 std::cout <<
"\nTF1 Stats:" << std::endl;
112 bool ret = brf.
Solve(maxiter,tol,tol);
113 if (!ret && i == 0) std::cout <<
"Error returned from RootFinder::Solve BRENT " << std::endl;
117 std::cout <<
"Brent RootFinder Stats:" << std::endl;
120 #ifdef R__HAS_MATHMORE 126 bool ret = grf.
Solve(maxiter,tol,tol);
128 if (!ret && i == 0) std::cout <<
"Error returned from RootFinder::Solve GSL_BRENT" << std::endl;
131 std::cout <<
"GSL Brent RootFinder Stats:" << std::endl;
135 if (status) std::cout <<
"Test-case " << testcase <<
" FAILED" << std::endl;
145 if (status) std::cerr <<
"Test pol function FAILED" << std::endl;
148 if (status) std::cerr <<
"Test gamma function FAILED" << std::endl;
150 std::cerr <<
"*************************************************************\n";
151 std::cerr <<
"\nTest RootFinder :\t";
153 std::cerr <<
"OK " << std::endl;
155 std::cerr <<
"Failed !" << std::endl;
User Class to find the Root of one dimensional functions.
int printStats(TStopwatch &timer, double root)
double Root() const
Return the current and latest estimate of the Root.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
double myfunc_p(double *x, double *)
int runTest(int testcase=0)
bool SetFunction(const IGenFunction &f, double xlow, double xup)
Provide to the solver the function and the initial search interval [xlow, xup] for algorithms not usi...
double func(double *x, double *p)
virtual Double_t GetX(Double_t y, Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
Returns the X value corresponding to the function value fy for (xmin<x<xmax).
double gamma_cdf(double x, double alpha, double theta, double x0=0)
Cumulative distribution function of the gamma distribution (lower tail).
Functor1D class for one-dimensional functions.
const double ERRORLIMIT
Test of ROOT finder for various function.
bool Solve(Function &f, Derivative &d, double start, int maxIter=100, double absTol=1E-8, double relTol=1E-10)