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). | |
| BaseFunc * | Clone () 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 |
| MultiDimParamGradFunctionAdapter & | operator= (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 double * | Parameters () 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 | |
| IParamGradFunction * | fFunc |
| bool | fOwn |
#include <Math/MultiDimParamFunctionAdapter.h>
|
inherited |
Definition at line 67 of file IFunction.h.
Definition at line 176 of file MultiDimParamFunctionAdapter.h.
|
inherited |
Definition at line 231 of file IParamFunction.h.
|
inherited |
Definition at line 230 of file IParamFunction.h.
|
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.
|
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.
|
inline |
Copy constructor.
Different behaviour according if function is owned or not
Definition at line 202 of file MultiDimParamFunctionAdapter.h.
|
inlineoverride |
Destructor (no operations).
Definition at line 215 of file MultiDimParamFunctionAdapter.h.
|
inlineoverridevirtual |
clone
Implements ROOT::Math::IBaseFunctionMultiDimTempl< double >.
Definition at line 239 of file MultiDimParamFunctionAdapter.h.
|
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.
|
inlineinherited |
Return the partial derivative with respect to the passed coordinate.
Definition at line 115 of file IFunction.h.
|
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.
|
inlineoverrideprivatevirtual |
functions needed by interface
Implements ROOT::Math::IParametricGradFunctionMultiDimTempl< double >.
Definition at line 281 of file MultiDimParamFunctionAdapter.h.
|
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.
|
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.
|
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.
|
inlinevirtualinherited |
Reimplemented in ROOT::Math::IGradientFunctionMultiDimTempl< double >.
Definition at line 92 of file IFunction.h.
|
inlinevirtualinherited |
Reimplemented in ROOT::Math::WrappedMultiTF1Templ< double >.
Definition at line 265 of file IParamFunction.h.
|
inlineoverridevirtual |
Retrieve the dimension of the function.
Implements ROOT::Math::IBaseFunctionMultiDimTempl< double >.
Definition at line 262 of file MultiDimParamFunctionAdapter.h.
|
inlineoverridevirtual |
Return the number of Parameters.
Implements ROOT::Math::IBaseParam.
Definition at line 257 of file MultiDimParamFunctionAdapter.h.
|
inlineinherited |
Definition at line 248 of file IParamFunction.h.
|
inlineinherited |
Definition at line 243 of file IParamFunction.h.
|
inline |
Assignment operator.
Definition at line 224 of file MultiDimParamFunctionAdapter.h.
|
inlineinherited |
Evaluate the partial derivative w.r.t a parameter ipar from values and parameters.
Definition at line 283 of file IParamFunction.h.
|
inlineinherited |
Evaluate partial derivative using cached parameter values.
Definition at line 295 of file IParamFunction.h.
|
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.
|
inlineinherited |
Evaluate all derivatives using cached parameter values.
Definition at line 291 of file IParamFunction.h.
|
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.
|
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.
|
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.
|
inlineoverridevirtual |
Access the parameter values.
Implements ROOT::Math::IBaseParam.
Definition at line 247 of file MultiDimParamFunctionAdapter.h.
|
inlineoverridevirtual |
Set the parameter values.
| p | vector 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.
|
private |
Definition at line 298 of file MultiDimParamFunctionAdapter.h.
|
private |
Definition at line 297 of file MultiDimParamFunctionAdapter.h.