Object-oriented Scientific Computing Library: Version 0.910
Public Member Functions | Data Fields
mroot< func_t, vec_t, jfunc_t > Class Template Reference

Multidimensional root-finding [abstract base]. More...

#include <mroot.h>

Inheritance diagram for mroot< func_t, vec_t, jfunc_t >:
cern_mroot< func_t, vec_t, alloc_vec_t, alloc_t, jfunc_t > gsl_mroot_broyden< func_t, vec_t, alloc_vec_t, alloc_t, mat_t, alloc_mat_t, mat_alloc_t, jfunc_t > gsl_mroot_hybrids< func_t, vec_t, alloc_vec_t, alloc_t, mat_t, alloc_mat_t, mat_alloc_t, jfunc_t >

Detailed Description

template<class func_t, class vec_t = ovector_base, class jfunc_t = jac_funct<vec_t,omatrix_base>>
class mroot< func_t, vec_t, jfunc_t >

The template parameters: The template parameter func_t specifies the functions to solve and should be a class containing a definition

      func_t::operator()(size_t nv, const vec_t &x, vec_t &y);

where y is the value of the functions at x with parameter pa and x and y are a array-like classes defining operator[] of size nv. If the Jacobian matrix is to be specified by the user, then the parameter jfunc_t specifies the jacobian and should contain the definition

      jfunc_t::operator(size_t nv, vec_t &x, vec_t &y, mat_t &j);

where x is the independent variables, y is the array of function values, and j is the Jacobian matrix. This template parameter can be ignored if only the function msolve() will be used.

Warning:
Many of the routines assume that the scale of the functions and their variables is of order unity. The solution routines may lose precision if this is not the case.

There is an example for the usage of the multidimensional solver classes given in examples/ex_mroot.cpp, see Multi-dimensional solver .

Idea for Future:
Change ntrial to size_t?

Definition at line 65 of file mroot.h.

Public Member Functions

virtual const char * type ()
 Return the type, "mroot".
virtual int msolve (size_t n, vec_t &x, func_t &func)=0
 Solve func using x as an initial guess, returning x.
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.
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.

Data Fields

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)
int last_conv
 Zero if last call to msolve() or msolve_de() converged.

Member Function Documentation

template<class func_t, class vec_t = ovector_base, class jfunc_t = jac_funct<vec_t,omatrix_base>>
virtual int mroot< func_t, vec_t, jfunc_t >::msolve_de ( size_t  n,
vec_t &  x,
func_t &  func,
jfunc_t &  dfunc 
) [inline, virtual]

By default, this function just calls msolve() and ignores the last argument.

Reimplemented in gsl_mroot_hybrids< func_t, vec_t, alloc_vec_t, alloc_t, mat_t, alloc_mat_t, mat_alloc_t, jfunc_t >.

Definition at line 119 of file mroot.h.

template<class func_t, class vec_t = ovector_base, class jfunc_t = jac_funct<vec_t,omatrix_base>>
template<class vec2_t , class vec3_t >
int mroot< func_t, vec_t, jfunc_t >::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 = "" 
) [inline]

Depending on the value of the variable verbose, this prints out the iteration information. If verbose=0, then no information is printed, while if verbose>1, then after each iteration, the present values of x and y are output to std::cout along with the iteration number. If verbose>=2 then each iteration waits for a character.

This is implemented as a template class using a new vector type because sometimes the internal vector class is distinct from the user-specified vector class (e.g. in gsl_mroot_hybrids).

Definition at line 138 of file mroot.h.


Field Documentation

template<class func_t, class vec_t = ovector_base, class jfunc_t = jac_funct<vec_t,omatrix_base>>
int mroot< func_t, vec_t, jfunc_t >::last_conv

This is particularly useful if err_nonconv is false to test if the last call to msolve() or msolve_de() converged.

Definition at line 105 of file mroot.h.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.