Class mroot (o2scl)¶
-
template<class func_t = mm_funct, class vec_t = boost::numeric::ublas::vector<double>, class jfunc_t = jac_funct, class fp_t = double>
class mroot¶ Multidimensional root-finding [abstract base].
The template parameters: The template parameter
func_t
specifies the functions to solve and should be a class containing a definitionwherefunc_t::operator()(size_t nv, const vec_t &x, vec_t &y);
y
is the value of the functions atx
with parameterpa
andx
andy
are a array-like classes definingoperator
[] of sizenv
. If the Jacobian matrix is to be specified by the user, then the parameterjfunc_t
specifies the jacobian and should contain the definitionwherejfunc_t::operator(size_t nv, vec_t &x, vec_t &y, mat_t &j);
x
is the independent variables,y
is the array of function values, andj
is the Jacobian matrix. This template parameter can be ignored if only the function msolve() will be used.There is an example for the usage of the multidimensional solver classes given in
examples/ex_mroot.cpp
, see the Multi-dimensional solver example.Todo
Class mroot:
Future: Change ntrial to size_t?
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.
Subclassed by o2scl::mroot_hybrids< mm_funct >, o2scl::mroot_hybrids< mm_funct, boost::numeric::ublas::vector< double >, boost::numeric::ublas::matrix< double >, jac_funct >, o2scl::mroot_hybrids< mm_funct, vector< double >, matrix< double >, jac_funct >, o2scl::mroot_broyden< func_t, vec_t, mat_t, jfunc_t >, o2scl::mroot_cern< func_t, vec_t, jfunc_t, fp_t >, o2scl::mroot_hybrids< func_t, vec_t, mat_t, jfunc_t >
Public Functions
-
inline mroot()¶
-
inline virtual ~mroot()¶
-
inline virtual const char *type()¶
Return the type,
"mroot"
.
-
virtual int msolve(size_t n, vec_t &x, func_t &func) = 0¶
Solve
func
usingx
as an initial guess, returningx
.
-
inline virtual int msolve_de(size_t n, vec_t &x, func_t &func, jfunc_t &dfunc)¶
Solve
func
with derivativesdfunc
usingx
as an initial guess, returningx
.By default, this function just calls msolve() and ignores the last argument.
-
template<class vec2_t, class vec3_t>
inline int print_iter(size_t n, const vec2_t &x, const vec3_t &y, int iter, fp_t value = 0, fp_t limit = 0, std::string comment = "")¶ Print out iteration information.
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 o2scl::mroot_hybrids).
-
inline mroot()¶