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

typedef double BackendType
typedef IParamMultiGradFunction::BaseFunc BaseFunc
using BaseGradFunc
using BaseParamFunc

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
double Derivative (const double *x, unsigned int icoord, double *previous_grad, double *previous_g2, double *previous_gstep) const
 In some cases, the derivative algorithm will use information from the previous step, these can be passed in with this overload.
double Derivative (const double *x, unsigned int icoord=0) const
 Return the partial derivative with respect to the passed coordinate.
virtual void FdF (const double *x, double &f, double *df) const
 Optimized method to evaluate at the same time the function value and derivative at a point x.
virtual void Gradient (const double *x, double *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.
double operator() (const double *x) const
double operator() (const double *x, const double *p) const
MultiDimParamGradFunctionAdapteroperator= (const MultiDimParamGradFunctionAdapter &rhs)
 Assignment operator.
double ParameterDerivative (const double *x, const double *p, unsigned int ipar=0) const
 Evaluate the partial derivative w.r.t a parameter ipar from values and parameters.
double ParameterDerivative (const double *x, unsigned int ipar=0) const
 Evaluate partial derivative using cached parameter values.
virtual bool ParameterG2 (const double *, const double *, double *) 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, double *grad) const
 Evaluate all derivatives using cached parameter values.
void ParameterGradient (const double *x, const double *p, double *grad) const override
 Evaluate the all the derivatives (gradient vector) of the function with respect to the parameters at a point x.
virtual bool ParameterHessian (const double *, const double *, double *) 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

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
 functions needed by interface
double DoParameterDerivative (const double *x, const double *p, unsigned int ipar) const override
 Evaluate the partial derivative w.r.t a parameter ipar , to be implemented by the derived classes.

Private Attributes

IParamGradFunctionfFunc
bool fOwn

#include <Math/MultiDimParamFunctionAdapter.h>

Inheritance diagram for ROOT::Math::MultiDimParamGradFunctionAdapter:
ROOT::Math::IParametricGradFunctionMultiDimTempl< double > ROOT::Math::IParametricFunctionMultiDimTempl< double > ROOT::Math::IBaseParam ROOT::Math::IBaseFunctionMultiDimTempl< double > ROOT::Math::IBaseParam

Member Typedef Documentation

◆ BackendType

Definition at line 67 of file IFunction.h.

◆ BaseFunc

◆ BaseGradFunc

using ROOT::Math::IParametricGradFunctionMultiDimTempl< double >::BaseGradFunc
inherited

Definition at line 231 of file IParamFunction.h.

◆ BaseParamFunc

using ROOT::Math::IParametricGradFunctionMultiDimTempl< double >::BaseParamFunc
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]

double ROOT::Math::IBaseFunctionMultiDimTempl< double >::Derivative ( const double * x,
unsigned int icoord,
double * previous_grad,
double * previous_g2,
double * 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]

double ROOT::Math::IBaseFunctionMultiDimTempl< double >::Derivative ( const double * 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()

double ROOT::Math::IParametricGradFunctionMultiDimTempl< double >::DoEval ( const double * x) const
inlineoverrideprivatevirtualinherited

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

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

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

Definition at line 307 of file IParamFunction.h.

◆ DoEvalPar()

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

functions needed by interface

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

Definition at line 281 of file MultiDimParamFunctionAdapter.h.

◆ DoParameterDerivative()

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

Evaluate the partial derivative w.r.t a parameter ipar , to be implemented by the derived classes.

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

Definition at line 290 of file MultiDimParamFunctionAdapter.h.

◆ FdF()

virtual void ROOT::Math::IBaseFunctionMultiDimTempl< double >::FdF ( const double * x,
double & f,
double * 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.

◆ Gradient()

virtual void ROOT::Math::IBaseFunctionMultiDimTempl< double >::Gradient ( const double * x,
double * 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()

virtual bool ROOT::Math::IBaseFunctionMultiDimTempl< double >::HasGradient ( ) const
inlinevirtualinherited

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

Definition at line 92 of file IFunction.h.

◆ HasParameterHessian()

virtual bool ROOT::Math::IParametricGradFunctionMultiDimTempl< double >::HasParameterHessian ( ) const
inlinevirtualinherited

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

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

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]

double ROOT::Math::IParametricGradFunctionMultiDimTempl< double >::operator() ( const double * x) const
inlineinherited

Definition at line 248 of file IParamFunction.h.

◆ operator()() [2/2]

double ROOT::Math::IParametricGradFunctionMultiDimTempl< double >::operator() ( const double * 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]

double ROOT::Math::IParametricGradFunctionMultiDimTempl< double >::ParameterDerivative ( const double * 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]

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

Evaluate partial derivative using cached parameter values.

Definition at line 295 of file IParamFunction.h.

◆ ParameterG2()

virtual bool ROOT::Math::IParametricGradFunctionMultiDimTempl< double >::ParameterG2 ( const double * ,
const double * ,
double *  ) 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< double >.

Definition at line 278 of file IParamFunction.h.

◆ ParameterGradient() [1/2]

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

Evaluate all derivatives using cached parameter values.

Definition at line 291 of file IParamFunction.h.

◆ ParameterGradient() [2/2]

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

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

Definition at line 271 of file MultiDimParamFunctionAdapter.h.

◆ ParameterHessian()

virtual bool ROOT::Math::IParametricGradFunctionMultiDimTempl< double >::ParameterHessian ( const double * ,
const double * ,
double *  ) 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< double >.

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::VavilovAccurateCdf, ROOT::Math::VavilovAccuratePdf, ROOT::Math::VavilovAccurateQuantile, ROOT::Math::WrappedMultiTF1Templ< T >, ROOT::Math::WrappedMultiTF1Templ< double >, and ROOT::Math::WrappedTF1.

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: