BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Math::Derivator Class Reference

Description

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.

Collaboration diagram for ROOT::Math::Derivator:
[legend]

Public Types

typedef double(* GSLFuncPointer) (double, void *)
 

Public Member Functions

 Derivator ()
 
 Derivator (const GSLFuncPointer &f, void *p=0)
 
 Derivator (const IGenFunction &f)
 
virtual ~Derivator ()
 destructor More...
 
double Eval (double x, double h=1E-8) const
 
double EvalBackward (double x, double h=1E-8) const
 
double EvalCentral (double x, double h=1E-8) const
 
double EvalForward (double x, double h=1E-8) const
 
void SetFunction (const GSLFuncPointer &f, void *p=0)
 
void SetFunction (const IGenFunction &f)
 

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
 
double Result () const
 
double Error () const
 
static double Eval (const IGenFunction &f, double x, double h=1E-8)
 
static double EvalCentral (const IGenFunction &f, double x, double h=1E-8)
 
static double EvalForward (const IGenFunction &f, double x, double h=1E-8)
 
static double EvalBackward (const IGenFunction &f, double x, double h=1E-8)
 
static double Eval (const IMultiGenFunction &f, const double *x, unsigned int icoord=0, double h=1E-8)
 
static double Eval (IParamFunction &f, double x, const double *p, unsigned int ipar=0, double h=1E-8)
 
static double Eval (IParamMultiFunction &f, const double *x, const double *p, unsigned int ipar=0, double h=1E-8)
 

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

◆ Derivator() [2/4]

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

Construct using a ROOT::Math::IGenFunction interface

◆ 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)

◆ ~Derivator()

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

destructor

◆ Derivator() [4/4]

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

Member Function Documentation

◆ Error()

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

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

◆ Eval() [1/5]

static 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

◆ Eval() [2/5]

static 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[]

◆ Eval() [3/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

◆ Eval() [4/5]

static 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

◆ Eval() [5/5]

static 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

◆ EvalBackward() [1/2]

static 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

◆ EvalBackward() [2/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.

◆ EvalCentral() [1/2]

static 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

◆ EvalCentral() [2/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.

◆ EvalForward() [1/2]

static 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

◆ EvalForward() [2/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.

◆ operator=()

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

◆ Result()

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

return the result of the last derivative calculation

◆ SetFunction() [1/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)

◆ SetFunction() [2/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

◆ Status()

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

return the error status of the last derivative calculation

Member Data Documentation

◆ fDerivator

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

Definition at line 232 of file Derivator.h.


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