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 677 of file Functor.h.

Public Types

typedef FunctorImpl< IGradientFunctionMultiDimImpl
 
typedef IGradientFunctionMultiDim::BaseFunc ImplBase
 
- Public Types inherited from ROOT::Math::IGradientFunctionMultiDimTempl< T >
typedef IBaseFunctionMultiDimTempl< T > BaseFunc
 
typedef IGradientMultiDimTempl< T > BaseGrad
 
- Public Types inherited from ROOT::Math::IBaseFunctionMultiDimTempl< T >
typedef T BackendType
 
typedef IBaseFunctionMultiDimTempl< T > BaseFunc
 

Public Member Functions

 GradFunctor ()
 Default constructor.
 
template<typename Func , typename GradFunc >
 GradFunctor (const Func &f, const GradFunc &g, int dim)
 construct for Gradient Functions of multi-dimension Func gives the function evaluation, GradFunc the partial derivatives The function dimension is required
 
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)
 
 GradFunctor (const GradFunctor &rhs)
 Copy constructor for functor based on ROOT::Math::IMultiGradFunction.
 
template<class PtrObj , typename MemFn , typename GradMemFn >
 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 derivative evaluations
 
 GradFunctor (const std::function< double(double const *)> &f, const std::function< double(double const *, unsigned int)> &g, unsigned int dim)
 specialized constructor from 2 std::functions with the right signature (the first one implementing double operator()(double const *x) for the function evaluation and the second one implementing double operator()(double const *x, unsigned int icoord) for the function partial derivatives.
 
 GradFunctor (const std::function< double(double const *)> &f, int dim, const std::function< void(double const *, double *)> &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.
 
virtual ~GradFunctor ()
 Destructor (no operations)
 
ImplBaseClone () const
 Clone a function.
 
void Gradient (const double *x, double *g) const
 
unsigned int NDim () const
 Retrieve the dimension of the function.
 
GradFunctoroperator= (const GradFunctor &rhs)
 Assignment operator.
 
- Public Member Functions inherited from ROOT::Math::IGradientFunctionMultiDimTempl< T >
virtual ~IGradientFunctionMultiDimTempl ()
 Virtual Destructor (no operations)
 
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.
 
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 >
 IBaseFunctionMultiDimTempl ()
 
virtual ~IBaseFunctionMultiDimTempl ()
 virtual destructor
 
operator() (const T *x) const
 Evaluate the function at a point x[].
 
- Public Member Functions inherited from ROOT::Math::IGradientMultiDimTempl< T >
virtual ~IGradientMultiDimTempl ()
 virtual destructor
 
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.
 

Private Member Functions

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

Private Attributes

std::unique_ptr< ImplfImpl
 

#include <Math/Functor.h>

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

Member Typedef Documentation

◆ Impl

◆ ImplBase

Constructor & Destructor Documentation

◆ GradFunctor() [1/7]

ROOT::Math::GradFunctor::GradFunctor ( )
inline

Default constructor.

Definition at line 689 of file Functor.h.

◆ GradFunctor() [2/7]

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 697 of file Functor.h.

◆ GradFunctor() [3/7]

template<class PtrObj , typename MemFn , typename GradMemFn >
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 derivative evaluations

Definition at line 705 of file Functor.h.

◆ GradFunctor() [4/7]

template<typename Func , typename GradFunc >
ROOT::Math::GradFunctor::GradFunctor ( const Func &  f,
const GradFunc &  g,
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 715 of file Functor.h.

◆ GradFunctor() [5/7]

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

specialized constructor from 2 std::functions with the right signature (the first one implementing double operator()(double const *x) for the function evaluation and the second one implementing double operator()(double const *x, unsigned int icoord) for the function partial derivatives.

This specialized constructor is introduced in order to use the Functor class in Python passing Python user defined functions

Definition at line 728 of file Functor.h.

◆ GradFunctor() [6/7]

ROOT::Math::GradFunctor::GradFunctor ( const std::function< double(double const *)> &  f,
int  dim,
const std::function< void(double const *, double *)> &  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 744 of file Functor.h.

◆ ~GradFunctor()

virtual ROOT::Math::GradFunctor::~GradFunctor ( )
inlinevirtual

Destructor (no operations)

Definition at line 752 of file Functor.h.

◆ GradFunctor() [7/7]

ROOT::Math::GradFunctor::GradFunctor ( const GradFunctor rhs)
inline

Copy constructor for functor based on ROOT::Math::IMultiGradFunction.

Definition at line 758 of file Functor.h.

Member Function Documentation

◆ Clone()

ImplBase * ROOT::Math::GradFunctor::Clone ( ) const
inlinevirtual

Clone a function.

Each derived class must implement their version of the Clone method

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

Definition at line 776 of file Functor.h.

◆ DoDerivative()

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

Definition at line 793 of file Functor.h.

◆ DoEval()

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

Definition at line 788 of file Functor.h.

◆ Gradient()

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

Definition at line 781 of file Functor.h.

◆ NDim()

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

Retrieve the dimension of the function.

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

Definition at line 779 of file Functor.h.

◆ operator=()

GradFunctor & ROOT::Math::GradFunctor::operator= ( const GradFunctor rhs)
inline

Assignment operator.

Definition at line 768 of file Functor.h.

Member Data Documentation

◆ fImpl

std::unique_ptr<Impl> ROOT::Math::GradFunctor::fImpl
private

Definition at line 797 of file Functor.h.

Libraries for ROOT::Math::GradFunctor:

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