Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::Math::WrappedMultiTF1Templ< T > Class Template Reference

template<class T>
class ROOT::Math::WrappedMultiTF1Templ< T >

Class to Wrap a ROOT Function class (like TF1) in a IParamMultiFunction interface of multi-dimensions to be used in the ROOT::Math numerical algorithm.

This wrapper class does not own the TF1 pointer, so it assumes it exists during the wrapper lifetime. The class copy the TF1 pointer only when it owns it.

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 48 of file WrappedMultiTF1.h.

Public Types

typedef T BackendType
typedef ROOT::Math::IParametricFunctionMultiDimTempl< T >::BaseFunc BaseFunc
using BaseGradFunc = IGradientFunctionMultiDimTempl<T>
typedef ROOT::Math::IParametricGradFunctionMultiDimTempl< T > BaseParamFunc

Public Member Functions

 WrappedMultiTF1Templ (const WrappedMultiTF1Templ< T > &rhs)
 Copy constructor.
 WrappedMultiTF1Templ (TF1 &f, unsigned int dim=0)
 constructor from a function pointer to a TF1 If dim = 0 dimension is taken from TF1::GetNdim().
 ~WrappedMultiTF1Templ () override
 Destructor (no operations).
Derivative (const T *x, unsigned int icoord, T *previous_grad, T *previous_g2, T *previous_gstep) const
 In some cases, the derivative algorithm will use information from the previous step, these can be passed in with this overload.
Derivative (const T *x, unsigned int icoord=0) const
 Return the partial derivative with respect to the passed coordinate.
virtual void FdF (const T *x, T &f, T *df) const
 Optimized method to evaluate at the same time the function value and derivative at a point x.
virtual void Gradient (const T *x, T *grad) const
 Evaluate all the vector of function derivatives (gradient) at a point x.
virtual bool HasGradient () const
operator() (const T *x) const
operator() (const T *x, const double *p) const
WrappedMultiTF1Temploperator= (const WrappedMultiTF1Templ< T > &rhs)
 Assignment operator.
ParameterDerivative (const T *x, const double *p, unsigned int ipar=0) const
 Evaluate the partial derivative w.r.t a parameter ipar from values and parameters.
ParameterDerivative (const T *x, unsigned int ipar=0) const
 Evaluate partial derivative using cached parameter values.
void ParameterGradient (const T *x, T *grad) const
 Evaluate all derivatives using cached parameter values.

interface inherited from IParamFunction

bool fLinear
bool fPolynomial
bool fOwnFunc
TF1fFunc
unsigned int fDim
IMultiGenFunctionTempl< T > * Clone () const override
 Clone the wrapper but not the original function.
unsigned int NDim () const override
 Retrieve the dimension of the function.
const doubleParameters () const override
 get the parameter values (return values from TF1)
void SetParameters (const double *p) override
 set parameter values (only the cached one in this class,leave unchanges those of TF1)
unsigned int NPar () const override
 return number of parameters
std::string ParameterName (unsigned int i) const override
 return parameter name (from TF1)
void ParameterGradient (const T *x, const double *par, T *grad) const override
 Evaluate the all the derivatives (gradient vector) of the function with respect to the parameters at a point x.
bool ParameterHessian (const T *x, const double *par, T *h) const override
 Evaluate the all the Hessian (second derivatives matrix) of the function with respect to the parameters at a point x.
bool HasParameterHessian () const override
bool ParameterG2 (const T *, const double *, T *) const override
 Evaluate all the second derivatives (diagonal ones) of the function with respect to the parameters at a point x.
const TF1GetFunction () const
 method to retrieve the internal function pointer
void SetAndCopyFunction (const TF1 *f=nullptr)
 method to set a new function pointer and copy it inside.
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
DoEvalPar (const T *x, const double *p) const override
 evaluate function passing coordinates x and vector of parameters
DoEvalVec (const T *x) const
 evaluate function using the cached parameter values (of TF1) re-implement for better efficiency
DoEval (const T *x) const override
 evaluate function using the cached parameter values (of TF1) re-implement for better efficiency
DoParameterDerivative (const T *x, const double *p, unsigned int ipar) const override
 evaluate the partial derivative with respect to the parameter

#include <Math/WrappedMultiTF1.h>

Inheritance diagram for ROOT::Math::WrappedMultiTF1Templ< T >:
ROOT::Math::IParametricGradFunctionMultiDimTempl< T > ROOT::Math::IParametricFunctionMultiDimTempl< T > ROOT::Math::IBaseParam ROOT::Math::IBaseFunctionMultiDimTempl< T > ROOT::Math::IBaseParam

Member Typedef Documentation

◆ BackendType

template<class T>
typedef T ROOT::Math::IBaseFunctionMultiDimTempl< T >::BackendType
inherited

Definition at line 67 of file IFunction.h.

◆ BaseFunc

template<class T>
typedef ROOT::Math::IParametricFunctionMultiDimTempl<T>::BaseFunc ROOT::Math::WrappedMultiTF1Templ< T >::BaseFunc

Definition at line 53 of file WrappedMultiTF1.h.

◆ BaseGradFunc

template<class T>
using ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::BaseGradFunc = IGradientFunctionMultiDimTempl<T>
inherited

Definition at line 231 of file IParamFunction.h.

◆ BaseParamFunc

Definition at line 52 of file WrappedMultiTF1.h.

Constructor & Destructor Documentation

◆ WrappedMultiTF1Templ() [1/2]

template<class T>
ROOT::Math::WrappedMultiTF1Templ< T >::WrappedMultiTF1Templ ( TF1 & f,
unsigned int dim = 0 )

constructor from a function pointer to a TF1 If dim = 0 dimension is taken from TF1::GetNdim().

In case of multi-dimensional function created using directly TF1 object the dimension returned by TF1::GetNdim is always 1. The user must then pass the correct value of dim

Definition at line 227 of file WrappedMultiTF1.h.

◆ ~WrappedMultiTF1Templ()

template<class T>
ROOT::Math::WrappedMultiTF1Templ< T >::~WrappedMultiTF1Templ ( )
inlineoverride

Destructor (no operations).

Function pointer is not owned

Definition at line 66 of file WrappedMultiTF1.h.

◆ WrappedMultiTF1Templ() [2/2]

template<class T>
ROOT::Math::WrappedMultiTF1Templ< T >::WrappedMultiTF1Templ ( const WrappedMultiTF1Templ< T > & rhs)

Copy constructor.

Definition at line 259 of file WrappedMultiTF1.h.

Member Function Documentation

◆ Clone()

template<class T>
IMultiGenFunctionTempl< T > * ROOT::Math::WrappedMultiTF1Templ< T >::Clone ( ) const
inlineoverridevirtual

Clone the wrapper but not the original function.

Implements ROOT::Math::IBaseFunctionMultiDimTempl< T >.

Definition at line 86 of file WrappedMultiTF1.h.

◆ Derivative() [1/2]

template<class T>
T ROOT::Math::IBaseFunctionMultiDimTempl< T >::Derivative ( const T * x,
unsigned int icoord,
T * previous_grad,
T * previous_g2,
T * previous_gstep ) const
inlineinherited

In some cases, the derivative algorithm will use information from the previous step, these can be passed in with this overload.

The previous_* arrays can also be used to return second derivative and step size so that these can be passed forward again as well at the call site, if necessary.

Definition at line 120 of file IFunction.h.

◆ Derivative() [2/2]

template<class T>
T ROOT::Math::IBaseFunctionMultiDimTempl< T >::Derivative ( const T * x,
unsigned int icoord = 0 ) const
inlineinherited

Return the partial derivative with respect to the passed coordinate.

Definition at line 115 of file IFunction.h.

◆ DoEval()

template<class T>
T ROOT::Math::WrappedMultiTF1Templ< T >::DoEval ( const T * x) const
inlineoverrideprivatevirtual

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

Reimplemented from ROOT::Math::IParametricGradFunctionMultiDimTempl< T >.

Definition at line 172 of file WrappedMultiTF1.h.

◆ DoEvalPar()

template<class T>
T ROOT::Math::WrappedMultiTF1Templ< T >::DoEvalPar ( const T * x,
const double * p ) const
inlineoverrideprivatevirtual

evaluate function passing coordinates x and vector of parameters

Implements ROOT::Math::IParametricGradFunctionMultiDimTempl< T >.

Definition at line 158 of file WrappedMultiTF1.h.

◆ DoEvalVec()

template<class T>
T ROOT::Math::WrappedMultiTF1Templ< T >::DoEvalVec ( const T * x) const
inlineprivate

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

Definition at line 165 of file WrappedMultiTF1.h.

◆ DoParameterDerivative()

template<class T>
T ROOT::Math::WrappedMultiTF1Templ< T >::DoParameterDerivative ( const T * x,
const double * p,
unsigned int ipar ) const
overrideprivatevirtual

evaluate the partial derivative with respect to the parameter

Implements ROOT::Math::IParametricGradFunctionMultiDimTempl< T >.

Definition at line 363 of file WrappedMultiTF1.h.

◆ FdF()

template<class T>
virtual void ROOT::Math::IBaseFunctionMultiDimTempl< T >::FdF ( const T * x,
T & f,
T * df ) const
inlinevirtualinherited

Optimized method to evaluate at the same time the function value and derivative at a point x.

Often both value and derivatives are needed and it is often more efficient to compute them at the same time. Derived class should implement this method if performances play an important role and if it is faster to evaluate value and derivative at the same time

Reimplemented in ROOT::Math::LSResidualFunc< Func >.

Definition at line 108 of file IFunction.h.

◆ GetDerivPrecision()

template<class T>
double ROOT::Math::WrappedMultiTF1Templ< T >::GetDerivPrecision ( )
static

get precision value used for calculating the derivative step-size

Definition at line 389 of file WrappedMultiTF1.h.

◆ GetFunction()

template<class T>
const TF1 * ROOT::Math::WrappedMultiTF1Templ< T >::GetFunction ( ) const
inline

method to retrieve the internal function pointer

Definition at line 147 of file WrappedMultiTF1.h.

◆ Gradient()

template<class T>
virtual void ROOT::Math::IBaseFunctionMultiDimTempl< T >::Gradient ( const T * x,
T * grad ) const
inlinevirtualinherited

Evaluate all the vector of function derivatives (gradient) at a point x.

Derived classes must re-implement it if more efficient than evaluating one at a time

Reimplemented in ROOT::Math::GradFunctor, and ROOT::Math::LSResidualFunc< Func >.

Definition at line 96 of file IFunction.h.

◆ HasGradient()

template<class T>
virtual bool ROOT::Math::IBaseFunctionMultiDimTempl< T >::HasGradient ( ) const
inlinevirtualinherited

◆ HasParameterHessian()

template<class T>
bool ROOT::Math::WrappedMultiTF1Templ< T >::HasParameterHessian ( ) const
overridevirtual

Reimplemented from ROOT::Math::IParametricGradFunctionMultiDimTempl< T >.

Definition at line 357 of file WrappedMultiTF1.h.

◆ NDim()

template<class T>
unsigned int ROOT::Math::WrappedMultiTF1Templ< T >::NDim ( ) const
inlineoverridevirtual

Retrieve the dimension of the function.

Implements ROOT::Math::IBaseFunctionMultiDimTempl< T >.

Definition at line 94 of file WrappedMultiTF1.h.

◆ NPar()

template<class T>
unsigned int ROOT::Math::WrappedMultiTF1Templ< T >::NPar ( ) const
inlineoverridevirtual

return number of parameters

Implements ROOT::Math::IBaseParam.

Definition at line 114 of file WrappedMultiTF1.h.

◆ operator()() [1/2]

template<class T>
T ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::operator() ( const T * x) const
inlineinherited

Definition at line 248 of file IParamFunction.h.

◆ operator()() [2/2]

template<class T>
T ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::operator() ( const T * x,
const double * p ) const
inlineinherited

Definition at line 243 of file IParamFunction.h.

◆ operator=()

template<class T>
WrappedMultiTF1Templ< T > & ROOT::Math::WrappedMultiTF1Templ< T >::operator= ( const WrappedMultiTF1Templ< T > & rhs)

Assignment operator.

Definition at line 273 of file WrappedMultiTF1.h.

◆ ParameterDerivative() [1/2]

template<class T>
T ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::ParameterDerivative ( const T * x,
const double * p,
unsigned int ipar = 0 ) const
inlineinherited

Evaluate the partial derivative w.r.t a parameter ipar from values and parameters.

Definition at line 283 of file IParamFunction.h.

◆ ParameterDerivative() [2/2]

template<class T>
T ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::ParameterDerivative ( const T * x,
unsigned int ipar = 0 ) const
inlineinherited

Evaluate partial derivative using cached parameter values.

Definition at line 295 of file IParamFunction.h.

◆ ParameterG2()

template<class T>
bool ROOT::Math::WrappedMultiTF1Templ< T >::ParameterG2 ( const T * ,
const double * ,
T *  ) const
inlineoverridevirtual

Evaluate all the second derivatives (diagonal ones) of the function with respect to the parameters at a point x.

g2 is a vector of dimension npar

Reimplemented from ROOT::Math::IParametricGradFunctionMultiDimTempl< T >.

Definition at line 135 of file WrappedMultiTF1.h.

◆ ParameterGradient() [1/2]

template<class T>
void ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::ParameterGradient ( const T * x,
T * grad ) const
inlineinherited

Evaluate all derivatives using cached parameter values.

Definition at line 291 of file IParamFunction.h.

◆ ParameterGradient() [2/2]

template<class T>
void ROOT::Math::WrappedMultiTF1Templ< T >::ParameterGradient ( const T * x,
const double * p,
T * grad ) const
overridevirtual

Evaluate the all the derivatives (gradient vector) of the function with respect to the parameters at a point x.

It is optional to be implemented by the derived classes for better efficiency

Reimplemented from ROOT::Math::IParametricGradFunctionMultiDimTempl< T >.

Definition at line 286 of file WrappedMultiTF1.h.

◆ ParameterHessian()

template<class T>
bool ROOT::Math::WrappedMultiTF1Templ< T >::ParameterHessian ( const T * ,
const double * ,
T *  ) const
overridevirtual

Evaluate the all the Hessian (second derivatives matrix) of the function with respect to the parameters at a point x.

It is optional to be implemented by the derived classes if needed. If it is not implemented return a false. h must be dimensioned as a n x (n+1)/2 matrix (since it is a symmetric matrix)

Reimplemented from ROOT::Math::IParametricGradFunctionMultiDimTempl< T >.

Definition at line 347 of file WrappedMultiTF1.h.

◆ ParameterName()

template<class T>
std::string ROOT::Math::WrappedMultiTF1Templ< T >::ParameterName ( unsigned int i) const
inlineoverridevirtual

return parameter name (from TF1)

Reimplemented from ROOT::Math::IBaseParam.

Definition at line 121 of file WrappedMultiTF1.h.

◆ Parameters()

template<class T>
const double * ROOT::Math::WrappedMultiTF1Templ< T >::Parameters ( ) const
inlineoverridevirtual

get the parameter values (return values from TF1)

Implements ROOT::Math::IBaseParam.

Definition at line 100 of file WrappedMultiTF1.h.

◆ SetAndCopyFunction()

template<class T>
void ROOT::Math::WrappedMultiTF1Templ< T >::SetAndCopyFunction ( const TF1 * f = nullptr)

method to set a new function pointer and copy it inside.

By calling this method the class manages now the passed TF1 pointer

Definition at line 395 of file WrappedMultiTF1.h.

◆ SetDerivPrecision()

template<class T>
void ROOT::Math::WrappedMultiTF1Templ< T >::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 383 of file WrappedMultiTF1.h.

◆ SetParameters()

template<class T>
void ROOT::Math::WrappedMultiTF1Templ< T >::SetParameters ( const double * p)
inlineoverridevirtual

set parameter values (only the cached one in this class,leave unchanges those of TF1)

Implements ROOT::Math::IBaseParam.

Definition at line 107 of file WrappedMultiTF1.h.

Member Data Documentation

◆ fDim

template<class T>
unsigned int ROOT::Math::WrappedMultiTF1Templ< T >::fDim
private

Definition at line 188 of file WrappedMultiTF1.h.

◆ fFunc

template<class T>
TF1* ROOT::Math::WrappedMultiTF1Templ< T >::fFunc
private

Definition at line 187 of file WrappedMultiTF1.h.

◆ fLinear

template<class T>
bool ROOT::Math::WrappedMultiTF1Templ< T >::fLinear
private

Definition at line 184 of file WrappedMultiTF1.h.

◆ fOwnFunc

template<class T>
bool ROOT::Math::WrappedMultiTF1Templ< T >::fOwnFunc
private

Definition at line 186 of file WrappedMultiTF1.h.

◆ fPolynomial

template<class T>
bool ROOT::Math::WrappedMultiTF1Templ< T >::fPolynomial
private

Definition at line 185 of file WrappedMultiTF1.h.


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