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 an function object implementing double operator()( const double * ) for the function evaluation and another function object implementing double operator() (const double *, int icoord) for the partial derivatives

The function dimension is required when constructing the functor.

Definition at line 604 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 evaluatiion, 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.
 
virtual ~GradFunctor ()
 Destructor (no operations)
 
ImplBaseClone () const
 Clone a function.
 
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 ()
 virual 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/6]

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

Default constructor.

Definition at line 616 of file Functor.h.

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

◆ GradFunctor() [3/6]

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

◆ GradFunctor() [4/6]

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 evaluatiion, GradFunc the partial derivatives The function dimension is required

Definition at line 642 of file Functor.h.

◆ GradFunctor() [5/6]

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

◆ ~GradFunctor()

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

Destructor (no operations)

Definition at line 664 of file Functor.h.

◆ GradFunctor() [6/6]

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

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

Definition at line 670 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 688 of file Functor.h.

◆ DoDerivative()

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

Definition at line 701 of file Functor.h.

◆ DoEval()

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

Definition at line 696 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 691 of file Functor.h.

◆ operator=()

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

Assignment operator.

Definition at line 680 of file Functor.h.

Member Data Documentation

◆ fImpl

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

Definition at line 705 of file Functor.h.

Libraries for ROOT::Math::GradFunctor:

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