BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Math::IGradientFunctionMultiDimTempl< T > Class Template Referenceabstract

Description

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

Interface (abstract class) for multi-dimensional functions providing a gradient calculation. It implements both the ROOT::Math::IBaseFunctionMultiDimTempl and ROOT::Math::IGradientMultiDimTempl interfaces. 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.

Definition at line 326 of file IFunction.h.

Inheritance diagram for ROOT::Math::IGradientFunctionMultiDimTempl< T >:
[legend]
Collaboration diagram for ROOT::Math::IGradientFunctionMultiDimTempl< T >:
[legend]

Public Types

typedef T BackendType
 
typedef IBaseFunctionMultiDimTempl< T > BaseFunc
 
typedef IGradientMultiDimTempl< T > BaseGrad
 

Public Member Functions

virtual ~IGradientFunctionMultiDimTempl ()
 
virtual IBaseFunctionMultiDimTempl< T > * Clone () const =0
 
Derivative (const T *x, unsigned int icoord=0) const
 
virtual void FdF (const T *x, T &f, T *df) const
 
virtual void Gradient (const T *x, T *grad) const
 
virtual unsigned int NDim () const =0
 
virtual unsigned int NDim () const=0
 
operator() (const T *x) const
 

Private Member Functions

virtual T DoDerivative (const T *x, unsigned int icoord) const =0
 
virtual T DoEval (const T *x) const =0
 

Member Typedef Documentation

◆ BackendType

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

Definition at line 66 of file IFunction.h.

◆ BaseFunc

Definition at line 330 of file IFunction.h.

◆ BaseGrad

Definition at line 331 of file IFunction.h.

Constructor & Destructor Documentation

◆ ~IGradientFunctionMultiDimTempl()

template<class T >
virtual ROOT::Math::IGradientFunctionMultiDimTempl< T >::~IGradientFunctionMultiDimTempl ( )
inlinevirtual

Virtual Destructor (no operations)

Definition at line 336 of file IFunction.h.

336 {}

Member Function Documentation

◆ Clone()

◆ Derivative()

template<class T >
T ROOT::Math::IGradientMultiDimTempl< T >::Derivative ( const T *  x,
unsigned int  icoord = 0 
) const
inlineinherited

Return the partial derivative with respect to the passed coordinate

Definition at line 217 of file IFunction.h.

217 { return DoDerivative(x, icoord); }
virtual T DoDerivative(const T *x, unsigned int icoord) const =0

References ROOT::Math::IGradientMultiDimTempl< T >::DoDerivative().

Referenced by ROOT::Math::MinimTransformFunction::DoDerivative(), and ROOT::Math::IGradientFunctionMultiDimTempl< T >::Gradient().

Here is the call graph for this function:

◆ DoDerivative()

template<class T >
virtual T ROOT::Math::IGradientMultiDimTempl< T >::DoDerivative ( const T *  x,
unsigned int  icoord 
) const
privatepure virtualinherited

function to evaluate the derivative with respect each coordinate. To be implemented by the derived class

Referenced by ROOT::Math::IGradientMultiDimTempl< T >::Derivative().

◆ DoEval()

template<class T >
virtual T ROOT::Math::IBaseFunctionMultiDimTempl< T >::DoEval ( const T *  x) const
privatepure virtualinherited

Implementation of the evaluation function. Must be implemented by derived classes

Implemented in ROOT::Math::IParametricGradFunctionMultiDimTempl< T >, and ROOT::Math::IParametricFunctionMultiDimTempl< T >.

Referenced by ROOT::Math::IBaseFunctionMultiDimTempl< T >::operator()().

◆ FdF()

template<class T >
virtual void ROOT::Math::IGradientFunctionMultiDimTempl< T >::FdF ( const T *  x,
T &  f,
T *  df 
) const
inlinevirtual

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

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

Definition at line 357 of file IFunction.h.

358  {
359  f = BaseFunc::operator()(x);
360  Gradient(x, df);
361  }
virtual void Gradient(const T *x, T *grad) const
Definition: IFunction.h:342

References ROOT::Math::IGradientFunctionMultiDimTempl< T >::Gradient(), and ROOT::Math::IBaseFunctionMultiDimTempl< T >::operator()().

Here is the call graph for this function:

◆ Gradient()

template<class T >
virtual void ROOT::Math::IGradientFunctionMultiDimTempl< T >::Gradient ( const T *  x,
T *  grad 
) const
inlinevirtual

Evaluate all the vector of function derivatives (gradient) at a point x. Derived classes must re-implement it if more efficient than evaluting one at a time

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

Definition at line 342 of file IFunction.h.

343  {
344  unsigned int ndim = NDim();
345  for (unsigned int icoord = 0; icoord < ndim; ++icoord)
346  grad[icoord] = BaseGrad::Derivative(x, icoord);
347  }
virtual unsigned int NDim() const=0
T Derivative(const T *x, unsigned int icoord=0) const
Definition: IFunction.h:217

References ROOT::Math::IGradientMultiDimTempl< T >::Derivative(), and ROOT::Math::IGradientFunctionMultiDimTempl< T >::NDim().

Referenced by ROOT::Math::IGradientFunctionMultiDimTempl< T >::FdF().

Here is the call graph for this function:

◆ NDim() [1/2]

◆ NDim() [2/2]

◆ 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 92 of file IFunction.h.

93  {
94  return DoEval(x);
95  }
virtual T DoEval(const T *x) const =0

References ROOT::Math::IBaseFunctionMultiDimTempl< T >::DoEval().

Referenced by ROOT::Math::IGradientFunctionMultiDimTempl< T >::FdF().

Here is the call graph for this function:

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