Public Member Functions | Public Attributes | Protected Attributes | List of all members
o2scl::mroot_cern< func_t, vec_t, jfunc_t > Class Template Reference

Multi-dimensional mroot-finding routine (CERNLIB) More...

#include <mroot_cern.h>

Inheritance diagram for o2scl::mroot_cern< func_t, vec_t, jfunc_t >:
o2scl::mroot< func_t, vec_t, jfunc_t >

Public Member Functions

int get_info ()
 Get the value of INFO from the last call to msolve() More...
 
std::string get_info_string ()
 Get the a string corresponding to the integer returned by mroot_cern::get_info().
 
virtual const char * type ()
 Return the type, "mroot_cern".
 
virtual int msolve (size_t nvar, vec_t &x, func_t &func)
 Solve func using x as an initial guess, returning x.
 
- Public Member Functions inherited from o2scl::mroot< func_t, vec_t, jfunc_t >
virtual int msolve_de (size_t n, vec_t &x, func_t &func, jfunc_t &dfunc)
 Solve func with derivatives dfunc using x as an initial guess, returning x. More...
 
template<class vec2_t , class vec3_t >
int print_iter (size_t n, const vec2_t &x, const vec3_t &y, int iter, double value=0.0, double limit=0.0, std::string comment="")
 Print out iteration information. More...
 

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::mroot< func_t, vec_t, jfunc_t >
double tol_rel
 The maximum value of the functions for success (default 1.0e-8)
 
double tol_abs
 The minimum allowable stepsize (default 1.0e-12)
 
int verbose
 Output control (default 0)
 
int ntrial
 Maximum number of iterations (default 100)
 
int last_ntrial
 The number of iterations for in the most recent minimization.
 
bool err_nonconv
 If true, call the error handler if msolve() or msolve_de() does not converge (default true)
 

Protected Attributes

boost::numeric::ublas::matrix< double > w
 Desc.
 
int info
 Internal storage for the value of info.
 
int mpt [289]
 Store the number of function evaluations.
 

Detailed Description

template<class func_t = mm_funct11, class vec_t = boost::numeric::ublas::vector<double>, class jfunc_t = jac_funct11>
class o2scl::mroot_cern< func_t, vec_t, jfunc_t >

If $ x_i $ denotes the current iteration, and $ x^{\prime}_i $ denotes the previous iteration, then the calculation is terminated if either 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 | \]

This routine treats the functions specified as a mm_funct11 object slightly differently than o2scl::mroot_hybrids. First the equations should be numbered (as much as is possible) in order of increasing nonlinearity. Also, instead of calculating all of the equations on each function call, only the equation specified by the size_t parameter needs to be calculated. If the equations are specified as

\begin{eqnarray*} &0=f_0(x_0,x_1,...,x_{n-1})& \\ &0=f_1(x_0,x_1,...,x_{n-1})& \\ &...& \\ &0=f_{n-1}(x_0,x_1,...,x_{n-1})& \\ \end{eqnarray*}

then when the size_t argument is given as i, then only the function $ f_i $ needs to be calculated.

Warning
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 Multi-dimensional solvers section of the User's guide for general information about O2scl solvers. There is an example for the usage of the multidimensional solver classes given in examples/ex_mroot.cpp, see Multi-dimensional solver example .

Idea for Future:

Modify this so it handles functions which return non-zero values.

Move some of the memory allocation out of msolve()

Give the user access to the number of function calls

Rename nier6, nier7, and nier8 to something sensible.

It may be that the O2scl native Householder transformations should be used here instead of the inline version given here.

Based on the CERNLIB routines RSNLEQ and DSNLEQ, which was based on More79 and More80 and is documented at http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/c201/top.html

Definition at line 95 of file mroot_cern.h.

Member Function Documentation

◆ get_info()

template<class func_t = mm_funct11, class vec_t = boost::numeric::ublas::vector<double>, class jfunc_t = jac_funct11>
int o2scl::mroot_cern< func_t, vec_t, jfunc_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 mroot_cern_root::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 mroot_cern_root::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 or the specified number of variables is $ \leq 0$.

The return values returned by msolve() corresponding to the values of INFO above are 1 - success 2 - success 3 - success 4 - exc_emaxiter 5 - exc_esing 6 - exc_enoprog 7 - exc_erunaway 8 - exc_efailed 9 - exc_einval

Definition at line 166 of file mroot_cern.h.

Member Data Documentation

◆ eps

template<class func_t = mm_funct11, class vec_t = boost::numeric::ublas::vector<double>, class jfunc_t = jac_funct11>
double o2scl::mroot_cern< func_t, vec_t, jfunc_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

Definition at line 230 of file mroot_cern.h.

◆ maxf

template<class func_t = mm_funct11, class vec_t = boost::numeric::ublas::vector<double>, class jfunc_t = jac_funct11>
int o2scl::mroot_cern< func_t, vec_t, jfunc_t >::maxf

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

Definition at line 201 of file mroot_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).