gsl_mroot_hybrids Class Template Reference

#include <gsl_mroot_hybrids.h>

Inheritance diagram for gsl_mroot_hybrids:

mroot hybrids_base

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 gsl_mroot_hybrids< param_t, func_t, vec_t, alloc_vec_t, alloc_t, jfunc_t >

Multidimensional root-finding algorithm using Powell's Hybrid method (GSL).

This is a recasted version of the GSL routines which use a modified version of Powell's Hybrid method as implemented in the HYBRJ algorithm in MINPACK. Both the scaled and unscaled options are available by setting int_scaling (the scaled version is the default). If derivatives are not provided, they will be computed automatically. This class provides the GSL-like interface using allocate(), set() (or set_de() in case where derivatives are available), iterate(), and free() and higher-level interfaces, msolve() and msolve_de(), which perform the solution automatically. Some additional checking is performed in case the user calls the functions out of order (i.e. set() without allocate()).

The functions msolve() and msolve_de() use the condition $ \sum_i |f_i| < $ mroot::tolf to determine if the solver has succeeded.

The original GSL algorithm has been modified to shrink the stepsize if a proposed step causes the function to return a non-zero value. This allows the routine to automatically try to avoid regions where the function is not defined. To return to the default GSL behavior, set shrink_step to false.

Todo:
Internally, there is a little unnecessary copying back and forth of vectors

Definition at line 72 of file gsl_mroot_hybrids.h.


Public Member Functions

 gsl_mroot_hybrids ()
virtual ~gsl_mroot_hybrids ()
virtual int set_jacobian (jacobian< param_t, func_t, vec_t, omatrix_view > &j)
 Set the automatic Jacobian object.
int iterate (vec_t &ux)
 Perform an iteration.
int allocate (size_t n)
 Allocate the memory.
int free ()
 Free the allocated memory.
virtual const char * type ()
 Return the type,"gsl_mroot_hybrids".
virtual int msolve_de (size_t nn, vec_t &xx, param_t &pa, func_t &ufunc, jfunc_t &dfunc)
 Solve func with derivatives dfunc using x as an initial guess,returning x.
virtual int msolve (size_t nn, vec_t &xx, param_t &pa, func_t &ufunc)
 Solve ufunc using xx as an initial guess,returning xx.
int set (size_t nn, vec_t &ax, func_t &ufunc, param_t &pa)
 Set the function, the parameters, and the initial guess.
int set_de (size_t nn, vec_t &ax, func_t &ufunc, jfunc_t &dfunc, param_t &pa)
 Set the function, the Jacobian, the parameters, and the initial guess.

Data Fields

bool shrink_step
 If true, iterate() will shrink the step-size automatically if the function returns a non-zero value (default true).
bool int_scaling
 If true, use the internal scaling method (default true).
simple_jacobian
< param_t, func_t,
vec_t, omatrix_view,
alloc_vec_t,
alloc_t > 
def_jac
 Default automatic Jacobian object.
gsl_vector * f
 The value of the function at the present iteration.

Protected Member Functions

int solve_set (size_t nn, vec_t &xx, param_t &pa, func_t &ufunc)
 Finish the solution after set() or set_de() has been called.

Protected Attributes

jfunc_t * jac
 Pointer to the user-specified Jacobian object.
jacobian< param_t,
func_t, vec_t,
omatrix_view > * 
ajac
 Pointer to the automatic Jacobian object.
alloc_t ao
 Memory allocator for objects of type alloc_vec_t.
gsl_vector * x
 The present solution.
gsl_vector * dx
 The value of the derivative.
o2scl_hybrid_state_tstate
 The solver state.
param_t * params
 The function parameters.
size_t dim
 The number of equations and unknowns.
bool jac_given
 True if the jacobian has been given.
func_t * fnewp
 Pointer to the user-specified function.
bool set_called
 True if "set" has been called.

Data Structures

struct  o2scl_hybrid_state_t
 A structure for gsl_mroot_hybrids. More...

Member Function Documentation

int iterate ( vec_t &  ux  )  [inline]

Perform an iteration.

At the end of the iteration, the current value of the solution is stored in ux.

Definition at line 246 of file gsl_mroot_hybrids.h.

int set_de ( size_t  nn,
vec_t &  ax,
func_t &  ufunc,
jfunc_t &  dfunc,
param_t &  pa 
) [inline]

Set the function, the Jacobian, the parameters, and the initial guess.

Make sure set() uses the right Jacobian

Reset jac_given since set() will set it back to false

Definition at line 694 of file gsl_mroot_hybrids.h.


Field Documentation

bool shrink_step

If true, iterate() will shrink the step-size automatically if the function returns a non-zero value (default true).

The original GSL behavior can be obtained by setting this to false.

Definition at line 214 of file gsl_mroot_hybrids.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