cern_mroot Class Template Reference

#include <cern_mroot.h>

Inheritance diagram for cern_mroot:

mroot

Detailed Description

template<class param_t, class func_t = mm_funct<param_t>, class vec_t = ovector_view, class alloc_vec_t = ovector, class alloc_t = ovector_alloc, class jfunc_t = jac_funct<param_t,vec_t,omatrix_view>>
class cern_mroot< param_t, func_t, vec_t, alloc_vec_t, alloc_t, jfunc_t >

Multi-dimensional mroot-finding routine (CERNLIB).

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{tolf} \]

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

This routine treats the functions specified as a mm_funct object slightly differently than gsl_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.

Based on More79 and More80

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.
Idea for future:
Modify this so it handles functions which return non-zero values.

Definition at line 78 of file cern_mroot.h.


Public Member Functions

 cern_mroot ()
int get_info ()
 Get the value of INFO from the last call to msolve().
virtual const char * type ()
 Return the type, "cern_mroot".
virtual int msolve (size_t nvar, vec_t &x, 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

alloc_t ao
 Memory allocator for objects of type alloc_vec_t.
int info
 Internal storage for the value of info.
int mpt [289]
 Store the number of function evaluations.

Member Function Documentation

int get_info (  )  [inline]

Get the value of INFO from the last call to msolve().

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 or the specified number of variables is $ \leq 0$.

Definition at line 135 of file cern_mroot.h.


Field Documentation

int maxf

Maximum number of function evaluations.

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 144 of file cern_mroot.h.

double eps

The smallest floating point number (default $ \sim 1.49012 \times 10^{-8} $ ).

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 173 of file cern_mroot.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