Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::Math::WrappedParamFunctionGen< FuncPtr > Class Template Reference

template<typename FuncPtr = FreeMultiFunctionPtr>
class ROOT::Math::WrappedParamFunctionGen< FuncPtr >

WrappedParamGenFunction class to wrap any multi-dimensional function implementing the operator()(const double * ) in an interface-like IParamFunction, by fixing some of the variables and define them as parameters.

i.e. transform any multi-dim function in a parametric function

Definition at line 143 of file WrappedParamFunction.h.

Public Types

typedef double BackendType
typedef IBaseFunctionMultiDimTempl< doubleBaseFunc

Public Member Functions

 WrappedParamFunctionGen (const FuncPtr &func, unsigned int dim, unsigned int npar, const double *par, const unsigned int *idx)
 Constructor a wrapped function from a pointer to a generic callable object implementation operator()(const double *), the new function dimension, the number of parameters (number of fixed variables) and an array specifying the index of the fixed variables which became parameters in the new API.
 WrappedParamFunctionGen (FuncPtr &func, unsigned int dim, unsigned int npar, const double *par, const unsigned int *idx)
 Constructor as before but taking now a non - const pointer to a callable object.
IMultiGenFunctionClone () const override
 clone the function
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
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.
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

 WrappedParamFunctionGen (const WrappedParamFunctionGen &)=delete
virtual double DoDerivative (const double *, unsigned int) const
 Function to evaluate the derivative with respect each coordinate. To be implemented by the derived class.
virtual double DoDerivativeWithPrevResult (const double *x, unsigned int icoord, double *, double *, double *) 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
 evaluate the function (re-implement for being more efficient)
double DoEvalPar (const double *x, const double *p) const override
 implement the required IParamFunction interface
void DoInit ()
WrappedParamFunctionGenoperator= (const WrappedParamFunctionGen &)=delete
void SetParValues (unsigned int npar, const double *p) const

Private Attributes

unsigned int fDim
FuncPtr fFunc
std::vector< doublefParams
std::vector< unsigned intfParIndices
std::vector< unsigned intfVarIndices
std::vector< doublefX

#include <Math/WrappedParamFunction.h>

Inheritance diagram for ROOT::Math::WrappedParamFunctionGen< FuncPtr >:
ROOT::Math::IParametricFunctionMultiDimTempl< double > ROOT::Math::IBaseFunctionMultiDimTempl< double > ROOT::Math::IBaseParam

Member Typedef Documentation

◆ BackendType

typedef double ROOT::Math::IBaseFunctionMultiDimTempl< double >::BackendType
inherited

Definition at line 67 of file IFunction.h.

◆ BaseFunc

Constructor & Destructor Documentation

◆ WrappedParamFunctionGen() [1/3]

template<typename FuncPtr = FreeMultiFunctionPtr>
ROOT::Math::WrappedParamFunctionGen< FuncPtr >::WrappedParamFunctionGen ( const FuncPtr & func,
unsigned int dim,
unsigned int npar,
const double * par,
const unsigned int * idx )
inline

Constructor a wrapped function from a pointer to a generic callable object implementation operator()(const double *), the new function dimension, the number of parameters (number of fixed variables) and an array specifying the index of the fixed variables which became parameters in the new API.

Definition at line 152 of file WrappedParamFunction.h.

◆ WrappedParamFunctionGen() [2/3]

template<typename FuncPtr = FreeMultiFunctionPtr>
ROOT::Math::WrappedParamFunctionGen< FuncPtr >::WrappedParamFunctionGen ( FuncPtr & func,
unsigned int dim,
unsigned int npar,
const double * par,
const unsigned int * idx )
inline

Constructor as before but taking now a non - const pointer to a callable object.

This constructor is needed in the case FuncPtr is a std::unique_ptr which has a copy ctor taking non const objects

Definition at line 166 of file WrappedParamFunction.h.

◆ WrappedParamFunctionGen() [3/3]

template<typename FuncPtr = FreeMultiFunctionPtr>
ROOT::Math::WrappedParamFunctionGen< FuncPtr >::WrappedParamFunctionGen ( const WrappedParamFunctionGen< FuncPtr > & )
privatedelete

Member Function Documentation

◆ Clone()

template<typename FuncPtr = FreeMultiFunctionPtr>
IMultiGenFunction * ROOT::Math::WrappedParamFunctionGen< FuncPtr >::Clone ( ) const
inlineoverridevirtual

clone the function

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

Definition at line 177 of file WrappedParamFunction.h.

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

◆ DoDerivative()

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

virtual double ROOT::Math::IBaseFunctionMultiDimTempl< double >::DoDerivativeWithPrevResult ( const double * x,
unsigned int icoord,
double * ,
double * ,
double *  ) 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<typename FuncPtr = FreeMultiFunctionPtr>
double ROOT::Math::WrappedParamFunctionGen< FuncPtr >::DoEval ( const double * x) const
inlineoverrideprivatevirtual

evaluate the function (re-implement for being more efficient)

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

Definition at line 213 of file WrappedParamFunction.h.

◆ DoEvalPar()

template<typename FuncPtr = FreeMultiFunctionPtr>
double ROOT::Math::WrappedParamFunctionGen< FuncPtr >::DoEvalPar ( const double * x,
const double * p ) const
inlineoverrideprivatevirtual

implement the required IParamFunction interface

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

Definition at line 240 of file WrappedParamFunction.h.

◆ DoInit()

template<typename FuncPtr = FreeMultiFunctionPtr>
void ROOT::Math::WrappedParamFunctionGen< FuncPtr >::DoInit ( )
inlineprivate

Definition at line 246 of file WrappedParamFunction.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

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

Definition at line 96 of file IFunction.h.

◆ HasGradient()

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

Definition at line 92 of file IFunction.h.

◆ NDim()

template<typename FuncPtr = FreeMultiFunctionPtr>
unsigned int ROOT::Math::WrappedParamFunctionGen< FuncPtr >::NDim ( ) const
inlineoverridevirtual

Retrieve the dimension of the function.

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

Definition at line 200 of file WrappedParamFunction.h.

◆ NPar()

template<typename FuncPtr = FreeMultiFunctionPtr>
unsigned int ROOT::Math::WrappedParamFunctionGen< FuncPtr >::NPar ( ) const
inlineoverridevirtual

Return the number of Parameters.

Implements ROOT::Math::IBaseParam.

Definition at line 198 of file WrappedParamFunction.h.

◆ operator()() [1/2]

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

Definition at line 128 of file IParamFunction.h.

◆ operator()() [2/2]

double ROOT::Math::IParametricFunctionMultiDimTempl< double >::operator() ( const 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 123 of file IParamFunction.h.

◆ operator=()

template<typename FuncPtr = FreeMultiFunctionPtr>
WrappedParamFunctionGen & ROOT::Math::WrappedParamFunctionGen< FuncPtr >::operator= ( const WrappedParamFunctionGen< FuncPtr > & )
privatedelete

◆ 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, ...").

Definition at line 86 of file IParamFunction.h.

◆ Parameters()

template<typename FuncPtr = FreeMultiFunctionPtr>
const double * ROOT::Math::WrappedParamFunctionGen< FuncPtr >::Parameters ( ) const
inlineoverridevirtual

Access the parameter values.

Implements ROOT::Math::IBaseParam.

Definition at line 188 of file WrappedParamFunction.h.

◆ SetParameters()

template<typename FuncPtr = FreeMultiFunctionPtr>
void ROOT::Math::WrappedParamFunctionGen< FuncPtr >::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 192 of file WrappedParamFunction.h.

◆ SetParValues()

template<typename FuncPtr = FreeMultiFunctionPtr>
void ROOT::Math::WrappedParamFunctionGen< FuncPtr >::SetParValues ( unsigned int npar,
const double * p ) const
inlineprivate

Definition at line 281 of file WrappedParamFunction.h.

Member Data Documentation

◆ fDim

template<typename FuncPtr = FreeMultiFunctionPtr>
unsigned int ROOT::Math::WrappedParamFunctionGen< FuncPtr >::fDim
private

Definition at line 291 of file WrappedParamFunction.h.

◆ fFunc

template<typename FuncPtr = FreeMultiFunctionPtr>
FuncPtr ROOT::Math::WrappedParamFunctionGen< FuncPtr >::fFunc
mutableprivate

Definition at line 290 of file WrappedParamFunction.h.

◆ fParams

template<typename FuncPtr = FreeMultiFunctionPtr>
std::vector<double> ROOT::Math::WrappedParamFunctionGen< FuncPtr >::fParams
private

Definition at line 292 of file WrappedParamFunction.h.

◆ fParIndices

template<typename FuncPtr = FreeMultiFunctionPtr>
std::vector<unsigned int> ROOT::Math::WrappedParamFunctionGen< FuncPtr >::fParIndices
private

Definition at line 294 of file WrappedParamFunction.h.

◆ fVarIndices

template<typename FuncPtr = FreeMultiFunctionPtr>
std::vector<unsigned int> ROOT::Math::WrappedParamFunctionGen< FuncPtr >::fVarIndices
private

Definition at line 293 of file WrappedParamFunction.h.

◆ fX

template<typename FuncPtr = FreeMultiFunctionPtr>
std::vector<double> ROOT::Math::WrappedParamFunctionGen< FuncPtr >::fX
mutableprivate

Definition at line 295 of file WrappedParamFunction.h.


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