cern_mroot_root Class Template Reference

One-dimensional version of cern_mroot. More...

#include <cern_mroot_root.h>

Inheritance diagram for cern_mroot_root:

root

Detailed Description

template<class param_t = int, class func_t = funct<param_t>>
class cern_mroot_root< param_t, func_t >

This one-dimensional root-finding routine, based on cern_mroot, is probably slower than the more typical 1-d routines, but also tends to converge for a larger class of functions than cern_root, gsl_root_brent, or gsl_root_stef. It has been modified from cern_mroot 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{tolf} \]

\[ 2:\quad \mathrm{max} |x_i-x^{\prime}_i| \leq \mathrm{tolx} \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.
Idea for future:
Double-check this class to make sure it cannot fail while returning 0 for success.

Definition at line 64 of file cern_mroot_root.h.


Public Member Functions

int get_info ()
 Get the value of INFO from the last call to solve() (default 0).
virtual const char * type ()
 Return the type, "cern_mroot_root".
virtual int solve (double &ux, param_t &pa, func_t &func)
 Solve func using x as an initial guess, returning x.

Data Fields

int maxf
 Maximum number of function evaluations.
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} $).

Protected Attributes

int info
 Internal storage for the value of info.

Member Function Documentation

int 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 cern_mroot_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 cern_mroot_root::tolx is too small or the Jacobian is nearly singular or the variables are badly scaled.
9 - Either root::tolf or root::tolx is not greater than zero.

Definition at line 102 of file cern_mroot_root.h.


Field Documentation

double 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 143 of file cern_mroot_root.h.

int 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 111 of file cern_mroot_root.h.


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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page