Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches

MultiDimParamFunctionAdapter class to wrap a one-dimensional parametric function in a multi dimensional parametric function interface This is used typically in fitting where internally the function is stored as multidimensional.

To wrap a non-parametric one-dim function in a multi-dim interface one can use simply a ROOT::Math::WrappedFunction<ROOT::Math::IGenFunction> or ROOT::Math::Functor and ROOT::Math::GradFunctor for gradient functions

This class differs from WrappedParamFunction in the fact that the parameters are not stored in the adapter class and optionally it keeps a cloned and managed copy of the adapter class.

Definition at line 41 of file MultiDimParamFunctionAdapter.h.

Public Types

typedefBackendType
 
typedef IParamMultiFunction::BaseFunc BaseFunc
 

Public Member Functions

 MultiDimParamFunctionAdapter (const IParamFunction &f)
 Constructor from a parametric one dim function interface from a const reference Own the function in this case.
 
 MultiDimParamFunctionAdapter (const MultiDimParamFunctionAdapter &rhs)
 Copy constructor.
 
 MultiDimParamFunctionAdapter (IParamFunction &f)
 Constructor from a parametric one dim function interface from a non-const reference Do not own the function in this case.
 
 ~MultiDimParamFunctionAdapter () override
 Destructor (no operations)
 
BaseFuncClone () const override
 clone
 
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
 
unsigned int NDim () const override
 Retrieve the dimension of the function.
 
unsigned int NPar () const override
 Return the number of Parameters.
 
double operator() (const double *x) const
 
double operator() (const double *x, const double *p) const
 Evaluate function at a point x and for given parameters p.
 
operator() (const T *x) const
 Evaluate the function at a point x[].
 
MultiDimParamFunctionAdapteroperator= (const MultiDimParamFunctionAdapter &rhs)
 Assignment operator.
 
virtual std::string ParameterName (unsigned int i) const
 Return the name of the i-th parameter (starting from zero) Overwrite if want to avoid the default name ("Par_0, Par_1, ...")
 
const doubleParameters () const override
 Access the parameter values.
 
void SetParameters (const double *p) override
 Set the parameter values.
 

Private Member Functions

virtualDoDerivative (const T *, unsigned int) const
 Function to evaluate the derivative with respect each coordinate. To be implemented by the derived class.
 
virtualDoDerivativeWithPrevResult (const T *x, unsigned int icoord, T *, T *, T *) const
 In some cases, the derivative algorithm will use information from the previous step, these can be passed in with this overload.
 
double DoEval (const double *x) const override
 Implement the ROOT::Math::IBaseFunctionMultiDim interface DoEval(x) using the cached parameter values.
 
double DoEvalPar (const double *x, const double *p) const override
 needed by the interface
 

Private Attributes

IParamFunctionfFunc
 
bool fOwn
 

#include <Math/MultiDimParamFunctionAdapter.h>

Inheritance diagram for ROOT::Math::MultiDimParamFunctionAdapter:
ROOT::Math::IParametricFunctionMultiDimTempl< double > 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

Constructor & Destructor Documentation

◆ MultiDimParamFunctionAdapter() [1/3]

ROOT::Math::MultiDimParamFunctionAdapter::MultiDimParamFunctionAdapter ( const IParamFunction & f)
inline

Constructor from a parametric one dim function interface from a const reference Own the function in this case.

Definition at line 52 of file MultiDimParamFunctionAdapter.h.

◆ MultiDimParamFunctionAdapter() [2/3]

ROOT::Math::MultiDimParamFunctionAdapter::MultiDimParamFunctionAdapter ( IParamFunction & f)
inline

Constructor from a parametric one dim function interface from a non-const reference Do not own the function in this case.

Definition at line 62 of file MultiDimParamFunctionAdapter.h.

◆ MultiDimParamFunctionAdapter() [3/3]

ROOT::Math::MultiDimParamFunctionAdapter::MultiDimParamFunctionAdapter ( const MultiDimParamFunctionAdapter & rhs)
inline

Copy constructor.

Different behaviour according if function is owned or not

Definition at line 71 of file MultiDimParamFunctionAdapter.h.

◆ ~MultiDimParamFunctionAdapter()

ROOT::Math::MultiDimParamFunctionAdapter::~MultiDimParamFunctionAdapter ( )
inlineoverride

Destructor (no operations)

Definition at line 84 of file MultiDimParamFunctionAdapter.h.

Member Function Documentation

◆ Clone()

BaseFunc * ROOT::Math::MultiDimParamFunctionAdapter::Clone ( ) const
inlineoverridevirtual

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

◆ DoDerivative()

template<class T >
virtual T ROOT::Math::IBaseFunctionMultiDimTempl< T >::DoDerivative ( const T * ,
unsigned int  ) const
inlineprivatevirtualinherited

Function to evaluate the derivative with respect each coordinate. To be implemented by the derived class.

Definition at line 131 of file IFunction.h.

◆ DoDerivativeWithPrevResult()

template<class T >
virtual T ROOT::Math::IBaseFunctionMultiDimTempl< T >::DoDerivativeWithPrevResult ( const T * x,
unsigned int icoord,
T * ,
T * ,
T *  ) const
inlineprivatevirtualinherited

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 136 of file IFunction.h.

◆ DoEval()

double ROOT::Math::IParametricFunctionMultiDimTempl< double >::DoEval ( const double * x) const
inlineoverrideprivateinherited

Implement the ROOT::Math::IBaseFunctionMultiDim interface DoEval(x) using the cached parameter values.

Definition at line 143 of file IParamFunction.h.

◆ DoEvalPar()

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

needed by the interface

Implements ROOT::Math::IParametricFunctionMultiDimTempl< double >.

Definition at line 140 of file MultiDimParamFunctionAdapter.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

Definition at line 108 of file IFunction.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

Definition at line 96 of file IFunction.h.

◆ HasGradient()

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

Reimplemented in ROOT::Math::IGradientFunctionMultiDimTempl< T >.

Definition at line 92 of file IFunction.h.

◆ NDim()

unsigned int ROOT::Math::MultiDimParamFunctionAdapter::NDim ( ) const
inlineoverridevirtual

Retrieve the dimension of the function.

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

Definition at line 131 of file MultiDimParamFunctionAdapter.h.

◆ NPar()

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

Return the number of Parameters.

Implements ROOT::Math::IBaseParam.

Definition at line 126 of file MultiDimParamFunctionAdapter.h.

◆ operator()() [1/3]

Definition at line 128 of file IParamFunction.h.

◆ operator()() [2/3]

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 123 of file IParamFunction.h.

◆ operator()() [3/3]

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

Evaluate the function at a point x[].

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

Definition at line 81 of file IFunction.h.

◆ operator=()

MultiDimParamFunctionAdapter & ROOT::Math::MultiDimParamFunctionAdapter::operator= ( const MultiDimParamFunctionAdapter & rhs)
inline

Assignment operator.

Definition at line 93 of file MultiDimParamFunctionAdapter.h.

◆ ParameterName()

virtual std::string ROOT::Math::IBaseParam::ParameterName ( unsigned int i) const
inlinevirtualinherited

Return the name of the i-th parameter (starting from zero) Overwrite if want to avoid the default name ("Par_0, Par_1, ...")

Reimplemented in ROOT::Math::WrappedMultiTF1Templ< T >, ROOT::Math::WrappedTF1, ROOT::Math::VavilovAccurateCdf, ROOT::Math::VavilovAccuratePdf, and ROOT::Math::VavilovAccurateQuantile.

Definition at line 86 of file IParamFunction.h.

◆ Parameters()

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

Access the parameter values.

Implements ROOT::Math::IBaseParam.

Definition at line 116 of file MultiDimParamFunctionAdapter.h.

◆ SetParameters()

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

Set the parameter values.

Parameters
pvector of doubles containing the parameter values.

to be defined: can user change number of params ? At the moment no.

Implements ROOT::Math::IBaseParam.

Definition at line 121 of file MultiDimParamFunctionAdapter.h.

Member Data Documentation

◆ fFunc

IParamFunction* ROOT::Math::MultiDimParamFunctionAdapter::fFunc
private

Definition at line 149 of file MultiDimParamFunctionAdapter.h.

◆ fOwn

bool ROOT::Math::MultiDimParamFunctionAdapter::fOwn
private

Definition at line 148 of file MultiDimParamFunctionAdapter.h.


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