14 #ifndef ROOT_Math_Functor 15 #define ROOT_Math_Functor 42 template<
class IBaseFunc>
75 template<
class ParentFunctor,
class Func >
119 inline double DoEval (
const double *
x)
const {
124 return fFunc.Derivative(x);
128 return fFunc.Derivative(x,icoord);
151 template<
class ParentFunctor,
class Func,
class GradFunc >
194 inline double DoEval (
const double *
x)
const {
203 return fGradFunc(x, icoord);
223 template <
class ParentFunctor,
typename PointerToObj,
224 typename PointerToMemFn>
235 : fDim(1), fObj(pObj), fMemFn(pMemFn)
239 MemFunHandler(
unsigned int dim,
const PointerToObj& pObj, PointerToMemFn pMemFn)
240 : fDim(dim), fObj(pObj), fMemFn(pMemFn)
259 return ((*fObj).*fMemFn)(
x);
262 inline double DoEval (
const double *
x)
const {
263 return ((*fObj).*fMemFn)(
x);
283 template <
class ParentFunctor,
typename PointerToObj,
284 typename PointerToMemFn,
typename PointerToGradMemFn>
294 MemGradFunHandler(
const PointerToObj& pObj, PointerToMemFn pMemFn, PointerToGradMemFn pGradMemFn)
298 fGradMemFn(pGradMemFn)
303 const PointerToObj& pObj,
304 PointerToMemFn pMemFn,
305 PointerToGradMemFn pGradMemFn )
309 fGradMemFn(pGradMemFn)
328 return ((*fObj).*fMemFn)(
x);
331 inline double DoEval (
const double *
x)
const {
332 return ((*fObj).*fMemFn)(
x);
336 return ((*fObj).*fGradMemFn)(
x);
340 return ((*fObj).*fGradMemFn)(
x,icoord);
409 template <
class PtrObj,
typename MemFn>
410 Functor(
const PtrObj& p, MemFn memFn,
unsigned int dim )
420 template <
typename Func>
438 fImpl = std::unique_ptr<Impl>((rhs.
fImpl)->
Copy());
448 fImpl.swap(copy.
fImpl);
457 unsigned int NDim()
const {
return fImpl->NDim(); }
462 inline double DoEval (
const double *
x)
const {
504 template <
typename Func>
513 template <
class PtrObj,
typename MemFn>
533 fImpl = std::unique_ptr<Impl>( (rhs.
fImpl)->
Copy() );
542 fImpl.swap(copy.
fImpl);
596 template <
typename Func>
604 template <
class PtrObj,
typename MemFn,
typename GradMemFn>
605 GradFunctor(
const PtrObj& p, MemFn memFn, GradMemFn gradFn,
unsigned int dim )
614 template <
typename Func,
typename GradFunc>
633 fImpl = std::unique_ptr<Impl>(rhs.
fImpl->Copy());
641 fImpl.swap(copy.
fImpl);
650 unsigned int NDim()
const {
return fImpl->NDim(); }
655 inline double DoEval (
const double *
x)
const {
661 return fImpl->Derivative(x,icoord);
708 template <
typename Func>
719 template <
class PtrObj,
typename MemFn,
typename GradMemFn>
729 template <
typename Func,
typename GradFunc>
748 fImpl = std::unique_ptr<Impl>( rhs.
fImpl->Copy() );
757 fImpl.swap(copy.
fImpl);
775 return fImpl->Derivative(x);
double DoDerivative(double x) const
FunctorHandler(const Func &fun)
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
GradFunctor1D(const Func &f, const GradFunc &g)
construct from two 1D function objects
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes ...
FunctorImpl< IBaseFunctionMultiDim > Impl
unsigned int NDim() const
Retrieve the dimension of the function.
Functor Handler class is responsible for wrapping any other functor and pointer to free C functions...
double DoEval(double x) const
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
FunctorImpl< IGradientFunctionMultiDim > Impl
double DoDerivative(const double *x, unsigned int icoord) const
MemFunHandler(const PointerToObj &pObj, PointerToMemFn pMemFn)
constructor from a pointer to the class and a pointer to the function
virtual ~FunctorGradHandler()
Namespace for new ROOT classes and functions.
GradFunctor class for Multidimensional gradient functions.
GradFunctor1D class for one-dimensional gradient functions.
FunctorImpl< IGradientFunctionOneDim > Impl
GradFunctor1D(const GradFunctor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGradFunction.
Documentation for class Functor class.
double DoEval(const double *x) const
virtual FunctorImpl * Copy() const =0
double DoEval(const double *x) const
ImplBase * Clone() const
Clone a function.
IBaseFunctionOneDim::BaseFunc ImplBase
GradFunctor1D(const Func &f)
construct from an object with the right signature implementing both operator() (double x) and Derivat...
virtual ~MemGradFunHandler()
double DoEval(const double *x) const
GradFunctor()
Default constructor.
double DoDerivative(const double *x, unsigned int icoord) const
unsigned int NDim() const
ImplBase * Clone() const
Clone a function.
std::unique_ptr< Impl > fImpl
unsigned int NDim() const
FunctorHandler(unsigned int dim, const Func &fun)
MemGradFunHandler(const PointerToObj &pObj, PointerToMemFn pMemFn, PointerToGradMemFn pGradMemFn)
constructor from a pointer to the class and a pointer to the function
Interface (abstract class) for one-dimensional functions providing a gradient calculation.
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
double DoEval(double x) const
double DoEval(const double *x) const
GradFunctor(const Func &f, unsigned int dim)
construct from a callable object of multi-dimension implementing operator()(const double *x) and Deri...
double DoDerivative(const double *x, unsigned int icoord) const
function to evaluate the derivative with respect each coordinate.
double DoDerivative(double x) const
ImplFunc::BaseFunc BaseFunc
FunctorGradHandler(unsigned int dim, const Func &fun, const GradFunc &gfun)
virtual ~GradFunctor()
Destructor (no operations)
Functor(const Func &f, unsigned int dim)
construct from a callable object of multi-dimension with the right signature (implementing operator()...
ParentFunctor::Impl ImplFunc
double DoEval(double x) const
Functor1D(const Functor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGenFunction.
ParentFunctor::Impl ImplFunc
GradFunctor1D()
Default constructor.
Functor Handler to Wrap pointers to member functions The member function type must be (XXX means any ...
Functor1D(const PtrObj &p, MemFn memFn)
construct from a pointer to member function (1D type)
Functor(const PtrObj &p, MemFn memFn, unsigned int dim)
construct from a pointer to member function (multi-dim type)
Documentation for the abstract class IBaseFunctionMultiDim.
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
Functor(const Functor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGenFunction.
FunctorImpl is a base class for the functor handler implementation class.
Functor1D()
Default constructor.
ImplBase * Clone() const
Clone a function.
GradFunctor(const GradFunctor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGradFunction.
std::unique_ptr< Impl > fImpl
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes ...
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...
unsigned int NDim() const
double DoDerivative(double x) const
ImplBase * Clone() const
Clone a function.
Functor()
Default constructor.
virtual ~FunctorHandler()
std::unique_ptr< Impl > fImpl
virtual ~Functor1D()
Destructor (no operations)
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...
double DoEval(const double *x) const
double DoDerivative(const double *x, unsigned int icoord) const
IGradientFunctionOneDim::BaseFunc ImplBase
unsigned int NDim() const
Functor1D(const Func &f)
construct from a callable object with the right signature implementing operator() (double x) ...
virtual ~Functor()
Destructor (no operations)
Namespace for new Math classes and functions.
PointerToGradMemFn fGradMemFn
Binding & operator=(OUT(*fun)(void))
ImplFunc::BaseFunc BaseFunc
ParentFunctor::Impl ImplFunc
MemFunHandler(unsigned int dim, const PointerToObj &pObj, PointerToMemFn pMemFn)
constructor from a pointer to the class and a pointer to the function
virtual ~GradFunctor1D()
Destructor (no operations)
ParentFunctor::Impl ImplFunc
std::unique_ptr< Impl > fImpl
double DoDerivative(double x) const
function to evaluate the derivative with respect each coordinate.
Functor Handler to Wrap pointers to member functions for the evaluation of the function and the gradi...
FunctorGradHandler(const Func &fun, const GradFunc &gfun)
double DoEval(const double *x) const
Functor1D class for one-dimensional functions.
IGradientFunctionMultiDim::BaseFunc ImplBase
ImplFunc::BaseFunc BaseFunc
ImplFunc::BaseFunc BaseFunc
IBaseFunctionMultiDim::BaseFunc ImplBase
FunctorImpl< IBaseFunctionOneDim > Impl
Functor Handler class for gradient functions where both callable objects are provided for the functio...
unsigned int NDim() const
Retrieve the dimension of the function.