26 #ifndef O2SCL_ROOT_BKT_CERN_H 27 #define O2SCL_ROOT_BKT_CERN_H 29 #include <o2scl/root.h> 31 #ifndef DOXYGEN_NO_O2NS 76 #ifndef DOXYGEN_INTERNAL 90 inline double sign(
double a,
double b) {
91 if (b>=0.0)
return fabs(a);
118 O2SCL_ERR(
"Invalid mode in root_bkt_cern::set_mode().",
126 virtual const char *
type() {
return "root_bkt_cern"; }
133 double im1[2]={2.0,3.0}, im2[2]={-1.0,3.0}, c=0.0, fa, fb;
134 double atl, a, b, mft;
135 double fc=0.0, d=0.0, fd=0.0, tol, h, hb, w, p, q, fdb, fda, f=0.0;
144 O2SCL_ERR2(
"Endpoints don't bracket function in ",
159 }
else if (loop==2) {
162 if (fabs(fc)<fabs(fb)) {
174 tol=atl*(1.0+fabs(c));
179 this->
print_iter(c,fc,mf-2,fabs(hb),tol,
"root_bkt_cern");
202 if (ie==im2[mode]) p+=p;
203 if (p==0.0 || p<=q*tol) {
226 if (fb==0.0 ||
sign(1.0,fc)==
sign(1.0,fb)) {
245 #ifndef DOXYGEN_NO_O2NS One-dimensional root-finding routine (CERNLIB)
int ntrial
Maximum number of iterations (default 100)
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
int mode
Internal storage for the mode.
double tol_abs
The minimum allowable stepsize (default )
invalid argument supplied by user
exceeded max number of iterations
#define O2SCL_CONV2_RET(d, d2, n, b)
Set an error and return the error value, two-string version.
One-dimensional bracketing solver [abstract base].
bool err_nonconv
If true, call the error handler if the solver does not converge (default true)
virtual int solve_bkt(double &x1, double x2, func_t &func)
Solve func in region returning .
virtual int print_iter(double x, double y, int iter, double value=0.0, double limit=0.0, std::string comment="")
Print out iteration information.
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
int set_mode(int m)
Set mode of solution (1 or 2)
double sign(double a, double b)
FORTRAN-like function for sign.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
int last_ntrial
The number of iterations used in the most recent solve.
static const double x2[5]
virtual const char * type()
Return the type, "root_bkt_cern".
static const double x1[5]
int verbose
Output control (default 0)