14#ifndef ROOT_Math_Functor
15#define ROOT_Math_Functor
43template<
class IBaseFunc>
76template<
class ParentFunctor,
class Func >
120 inline double DoEval (
const double *
x)
const {
125 return fFunc.Derivative(
x);
129 return fFunc.Derivative(
x,icoord);
152template<
class ParentFunctor,
class Func,
class DerivFunc >
186 typename ParentFunctor::ImplBase*
Clone()
const {
return Copy(); }
202 inline double DoEval (
const double *
x)
const {
233template<
class ParentFunctor >
244 FunctorGradHandler(
unsigned int dim, std::function<
double(
const double *)> fun, std::function<
void(
const double *,
double*)> gfun) :
261 typename ParentFunctor::ImplBase*
Clone()
const {
return Copy(); }
277 inline double DoEval (
const double *
x)
const {
282 std::vector<double>
g(
fDim);
291 mutable std::function<void(
const double *,
double*)>
fGradFunc;
303template <
class ParentFunctor,
typename PointerToObj,
304 typename PointerToMemFn>
319 MemFunHandler(
unsigned int dim,
const PointerToObj& pObj, PointerToMemFn pMemFn)
342 inline double DoEval (
const double *
x)
const {
363template <
class ParentFunctor,
typename PointerToObj,
364 typename PointerToMemFn,
typename PointerToGradMemFn>
374 MemGradFunHandler(
const PointerToObj& pObj, PointerToMemFn pMemFn, PointerToGradMemFn pGradMemFn)
383 const PointerToObj& pObj,
384 PointerToMemFn pMemFn,
385 PointerToGradMemFn pGradMemFn )
411 inline double DoEval (
const double *
x)
const {
490 template <
class PtrObj,
typename MemFn>
491 Functor(
const PtrObj&
p, MemFn memFn,
unsigned int dim )
501 template <
typename Func>
513 Functor(
const std::function<
double(
double const *)> &
f,
unsigned int dim)
529 fImpl = std::unique_ptr<Impl>((rhs.
fImpl)->Copy());
553 inline double DoEval (
const double *
x)
const {
595 template <
typename Func>
604 template <
class PtrObj,
typename MemFn>
632 fImpl = std::unique_ptr<Impl>( (rhs.
fImpl)->Copy() );
696 template <
typename Func>
704 template <
class PtrObj,
typename MemFn,
typename GradMemFn>
705 GradFunctor(
const PtrObj&
p, MemFn memFn, GradMemFn gradFn,
unsigned int dim )
714 template <
typename Func,
typename GradFunc>
729 const std::function<
double(
double const *,
unsigned int)> &
g,
unsigned int dim)
745 const std::function<
void(
double const *,
double *)> &
g)
762 fImpl = std::unique_ptr<Impl>(rhs.
fImpl->Copy());
788 inline double DoEval (
const double *
x)
const {
794 return fImpl->Derivative(
x,icoord);
841 template <
typename Func>
852 template <
class PtrObj,
typename MemFn,
typename GradMemFn>
862 template <
typename Func,
typename GradFunc>
874 GradFunctor1D(
const std::function<
double(
double)> &
f,
const std::function<
double(
double)> &
g )
892 fImpl = std::unique_ptr<Impl>( rhs.
fImpl->Copy() );
919 return fImpl->Derivative(
x);
winID h TVirtualViewer3D TVirtualGLPainter p
Functor1D class for one-dimensional functions.
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes
IBaseFunctionOneDim::BaseFunc ImplBase
virtual ~Functor1D()
Destructor (no operations)
Functor1D & operator=(const Functor1D &rhs)
Assignment operator.
FunctorImpl< IBaseFunctionOneDim > Impl
Functor1D(const Functor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGenFunction.
Functor1D(const std::function< double(double)> &f)
specialized constructor from a std::function implementing the function evaluation.
ImplBase * Clone() const
Clone a function.
Functor1D(const PtrObj &p, MemFn memFn)
construct from a pointer to member function (1D type)
Functor1D(const Func &f)
construct from a callable object with the right signature implementing operator() (double x)
std::unique_ptr< Impl > fImpl
Functor1D()
Default constructor.
Functor Handler class for gradient functions where both callable objects are provided for the functio...
double DoDerivative(const double *x, unsigned int icoord) const
FunctorDerivHandler(const Func &fun, const DerivFunc &gfun)
ImplFunc::BaseFunc BaseFunc
FunctorDerivHandler(unsigned int dim, const Func &fun, const DerivFunc &gfun)
unsigned int NDim() const
ParentFunctor::Impl ImplFunc
double DoDerivative(double x) const
double DoEval(double x) const
virtual ~FunctorDerivHandler()
double DoEval(const double *x) const
Functor Handler class for gradient functions where both callable objects are provided for the functio...
std::function< void(const double *, double *)> fGradFunc
void Gradient(const double *x, double *g) const
ImplFunc::BaseFunc BaseFunc
unsigned int NDim() const
ParentFunctor::Impl ImplFunc
FunctorGradHandler(unsigned int dim, std::function< double(const double *)> fun, std::function< void(const double *, double *)> gfun)
virtual ~FunctorGradHandler()
double DoDerivative(const double *x, unsigned int icoord) const
double DoEval(const double *x) const
std::function< double(const double *)> fFunc
Functor Handler class is responsible for wrapping any other functor and pointer to free C functions.
unsigned int NDim() const
FunctorHandler(unsigned int dim, const Func &fun)
double DoEval(const double *x) const
double DoDerivative(const double *x, unsigned int icoord) const
ParentFunctor::Impl ImplFunc
double DoDerivative(double x) const
double DoEval(double x) const
virtual ~FunctorHandler()
ImplFunc::BaseFunc BaseFunc
FunctorHandler(const Func &fun)
FunctorImpl is a base class for the functor handler implementation class.
virtual FunctorImpl * Copy() const =0
Documentation for class Functor class.
Functor(const Functor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGenFunction.
Functor()
Default constructor.
unsigned int NDim() const
Retrieve the dimension of the function.
virtual ~Functor()
Destructor (no operations)
FunctorImpl< IBaseFunctionMultiDim > Impl
ImplBase * Clone() const
Clone a function.
Functor & operator=(const Functor &rhs)
Assignment operator.
double DoEval(const double *x) const
Implementation of the evaluation function.
Functor(const Func &f, unsigned int dim)
construct from a callable object of multi-dimension with the right signature (implementing operator()...
Functor(const std::function< double(double const *)> &f, unsigned int dim)
specialized constructor from a std::function of multi-dimension with the right signature (double oper...
std::unique_ptr< Impl > fImpl
IBaseFunctionMultiDim::BaseFunc ImplBase
Functor(const PtrObj &p, MemFn memFn, unsigned int dim)
construct from a pointer to member function (multi-dim type)
GradFunctor1D class for one-dimensional gradient functions.
IGradientFunctionOneDim::BaseFunc ImplBase
GradFunctor1D(const Func &f, const GradFunc &g)
construct from two 1D function objects
ImplBase * Clone() const
Clone a function.
FunctorImpl< IGradientFunctionOneDim > Impl
GradFunctor1D(const PtrObj &p, MemFn memFn, GradMemFn gradFn)
construct from a pointer to class and two pointers to member functions, one for the function evaluati...
GradFunctor1D(const Func &f)
construct from an object with the right signature implementing both operator() (double x) and Derivat...
std::unique_ptr< Impl > fImpl
GradFunctor1D()
Default constructor.
GradFunctor1D & operator=(const GradFunctor1D &rhs)
Assignment operator.
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes
virtual ~GradFunctor1D()
Destructor (no operations)
GradFunctor1D(const std::function< double(double)> &f, const std::function< double(double)> &g)
specialized constructor from 2 std::function objects implementing double operator()(double x).
double DoDerivative(double x) const
function to evaluate the derivative with respect each coordinate.
GradFunctor1D(const GradFunctor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGradFunction.
GradFunctor class for Multidimensional gradient functions.
GradFunctor & operator=(const GradFunctor &rhs)
Assignment operator.
GradFunctor(const Func &f, const GradFunc &g, int dim)
construct for Gradient Functions of multi-dimension Func gives the function evaluation,...
virtual ~GradFunctor()
Destructor (no operations)
IGradientFunctionMultiDim::BaseFunc ImplBase
double DoDerivative(const double *x, unsigned int icoord) const
void Gradient(const double *x, double *g) const
ImplBase * Clone() const
Clone a function.
GradFunctor(const GradFunctor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGradFunction.
GradFunctor()
Default constructor.
std::unique_ptr< Impl > fImpl
unsigned int NDim() const
Retrieve the dimension of the function.
GradFunctor(const Func &f, unsigned int dim)
construct from a callable object of multi-dimension implementing operator()(const double *x) and Deri...
FunctorImpl< IGradientFunctionMultiDim > Impl
double DoEval(const double *x) const
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 do...
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 eva...
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...
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Interface (abstract class) for one-dimensional functions providing a gradient calculation.
Functor Handler to Wrap pointers to member functions The member function type must be (XXX means any ...
ImplFunc::BaseFunc BaseFunc
ParentFunctor::Impl ImplFunc
unsigned int NDim() const
MemFunHandler(const PointerToObj &pObj, PointerToMemFn pMemFn)
constructor from a pointer to the class and a pointer to the function
double DoEval(const double *x) const
MemFunHandler(unsigned int dim, const PointerToObj &pObj, PointerToMemFn pMemFn)
constructor from a pointer to the class and a pointer to the function
double DoEval(double x) const
Functor Handler to Wrap pointers to member functions for the evaluation of the function and the gradi...
double DoEval(double x) const
MemGradFunHandler(unsigned int dim, const PointerToObj &pObj, PointerToMemFn pMemFn, PointerToGradMemFn pGradMemFn)
constructor from a pointer to the class and a pointer to the function
double DoDerivative(double x) const
double DoDerivative(const double *x, unsigned int icoord) const
ImplFunc::BaseFunc BaseFunc
virtual ~MemGradFunHandler()
ParentFunctor::Impl ImplFunc
PointerToGradMemFn fGradMemFn
unsigned int NDim() const
double DoEval(const double *x) const
MemGradFunHandler(const PointerToObj &pObj, PointerToMemFn pMemFn, PointerToGradMemFn pGradMemFn)
constructor from a pointer to the class and a pointer to the function
Namespace for new Math classes and functions.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.