Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
o2scl::root_bkt_cern< func_t > Class Template Reference

One-dimensional root-finding routine (CERNLIB) More...

#include <root_bkt_cern.h>

Inheritance diagram for o2scl::root_bkt_cern< func_t >:
o2scl::root_bkt< func_t > o2scl::root< func_t, func_t >

Public Member Functions

int set_mode (int m)
 Set mode of solution (1 or 2) More...
virtual const char * type ()
 Return the type, "root_bkt_cern".
virtual int solve_bkt (double &x1, double x2, func_t &func)
 Solve func in region $ x_1<x<x_2 $ returning $ x_1 $.
- Public Member Functions inherited from o2scl::root_bkt< func_t >
virtual int solve (double &x, func_t &func)
 Solve func using x as an initial guess. More...
virtual int solve_de (double &x, func_t &func, func_t &df)
 Solve func using x as an initial guess using derivatives df.
- Public Member Functions inherited from o2scl::root< func_t, func_t >
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. More...

Protected Member Functions

double sign (double a, double b)
 FORTRAN-like function for sign.

Protected Attributes

int mode
 Internal storage for the mode. More...

Additional Inherited Members

- Public Attributes inherited from o2scl::root_bkt< func_t >
double bracket_step
 The relative stepsize for automatic bracketing (default value is zero) More...
double bracket_min
 The minimum stepsize for automatic bracketing (default zero)
size_t bracket_iters
 The number of iterations in attempt to bracket root (default 10)
- Public Attributes inherited from o2scl::root< func_t, func_t >
double tol_rel
 The maximum value of the functions for success (default $ 10^{-8} $ )
double tol_abs
 The minimum allowable stepsize (default $ 10^{-12} $ )
int verbose
 Output control (default 0)
int ntrial
 Maximum number of iterations (default 100)
bool err_nonconv
 If true, call the error handler if the solver does not converge (default true)
int last_ntrial
 The number of iterations used in the most recent solve.

Detailed Description

template<class func_t = funct11>
class o2scl::root_bkt_cern< func_t >

This class attempts to find $ x_1 $ and $ x_2 $ in $ [a,b] $ such that:

The function solve_bkt() requires inputs x1 and x2 such that the first condition, $ f(x_1) f(x_2) \leq 0 $, already holds.

The variable root::tol_abs defaults to $ 10^{-8} $ and root::ntrial defaults to 200.

The function solve_bkt() will call the error handler if the root is not initially bracketed. If root::err_nonconv is true (as it is by default), then the error handler will also be called if the number function evaluations is greater than root::ntrial.

After a call to solve_bkt(), root::last_ntrial contains the total number of iterations which were used

See the One-dimensional solvers section of the User's guide for general information about O2scl solvers.

Based on the CERNLIB routines RZEROX and DZEROX, which was based on Bus75 and is documented at

Definition at line 73 of file root_bkt_cern.h.

Member Function Documentation

◆ set_mode()

template<class func_t = funct11>
int o2scl::root_bkt_cern< func_t >::set_mode ( int  m)
  • 1 should be used for simple functions where the cost is inexpensive in comparison to one iteration of solve_bkt(), or functions which have a pole near the root (this is the default).
  • 2 should be used for more time-consuming functions.

If an integer other than 1 or 2 is specified, the error handler is called.

Definition at line 116 of file root_bkt_cern.h.

Member Data Documentation

◆ mode

template<class func_t = funct11>
int o2scl::root_bkt_cern< func_t >::mode

This internal variable is actually defined to be smaller by 1 than the "mode" as it is defined in the CERNLIB documentation in order to avoid needless subtraction in solve_bkt().

Definition at line 87 of file root_bkt_cern.h.

The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).