Logo ROOT   6.14/05
Reference Guide
List of all members | Public Types | Public Member Functions | Private Member Functions | List of all members
ROOT::Math::Derivator Class Reference

Class for computing numerical derivative of a function.

Presently this class is implemented only using the numerical derivatives algorithms provided by GSL using the implementation class ROOT::Math::GSLDerivator

This class does not support copying

Definition at line 61 of file Derivator.h.

Public Types

typedef double(* GSLFuncPointer) (double, void *)
 signature for function pointers used by GSL More...
 

Public Member Functions

 Derivator ()
 Empty Construct for a Derivator class Need to set the function afterwards with Derivator::SetFunction. More...
 
 Derivator (const IGenFunction &f)
 Construct using a ROOT::Math::IGenFunction interface. More...
 
 Derivator (const GSLFuncPointer &f, void *p=0)
 Construct using a GSL function pointer type. More...
 
virtual ~Derivator ()
 destructor More...
 
double Eval (double x, double h=1E-8) const
 Computes the numerical derivative of a function f at a point x. More...
 
double EvalBackward (double x, double h=1E-8) const
 Computes the numerical derivative at a point x using an adaptive backward difference algorithm with a step size h. More...
 
double EvalCentral (double x, double h=1E-8) const
 Computes the numerical derivative at a point x using an adaptive central difference algorithm with a step size h. More...
 
double EvalForward (double x, double h=1E-8) const
 Computes the numerical derivative at a point x using an adaptive forward difference algorithm with a step size h. More...
 
void SetFunction (const IGenFunction &f)
 Set the function for calculating the derivatives. More...
 
void SetFunction (const GSLFuncPointer &f, void *p=0)
 Set the function f for evaluating the derivative using a GSL function pointer type. More...
 

Private Member Functions

 Derivator (const Derivator &)
 
Derivatoroperator= (const Derivator &)
 

--- Static methods ---

This methods don't require to use a Derivator object, and are designed to be used in fast calculation.

Error and status code cannot be retrieved in this case

GSLDerivatorfDerivator
 
int Status () const
 return the error status of the last derivative calculation More...
 
double Result () const
 return the result of the last derivative calculation More...
 
double Error () const
 return the estimate of the absolute error of the last derivative calculation More...
 
static double Eval (const IGenFunction &f, double x, double h=1E-8)
 Computes the numerical derivative of a function f at a point x. More...
 
static double EvalCentral (const IGenFunction &f, double x, double h=1E-8)
 Computes the numerical derivative of a function f at a point x using an adaptive central difference algorithm with a step size h. More...
 
static double EvalForward (const IGenFunction &f, double x, double h=1E-8)
 Computes the numerical derivative of a function f at a point x using an adaptive forward difference algorithm with a step size h. More...
 
static double EvalBackward (const IGenFunction &f, double x, double h=1E-8)
 Computes the numerical derivative of a function f at a point x using an adaptive backward difference algorithm with a step size h. More...
 
static double Eval (const IMultiGenFunction &f, const double *x, unsigned int icoord=0, double h=1E-8)
 Evaluate the partial derivative of a multi-dim function with respect coordinate x_icoord at the point x[]. More...
 
static double Eval (IParamFunction &f, double x, const double *p, unsigned int ipar=0, double h=1E-8)
 Evaluate the derivative with respect a parameter for one-dim parameteric function at the point ( x,p[]) with respect the parameter p_ipar. More...
 
static double Eval (IParamMultiFunction &f, const double *x, const double *p, unsigned int ipar=0, double h=1E-8)
 Evaluate the derivative with respect a parameter for a multi-dim parameteric function at the point ( x[],p[]) with respect the parameter p_ipar. More...
 

#include <Math/Derivator.h>

Member Typedef Documentation

◆ GSLFuncPointer

typedef double( * ROOT::Math::Derivator::GSLFuncPointer) (double, void *)

signature for function pointers used by GSL

Definition at line 68 of file Derivator.h.

Constructor & Destructor Documentation

◆ Derivator() [1/4]

ROOT::Math::Derivator::Derivator ( )

Empty Construct for a Derivator class Need to set the function afterwards with Derivator::SetFunction.

Definition at line 47 of file Derivator.cxx.

◆ Derivator() [2/4]

ROOT::Math::Derivator::Derivator ( const IGenFunction f)
explicit

Construct using a ROOT::Math::IGenFunction interface.

Definition at line 51 of file Derivator.cxx.

◆ Derivator() [3/4]

ROOT::Math::Derivator::Derivator ( const GSLFuncPointer f,
void p = 0 
)
explicit

Construct using a GSL function pointer type.

Parameters
f: free function pointer of the GSL required type
p: pointer to the object carrying the function state (for example the function object itself)

Definition at line 58 of file Derivator.cxx.

◆ ~Derivator()

ROOT::Math::Derivator::~Derivator ( )
virtual

destructor

Definition at line 66 of file Derivator.cxx.

◆ Derivator() [4/4]

ROOT::Math::Derivator::Derivator ( const Derivator )
private

Definition at line 72 of file Derivator.cxx.

Member Function Documentation

◆ Error()

double ROOT::Math::Derivator::Error ( ) const

return the estimate of the absolute error of the last derivative calculation

Definition at line 154 of file Derivator.cxx.

◆ Eval() [1/5]

double ROOT::Math::Derivator::Eval ( double  x,
double  h = 1E-8 
) const

Computes the numerical derivative of a function f at a point x.

It uses Derivator::EvalCentral to compute the derivative using an adaptive central difference algorithm with a step size h

Definition at line 93 of file Derivator.cxx.

◆ Eval() [2/5]

double ROOT::Math::Derivator::Eval ( const IGenFunction f,
double  x,
double  h = 1E-8 
)
static

Computes the numerical derivative of a function f at a point x.

It uses Derivator::EvalCentral to compute the derivative using an adaptive central difference algorithm with a step size h

Definition at line 110 of file Derivator.cxx.

◆ Eval() [3/5]

double ROOT::Math::Derivator::Eval ( const IMultiGenFunction f,
const double *  x,
unsigned int  icoord = 0,
double  h = 1E-8 
)
static

Evaluate the partial derivative of a multi-dim function with respect coordinate x_icoord at the point x[].

Definition at line 126 of file Derivator.cxx.

◆ Eval() [4/5]

double ROOT::Math::Derivator::Eval ( IParamFunction f,
double  x,
const double *  p,
unsigned int  ipar = 0,
double  h = 1E-8 
)
static

Evaluate the derivative with respect a parameter for one-dim parameteric function at the point ( x,p[]) with respect the parameter p_ipar.

Definition at line 134 of file Derivator.cxx.

◆ Eval() [5/5]

double ROOT::Math::Derivator::Eval ( IParamMultiFunction f,
const double *  x,
const double *  p,
unsigned int  ipar = 0,
double  h = 1E-8 
)
static

Evaluate the derivative with respect a parameter for a multi-dim parameteric function at the point ( x[],p[]) with respect the parameter p_ipar.

Definition at line 143 of file Derivator.cxx.

◆ EvalBackward() [1/2]

double ROOT::Math::Derivator::EvalBackward ( double  x,
double  h = 1E-8 
) const

Computes the numerical derivative at a point x using an adaptive backward difference algorithm with a step size h.

The function is evaluated only at points less than x and at x itself.

Definition at line 105 of file Derivator.cxx.

◆ EvalBackward() [2/2]

double ROOT::Math::Derivator::EvalBackward ( const IGenFunction f,
double  x,
double  h = 1E-8 
)
static

Computes the numerical derivative of a function f at a point x using an adaptive backward difference algorithm with a step size h.

The function is evaluated only at points less than x and at x itself

Definition at line 122 of file Derivator.cxx.

◆ EvalCentral() [1/2]

double ROOT::Math::Derivator::EvalCentral ( double  x,
double  h = 1E-8 
) const

Computes the numerical derivative at a point x using an adaptive central difference algorithm with a step size h.

Definition at line 97 of file Derivator.cxx.

◆ EvalCentral() [2/2]

double ROOT::Math::Derivator::EvalCentral ( const IGenFunction f,
double  x,
double  h = 1E-8 
)
static

Computes the numerical derivative of a function f at a point x using an adaptive central difference algorithm with a step size h.

Definition at line 114 of file Derivator.cxx.

◆ EvalForward() [1/2]

double ROOT::Math::Derivator::EvalForward ( double  x,
double  h = 1E-8 
) const

Computes the numerical derivative at a point x using an adaptive forward difference algorithm with a step size h.

The function is evaluated only at points greater than x and at x itself.

Definition at line 101 of file Derivator.cxx.

◆ EvalForward() [2/2]

double ROOT::Math::Derivator::EvalForward ( const IGenFunction f,
double  x,
double  h = 1E-8 
)
static

Computes the numerical derivative of a function f at a point x using an adaptive forward difference algorithm with a step size h.

The function is evaluated only at points greater than x and at x itself

Definition at line 118 of file Derivator.cxx.

◆ operator=()

Derivator & ROOT::Math::Derivator::operator= ( const Derivator rhs)
private

Definition at line 76 of file Derivator.cxx.

◆ Result()

double ROOT::Math::Derivator::Result ( ) const

return the result of the last derivative calculation

Definition at line 152 of file Derivator.cxx.

◆ SetFunction() [1/2]

void ROOT::Math::Derivator::SetFunction ( const IGenFunction f)

Set the function for calculating the derivatives.

The function must implement the ROOT::Math::IGenFunction signature

Definition at line 84 of file Derivator.cxx.

◆ SetFunction() [2/2]

void ROOT::Math::Derivator::SetFunction ( const GSLFuncPointer f,
void p = 0 
)

Set the function f for evaluating the derivative using a GSL function pointer type.

Parameters
f: free function pointer of the GSL required type
p: pointer to the object carrying the function state (for example the function object itself)

Definition at line 88 of file Derivator.cxx.

◆ Status()

int ROOT::Math::Derivator::Status ( ) const

return the error status of the last derivative calculation

Definition at line 156 of file Derivator.cxx.

Member Data Documentation

◆ fDerivator

GSLDerivator* ROOT::Math::Derivator::fDerivator
mutableprivate

Definition at line 232 of file Derivator.h.

Libraries for ROOT::Math::Derivator:
[legend]

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