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

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

To wrap a non-parametric one-dim gradient function in a multi-dim interface one can use simply a a ROOT::Math::GradFunctor

The parameters are not stored in the adapter class and by default the pointer to the 1D function is owned. This means that deleting the class deletes also the 1D function and copying the class copies also the 1D function 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 172 of file MultiDimParamFunctionAdapter.h.

Public Types

typedefBackendType
 
typedef IParamMultiGradFunction::BaseFunc BaseFunc
 
using BaseGradFunc = IGradientFunctionMultiDimTempl<T>
 
using BaseParamFunc = IParametricFunctionMultiDimTempl<T>
 

Public Member Functions

 MultiDimParamGradFunctionAdapter (const IParamGradFunction &f)
 Constructor from a param one dim function interface from a const reference Copy and manage the own function pointer.
 
 MultiDimParamGradFunctionAdapter (const MultiDimParamGradFunctionAdapter &rhs)
 Copy constructor.
 
 MultiDimParamGradFunctionAdapter (IParamGradFunction &f)
 Constructor from a param one dim function interface from a non const reference Do not own the function pointer in this case.
 
 ~MultiDimParamGradFunctionAdapter () 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
 
virtual bool HasParameterHessian () const
 
unsigned int NDim () const override
 Retrieve the dimension of the function.
 
unsigned int NPar () const override
 Return the number of Parameters.
 
operator() (const T *x) const
 
operator() (const T *x, const double *p) const
 
MultiDimParamGradFunctionAdapteroperator= (const MultiDimParamGradFunctionAdapter &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.
 
virtual bool ParameterG2 (const T *, const double *, T *) const
 Evaluate all the second derivatives (diagonal ones) of the function with respect to the parameters at a point x.
 
void ParameterGradient (const double *x, const double *p, double *grad) const override
 
virtual void ParameterGradient (const T *x, const double *p, T *grad) const
 Evaluate the all the derivatives (gradient vector) of the function with respect to the parameters at a point x.
 
void ParameterGradient (const T *x, T *grad) const
 Evaluate all derivatives using cached parameter values.
 
virtual bool ParameterHessian (const T *, const double *, T *) const
 Evaluate the all the Hessian (second derivatives matrix) of the function with respect to the parameters at a point x.
 
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.
 
DoEval (const T *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
 functions needed by interface
 
double DoParameterDerivative (const double *x, const double *p, unsigned int ipar) const override
 

Private Attributes

IParamGradFunctionfFunc
 
bool fOwn
 

#include <Math/MultiDimParamFunctionAdapter.h>

Inheritance diagram for ROOT::Math::MultiDimParamGradFunctionAdapter:
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

◆ BaseGradFunc

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

Definition at line 231 of file IParamFunction.h.

◆ BaseParamFunc

template<class T >
using ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::BaseParamFunc = IParametricFunctionMultiDimTempl<T>
inherited

Definition at line 230 of file IParamFunction.h.

Constructor & Destructor Documentation

◆ MultiDimParamGradFunctionAdapter() [1/3]

ROOT::Math::MultiDimParamGradFunctionAdapter::MultiDimParamGradFunctionAdapter ( const IParamGradFunction & f)
inline

Constructor from a param one dim function interface from a const reference Copy and manage the own function pointer.

Definition at line 183 of file MultiDimParamFunctionAdapter.h.

◆ MultiDimParamGradFunctionAdapter() [2/3]

ROOT::Math::MultiDimParamGradFunctionAdapter::MultiDimParamGradFunctionAdapter ( IParamGradFunction & f)
inline

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

Definition at line 193 of file MultiDimParamFunctionAdapter.h.

◆ MultiDimParamGradFunctionAdapter() [3/3]

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

Copy constructor.

Different behaviour according if function is owned or not

Definition at line 202 of file MultiDimParamFunctionAdapter.h.

◆ ~MultiDimParamGradFunctionAdapter()

ROOT::Math::MultiDimParamGradFunctionAdapter::~MultiDimParamGradFunctionAdapter ( )
inlineoverride

Destructor (no operations)

Definition at line 215 of file MultiDimParamFunctionAdapter.h.

Member Function Documentation

◆ Clone()

BaseFunc * ROOT::Math::MultiDimParamGradFunctionAdapter::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()

template<class T >
T ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::DoEval ( const T * x) const
inlineoverrideprivatevirtualinherited

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

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

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

Definition at line 307 of file IParamFunction.h.

◆ DoEvalPar()

double ROOT::Math::MultiDimParamGradFunctionAdapter::DoEvalPar ( const double * x,
const double * p ) const
inlineoverrideprivate

functions needed by interface

Definition at line 281 of file MultiDimParamFunctionAdapter.h.

◆ DoParameterDerivative()

double ROOT::Math::MultiDimParamGradFunctionAdapter::DoParameterDerivative ( const double * x,
const double * p,
unsigned int ipar ) const
inlineoverrideprivate

Definition at line 290 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.

◆ HasParameterHessian()

template<class T >
virtual bool ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::HasParameterHessian ( ) const
inlinevirtualinherited

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

Definition at line 265 of file IParamFunction.h.

◆ NDim()

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

Retrieve the dimension of the function.

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

Definition at line 262 of file MultiDimParamFunctionAdapter.h.

◆ NPar()

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

Return the number of Parameters.

Implements ROOT::Math::IBaseParam.

Definition at line 257 of file MultiDimParamFunctionAdapter.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=()

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

Assignment operator.

Definition at line 224 of file MultiDimParamFunctionAdapter.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 >
virtual bool ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::ParameterG2 ( const T * ,
const double * ,
T *  ) const
inlinevirtualinherited

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 in ROOT::Math::WrappedMultiTF1Templ< T >.

Definition at line 278 of file IParamFunction.h.

◆ ParameterGradient() [1/3]

void ROOT::Math::MultiDimParamGradFunctionAdapter::ParameterGradient ( const double * x,
const double * p,
double * grad ) const
inlineoverride

Definition at line 271 of file MultiDimParamFunctionAdapter.h.

◆ ParameterGradient() [2/3]

template<class T >
virtual void ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::ParameterGradient ( const T * x,
const double * p,
T * grad ) const
inlinevirtualinherited

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 in ROOT::Math::WrappedMultiTF1Templ< T >.

Definition at line 257 of file IParamFunction.h.

◆ ParameterGradient() [3/3]

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.

◆ ParameterHessian()

template<class T >
virtual bool ROOT::Math::IParametricGradFunctionMultiDimTempl< T >::ParameterHessian ( const T * ,
const double * ,
T *  ) const
inlinevirtualinherited

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 in ROOT::Math::WrappedMultiTF1Templ< T >.

Definition at line 272 of file IParamFunction.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::MultiDimParamGradFunctionAdapter::Parameters ( ) const
inlineoverridevirtual

Access the parameter values.

Implements ROOT::Math::IBaseParam.

Definition at line 247 of file MultiDimParamFunctionAdapter.h.

◆ SetParameters()

void ROOT::Math::MultiDimParamGradFunctionAdapter::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 252 of file MultiDimParamFunctionAdapter.h.

Member Data Documentation

◆ fFunc

IParamGradFunction* ROOT::Math::MultiDimParamGradFunctionAdapter::fFunc
private

Definition at line 298 of file MultiDimParamFunctionAdapter.h.

◆ fOwn

bool ROOT::Math::MultiDimParamGradFunctionAdapter::fOwn
private

Definition at line 297 of file MultiDimParamFunctionAdapter.h.


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