Go to the documentation of this file.
23 #ifndef O2SCL_JACOBIAN_H
24 #define O2SCL_JACOBIAN_H
31 #include <o2scl/mm_funct.h>
32 #include <o2scl/deriv_gsl.h>
33 #include <o2scl/columnify.h>
34 #include <o2scl/vector.h>
36 #ifndef DOXYGEN_NO_O2NS
41 typedef std::function<
85 virtual int operator()(
size_t nx, vec_t &x,
size_t ny, vec_t &y,
88 #ifndef DOXYGEN_INTERNAL
146 #ifndef DOXYGEN_INTERNAL
180 epsrel=sqrt(std::numeric_limits<double>::epsilon());
203 O2SCL_ERR2(
"Negative or zero value specified in ",
214 O2SCL_ERR(
"Negative value specified in jacobian_gsl::set_epsmin().",
224 if (l_shrink_fact<0.0) {
225 O2SCL_ERR(
"Negative value specified in jacobian_gsl::set_shrink_fact().",
241 virtual int operator()(
size_t nx, vec_t &x,
size_t ny, vec_t &y,
305 if (temp!=0.0) nonzero=
true;
308 if (nonzero==
false) {
310 " of the Jacobian is zero "+
311 "in jacobian_gsl::operator().").c_str(),
exc_esing,
340 public jacobian<func_t,vec_t,mat_t> {
386 virtual int operator()(
size_t nx, vec_t &x,
size_t ny, vec_t &y,
403 this,std::placeholders::_1,std::ref(ejp));
405 for (
size_t j=0;j<nx;j++) {
407 for (
size_t i=0;i<ny;i++) {
409 double tmp=(*ejp.
x)[j];
413 O2SCL_ERR2(
"Derivative object tailed in jacobian_exact::",
428 virtual int jac_err(
size_t nx, vec_t &x,
size_t ny, vec_t &y,
429 mat_t &jac, mat_t &err) {
442 this,std::placeholders::_1,std::ref(ejp));
444 for (
size_t j=0;j<nx;j++) {
446 for (
size_t i=0;i<ny;i++) {
448 double tmp=(*ejp.
x)[j];
452 O2SCL_ERR2(
"Derivative object tailed in jacobian_exact::",
464 #ifndef DOXYGEN_INTERNAL
474 (this->func)(ejp.
nx,*ejp.
x,*ejp.
y);
475 return (*ejp.
y)[ejp.
yi];
482 #ifndef DOXYGEN_NO_O2NS
@ exc_esing
apparent singularity detected
size_t mem_size_x
Size of allocated memory in x.
A direct calculation of the jacobian using a deriv_base object.
#define O2SCL_CONV2_RET(d, d2, n, b)
Set an error and return the error value, two-string version.
size_t nx
The number of variables.
func_t func
A pointer to the user-specified function.
@ exc_efailed
generic failure
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
size_t yi
The current y value.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
Numerical differentiation base [abstract base].
deriv_base * dptr
Pointer to the derivative object.
vec_t xx
Function arguments.
size_t xj
The current x value.
void vector_copy(const vec_t &src, vec2_t &dest)
Simple vector copy.
void set_max_shrink_iters(size_t it)
Set number of times to decrease step size.
virtual int deriv_err(fp_t x, func_t &func, fp_t &dfdx, fp_t &err)=0
Calculate the first derivative of func w.r.t. x and the uncertainty.
size_t max_shrink_iters
Maximum number of times to shrink the step size.
void set_epsrel(double l_epsrel)
Set the relative stepsize (must be )
int set_deriv(deriv_base<> &de)
Set the derivative object.
@ exc_einval
invalid argument supplied by user
double shrink_fact
Factor to shrink stepsize by.
double get_epsmin()
Get the minimum stepsize (default )
virtual int set_function(func_t &f)
Set the function to compute the Jacobian of.
#define O2SCL_CONV_RET(d, n, b)
Set a "convergence" error and return the error value.
size_t ny
The number of variables.
Base for providing a numerical jacobian [abstract base].
Simple automatic Jacobian.
virtual int operator()(size_t nx, vec_t &x, size_t ny, vec_t &y, mat_t &jac)
The operator()
double epsrel
The relative stepsize for finite-differencing.
std::function< int(size_t, const boost::numeric::ublas::vector< double > &, boost::numeric::ublas::vector< double > &) > mm_funct
Array of multi-dimensional functions typedef in src/base/mm_funct.h.
Numerical differentiation (GSL)
double dfn(double x, ej_parms &ejp)
Function for the derivative object.
std::function< int(size_t, boost::numeric::ublas::vector< double > &, size_t, boost::numeric::ublas::vector< double > &, boost::numeric::ublas::matrix< double > &) > jac_funct
Jacobian function (not necessarily square) in src/root/jacobian.h.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
std::function< double(double)> funct
One-dimensional function typedef in src/base/funct.h.
bool err_nonconv
If true, call the error handler if the routine does not converge.
deriv_gsl def_deriv
The default derivative object.
virtual int operator()(size_t nx, vec_t &x, size_t ny, vec_t &y, mat_t &jac)
The operator()
double get_epsrel()
Get the relative stepsize (default )
virtual int operator()(size_t nx, vec_t &x, size_t ny, vec_t &y, mat_t &j)=0
Evaluate the Jacobian j at point y(x)
void set_epsmin(double l_epsmin)
Set the minimum stepsize (must be )
std::string szttos(size_t x)
Convert a size_t to a string.
double epsmin
The minimum stepsize.
Parameter structure for passing information.
size_t mem_size_y
Size of allocated memory in y.
virtual int jac_err(size_t nx, vec_t &x, size_t ny, vec_t &y, mat_t &jac, mat_t &err)
Compute the Jacobian and its uncertainty from the numerical differentiation.
void set_shrink_fact(double l_shrink_fact)
Set shrink factor for decreasing step size.
@ exc_ebadfunc
problem with user-supplied function
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).