![]() |
Object-oriented Scientific Computing Library: Version 0.910
|
Numerical differentiation routine (CERNLIB) More...
#include <cern_deriv.h>
This uses Romberg extrapolation to compute the derivative with the finite-differencing formula
If deriv::verbose is greater than zero, then each iteration prints out the extrapolation table, and if deriv::verbose is greater than 1, then a keypress is required at the end of each iteration.
For sufficiently difficult functions, the derivative computation can fail, and will call the error handler and return zero with zero error.
Based on the CERNLIB routine DERIV, which was based on Rutishauser63 and is documented at http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/d401/top.html
An example demonstrating the usage of this class is given in examples/ex_deriv.cpp
and the Numerical differentiation .
If deriv::verbose is greater than zero, at each iteration this class prints something similar to
cern_deriv, iteration: 1 (hh, a[k], derivative) list: -4.193459e-05 4.387643e-14 8.775286e-01 -2.995402e-05 4.387792e-14 8.775585e-01 -1.048405e-05 4.387845e-14 8.775690e-01 -7.488654e-06 4.387882e-14 8.775765e-01 -2.621038e-06 4.387895e-14 8.775791e-01 -1.872173e-06 4.387905e-14 8.775810e-01 -6.552611e-07 4.387908e-14 8.775817e-01 -4.680438e-07 4.387910e-14 8.775821e-01 -1.638153e-07 4.387911e-14 8.775823e-01
If deriv::verbose is greater than 1, a keypress is required after each iteration.
Definition at line 91 of file cern_deriv.h.
Public Member Functions | |
virtual int | calc_err (double x, func_t &func, double &dfdx, double &err) |
Calculate the first derivative of func w.r.t. x and the uncertainty. | |
virtual const char * | type () |
Return string denoting type ("cern_deriv") | |
Data Fields | |
double | delta |
A scaling factor (default 1.0) | |
double | eps |
Extrapolation tolerance (default is ![]() | |
Protected Member Functions | |
template<class func2_t > | |
int | calc_base (double x, func2_t &func, double &dfdx, double &err) |
Internal template version of the derivative function. | |
virtual int | calc_err_int (double x, funct &func, double &dfdx, double &err) |
Calculate the first derivative of func w.r.t. x. | |
Protected Attributes | |
Storage for the fixed coefficients | |
double | dx [10] |
double | w [10][4] |
virtual int cern_deriv< func_t >::calc_err_int | ( | double | x, |
funct & | func, | ||
double & | dfdx, | ||
double & | err | ||
) | [inline, protected, virtual] |
This is an internal version of calc() which is used in computing second and third derivatives
Implements deriv< func_t >.
Definition at line 249 of file cern_deriv.h.
Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).