Public Member Functions | Protected Attributes | List of all members
o2scl::jacobian_gsl< func_t, vec_t, mat_t > Class Template Reference

Simple automatic Jacobian. More...

#include <jacobian.h>

Inheritance diagram for o2scl::jacobian_gsl< func_t, vec_t, mat_t >:
o2scl::jacobian< func_t, vec_t, mat_t >

Public Member Functions

double get_epsrel ()
 Get the relative stepsize (default $ 10^{-4} $ )
 
double get_epsmin ()
 Get the minimum stepsize (default $ 10^{-15} $)
 
void set_epsrel (double l_epsrel)
 Set the relative stepsize (must be $ > 0 $)
 
void set_epsmin (double l_epsmin)
 Set the minimum stepsize (must be $ \geq 0 $)
 
void set_shrink_fact (double l_shrink_fact)
 Set shrink factor for decreasing step size.
 
void set_max_shrink_iters (size_t it)
 Set number of times to decrease step size.
 
virtual int operator() (size_t nx, vec_t &x, size_t ny, vec_t &y, mat_t &jac)
 The operator()
 
- Public Member Functions inherited from o2scl::jacobian< func_t, vec_t, mat_t >
virtual int set_function (func_t &f)
 Set the function to compute the Jacobian of.
 

Protected Attributes

vec_t f
 Function values.
 
vec_t xx
 Function arguments.
 
size_t mem_size_x
 Size of allocated memory in x.
 
size_t mem_size_y
 Size of allocated memory in y.
 
double epsrel
 The relative stepsize for finite-differencing.
 
double epsmin
 The minimum stepsize.
 
size_t max_shrink_iters
 Maximum number of times to shrink the step size.
 
double shrink_fact
 Factor to shrink stepsize by.
 
- Protected Attributes inherited from o2scl::jacobian< func_t, vec_t, mat_t >
func_t func
 A pointer to the user-specified function.
 

Additional Inherited Members

- Public Attributes inherited from o2scl::jacobian< func_t, vec_t, mat_t >
bool err_nonconv
 If true, call the error handler if the routine does not converge.
 

Detailed Description

template<class func_t = mm_funct11, class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>>
class o2scl::jacobian_gsl< func_t, vec_t, mat_t >

This class computes a numerical Jacobian by finite differencing. The stepsize is initially chosen to be $ h_j = \mathrm{max}(\mathrm{epsrel}~|x_j|,\mathrm{epsmin}) $. Then if $ h_j = 0 $, the value of $ h_j $ is set to $ \mathrm{epsrel}) $ .

Values of epsmin which are non-zero are useful, for example, in mroot_hybrids when one of the variables is either very small or zero, so that the step size doesn't become too small.

If the function evaluation leads to a non-zero return value, then the step size is alternately flipped in sign or decreased by a fixed factor (default $ 10^2 $, set in set_shrink_fact() ) in order to obtain a valid result. This process is repeated a fixed number of times (default 10, set in set_max_shrink_iters() ).

This is equivalent to the GSL method for computing Jacobians as in multiroots/fdjac.c if one calls set_max_shrink_iters() with a parameter value of zero.

If one row of the Jacobian is all zero, or if there was no step-size found which would give a zero return value from the user-specified function, then the error handler is called depending on the value of err_nonconv.

This class does not separately check the vector and matrix sizes to ensure they are commensurate.

Default template arguments

Definition at line 144 of file jacobian.h.


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

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