Class jacobian_gsl (o2scl)¶
-
template<class func_t = mm_funct, class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>>
class jacobian_gsl : public o2scl::jacobian<mm_funct, boost::numeric::ublas::vector<double>, boost::numeric::ublas::matrix<double>>¶ Simple automatic Jacobian.
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
func_t
- mm_functvec_t
- boost::numeric::ublas::vector<double>mat_t
- boost::numeric::ublas::matrix<double>
Public Functions
-
inline jacobian_gsl()¶
-
inline virtual ~jacobian_gsl()¶
-
inline double get_epsrel()¶
Get the relative stepsize (default \( 10^{-4} \) )
-
inline double get_epsmin()¶
Get the minimum stepsize (default \( 10^{-15} \))
-
inline void set_epsrel(double l_epsrel)¶
Set the relative stepsize (must be \( > 0 \))
-
inline void set_epsmin(double l_epsmin)¶
Set the minimum stepsize (must be \( \geq 0 \))
-
inline void set_shrink_fact(double l_shrink_fact)¶
Set shrink factor for decreasing step size.
-
inline void set_max_shrink_iters(size_t it)¶
Set number of times to decrease step size.
Protected Attributes
-
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.