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

One-dimensional version of cern_mroot. More...

#include <root_cern.h>

Inheritance diagram for o2scl::root_cern< func_t >:
o2scl::root< func_t >

Public Member Functions

int get_info ()
 Get the value of INFO from the last call to solve() (default 0) More...
 
virtual const char * type ()
 Return the type, "root_cern".
 
virtual int solve (double &ux, func_t &func)
 Solve func using x as an initial guess, returning x.
 
- Public Member Functions inherited from o2scl::root< 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...
 
virtual int solve_bkt (double &x1, double x2, func_t &func)
 Solve func in region $ x_1<x<x_2 $ returning $ x_1 $ .
 
virtual int solve_de (double &x, func_t &func, func_t &df)
 Solve func using x as an initial guess using derivatives df.
 

Public Attributes

int maxf
 Maximum number of function evaluations. More...
 
double scale
 The original scale parameter from CERNLIB (default 10.0)
 
double eps
 The smallest floating point number (default $ \sim 1.49012 \times 10^{-8} $) More...
 
- Public Attributes inherited from o2scl::root< 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.
 

Protected Attributes

int info
 Internal storage for the value of info.
 

Detailed Description

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

This one-dimensional root-finding routine, based on o2scl::mroot_cern, is probably slower than the more typical 1-d routines, but also tends to converge for a larger class of functions than o2scl::root_bkt_cern, o2scl::root_brent_gsl, or o2scl::root_stef. It has been modified from o2scl::mroot_cern and slightly optimized, but has the same basic behavior.

If $ x_i $ denotes the current iteration, and $ x^{\prime}_i $ denotes the previous iteration, then the calculation is terminated if either (or both) of the following tests is successful

\[ 1:\quad \mathrm{max} | f_i(x) | \leq \mathrm{tol\_rel} \]

\[ 2:\quad \mathrm{max} |x_i-x^{\prime}_i| \leq \mathrm{tol\_abs} \times \mathrm{max} | x_i | \]

Note
This code has not been checked to ensure that it cannot fail to solve the equations without calling the error handler and returning a non-zero value. Until then, the solution may need to be checked explicitly by the caller.

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

Idea for Future:
Double-check this class to make sure it cannot fail while returning 0 for success.

Definition at line 72 of file root_cern.h.

Member Function Documentation

◆ get_info()

template<class func_t = funct11>
int o2scl::root_cern< func_t >::get_info ( )
inline

The value of info is assigned according to the following list. The values 1-8 are the standard behavior from CERNLIB. 0 - The function solve() has not been called. 1 - Test 1 was successful.
2 - Test 2 was successful.
3 - Both tests were successful.
4 - Number of iterations is greater than root_cern::maxf.
5 - Approximate (finite difference) Jacobian matrix is singular.
6 - Iterations are not making good progress.
7 - Iterations are diverging.
8 - Iterations are converging, but either root_cern::tol_abs is too small or the Jacobian is nearly singular or the variables are badly scaled.
9 - Either root::tol_rel or root::tol_abs is not greater than zero.

Definition at line 108 of file root_cern.h.

Member Data Documentation

◆ eps

template<class func_t = funct11>
double o2scl::root_cern< func_t >::eps

The original prescription from CERNLIB for eps is given below:

#if !defined(CERNLIB_DOUBLE)
PARAMETER (EPS =  0.84293 69702 17878 97282 52636 392E-07)
#endif
#if defined(CERNLIB_IBM)
PARAMETER (EPS =  0.14901 16119 38476 562D-07)
#endif
#if defined(CERNLIB_VAX)
PARAMETER (EPS =  0.37252 90298 46191 40625D-08)
#endif
#if (defined(CERNLIB_UNIX))&&(defined(CERNLIB_DOUBLE))
PARAMETER (EPS =  0.14901 16119 38476 600D-07)
#endif
Idea for Future:
This number should probably default to one of the GSL tolerances.

Definition at line 148 of file root_cern.h.

◆ maxf

template<class func_t = funct11>
int o2scl::root_cern< func_t >::maxf

If $ \mathrm{maxf}\leq 0 $, then 200 (which is the CERNLIB default) is used. The default value of maxf is zero which then implies the default from CERNLIB.

Definition at line 116 of file root_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).