Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::Math::IGradientFunctionMultiDimTempl< T > Class Template Referenceabstract

template<class T>
class ROOT::Math::IGradientFunctionMultiDimTempl< T >

Interface (abstract class) for multi-dimensional functions providing a gradient calculation.

The method ROOT::Math::IFunction::Gradient calculates the full gradient vector, ROOT::Math::IFunction::Derivative calculates the partial derivative for each coordinate and ROOT::Math::Fdf calculates the gradient and the function value at the same time. The pure private virtual method DoDerivative() must be implemented by the derived classes, while Gradient and FdF are by default implemented using DoDerivative, butthey can be overloaded by the derived classes to improve the efficiency in the derivative calculation.

Gradient interface (abstract class) defining the signature for calculating the gradient of a multi-dimensional function. Three methods are provided:

  • Gradient(const double *x, double * grad) evaluate the full gradient vector at the vector value x
  • Derivative(const double * x, int icoord) evaluate the partial derivative for the icoord coordinate
  • FdF(const double *x, double &f, double * g) evaluate at the same time gradient and function/

Definition at line 239 of file IFunction.h.

Public Types

typedef T BackendType
typedef IBaseFunctionMultiDimTempl< T > BaseFunc

Public Member Functions

virtual IBaseFunctionMultiDimTempl< T > * Clone () const =0
 Clone a function.
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.
bool HasGradient () const override
virtual unsigned int NDim () const =0
 Retrieve the dimension of the function.
operator() (const T *x) const
 Evaluate the function at a point x[].

Private Member Functions

virtual T DoDerivative (const T *, unsigned int) const
 Function to evaluate the derivative with respect each coordinate. To be implemented by the derived class.
virtual T DoDerivativeWithPrevResult (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.
virtual T DoEval (const T *x) const =0
 Implementation of the evaluation function. Must be implemented by derived classes.

#include <Math/IFunction.h>

Inheritance diagram for ROOT::Math::IGradientFunctionMultiDimTempl< T >:
ROOT::Math::IBaseFunctionMultiDimTempl< T >

Member Typedef Documentation

◆ BackendType

template<class T>
typedef T ROOT::Math::IBaseFunctionMultiDimTempl< T >::BackendType
inherited

Definition at line 67 of file IFunction.h.

◆ BaseFunc

template<class T>
typedef IBaseFunctionMultiDimTempl<T> ROOT::Math::IBaseFunctionMultiDimTempl< T >::BaseFunc
inherited

Definition at line 68 of file IFunction.h.

Member Function Documentation

◆ Clone()

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

Reimplemented in ROOT::Math::GradFunctor, ROOT::Math::LSResidualFunc< Func >, ROOT::Math::MinimTransformFunction, and ROOT::Math::MultiNumGradFunction.

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()

◆ 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

Reimplemented in ROOT::Math::LSResidualFunc< Func >.

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

Reimplemented in ROOT::Math::GradFunctor, and ROOT::Math::LSResidualFunc< Func >.

Definition at line 96 of file IFunction.h.

◆ HasGradient()

template<class T>
bool ROOT::Math::IGradientFunctionMultiDimTempl< T >::HasGradient ( ) const
inlineoverridevirtual

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

Definition at line 243 of file IFunction.h.

◆ NDim()

◆ operator()()

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.


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