gsl_deriv Class Template Reference

#include <gsl_deriv.h>

Inheritance diagram for gsl_deriv:

deriv

Detailed Description

template<class param_t, class func_t>
class gsl_deriv< param_t, func_t >

Numerical differentiation (GSL).

This class computes the numerical derivative of a function. The stepsize h should be specified before use. If similar functions are being differentiated in succession, the user may be able to increase the speed of later derivatives by setting the new stepsize equal to the optimized stepsize from the previous differentiation, by setting h to h_opt.

Note:
Second and third derivatives are computed by naive nested applications of the formula for the first derivative and the uncertainty for these will likely be underestimated.
Idea for future:
Include the forward and backward GSL derivatives

Definition at line 53 of file gsl_deriv.h.


Public Member Functions

 gsl_deriv ()
virtual ~gsl_deriv ()
virtual int calc_err (double x, param_t &pa, func_t &func, double &dfdx, double &err)
 Calculate the first derivative of func w.r.t. x and uncertainty.
virtual const char * type ()
 Return string denoting type ("gsl_deriv").

Data Fields

double h
 Initial stepsize.
double h_opt
 The last value of the optimized stepsize.

Protected Member Functions

virtual int calc_err_int (double x, typename deriv< param_t, func_t >::dpars &pa, funct< typename deriv< param_t, func_t >::dpars > &func, double &dfdx, double &err)
 Internal version of calc_err() for second and third derivatives.
template<class func2_t, class param2_t>
int central_deriv (double x, double hh, double &result, double &abserr_round, double &abserr_trunc, func2_t &func, param2_t &pa)
 Compute derivative using 5-point rule.

Member Function Documentation

int central_deriv ( double  x,
double  hh,
double &  result,
double &  abserr_round,
double &  abserr_trunc,
func2_t &  func,
param2_t &  pa 
) [inline, protected]

Compute derivative using 5-point rule.

Compute the derivative using the 5-point rule (x-h, x-h/2, x, x+h/2, x+h) and the error using the difference between the 5-point and the 3-point rule (x-h,x,x+h). Note that the central point is not used for either.

This must be a class template because it is used by both calc_err() and calc_err_int().

Definition at line 199 of file gsl_deriv.h.


Field Documentation

double h

Initial stepsize.

This should be specified before a call to calc() or calc_err(). If it is zero, then $ x 10^{-4} $ will used, or if x is zero, then $ 10^{-4} $ will be used.

Definition at line 70 of file gsl_deriv.h.

double h_opt

The last value of the optimized stepsize.

This is initialized to zero in the constructor and set by calc_err() to the most recent value of the optimized stepsize.

Definition at line 79 of file gsl_deriv.h.


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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page