Simple automatic Jacobian. More...
#include <jacobian.h>
This class computes a numerical Jacobian by finite differencing. The stepsize is initially chosen to be
. Then if
, the value of
is set to
.
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
, 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
func_t - mm_functvec_t - boost::numeric::ublas::vector<double>mat_t - boost::numeric::ublas::matrix<double> Definition at line 144 of file jacobian.h.
Public Member Functions | |
| double | get_epsrel () |
Get the relative stepsize (default ) | |
| double | get_epsmin () |
Get the minimum stepsize (default ) | |
| void | set_epsrel (double l_epsrel) |
Set the relative stepsize (must be ) | |
| void | set_epsmin (double l_epsmin) |
Set the minimum stepsize (must be ) | |
| 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< mm_funct, boost::numeric::ublas::vector< double >, boost::numeric::ublas::matrix< double > > | |
| virtual int | set_function (mm_funct &f) |
| Set the function to compute the Jacobian of. | |
| virtual int | operator() (size_t nx, boost::numeric::ublas::vector< double > &x, size_t ny, boost::numeric::ublas::vector< double > &y, boost::numeric::ublas::matrix< double > &j)=0 |
Evaluate the Jacobian j at point y(x) | |
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< mm_funct, boost::numeric::ublas::vector< double >, boost::numeric::ublas::matrix< double > > | |
| mm_funct | func |
| A pointer to the user-specified function. | |
Additional Inherited Members | |
Public Attributes inherited from o2scl::jacobian< mm_funct, boost::numeric::ublas::vector< double >, boost::numeric::ublas::matrix< double > > | |
| bool | err_nonconv |
| If true, call the error handler if the routine does not converge. | |
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).