Logo ROOT   6.16/01
Reference Guide
Functor.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: L. Moneta Mon Nov 13 15:58:13 2006
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10
11// Heaer file for Functor classes.
12// designed is inspired by the Loki Functor
13
14#ifndef ROOT_Math_Functor
15#define ROOT_Math_Functor
16
17#include "Math/IFunction.h"
18
19// #ifndef Root_Math_StaticCheck
20// #include "Math/StaticCheck.h"
21// #endif
22
23#include <memory>
24
25
26namespace ROOT {
27
28namespace Math {
29
30/**
31 @defgroup Functor_int Internal Functor Classes
32 Internal classes for implementing Functor and Functor1D classes
33 @ingroup GenFunc
34 */
35
36/**
37 FunctorImpl is a base class for the functor
38 handler implementation class.
39 It defines the Copy operator used to clone the functor objects
40*/
41
42template<class IBaseFunc>
43class FunctorImpl : public IBaseFunc {
44
45public:
46
47 typedef IBaseFunc BaseFunc;
48
49
50 FunctorImpl() : IBaseFunc() { }
51
52 virtual ~FunctorImpl() {}
53
54 virtual FunctorImpl* Copy() const = 0;
55
56};
57
58/**
59 Functor Handler class is responsible for wrapping any other functor and pointer to
60 free C functions.
61 It can be created from any function implementing the correct signature
62 corresponding to the requested type
63 In the case of one dimension the function evaluation object must implement
64 double operator() (double x). If it implements a method: double Derivative(double x)
65 can be used to create a Gradient function type.
66
67 In the case of multi-dimension the function evaluation object must implement
68 double operator()(const double *x). If it implements a method:
69 double Derivative(const double *x, int icoord)
70 can be used to create a Gradient function type.
71
72 @ingroup Functor_int
73
74*/
75template<class ParentFunctor, class Func >
76class FunctorHandler : public ParentFunctor::Impl {
77
78 typedef typename ParentFunctor::Impl ImplFunc;
79 typedef typename ImplFunc::BaseFunc BaseFunc;
80 //typedef typename ParentFunctor::Dim Dim;
81
82
83public:
84
85 // constructor for 1d functions
86 FunctorHandler(const Func & fun) : fDim(1), fFunc(fun) {}
87
88
89 // constructor for multi-dimensional functions w/0 NDim()
90 FunctorHandler(unsigned int dim, const Func & fun ) :
91 fDim(dim),
92 fFunc(fun)
93 {}
94
95 virtual ~FunctorHandler() {}
96
97 // copy of the function handler (use copy-ctor)
98 ImplFunc * Copy() const {
99 return new FunctorHandler(*this);
100 }
101
102 // clone of the function handler (use copy-ctor)
103 BaseFunc * Clone() const {
104 return Copy();
105 }
106
107
108 // constructor for multi-dimensional functions
109 unsigned int NDim() const {
110 return fDim;
111 }
112
113private :
114
115 inline double DoEval (double x) const {
116 return fFunc(x);
117 }
118
119 inline double DoEval (const double * x) const {
120 return fFunc(x);
121 }
122
123 inline double DoDerivative (double x) const {
124 return fFunc.Derivative(x);
125 }
126
127 inline double DoDerivative (const double * x, unsigned int icoord ) const {
128 return fFunc.Derivative(x,icoord);
129 }
130
131
132 unsigned int fDim;
133 mutable Func fFunc; // should here be a reference and pass a non-const ref in ctor
134
135};
136
137
138/**
139 Functor Handler class for gradient functions where both callable objects are provided for the function
140 evaluation (type Func) and for the gradient (type GradFunc) .
141 It can be created from any function implementing the correct signature
142 corresponding to the requested type
143 In the case of one dimension the function evaluation object and the derivative function object must implement
144 double operator() (double x).
145 In the case of multi-dimension the function evaluation object must implement
146 double operator() (const double * x) and the gradient function object must implement
147 double operator() (const double * x, int icoord)
148
149 @ingroup Functor_int
150*/
151template<class ParentFunctor, class Func, class GradFunc >
152class FunctorGradHandler : public ParentFunctor::Impl {
153
154 typedef typename ParentFunctor::Impl ImplFunc;
155 typedef typename ImplFunc::BaseFunc BaseFunc;
156 //typedef typename ParentFunctor::Dim Dim;
157
158public:
159
160 // constructor for 1d functions
161 FunctorGradHandler(const Func & fun, const GradFunc & gfun) :
162 fDim(1),
163 fFunc(fun),
164 fGradFunc(gfun)
165 {}
166
167
168 // constructor for multi-dimensional functions
169 FunctorGradHandler(unsigned int dim, const Func & fun, const GradFunc & gfun) :
170 fDim(dim),
171 fFunc(fun),
172 fGradFunc( gfun )
173 {}
174
176
177 // clone of the function handler (use copy-ctor)
178 ImplFunc * Copy() const { return new FunctorGradHandler(*this); }
179
180 // clone of the function handler (use copy-ctor)
181 BaseFunc * Clone() const { return Copy(); }
182
183 // constructor for multi-dimensional functions
184 unsigned int NDim() const {
185 return fDim;
186 }
187
188private :
189
190 inline double DoEval (double x) const {
191 return fFunc(x);
192 }
193
194 inline double DoEval (const double * x) const {
195 return fFunc(x);
196 }
197
198 inline double DoDerivative (double x) const {
199 return fGradFunc(x);
200 }
201
202 inline double DoDerivative (const double * x, unsigned int icoord ) const {
203 return fGradFunc(x, icoord);
204 }
205
206
207 unsigned int fDim;
208 mutable Func fFunc;
209 mutable GradFunc fGradFunc;
210
211};
212
213
214/**
215 Functor Handler to Wrap pointers to member functions
216 The member function type must be (XXX means any name is allowed) :
217 double XXX ( double x) for 1D functions
218 and
219 double XXXX (const double *x) for multi-dimensional functions
220
221 @ingroup Functor_int
222*/
223template <class ParentFunctor, typename PointerToObj,
224 typename PointerToMemFn>
225class MemFunHandler : public ParentFunctor::Impl
226{
227 //typedef typename ParentFunctor::Dim Dim;
228 typedef typename ParentFunctor::Impl ImplFunc;
229 typedef typename ImplFunc::BaseFunc BaseFunc;
230
231public:
232
233 /// constructor from a pointer to the class and a pointer to the function
234 MemFunHandler(const PointerToObj& pObj, PointerToMemFn pMemFn)
235 : fDim(1), fObj(pObj), fMemFn(pMemFn) // should pass pointer by value ??
236 {}
237
238 /// constructor from a pointer to the class and a pointer to the function
239 MemFunHandler(unsigned int dim, const PointerToObj& pObj, PointerToMemFn pMemFn)
240 : fDim(dim), fObj(pObj), fMemFn(pMemFn)
241 {}
242
243 virtual ~MemFunHandler() {}
244
245 // clone of the function handler (use copy-ctor)
246 ImplFunc * Copy() const { return new MemFunHandler(*this); }
247
248 // clone of the function handler (use copy-ctor)
249 BaseFunc * Clone() const { return new MemFunHandler(*this); }
250
251 // constructor for multi-dimensional functions
252 unsigned int NDim() const {
253 return fDim;
254 }
255
256private :
257
258 inline double DoEval (double x) const {
259 return ((*fObj).*fMemFn)(x);
260 }
261
262 inline double DoEval (const double * x) const {
263 return ((*fObj).*fMemFn)(x);
264 }
265
266 unsigned int fDim;
267 mutable PointerToObj fObj;
268 PointerToMemFn fMemFn;
269
270};
271
272/**
273 Functor Handler to Wrap pointers to member functions for the evaluation of the function
274 and the gradient.
275 The member function type must be (XXX means any name is allowed) :
276 double XXX ( double x) for 1D function and derivative evaluation
277 double XXX (const double *x) for multi-dimensional function evaluation and
278 double XXX (cost double *x, int icoord) for partial derivatives evaluation
279
280 @ingroup Functor_int
281
282*/
283template <class ParentFunctor, typename PointerToObj,
284 typename PointerToMemFn, typename PointerToGradMemFn>
285class MemGradFunHandler : public ParentFunctor::Impl
286{
287 typedef typename ParentFunctor::Impl ImplFunc;
288 typedef typename ImplFunc::BaseFunc BaseFunc;
289 //typedef typename ParentFunctor::Dim Dim;
290
291public:
292
293 /// constructor from a pointer to the class and a pointer to the function
294 MemGradFunHandler(const PointerToObj& pObj, PointerToMemFn pMemFn, PointerToGradMemFn pGradMemFn)
295 : fDim(1),
296 fObj(pObj),
297 fMemFn(pMemFn),
298 fGradMemFn(pGradMemFn)
299 {}
300
301 /// constructor from a pointer to the class and a pointer to the function
302 MemGradFunHandler(unsigned int dim,
303 const PointerToObj& pObj,
304 PointerToMemFn pMemFn,
305 PointerToGradMemFn pGradMemFn )
306 : fDim(dim),
307 fObj(pObj),
308 fMemFn(pMemFn),
309 fGradMemFn(pGradMemFn)
310 {}
311
313
314 // clone of the function handler (use copy-ctor)
315 ImplFunc * Copy() const { return new MemGradFunHandler(*this); }
316
317 // clone of the function handler (use copy-ctor)
318 BaseFunc * Clone() const { return new MemGradFunHandler(*this); }
319
320 // constructor for multi-dimensional functions
321 unsigned int NDim() const {
322 return fDim;
323 }
324
325private :
326
327 inline double DoEval (double x) const {
328 return ((*fObj).*fMemFn)(x);
329 }
330
331 inline double DoEval (const double * x) const {
332 return ((*fObj).*fMemFn)(x);
333 }
334
335 inline double DoDerivative (double x) const {
336 return ((*fObj).*fGradMemFn)(x);
337 }
338
339 inline double DoDerivative (const double * x, unsigned int icoord ) const {
340 return ((*fObj).*fGradMemFn)(x,icoord);
341 }
342
343 unsigned int fDim;
344 mutable PointerToObj fObj;
345 PointerToMemFn fMemFn;
346 PointerToGradMemFn fGradMemFn;
347};
348
349
350//****************************
351// LM 7/2/2014: no needed this : make template ctor of Functor1D and GradFunctor1D not
352// available to CINT s
353//***************************************
354//#if defined(__MAKECINT__) || defined(G__DICTIONARY)
355// needed since CINT initialize it with TRootIOCtor
356//class TRootIOCtor;
357
358// template<class ParentFunctor>
359// class FunctorHandler<ParentFunctor,TRootIOCtor *> : public ParentFunctor::Impl
360// {
361// public:
362// typedef typename ParentFunctor::Impl ImplFunc;
363// typedef typename ImplFunc::BaseFunc BaseFunc;
364
365// FunctorHandler(TRootIOCtor *) {}
366// // function required by interface
367// virtual ~FunctorHandler() {}
368// double DoEval (double ) const { return 0; }
369// double DoDerivative (double ) const { return 0; }
370// ImplFunc * Copy() const { return 0; }
371// BaseFunc * Clone() const { return 0; }
372
373// };
374// #endif
375
376
377/**
378 Documentation for class Functor class.
379 It is used to wrap in a very simple and convenient way multi-dimensional function objects.
380 It can wrap all the following types:
381 <ul>
382 <li> any C++ callable object implemention double operator()( const double * )
383 <li> a free C function of type double ()(const double * )
384 <li> a member function with the correct signature like Foo::Eval(const double * ).
385 In this case one pass the object pointer and a pointer to the member function (&Foo::Eval)
386 </ul>
387 The function dimension is required when constructing the functor.
388
389 @ingroup GenFunc
390
391 */
393
394
395public:
396
399
400 /**
401 Default constructor
402 */
404
405
406 /**
407 construct from a pointer to member function (multi-dim type)
408 */
409 template <class PtrObj, typename MemFn>
410 Functor(const PtrObj& p, MemFn memFn, unsigned int dim )
411 : fImpl(new MemFunHandler<Functor, PtrObj, MemFn>(dim, p, memFn))
412 {}
413
414
415
416 /**
417 construct from a callable object of multi-dimension
418 with the right signature (implementing operator()(double *x)
419 */
420 template <typename Func>
421 Functor( const Func & f, unsigned int dim ) :
422 fImpl(new FunctorHandler<Functor,Func>(dim,f) )
423 {}
424
425
426 /**
427 Destructor (no operations)
428 */
429 virtual ~Functor () {}
430
431 /**
432 Copy constructor for functor based on ROOT::Math::IMultiGenFunction
433 */
434 Functor(const Functor & rhs) :
435 ImplBase()
436 {
437 if (rhs.fImpl)
438 fImpl = std::unique_ptr<Impl>((rhs.fImpl)->Copy());
439 }
440 // need a specialization in order to call base classes and use clone
441
442
443 /**
444 Assignment operator
445 */
446 Functor & operator = (const Functor & rhs) {
447 Functor copy(rhs);
448 fImpl.swap(copy.fImpl);
449 return *this;
450 }
451
452
453 // clone of the function handler (use copy-ctor)
454 ImplBase * Clone() const { return new Functor(*this); }
455
456 // for multi-dimensional functions
457 unsigned int NDim() const { return fImpl->NDim(); }
458
459private :
460
461
462 inline double DoEval (const double * x) const {
463 return (*fImpl)(x);
464 }
465
466
467 std::unique_ptr<Impl> fImpl; // pointer to base functor handler
468
469
470};
471
472/**
473 Functor1D class for one-dimensional functions.
474 It is used to wrap in a very simple and convenient way:
475 <ul>
476 <li> any C++ callable object implemention double operator()( double )
477 <li> a free C function of type double ()(double )
478 <li> a member function with the correct signature like Foo::Eval(double ).
479 In this case one pass the object pointer and a pointer to the member function (&Foo::Eval)
480 </ul>
481
482
483 @ingroup GenFunc
484
485 */
486
488
489
490public:
491
494
495 /**
496 Default constructor
497 */
499
500 /**
501 construct from a callable object with the right signature
502 implementing operator() (double x)
503 */
504 template <typename Func>
505 Functor1D(const Func & f) :
506 fImpl(new FunctorHandler<Functor1D,Func>(f))
507 {}
508
509
510 /**
511 construct from a pointer to member function (1D type)
512 */
513 template <class PtrObj, typename MemFn>
514 Functor1D(const PtrObj& p, MemFn memFn)
515 : fImpl(new MemFunHandler<Functor1D, PtrObj, MemFn>(p, memFn))
516 {}
517
518
519 /**
520 Destructor (no operations)
521 */
522 virtual ~Functor1D () {}
523
524
525 /**
526 Copy constructor for Functor based on ROOT::Math::IGenFunction
527 */
528 Functor1D(const Functor1D & rhs) :
529 // strange that this is required eventhough ImplBase is an abstract class
530 ImplBase()
531 {
532 if (rhs.fImpl)
533 fImpl = std::unique_ptr<Impl>( (rhs.fImpl)->Copy() );
534 }
535
536
537 /**
538 Assignment operator
539 */
541 Functor1D copy(rhs);
542 fImpl.swap(copy.fImpl);
543 return *this;
544 }
545
546 // clone of the function handler (use copy-ctor)
547 ImplBase * Clone() const { return new Functor1D(*this); }
548
549private :
550
551 inline double DoEval (double x) const {
552 return (*fImpl)(x);
553 }
554
555 std::unique_ptr<Impl> fImpl; // pointer to base functor handler
556};
557
558/**
559 GradFunctor class for Multidimensional gradient functions.
560 It is used to wrap in a very C++ callable object to make gradient functions.
561 It can be constructed in three different way:
562 <ol>
563 <li> from an object implementing both
564 double operator()( const double * ) for the function evaluation and
565 double Derivative(const double *, int icoord) for the partial derivatives
566 <li>from an object implementing any member function like Foo::XXX(const double *) for the function evaluation
567 and any member function like Foo::XXX(const double *, int icoord) for the partial derivatives
568 <li>from an function object implementing
569 double operator()( const double * ) for the function evaluation and another function object implementing
570 double operator() (const double *, int icoord) for the partial derivatives
571 </ol>
572 The function dimension is required when constructing the functor.
573
574 @ingroup GenFunc
575
576 */
578
579
580public:
581
584
585
586 /**
587 Default constructor
588 */
590
591 /**
592 construct from a callable object of multi-dimension
593 implementing operator()(const double *x) and
594 Derivative(const double * x,icoord)
595 */
596 template <typename Func>
597 GradFunctor( const Func & f, unsigned int dim ) :
598 fImpl(new FunctorHandler<GradFunctor,Func>(dim,f) )
599 {}
600
601 /**
602 construct from a pointer to member function and member function types for function and derivative evaluations
603 */
604 template <class PtrObj, typename MemFn, typename GradMemFn>
605 GradFunctor(const PtrObj& p, MemFn memFn, GradMemFn gradFn, unsigned int dim )
606 : fImpl(new MemGradFunHandler<GradFunctor, PtrObj, MemFn, GradMemFn>(dim, p, memFn, gradFn))
607 {}
608
609 /**
610 construct for Gradient Functions of multi-dimension
611 Func gives the function evaluatiion, GradFunc the partial derivatives
612 The function dimension is required
613 */
614 template <typename Func, typename GradFunc>
615 GradFunctor(const Func & f, const GradFunc & g, int dim ) :
616 fImpl(new FunctorGradHandler<GradFunctor,Func,GradFunc>(dim, f, g) )
617 { }
618
619
620 /**
621 Destructor (no operations)
622 */
623 virtual ~GradFunctor () {}
624
625
626 /**
627 Copy constructor for functor based on ROOT::Math::IMultiGradFunction
628 */
630 ImplBase()
631 {
632 if (rhs.fImpl)
633 fImpl = std::unique_ptr<Impl>(rhs.fImpl->Copy());
634 }
635
636 /**
637 Assignment operator
638 */
640 GradFunctor copy(rhs);
641 fImpl.swap(copy.fImpl);
642 return *this;
643 }
644
645
646 // clone of the function handler (use copy-ctor)
647 ImplBase * Clone() const { return new GradFunctor(*this); }
648
649 // for multi-dimensional functions
650 unsigned int NDim() const { return fImpl->NDim(); }
651
652private :
653
654
655 inline double DoEval (const double * x) const {
656 return (*fImpl)(x);
657 }
658
659
660 inline double DoDerivative (const double * x, unsigned int icoord ) const {
661 return fImpl->Derivative(x,icoord);
662 }
663
664 std::unique_ptr<Impl> fImpl; // pointer to base grad functor handler
665
666
667};
668
669
670//_______________________________________________________________________________________________
671/**
672 GradFunctor1D class for one-dimensional gradient functions.
673 It is used to wrap in a very C++ callable object to make a 1D gradient functions.
674 It can be constructed in three different way:
675 <ol>
676 <li> from an object implementing both
677 double operator()( double ) for the function evaluation and
678 double Derivative(double ) for the partial derivatives
679 <li>from an object implementing any member function like Foo::XXX(double ) for the function evaluation
680 and any other member function like Foo::YYY(double ) for the derivative.
681 <li>from an 2 function objects implementing
682 double operator()( double ) . One object provides the function evaluation, the other the derivative.
683 </ol>
684
685 @ingroup GenFunc
686
687 */
688
690
691
692public:
693
696
697
698 /**
699 Default constructor
700 */
702
703
704 /**
705 construct from an object with the right signature
706 implementing both operator() (double x) and Derivative(double x)
707 */
708 template <typename Func>
709 GradFunctor1D(const Func & f) :
711 {}
712
713
714 /**
715 construct from a pointer to class and two pointers to member functions, one for
716 the function evaluation and the other for the derivative.
717 The member functions must take a double as argument and return a double
718 */
719 template <class PtrObj, typename MemFn, typename GradMemFn>
720 GradFunctor1D(const PtrObj& p, MemFn memFn, GradMemFn gradFn)
721 : fImpl(new MemGradFunHandler<GradFunctor1D, PtrObj, MemFn, GradMemFn>(p, memFn, gradFn))
722 {}
723
724
725
726 /**
727 construct from two 1D function objects
728 */
729 template <typename Func, typename GradFunc>
730 GradFunctor1D(const Func & f, const GradFunc & g ) :
731 fImpl(new FunctorGradHandler<GradFunctor1D,Func, GradFunc>(f, g) )
732 {}
733
734 /**
735 Destructor (no operations)
736 */
737 virtual ~GradFunctor1D () {}
738
739
740 /**
741 Copy constructor for Functor based on ROOT::Math::IGradFunction
742 */
744 // strange that this is required eventhough Impl is an abstract class
745 ImplBase()
746 {
747 if (rhs.fImpl)
748 fImpl = std::unique_ptr<Impl>( rhs.fImpl->Copy() );
749 }
750
751
752 /**
753 Assignment operator
754 */
756 GradFunctor1D copy(rhs);
757 fImpl.swap(copy.fImpl);
758 return *this;
759 }
760
761
762 // clone of the function handler (use copy-ctor)
763 ImplBase * Clone() const { return new GradFunctor1D(*this); }
764
765
766private :
767
768
769 inline double DoEval (double x) const {
770 return (*fImpl)(x);
771 }
772
773
774 inline double DoDerivative (double x) const {
775 return fImpl->Derivative(x);
776 }
777
778 std::unique_ptr<Impl> fImpl; // pointer to base gradient functor handler
779
780};
781
782
783
784 } // end namespace Math
785
786} // end namespace ROOT
787
788
789#endif /* ROOT_Math_Functor */
#define f(i)
Definition: RSha256.hxx:104
#define g(i)
Definition: RSha256.hxx:105
Functor1D class for one-dimensional functions.
Definition: Functor.h:487
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes
Definition: Functor.h:551
IBaseFunctionOneDim::BaseFunc ImplBase
Definition: Functor.h:493
virtual ~Functor1D()
Destructor (no operations)
Definition: Functor.h:522
Functor1D & operator=(const Functor1D &rhs)
Assignment operator.
Definition: Functor.h:540
FunctorImpl< IBaseFunctionOneDim > Impl
Definition: Functor.h:492
Functor1D(const Functor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGenFunction.
Definition: Functor.h:528
ImplBase * Clone() const
Clone a function.
Definition: Functor.h:547
Functor1D(const PtrObj &p, MemFn memFn)
construct from a pointer to member function (1D type)
Definition: Functor.h:514
Functor1D(const Func &f)
construct from a callable object with the right signature implementing operator() (double x)
Definition: Functor.h:505
std::unique_ptr< Impl > fImpl
Definition: Functor.h:555
Functor1D()
Default constructor.
Definition: Functor.h:498
Functor Handler class for gradient functions where both callable objects are provided for the functio...
Definition: Functor.h:152
FunctorGradHandler(const Func &fun, const GradFunc &gfun)
Definition: Functor.h:161
BaseFunc * Clone() const
Definition: Functor.h:181
FunctorGradHandler(unsigned int dim, const Func &fun, const GradFunc &gfun)
Definition: Functor.h:169
double DoEval(const double *x) const
Definition: Functor.h:194
unsigned int NDim() const
Definition: Functor.h:184
double DoDerivative(double x) const
Definition: Functor.h:198
ParentFunctor::Impl ImplFunc
Definition: Functor.h:154
double DoDerivative(const double *x, unsigned int icoord) const
Definition: Functor.h:202
double DoEval(double x) const
Definition: Functor.h:190
ImplFunc * Copy() const
Definition: Functor.h:178
ImplFunc::BaseFunc BaseFunc
Definition: Functor.h:155
Functor Handler class is responsible for wrapping any other functor and pointer to free C functions.
Definition: Functor.h:76
unsigned int NDim() const
Definition: Functor.h:109
FunctorHandler(unsigned int dim, const Func &fun)
Definition: Functor.h:90
double DoEval(const double *x) const
Definition: Functor.h:119
double DoDerivative(const double *x, unsigned int icoord) const
Definition: Functor.h:127
ImplFunc * Copy() const
Definition: Functor.h:98
BaseFunc * Clone() const
Definition: Functor.h:103
ParentFunctor::Impl ImplFunc
Definition: Functor.h:78
double DoDerivative(double x) const
Definition: Functor.h:123
double DoEval(double x) const
Definition: Functor.h:115
virtual ~FunctorHandler()
Definition: Functor.h:95
ImplFunc::BaseFunc BaseFunc
Definition: Functor.h:79
FunctorHandler(const Func &fun)
Definition: Functor.h:86
FunctorImpl is a base class for the functor handler implementation class.
Definition: Functor.h:43
virtual FunctorImpl * Copy() const =0
IBaseFunc BaseFunc
Definition: Functor.h:47
virtual ~FunctorImpl()
Definition: Functor.h:52
Documentation for class Functor class.
Definition: Functor.h:392
Functor(const Functor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGenFunction.
Definition: Functor.h:434
Functor()
Default constructor.
Definition: Functor.h:403
unsigned int NDim() const
Retrieve the dimension of the function.
Definition: Functor.h:457
virtual ~Functor()
Destructor (no operations)
Definition: Functor.h:429
FunctorImpl< IBaseFunctionMultiDim > Impl
Definition: Functor.h:397
ImplBase * Clone() const
Clone a function.
Definition: Functor.h:454
Functor & operator=(const Functor &rhs)
Assignment operator.
Definition: Functor.h:446
double DoEval(const double *x) const
Definition: Functor.h:462
Functor(const Func &f, unsigned int dim)
construct from a callable object of multi-dimension with the right signature (implementing operator()...
Definition: Functor.h:421
std::unique_ptr< Impl > fImpl
Definition: Functor.h:467
IBaseFunctionMultiDim::BaseFunc ImplBase
Definition: Functor.h:398
Functor(const PtrObj &p, MemFn memFn, unsigned int dim)
construct from a pointer to member function (multi-dim type)
Definition: Functor.h:410
GradFunctor1D class for one-dimensional gradient functions.
Definition: Functor.h:689
IGradientFunctionOneDim::BaseFunc ImplBase
Definition: Functor.h:695
GradFunctor1D(const Func &f, const GradFunc &g)
construct from two 1D function objects
Definition: Functor.h:730
ImplBase * Clone() const
Clone a function.
Definition: Functor.h:763
FunctorImpl< IGradientFunctionOneDim > Impl
Definition: Functor.h:694
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...
Definition: Functor.h:720
GradFunctor1D(const Func &f)
construct from an object with the right signature implementing both operator() (double x) and Derivat...
Definition: Functor.h:709
std::unique_ptr< Impl > fImpl
Definition: Functor.h:778
GradFunctor1D()
Default constructor.
Definition: Functor.h:701
GradFunctor1D & operator=(const GradFunctor1D &rhs)
Assignment operator.
Definition: Functor.h:755
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes
Definition: Functor.h:769
virtual ~GradFunctor1D()
Destructor (no operations)
Definition: Functor.h:737
double DoDerivative(double x) const
function to evaluate the derivative with respect each coordinate.
Definition: Functor.h:774
GradFunctor1D(const GradFunctor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGradFunction.
Definition: Functor.h:743
GradFunctor class for Multidimensional gradient functions.
Definition: Functor.h:577
GradFunctor & operator=(const GradFunctor &rhs)
Assignment operator.
Definition: Functor.h:639
GradFunctor(const Func &f, const GradFunc &g, int dim)
construct for Gradient Functions of multi-dimension Func gives the function evaluatiion,...
Definition: Functor.h:615
virtual ~GradFunctor()
Destructor (no operations)
Definition: Functor.h:623
IGradientFunctionMultiDim::BaseFunc ImplBase
Definition: Functor.h:583
double DoDerivative(const double *x, unsigned int icoord) const
Definition: Functor.h:660
ImplBase * Clone() const
Clone a function.
Definition: Functor.h:647
GradFunctor(const GradFunctor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGradFunction.
Definition: Functor.h:629
GradFunctor()
Default constructor.
Definition: Functor.h:589
std::unique_ptr< Impl > fImpl
Definition: Functor.h:664
unsigned int NDim() const
Retrieve the dimension of the function.
Definition: Functor.h:650
GradFunctor(const Func &f, unsigned int dim)
construct from a callable object of multi-dimension implementing operator()(const double *x) and Deri...
Definition: Functor.h:597
FunctorImpl< IGradientFunctionMultiDim > Impl
Definition: Functor.h:582
double DoEval(const double *x) const
Definition: Functor.h:655
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...
Definition: Functor.h:605
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:62
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition: IFunction.h:135
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition: IFunction.h:327
Interface (abstract class) for one-dimensional functions providing a gradient calculation.
Definition: IFunction.h:383
Functor Handler to Wrap pointers to member functions The member function type must be (XXX means any ...
Definition: Functor.h:226
ImplFunc::BaseFunc BaseFunc
Definition: Functor.h:229
BaseFunc * Clone() const
Definition: Functor.h:249
ParentFunctor::Impl ImplFunc
Definition: Functor.h:228
PointerToMemFn fMemFn
Definition: Functor.h:268
unsigned int NDim() const
Definition: Functor.h:252
MemFunHandler(const PointerToObj &pObj, PointerToMemFn pMemFn)
constructor from a pointer to the class and a pointer to the function
Definition: Functor.h:234
ImplFunc * Copy() const
Definition: Functor.h:246
double DoEval(const double *x) const
Definition: Functor.h:262
virtual ~MemFunHandler()
Definition: Functor.h:243
MemFunHandler(unsigned int dim, const PointerToObj &pObj, PointerToMemFn pMemFn)
constructor from a pointer to the class and a pointer to the function
Definition: Functor.h:239
double DoEval(double x) const
Definition: Functor.h:258
Functor Handler to Wrap pointers to member functions for the evaluation of the function and the gradi...
Definition: Functor.h:286
double DoEval(double x) const
Definition: Functor.h:327
BaseFunc * Clone() const
Definition: Functor.h:318
MemGradFunHandler(unsigned int dim, const PointerToObj &pObj, PointerToMemFn pMemFn, PointerToGradMemFn pGradMemFn)
constructor from a pointer to the class and a pointer to the function
Definition: Functor.h:302
double DoDerivative(double x) const
Definition: Functor.h:335
double DoDerivative(const double *x, unsigned int icoord) const
Definition: Functor.h:339
ImplFunc::BaseFunc BaseFunc
Definition: Functor.h:288
ParentFunctor::Impl ImplFunc
Definition: Functor.h:287
PointerToGradMemFn fGradMemFn
Definition: Functor.h:346
unsigned int NDim() const
Definition: Functor.h:321
ImplFunc * Copy() const
Definition: Functor.h:315
double DoEval(const double *x) const
Definition: Functor.h:331
MemGradFunHandler(const PointerToObj &pObj, PointerToMemFn pMemFn, PointerToGradMemFn pGradMemFn)
constructor from a pointer to the class and a pointer to the function
Definition: Functor.h:294
Double_t x[n]
Definition: legend1.C:17
Namespace for new Math classes and functions.
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21