Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches

GradFunctor class for Multidimensional gradient functions.

It is used to wrap in a very C++ callable object to make gradient functions. It can be constructed in three different way:

  1. from an object implementing both double operator()( const double * ) for the function evaluation and double Derivative(const double *, int icoord) for the partial derivatives
  2. from an object implementing any member function like Foo::XXX(const double *) for the function evaluation and any member function like Foo::XXX(const double *, int icoord) for the partial derivatives
  3. from two function objects implementing double operator()( const double * ) for the function evaluation and another function object implementing double operator() (const double *, int icoord) for the partial derivatives
  4. from two function objects

The function dimension is required when constructing the functor.

Definition at line 142 of file Functor.h.

Public Member Functions

 GradFunctor ()=default
 Default constructor.
 
template<typename Func >
 GradFunctor (const Func &f, unsigned int dim)
 construct from a callable object of multi-dimension implementing operator()(const double *x) and Derivative(const double * x,icoord)
 
template<class PtrObj , typename MemFn , typename DerivMemFn , std::enable_if_t< std::is_floating_point< decltype((std::declval< std::remove_pointer_t< PtrObj > >().*std::declval< DerivMemFn >())(std::declval< const double * >(), std::declval< int >()))>::value , bool >
 GradFunctor (const PtrObj &p, MemFn memFn, DerivMemFn gradFn, unsigned int dim)
 Construct from a pointer to member function and member function types for function and derivative evaluations.
 
template<class PtrObj , typename MemFn , typename GradMemFn , std::enable_if_t< std::is_void< decltype((std::declval< std::remove_pointer_t< PtrObj > >().*std::declval< GradMemFn >())(std::declval< const double * >(), std::declval< double * >()))>::value , bool >
 GradFunctor (const PtrObj &p, MemFn memFn, GradMemFn gradFn, unsigned int dim)
 Construct from a pointer to member function and member function, types for function and full derivative evaluations.
 
 GradFunctor (std::function< double(double const *)> const &f, std::function< double(double const *, unsigned int)> const &g, unsigned int dim)
 Construct for Gradient Functions of multi-dimension Func gives the function evaluation, GradFunc the partial derivatives The function dimension is required.
 
 GradFunctor (std::function< double(double const *)> const &f, unsigned int dim, std::function< void(double const *, double *)> const &g)
 Construct a new GradFunctor object using 2 std::function, one for the function evaluation and one for the Gradient Note the difference with the constructor above where partial derivative function is used as input.
 
GradFunctorClone () const override
 Clone a function.
 
void Gradient (const double *x, double *g) const override
 
unsigned int NDim () const override
 Retrieve the dimension of the function.
 
- Public Member Functions inherited from ROOT::Math::IGradientFunctionMultiDimTempl< T >
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.
 
virtual void GradientWithPrevResult (const T *x, T *grad, T *previous_grad, T *previous_g2, T *previous_gstep) const
 In some cases, the gradient algorithm will use information from the previous step, these can be passed in with this overload.
 
bool HasGradient () const
 
virtual unsigned int NDim () const=0
 Retrieve the dimension of the function.
 
virtual bool returnsInMinuit2ParameterSpace () const
 
- Public Member Functions inherited from ROOT::Math::IBaseFunctionMultiDimTempl< T >
virtual ~IBaseFunctionMultiDimTempl ()=default
 
operator() (const T *x) const
 Evaluate the function at a point x[].
 

Private Member Functions

double DoDerivative (const double *x, unsigned int icoord) const override
 
double DoEval (const double *x) const override
 

Private Attributes

std::function< double(double const *, unsigned int)> fDerivFunc
 
unsigned int fDim
 
std::function< double(const double *)> fFunc
 
std::function< void(const double *, double *)> fGradFunc
 

Additional Inherited Members

- Public Types inherited from ROOT::Math::IGradientFunctionMultiDimTempl< T >
typedef IBaseFunctionMultiDimTempl< T > BaseFunc
 
typedef IGradientFunctionMultiDimTempl< T > BaseGrad
 
- Public Types inherited from ROOT::Math::IBaseFunctionMultiDimTempl< T >
typedef T BackendType
 
typedef IBaseFunctionMultiDimTempl< T > BaseFunc
 

#include <Math/Functor.h>

Inheritance diagram for ROOT::Math::GradFunctor:
[legend]

Constructor & Destructor Documentation

◆ GradFunctor() [1/6]

ROOT::Math::GradFunctor::GradFunctor ( )
default

Default constructor.

◆ GradFunctor() [2/6]

template<typename Func >
ROOT::Math::GradFunctor::GradFunctor ( const Func &  f,
unsigned int  dim 
)
inline

construct from a callable object of multi-dimension implementing operator()(const double *x) and Derivative(const double * x,icoord)

Definition at line 156 of file Functor.h.

◆ GradFunctor() [3/6]

template<class PtrObj , typename MemFn , typename DerivMemFn , std::enable_if_t< std::is_floating_point< decltype((std::declval< std::remove_pointer_t< PtrObj > >().*std::declval< DerivMemFn >())(std::declval< const double * >(), std::declval< int >()))>::value , bool >
ROOT::Math::GradFunctor::GradFunctor ( const PtrObj &  p,
MemFn  memFn,
DerivMemFn  gradFn,
unsigned int  dim 
)
inline

Construct from a pointer to member function and member function types for function and derivative evaluations.

Definition at line 166 of file Functor.h.

◆ GradFunctor() [4/6]

template<class PtrObj , typename MemFn , typename GradMemFn , std::enable_if_t< std::is_void< decltype((std::declval< std::remove_pointer_t< PtrObj > >().*std::declval< GradMemFn >())(std::declval< const double * >(), std::declval< double * >()))>::value , bool >
ROOT::Math::GradFunctor::GradFunctor ( const PtrObj &  p,
MemFn  memFn,
GradMemFn  gradFn,
unsigned int  dim 
)
inline

Construct from a pointer to member function and member function, types for function and full derivative evaluations.

Definition at line 179 of file Functor.h.

◆ GradFunctor() [5/6]

ROOT::Math::GradFunctor::GradFunctor ( std::function< double(double const *)> const &  f,
std::function< double(double const *, unsigned int)> const &  g,
unsigned int  dim 
)
inline

Construct for Gradient Functions of multi-dimension Func gives the function evaluation, GradFunc the partial derivatives The function dimension is required.

Definition at line 189 of file Functor.h.

◆ GradFunctor() [6/6]

ROOT::Math::GradFunctor::GradFunctor ( std::function< double(double const *)> const &  f,
unsigned int  dim,
std::function< void(double const *, double *)> const &  g 
)
inline

Construct a new GradFunctor object using 2 std::function, one for the function evaluation and one for the Gradient Note the difference with the constructor above where partial derivative function is used as input.

Parameters
f: function object computing the function value
dim: number of function dimension
g: function object computing the function gradient

Definition at line 204 of file Functor.h.

Member Function Documentation

◆ Clone()

GradFunctor * ROOT::Math::GradFunctor::Clone ( ) const
inlineoverridevirtual

Clone a function.

Each derived class must implement their version of the Clone method.

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

Definition at line 210 of file Functor.h.

◆ DoDerivative()

double ROOT::Math::GradFunctor::DoDerivative ( const double x,
unsigned int  icoord 
) const
inlineoverrideprivate

Definition at line 231 of file Functor.h.

◆ DoEval()

double ROOT::Math::GradFunctor::DoEval ( const double x) const
inlineoverrideprivate

Definition at line 227 of file Functor.h.

◆ Gradient()

void ROOT::Math::GradFunctor::Gradient ( const double x,
double g 
) const
inlineoverride

Definition at line 215 of file Functor.h.

◆ NDim()

unsigned int ROOT::Math::GradFunctor::NDim ( ) const
inlineoverridevirtual

Retrieve the dimension of the function.

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

Definition at line 213 of file Functor.h.

Member Data Documentation

◆ fDerivFunc

std::function<double(double const *, unsigned int)> ROOT::Math::GradFunctor::fDerivFunc
private

Definition at line 245 of file Functor.h.

◆ fDim

unsigned int ROOT::Math::GradFunctor::fDim
private

Definition at line 243 of file Functor.h.

◆ fFunc

std::function<double(const double *)> ROOT::Math::GradFunctor::fFunc
private

Definition at line 244 of file Functor.h.

◆ fGradFunc

std::function<void(const double *, double*)> ROOT::Math::GradFunctor::fGradFunc
private

Definition at line 246 of file Functor.h.

Libraries for ROOT::Math::GradFunctor:

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