Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::Math::WrappedTF1 Class Reference

Class to Wrap a ROOT Function class (like TF1) in a IParamFunction interface of one dimensions to be used in the ROOT::Math numerical algorithms The wrapper does not own bby default the TF1 pointer, so it assumes it exists during the wrapper lifetime.

The class from ROOT version 6.03 does not contain anymore a copy of the parameters. The parameters are stored in the TF1 class.

Definition at line 39 of file WrappedTF1.h.

Public Types

typedef ROOT::Math::IParamGradFunction::BaseFunc BaseFunc
typedef ROOT::Math::IParamGradFunction BaseGradFunc
typedef IParametricFunctionOneDim BaseParamFunc
typedef ROOT::Math::IGradientFunctionOneDim IGrad

Public Member Functions

 WrappedTF1 (const WrappedTF1 &rhs)
 Copy constructor.
 WrappedTF1 (TF1 &f)
 constructor from a TF1 function pointer.
 ~WrappedTF1 () override
 Destructor (no operations).
double Derivative (const double *x) const
 Compatibility method with multi-dimensional interface for partial derivative.
double Derivative (double x) const
 Return the derivative of the function at a point x Use the private method DoDerivative.
void FdF (const double *x, double &f, double *df) const
 Compatibility method with multi-dimensional interface for Gradient and function evaluation.
void Gradient (const double *x, double *g) const
 Compatibility method with multi-dimensional interface for Gradient.
virtual bool HasGradient () const
bool HasGradient () const override
double operator() (const double *x) const
 Evaluate the function at a point x[].
double operator() (const double *x, const double *p) const
 multidim-like interface
double operator() (double x) const
 Evaluate the function at a point x.
double operator() (double x, const double *p) const
 Evaluate function at a point x and for given parameters p.
WrappedTF1operator= (const WrappedTF1 &rhs)
 Assignment operator.
double ParameterDerivative (const double *x, const double *p, unsigned int ipar=0) const
 Partial derivative with respect a parameter Compatibility interface with multi-dimensional functions.
double ParameterDerivative (const double *x, unsigned int ipar=0) const
 Evaluate partial derivative using cached parameter values (multi-dim like interface).
double ParameterDerivative (double x, const double *p, unsigned int ipar=0) const
 Partial derivative with respect a parameter.
double ParameterDerivative (double x, unsigned int ipar=0) const
 Evaluate partial derivative using cached parameter values.
void ParameterGradient (const double *x, const double *p, double *grad) const
 Compatibility interface with multi-dimensional functions.
void ParameterGradient (const double *x, double *grad) const
 Evaluate all derivatives using cached parameter values (multi-dim like interface).
void ParameterGradient (double x, double *grad) const
 Evaluate all derivatives using cached parameter values.
interface inherited from IFunction
ROOT::Math::IGenFunctionClone () const override
 Clone the wrapper but not the original function.

interface inherited from IParamFunction

bool fLinear
bool fPolynomial
TF1fFunc
double fX [1]
 ! cached vector for x value (needed for TF1::EvalPar signature)
const doubleParameters () const override
 get the parameter values (return values cachen inside, those inside TF1 might be different)
void SetParameters (const double *p) override
 set parameter values need to call also SetParameters in TF1 in ace some other operations (re-normalizations) are needed
unsigned int NPar () const override
 return number of parameters
std::string ParameterName (unsigned int i) const override
 return parameter name (this is stored in TF1)
void ParameterGradient (double x, const double *par, double *grad) const override
 evaluate the derivative of the function with respect to the parameters
void FdF (double x, double &f, double &deriv) const override
 calculate function and derivative at same time (required by IGradient interface)
static void SetDerivPrecision (double eps)
 precision value used for calculating the derivative step-size h = eps * |x|.
static double GetDerivPrecision ()
 get precision value used for calculating the derivative step-size
double DoEvalPar (double x, const double *p) const override
 evaluate function passing coordinates x and vector of parameters
double DoEval (double x) const override
 evaluate function using the cached parameter values (of TF1) re-implement for better efficiency
double DoDerivative (double x) const override
 return the function derivatives w.r.t. x
double DoParameterDerivative (double x, const double *p, unsigned int ipar) const override
 evaluate the derivative of the function with respect to the parameters

#include <Math/WrappedTF1.h>

Inheritance diagram for ROOT::Math::WrappedTF1:
ROOT::Math::IParametricGradFunctionOneDim ROOT::Math::IGradientFunctionOneDim ROOT::Math::IParametricFunctionOneDim ROOT::Math::IBaseFunctionOneDim ROOT::Math::IBaseFunctionOneDim ROOT::Math::IBaseParam

Member Typedef Documentation

◆ BaseFunc

◆ BaseGradFunc

◆ BaseParamFunc

◆ IGrad

Constructor & Destructor Documentation

◆ WrappedTF1() [1/2]

ROOT::Math::WrappedTF1::WrappedTF1 ( TF1 & f)

constructor from a TF1 function pointer.

Definition at line 41 of file WrappedTF1.cxx.

◆ ~WrappedTF1()

ROOT::Math::WrappedTF1::~WrappedTF1 ( )
inlineoverride

Destructor (no operations).

TF1 Function pointer is not owned

Definition at line 56 of file WrappedTF1.h.

◆ WrappedTF1() [2/2]

ROOT::Math::WrappedTF1::WrappedTF1 ( const WrappedTF1 & rhs)

Copy constructor.

Definition at line 69 of file WrappedTF1.cxx.

Member Function Documentation

◆ Clone()

ROOT::Math::IGenFunction * ROOT::Math::WrappedTF1::Clone ( ) const
inlineoverridevirtual

Clone the wrapper but not the original function.

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 73 of file WrappedTF1.h.

◆ Derivative() [1/2]

double ROOT::Math::IBaseFunctionOneDim::Derivative ( const double * x) const
inlineinherited

Compatibility method with multi-dimensional interface for partial derivative.

Definition at line 186 of file IFunction.h.

◆ Derivative() [2/2]

double ROOT::Math::IBaseFunctionOneDim::Derivative ( double x) const
inlineinherited

Return the derivative of the function at a point x Use the private method DoDerivative.

Definition at line 183 of file IFunction.h.

◆ DoDerivative()

double ROOT::Math::WrappedTF1::DoDerivative ( double x) const
overrideprivatevirtual

return the function derivatives w.r.t. x

Reimplemented from ROOT::Math::IBaseFunctionOneDim.

Definition at line 110 of file WrappedTF1.cxx.

◆ DoEval()

double ROOT::Math::WrappedTF1::DoEval ( double x) const
inlineoverrideprivatevirtual

evaluate function using the cached parameter values (of TF1) re-implement for better efficiency

Reimplemented from ROOT::Math::IParametricFunctionOneDim.

Definition at line 142 of file WrappedTF1.h.

◆ DoEvalPar()

double ROOT::Math::WrappedTF1::DoEvalPar ( double x,
const double * p ) const
inlineoverrideprivatevirtual

evaluate function passing coordinates x and vector of parameters

Implements ROOT::Math::IParametricFunctionOneDim.

Definition at line 133 of file WrappedTF1.h.

◆ DoParameterDerivative()

double ROOT::Math::WrappedTF1::DoParameterDerivative ( double x,
const double * p,
unsigned int ipar ) const
overrideprivatevirtual

evaluate the derivative of the function with respect to the parameters

Implements ROOT::Math::IParametricGradFunctionOneDim.

Definition at line 119 of file WrappedTF1.cxx.

◆ FdF() [1/2]

void ROOT::Math::IBaseFunctionOneDim::FdF ( const double * x,
double & f,
double * df ) const
inlineinherited

Compatibility method with multi-dimensional interface for Gradient and function evaluation.

Definition at line 202 of file IFunction.h.

◆ FdF() [2/2]

void ROOT::Math::WrappedTF1::FdF ( double x,
double & f,
double & deriv ) const
inlineoverridevirtual

calculate function and derivative at same time (required by IGradient interface)

Reimplemented from ROOT::Math::IBaseFunctionOneDim.

Definition at line 116 of file WrappedTF1.h.

◆ GetDerivPrecision()

double ROOT::Math::WrappedTF1::GetDerivPrecision ( )
static

get precision value used for calculating the derivative step-size

Definition at line 147 of file WrappedTF1.cxx.

◆ Gradient()

void ROOT::Math::IBaseFunctionOneDim::Gradient ( const double * x,
double * g ) const
inlineinherited

Compatibility method with multi-dimensional interface for Gradient.

Definition at line 189 of file IFunction.h.

◆ HasGradient() [1/2]

virtual bool ROOT::Math::IBaseFunctionOneDim::HasGradient ( ) const
inlinevirtualinherited

Reimplemented in ROOT::Math::IGradientFunctionOneDim.

Definition at line 179 of file IFunction.h.

◆ HasGradient() [2/2]

bool ROOT::Math::IGradientFunctionOneDim::HasGradient ( ) const
inlineoverridevirtualinherited

Reimplemented from ROOT::Math::IBaseFunctionOneDim.

Definition at line 266 of file IFunction.h.

◆ NPar()

unsigned int ROOT::Math::WrappedTF1::NPar ( ) const
inlineoverridevirtual

return number of parameters

Implements ROOT::Math::IBaseParam.

Definition at line 97 of file WrappedTF1.h.

◆ operator()() [1/4]

double ROOT::Math::IBaseFunctionOneDim::operator() ( const double * x) const
inlineinherited

Evaluate the function at a point x[].

Compatible method with multi-dimensional functions.

Definition at line 169 of file IFunction.h.

◆ operator()() [2/4]

double ROOT::Math::IParametricFunctionOneDim::operator() ( const double * x,
const double * p ) const
inlineinherited

multidim-like interface

Definition at line 187 of file IParamFunction.h.

◆ operator()() [3/4]

double ROOT::Math::IBaseFunctionOneDim::operator() ( double x) const
inlineinherited

Evaluate the function at a point x.

Use the a pure virtual private method DoEval which must be implemented by sub-classes.

Definition at line 169 of file IFunction.h.

◆ operator()() [4/4]

double ROOT::Math::IParametricFunctionOneDim::operator() ( double x,
const double * p ) const
inlineinherited

Evaluate function at a point x and for given parameters p.

This method does not change the internal status of the function (internal parameter values). If for some reason one prefers caching the parameter values, SetParameters(p) and then operator()(x) should be called. Use the pure virtual function DoEvalPar to implement it

Definition at line 178 of file IParamFunction.h.

◆ operator=()

WrappedTF1 & ROOT::Math::WrappedTF1::operator= ( const WrappedTF1 & rhs)

Assignment operator.

Definition at line 83 of file WrappedTF1.cxx.

◆ ParameterDerivative() [1/4]

double ROOT::Math::IParametricGradFunctionOneDim::ParameterDerivative ( const double * x,
const double * p,
unsigned int ipar = 0 ) const
inlineinherited

Partial derivative with respect a parameter Compatibility interface with multi-dimensional functions.

Definition at line 403 of file IParamFunction.h.

◆ ParameterDerivative() [2/4]

double ROOT::Math::IParametricGradFunctionOneDim::ParameterDerivative ( const double * x,
unsigned int ipar = 0 ) const
inlineinherited

Evaluate partial derivative using cached parameter values (multi-dim like interface).

Definition at line 412 of file IParamFunction.h.

◆ ParameterDerivative() [3/4]

double ROOT::Math::IParametricGradFunctionOneDim::ParameterDerivative ( double x,
const double * p,
unsigned int ipar = 0 ) const
inlineinherited

Partial derivative with respect a parameter.

Definition at line 386 of file IParamFunction.h.

◆ ParameterDerivative() [4/4]

double ROOT::Math::IParametricGradFunctionOneDim::ParameterDerivative ( double x,
unsigned int ipar = 0 ) const
inlineinherited

Evaluate partial derivative using cached parameter values.

Definition at line 394 of file IParamFunction.h.

◆ ParameterGradient() [1/4]

void ROOT::Math::IParametricGradFunctionOneDim::ParameterGradient ( const double * x,
const double * p,
double * grad ) const
inlineinherited

Compatibility interface with multi-dimensional functions.

Definition at line 369 of file IParamFunction.h.

◆ ParameterGradient() [2/4]

void ROOT::Math::IParametricGradFunctionOneDim::ParameterGradient ( const double * x,
double * grad ) const
inlineinherited

Evaluate all derivatives using cached parameter values (multi-dim like interface).

Definition at line 377 of file IParamFunction.h.

◆ ParameterGradient() [3/4]

void ROOT::Math::IParametricGradFunctionOneDim::ParameterGradient ( double x,
double * grad ) const
inlineinherited

Evaluate all derivatives using cached parameter values.

Definition at line 361 of file IParamFunction.h.

◆ ParameterGradient() [4/4]

void ROOT::Math::WrappedTF1::ParameterGradient ( double x,
const double * par,
double * grad ) const
overridevirtual

evaluate the derivative of the function with respect to the parameters

Reimplemented from ROOT::Math::IParametricGradFunctionOneDim.

Definition at line 95 of file WrappedTF1.cxx.

◆ ParameterName()

std::string ROOT::Math::WrappedTF1::ParameterName ( unsigned int i) const
inlineoverridevirtual

return parameter name (this is stored in TF1)

Reimplemented from ROOT::Math::IBaseParam.

Definition at line 104 of file WrappedTF1.h.

◆ Parameters()

const double * ROOT::Math::WrappedTF1::Parameters ( ) const
inlineoverridevirtual

get the parameter values (return values cachen inside, those inside TF1 might be different)

Implements ROOT::Math::IBaseParam.

Definition at line 82 of file WrappedTF1.h.

◆ SetDerivPrecision()

void ROOT::Math::WrappedTF1::SetDerivPrecision ( double eps)
static

precision value used for calculating the derivative step-size h = eps * |x|.

The default is 0.001, give a smaller in case function changes rapidly

Definition at line 142 of file WrappedTF1.cxx.

◆ SetParameters()

void ROOT::Math::WrappedTF1::SetParameters ( const double * p)
inlineoverridevirtual

set parameter values need to call also SetParameters in TF1 in ace some other operations (re-normalizations) are needed

Implements ROOT::Math::IBaseParam.

Definition at line 90 of file WrappedTF1.h.

Member Data Documentation

◆ fFunc

TF1* ROOT::Math::WrappedTF1::fFunc
private

Definition at line 159 of file WrappedTF1.h.

◆ fLinear

bool ROOT::Math::WrappedTF1::fLinear
private

Definition at line 157 of file WrappedTF1.h.

◆ fPolynomial

bool ROOT::Math::WrappedTF1::fPolynomial
private

Definition at line 158 of file WrappedTF1.h.

◆ fX

double ROOT::Math::WrappedTF1::fX[1]
mutableprivate

! cached vector for x value (needed for TF1::EvalPar signature)

Definition at line 160 of file WrappedTF1.h.


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