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

GradFunctor1D class for one-dimensional gradient functions.

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

  1. from an object implementing both double operator()( double ) for the function evaluation and double Derivative(double ) for the partial derivatives
  2. from an object implementing any member function like Foo::XXX(double ) for the function evaluation and any other member function like Foo::YYY(double ) for the derivative.
  3. from an 2 function objects implementing double operator()( double ) . One object provides the function evaluation, the other the derivative.

Definition at line 271 of file Functor.h.

Public Types

typedef IBaseFunctionOneDim BaseFunc

Public Member Functions

 GradFunctor1D ()=default
 Default constructor.
template<typename Func>
 GradFunctor1D (const Func &f)
 Construct from an object with the right signature, implementing both operator() (double x) and Derivative(double x).
template<class PtrObj, typename MemFn, typename GradMemFn>
 GradFunctor1D (const PtrObj &p, MemFn memFn, GradMemFn gradFn)
 construct from a pointer to class and two pointers to member functions, one for the function evaluation and the other for the derivative.
 GradFunctor1D (std::function< double(double)> const &f, std::function< double(double)> const &g)
 Specialized constructor from 2 function objects implementing double operator()(double x).
GradFunctor1DClone () const override
 Clone a function.
double Derivative (const double *x) const
 Compatibility method with multi-dimensional interface for partial derivative.
double Derivative (double x) const
 Return the derivative of the function at a point x Use the private method DoDerivative.
void FdF (const double *x, double &f, double *df) const
 Compatibility method with multi-dimensional interface for Gradient and function evaluation.
virtual void FdF (double x, double &f, double &df) const
 Optimized method to evaluate at the same time the function value and derivative at a point x.
void Gradient (const double *x, double *g) const
 Compatibility method with multi-dimensional interface for Gradient.
bool HasGradient () const override
double operator() (const double *x) const
 Evaluate the function at a point x[].
double operator() (double x) const
 Evaluate the function at a point x.

Private Member Functions

double DoDerivative (double x) const override
 Function to evaluate the derivative with respect each coordinate. To be implemented by the derived class.
double DoEval (double x) const override
 implementation of the evaluation function. Must be implemented by derived classes

Private Attributes

std::function< double(double)> fDerivFunc
std::function< double(double)> fFunc

#include <Math/Functor.h>

Inheritance diagram for ROOT::Math::GradFunctor1D:
ROOT::Math::IGradientFunctionOneDim ROOT::Math::IBaseFunctionOneDim

Member Typedef Documentation

◆ BaseFunc

Definition at line 161 of file IFunction.h.

Constructor & Destructor Documentation

◆ GradFunctor1D() [1/4]

ROOT::Math::GradFunctor1D::GradFunctor1D ( )
default

Default constructor.

◆ GradFunctor1D() [2/4]

template<typename Func>
ROOT::Math::GradFunctor1D::GradFunctor1D ( const Func & f)
inline

Construct from an object with the right signature, implementing both operator() (double x) and Derivative(double x).

Definition at line 281 of file Functor.h.

◆ GradFunctor1D() [3/4]

template<class PtrObj, typename MemFn, typename GradMemFn>
ROOT::Math::GradFunctor1D::GradFunctor1D ( const PtrObj & p,
MemFn memFn,
GradMemFn gradFn )
inline

construct from a pointer to class and two pointers to member functions, one for the function evaluation and the other for the derivative.

The member functions must take a double as argument and return a double

Definition at line 289 of file Functor.h.

◆ GradFunctor1D() [4/4]

ROOT::Math::GradFunctor1D::GradFunctor1D ( std::function< double(double)> const & f,
std::function< double(double)> const & g )
inline

Specialized constructor from 2 function objects implementing double operator()(double x).

The first one for the function evaluation and the second one implementing the function derivative.

Definition at line 297 of file Functor.h.

Member Function Documentation

◆ Clone()

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

Clone a function.

Each derived class will implement their version of the private DoClone method.

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 302 of file Functor.h.

◆ Derivative() [1/2]

double ROOT::Math::IBaseFunctionOneDim::Derivative ( const double * x) const
inlineinherited

Compatibility method with multi-dimensional interface for partial derivative.

Definition at line 186 of file IFunction.h.

◆ Derivative() [2/2]

double ROOT::Math::IBaseFunctionOneDim::Derivative ( double x) const
inlineinherited

Return the derivative of the function at a point x Use the private method DoDerivative.

Definition at line 183 of file IFunction.h.

◆ DoDerivative()

double ROOT::Math::GradFunctor1D::DoDerivative ( double ) const
inlineoverrideprivatevirtual

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

Reimplemented from ROOT::Math::IBaseFunctionOneDim.

Definition at line 307 of file Functor.h.

◆ DoEval()

double ROOT::Math::GradFunctor1D::DoEval ( double x) const
inlineoverrideprivatevirtual

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

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 306 of file Functor.h.

◆ FdF() [1/2]

void ROOT::Math::IBaseFunctionOneDim::FdF ( const double * x,
double & f,
double * df ) const
inlineinherited

Compatibility method with multi-dimensional interface for Gradient and function evaluation.

Definition at line 202 of file IFunction.h.

◆ FdF() [2/2]

virtual void ROOT::Math::IBaseFunctionOneDim::FdF ( double x,
double & f,
double & 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::Polynomial, and ROOT::Math::WrappedTF1.

Definition at line 195 of file IFunction.h.

◆ Gradient()

void ROOT::Math::IBaseFunctionOneDim::Gradient ( const double * x,
double * g ) const
inlineinherited

Compatibility method with multi-dimensional interface for Gradient.

Definition at line 189 of file IFunction.h.

◆ HasGradient()

bool ROOT::Math::IGradientFunctionOneDim::HasGradient ( ) const
inlineoverridevirtualinherited

Reimplemented from ROOT::Math::IBaseFunctionOneDim.

Definition at line 266 of file IFunction.h.

◆ operator()() [1/2]

double ROOT::Math::IBaseFunctionOneDim::operator() ( const double * x) const
inlineinherited

Evaluate the function at a point x[].

Compatible method with multi-dimensional functions.

Definition at line 175 of file IFunction.h.

◆ operator()() [2/2]

double ROOT::Math::IBaseFunctionOneDim::operator() ( double x) const
inlineinherited

Evaluate the function at a point x.

Use the a pure virtual private method DoEval which must be implemented by sub-classes.

Definition at line 171 of file IFunction.h.

Member Data Documentation

◆ fDerivFunc

std::function<double(double)> ROOT::Math::GradFunctor1D::fDerivFunc
private

Definition at line 310 of file Functor.h.

◆ fFunc

std::function<double(double)> ROOT::Math::GradFunctor1D::fFunc
private

Definition at line 309 of file Functor.h.


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