Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include <functional>
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
48
49
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#ifdef _MSC_VER
182 // FIXME: this is a work-around for a a problem with how the compiler
183 // generates the covariant virtual function "Clone". To address the
184 // issue just use the original return type of the virtual base class.
185 // Try to remove this #ifdef when updating Visual Studio
186 typename ParentFunctor::ImplBase* Clone() const { return Copy(); }
187#else
188 BaseFunc * Clone() const { return Copy(); }
189#endif
190
191 // constructor for multi-dimensional functions
192 unsigned int NDim() const {
193 return fDim;
194 }
195
196private :
197
198 inline double DoEval (double x) const {
199 return fFunc(x);
200 }
201
202 inline double DoEval (const double * x) const {
203 return fFunc(x);
204 }
205
206 inline double DoDerivative (double x) const {
207 return fGradFunc(x);
208 }
209
210 inline double DoDerivative (const double * x, unsigned int icoord ) const {
211 return fGradFunc(x, icoord);
212 }
213
214
215 unsigned int fDim;
216 mutable Func fFunc;
217 mutable GradFunc fGradFunc;
218
219};
220
221
222/**
223 Functor Handler to Wrap pointers to member functions
224 The member function type must be (XXX means any name is allowed) :
225 double XXX ( double x) for 1D functions
226 and
227 double XXXX (const double *x) for multi-dimensional functions
228
229 @ingroup Functor_int
230*/
231template <class ParentFunctor, typename PointerToObj,
232 typename PointerToMemFn>
233class MemFunHandler : public ParentFunctor::Impl
234{
235 //typedef typename ParentFunctor::Dim Dim;
236 typedef typename ParentFunctor::Impl ImplFunc;
237 typedef typename ImplFunc::BaseFunc BaseFunc;
238
239public:
240
241 /// constructor from a pointer to the class and a pointer to the function
242 MemFunHandler(const PointerToObj& pObj, PointerToMemFn pMemFn)
243 : fDim(1), fObj(pObj), fMemFn(pMemFn) // should pass pointer by value ??
244 {}
245
246 /// constructor from a pointer to the class and a pointer to the function
247 MemFunHandler(unsigned int dim, const PointerToObj& pObj, PointerToMemFn pMemFn)
248 : fDim(dim), fObj(pObj), fMemFn(pMemFn)
249 {}
250
251 virtual ~MemFunHandler() {}
252
253 // clone of the function handler (use copy-ctor)
254 ImplFunc * Copy() const { return new MemFunHandler(*this); }
255
256 // clone of the function handler (use copy-ctor)
257 BaseFunc * Clone() const { return new MemFunHandler(*this); }
258
259 // constructor for multi-dimensional functions
260 unsigned int NDim() const {
261 return fDim;
262 }
263
264private :
265
266 inline double DoEval (double x) const {
267 return ((*fObj).*fMemFn)(x);
268 }
269
270 inline double DoEval (const double * x) const {
271 return ((*fObj).*fMemFn)(x);
272 }
273
274 unsigned int fDim;
275 mutable PointerToObj fObj;
276 PointerToMemFn fMemFn;
277
278};
279
280/**
281 Functor Handler to Wrap pointers to member functions for the evaluation of the function
282 and the gradient.
283 The member function type must be (XXX means any name is allowed) :
284 double XXX ( double x) for 1D function and derivative evaluation
285 double XXX (const double *x) for multi-dimensional function evaluation and
286 double XXX (cost double *x, int icoord) for partial derivatives evaluation
287
288 @ingroup Functor_int
289
290*/
291template <class ParentFunctor, typename PointerToObj,
292 typename PointerToMemFn, typename PointerToGradMemFn>
293class MemGradFunHandler : public ParentFunctor::Impl
294{
295 typedef typename ParentFunctor::Impl ImplFunc;
296 typedef typename ImplFunc::BaseFunc BaseFunc;
297 //typedef typename ParentFunctor::Dim Dim;
298
299public:
300
301 /// constructor from a pointer to the class and a pointer to the function
302 MemGradFunHandler(const PointerToObj& pObj, PointerToMemFn pMemFn, PointerToGradMemFn pGradMemFn)
303 : fDim(1),
304 fObj(pObj),
305 fMemFn(pMemFn),
306 fGradMemFn(pGradMemFn)
307 {}
308
309 /// constructor from a pointer to the class and a pointer to the function
310 MemGradFunHandler(unsigned int dim,
311 const PointerToObj& pObj,
312 PointerToMemFn pMemFn,
313 PointerToGradMemFn pGradMemFn )
314 : fDim(dim),
315 fObj(pObj),
316 fMemFn(pMemFn),
317 fGradMemFn(pGradMemFn)
318 {}
319
321
322 // clone of the function handler (use copy-ctor)
323 ImplFunc * Copy() const { return new MemGradFunHandler(*this); }
324
325 // clone of the function handler (use copy-ctor)
326 BaseFunc * Clone() const { return new MemGradFunHandler(*this); }
327
328 // constructor for multi-dimensional functions
329 unsigned int NDim() const {
330 return fDim;
331 }
332
333private :
334
335 inline double DoEval (double x) const {
336 return ((*fObj).*fMemFn)(x);
337 }
338
339 inline double DoEval (const double * x) const {
340 return ((*fObj).*fMemFn)(x);
341 }
342
343 inline double DoDerivative (double x) const {
344 return ((*fObj).*fGradMemFn)(x);
345 }
346
347 inline double DoDerivative (const double * x, unsigned int icoord ) const {
348 return ((*fObj).*fGradMemFn)(x,icoord);
349 }
350
351 unsigned int fDim;
352 mutable PointerToObj fObj;
353 PointerToMemFn fMemFn;
354 PointerToGradMemFn fGradMemFn;
355};
356
357
358//****************************
359// LM 7/2/2014: no needed this : make template ctor of Functor1D and GradFunctor1D not
360// available to CINT s
361//***************************************
362//#if defined(__MAKECINT__) || defined(G__DICTIONARY)
363// needed since CINT initialize it with TRootIOCtor
364//class TRootIOCtor;
365
366// template<class ParentFunctor>
367// class FunctorHandler<ParentFunctor,TRootIOCtor *> : public ParentFunctor::Impl
368// {
369// public:
370// typedef typename ParentFunctor::Impl ImplFunc;
371// typedef typename ImplFunc::BaseFunc BaseFunc;
372
373// FunctorHandler(TRootIOCtor *) {}
374// // function required by interface
375// virtual ~FunctorHandler() {}
376// double DoEval (double ) const { return 0; }
377// double DoDerivative (double ) const { return 0; }
378// ImplFunc * Copy() const { return 0; }
379// BaseFunc * Clone() const { return 0; }
380
381// };
382// #endif
383
384
385/**
386 Documentation for class Functor class.
387 It is used to wrap in a very simple and convenient way multi-dimensional function objects.
388 It can wrap all the following types:
389 <ul>
390 <li> any C++ callable object implemention double operator()( const double * )
391 <li> a free C function of type double ()(const double * )
392 <li> an std::function of type std::function<double (double const *)>
393 <li> a member function with the correct signature like Foo::Eval(const double * ).
394 In this case one pass the object pointer and a pointer to the member function (&Foo::Eval)
395 </ul>
396 The function dimension is required when constructing the functor.
397
398 @ingroup GenFunc
399
400 */
402
403
404public:
405
408
409 /**
410 Default constructor
411 */
413
414
415 /**
416 construct from a pointer to member function (multi-dim type)
417 */
418 template <class PtrObj, typename MemFn>
419 Functor(const PtrObj& p, MemFn memFn, unsigned int dim )
420 : fImpl(new MemFunHandler<Functor, PtrObj, MemFn>(dim, p, memFn))
421 {}
422
423
424
425 /**
426 construct from a callable object of multi-dimension
427 with the right signature (implementing operator()(const double *x)
428 */
429 template <typename Func>
430 Functor( const Func & f, unsigned int dim ) :
431 fImpl(new FunctorHandler<Functor,Func>(dim,f) )
432 {}
433
434 /**
435 specialized constructor from a std::function of multi-dimension
436 with the right signature (double operator()(double const *x)
437 This specialized constructor is introduced in order to use the Functor class in
438 Python passing Python user defined functions
439 */
440 //template <typename Func>
441 Functor(const std::function<double(double const *)> &f, unsigned int dim)
442 : fImpl(new FunctorHandler<Functor, std::function<double(double const *)> >(dim, f) )
443 {}
444
445 /**
446 Destructor (no operations)
447 */
448 virtual ~Functor () {}
449
450 /**
451 Copy constructor for functor based on ROOT::Math::IMultiGenFunction
452 */
453 Functor(const Functor & rhs) :
454 ImplBase()
455 {
456 if (rhs.fImpl)
457 fImpl = std::unique_ptr<Impl>((rhs.fImpl)->Copy());
458 }
459 // need a specialization in order to call base classes and use clone
460
461
462 /**
463 Assignment operator
464 */
465 Functor & operator = (const Functor & rhs) {
466 Functor copy(rhs);
467 fImpl.swap(copy.fImpl);
468 return *this;
469 }
470
471
472 // clone of the function handler (use copy-ctor)
473 ImplBase * Clone() const { return new Functor(*this); }
474
475 // for multi-dimensional functions
476 unsigned int NDim() const { return fImpl->NDim(); }
477
478private :
479
480
481 inline double DoEval (const double * x) const {
482 return (*fImpl)(x);
483 }
484
485
486 std::unique_ptr<Impl> fImpl; // pointer to base functor handler
487
488
489};
490
491/**
492 Functor1D class for one-dimensional functions.
493 It is used to wrap in a very simple and convenient way:
494 <ul>
495 <li> any C++ callable object implemention double operator()( double )
496 <li> a free C function of type double ()(double )
497 <li> a member function with the correct signature like Foo::Eval(double ).
498 In this case one pass the object pointer and a pointer to the member function (&Foo::Eval)
499 </ul>
500
501
502 @ingroup GenFunc
503
504 */
505
507
508
509public:
510
513
514 /**
515 Default constructor
516 */
518
519 /**
520 construct from a callable object with the right signature
521 implementing operator() (double x)
522 */
523 template <typename Func>
524 Functor1D(const Func & f) :
525 fImpl(new FunctorHandler<Functor1D,Func>(f))
526 {}
527
528
529 /**
530 construct from a pointer to member function (1D type)
531 */
532 template <class PtrObj, typename MemFn>
533 Functor1D(const PtrObj& p, MemFn memFn)
534 : fImpl(new MemFunHandler<Functor1D, PtrObj, MemFn>(p, memFn))
535 {}
536
537 /**
538 specialized constructor from a std::function implementing the function evaluation.
539 This specialized constructor is introduced in order to use the Functor class in
540 Python passing Python user defined functions
541 */
542 Functor1D(const std::function<double(double)> &f)
543 : fImpl(new FunctorHandler<Functor1D, std::function<double(double)>>(f))
544 {}
545
546 /**
547 Destructor (no operations)
548 */
549 virtual ~Functor1D () {}
550
551
552 /**
553 Copy constructor for Functor based on ROOT::Math::IGenFunction
554 */
555 Functor1D(const Functor1D & rhs) :
556 // strange that this is required eventhough ImplBase is an abstract class
557 ImplBase()
558 {
559 if (rhs.fImpl)
560 fImpl = std::unique_ptr<Impl>( (rhs.fImpl)->Copy() );
561 }
562
563
564 /**
565 Assignment operator
566 */
568 Functor1D copy(rhs);
569 fImpl.swap(copy.fImpl);
570 return *this;
571 }
572
573 // clone of the function handler (use copy-ctor)
574 ImplBase * Clone() const { return new Functor1D(*this); }
575
576private :
577
578 inline double DoEval (double x) const {
579 return (*fImpl)(x);
580 }
581
582 std::unique_ptr<Impl> fImpl; // pointer to base functor handler
583};
584
585/**
586 GradFunctor class for Multidimensional gradient functions.
587 It is used to wrap in a very C++ callable object to make gradient functions.
588 It can be constructed in three different way:
589 <ol>
590 <li> from an object implementing both
591 double operator()( const double * ) for the function evaluation and
592 double Derivative(const double *, int icoord) for the partial derivatives
593 <li>from an object implementing any member function like Foo::XXX(const double *) for the function evaluation
594 and any member function like Foo::XXX(const double *, int icoord) for the partial derivatives
595 <li>from an function object implementing
596 double operator()( const double * ) for the function evaluation and another function object implementing
597 double operator() (const double *, int icoord) for the partial derivatives
598 </ol>
599 The function dimension is required when constructing the functor.
600
601 @ingroup GenFunc
602
603 */
605
606
607public:
608
611
612
613 /**
614 Default constructor
615 */
617
618 /**
619 construct from a callable object of multi-dimension
620 implementing operator()(const double *x) and
621 Derivative(const double * x,icoord)
622 */
623 template <typename Func>
624 GradFunctor( const Func & f, unsigned int dim ) :
625 fImpl(new FunctorHandler<GradFunctor,Func>(dim,f) )
626 {}
627
628 /**
629 construct from a pointer to member function and member function types for function and derivative evaluations
630 */
631 template <class PtrObj, typename MemFn, typename GradMemFn>
632 GradFunctor(const PtrObj& p, MemFn memFn, GradMemFn gradFn, unsigned int dim )
633 : fImpl(new MemGradFunHandler<GradFunctor, PtrObj, MemFn, GradMemFn>(dim, p, memFn, gradFn))
634 {}
635
636 /**
637 construct for Gradient Functions of multi-dimension
638 Func gives the function evaluatiion, GradFunc the partial derivatives
639 The function dimension is required
640 */
641 template <typename Func, typename GradFunc>
642 GradFunctor(const Func & f, const GradFunc & g, int dim ) :
643 fImpl(new FunctorGradHandler<GradFunctor,Func,GradFunc>(dim, f, g) )
644 { }
645
646 /**
647 specialized constructor from 2 std::functions
648 with the right signature (the first one implementing double operator()(double const *x)
649 for the function evaluation and the second one implementing double operator()(double const *x, unsigned int icoord)
650 for the function partial derivatives.
651 This specialized constructor is introduced in order to use the Functor class in
652 Python passing Python user defined functions
653 */
654 // template <typename Func>
655 GradFunctor(const std::function<double(double const *)> &f,
656 const std::function<double(double const *, unsigned int)> &g, unsigned int dim)
657 : fImpl(new FunctorGradHandler<GradFunctor, std::function<double(double const *)>,
658 std::function<double(double const *, unsigned int)> >(dim, f, g))
659 {}
660
661 /**
662 Destructor (no operations)
663 */
664 virtual ~GradFunctor () {}
665
666
667 /**
668 Copy constructor for functor based on ROOT::Math::IMultiGradFunction
669 */
671 ImplBase()
672 {
673 if (rhs.fImpl)
674 fImpl = std::unique_ptr<Impl>(rhs.fImpl->Copy());
675 }
676
677 /**
678 Assignment operator
679 */
681 GradFunctor copy(rhs);
682 fImpl.swap(copy.fImpl);
683 return *this;
684 }
685
686
687 // clone of the function handler (use copy-ctor)
688 ImplBase * Clone() const { return new GradFunctor(*this); }
689
690 // for multi-dimensional functions
691 unsigned int NDim() const { return fImpl->NDim(); }
692
693private :
694
695
696 inline double DoEval (const double * x) const {
697 return (*fImpl)(x);
698 }
699
700
701 inline double DoDerivative (const double * x, unsigned int icoord ) const {
702 return fImpl->Derivative(x,icoord);
703 }
704
705 std::unique_ptr<Impl> fImpl; // pointer to base grad functor handler
706
707
708};
709
710
711//_______________________________________________________________________________________________
712/**
713 GradFunctor1D class for one-dimensional gradient functions.
714 It is used to wrap in a very C++ callable object to make a 1D gradient functions.
715 It can be constructed in three different way:
716 <ol>
717 <li> from an object implementing both
718 double operator()( double ) for the function evaluation and
719 double Derivative(double ) for the partial derivatives
720 <li>from an object implementing any member function like Foo::XXX(double ) for the function evaluation
721 and any other member function like Foo::YYY(double ) for the derivative.
722 <li>from an 2 function objects implementing
723 double operator()( double ) . One object provides the function evaluation, the other the derivative.
724 </ol>
725
726 @ingroup GenFunc
727
728 */
729
731
732
733public:
734
737
738
739 /**
740 Default constructor
741 */
743
744
745 /**
746 construct from an object with the right signature
747 implementing both operator() (double x) and Derivative(double x)
748 */
749 template <typename Func>
750 GradFunctor1D(const Func & f) :
752 {}
753
754
755 /**
756 construct from a pointer to class and two pointers to member functions, one for
757 the function evaluation and the other for the derivative.
758 The member functions must take a double as argument and return a double
759 */
760 template <class PtrObj, typename MemFn, typename GradMemFn>
761 GradFunctor1D(const PtrObj& p, MemFn memFn, GradMemFn gradFn)
762 : fImpl(new MemGradFunHandler<GradFunctor1D, PtrObj, MemFn, GradMemFn>(p, memFn, gradFn))
763 {}
764
765
766
767 /**
768 construct from two 1D function objects
769 */
770 template <typename Func, typename GradFunc>
771 GradFunctor1D(const Func & f, const GradFunc & g ) :
772 fImpl(new FunctorGradHandler<GradFunctor1D,Func, GradFunc>(f, g) )
773 {}
774
775 /**
776 specialized constructor from 2 std::function objects
777 implementing double operator()(double x). The first one for the function evaluation
778 and the second one implementing the function derivative.
779 This specialized constructor is introduced in order to use the class in
780 Python passing Python user defined functions
781 */
782 GradFunctor1D(const std::function<double(double)> &f, const std::function<double(double)> &g )
783 : fImpl(new FunctorGradHandler<GradFunctor1D, std::function<double(double)>, std::function<double(double)> >(f, g))
784 {}
785
786 /**
787 Destructor (no operations)
788 */
789 virtual ~GradFunctor1D () {}
790
791
792 /**
793 Copy constructor for Functor based on ROOT::Math::IGradFunction
794 */
796 // strange that this is required eventhough Impl is an abstract class
797 ImplBase()
798 {
799 if (rhs.fImpl)
800 fImpl = std::unique_ptr<Impl>( rhs.fImpl->Copy() );
801 }
802
803
804 /**
805 Assignment operator
806 */
808 GradFunctor1D copy(rhs);
809 fImpl.swap(copy.fImpl);
810 return *this;
811 }
812
813
814 // clone of the function handler (use copy-ctor)
815 ImplBase * Clone() const { return new GradFunctor1D(*this); }
816
817
818private :
819
820
821 inline double DoEval (double x) const {
822 return (*fImpl)(x);
823 }
824
825
826 inline double DoDerivative (double x) const {
827 return fImpl->Derivative(x);
828 }
829
830 std::unique_ptr<Impl> fImpl; // pointer to base gradient functor handler
831
832};
833
834
835
836 } // end namespace Math
837
838} // end namespace ROOT
839
840
841#endif /* ROOT_Math_Functor */
double
#define f(i)
Definition RSha256.hxx:104
#define g(i)
Definition RSha256.hxx:105
Functor1D class for one-dimensional functions.
Definition Functor.h:506
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes
Definition Functor.h:578
IBaseFunctionOneDim::BaseFunc ImplBase
Definition Functor.h:512
virtual ~Functor1D()
Destructor (no operations)
Definition Functor.h:549
Functor1D & operator=(const Functor1D &rhs)
Assignment operator.
Definition Functor.h:567
FunctorImpl< IBaseFunctionOneDim > Impl
Definition Functor.h:511
Functor1D(const Functor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGenFunction.
Definition Functor.h:555
Functor1D(const std::function< double(double)> &f)
specialized constructor from a std::function implementing the function evaluation.
Definition Functor.h:542
ImplBase * Clone() const
Clone a function.
Definition Functor.h:574
Functor1D(const PtrObj &p, MemFn memFn)
construct from a pointer to member function (1D type)
Definition Functor.h:533
Functor1D(const Func &f)
construct from a callable object with the right signature implementing operator() (double x)
Definition Functor.h:524
std::unique_ptr< Impl > fImpl
Definition Functor.h:582
Functor1D()
Default constructor.
Definition Functor.h:517
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:188
FunctorGradHandler(unsigned int dim, const Func &fun, const GradFunc &gfun)
Definition Functor.h:169
double DoEval(const double *x) const
Definition Functor.h:202
unsigned int NDim() const
Definition Functor.h:192
double DoDerivative(double x) const
Definition Functor.h:206
ParentFunctor::Impl ImplFunc
Definition Functor.h:154
double DoDerivative(const double *x, unsigned int icoord) const
Definition Functor.h:210
double DoEval(double x) const
Definition Functor.h:198
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
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
virtual ~FunctorImpl()
Definition Functor.h:52
Documentation for class Functor class.
Definition Functor.h:401
Functor(const Functor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGenFunction.
Definition Functor.h:453
Functor()
Default constructor.
Definition Functor.h:412
unsigned int NDim() const
Retrieve the dimension of the function.
Definition Functor.h:476
virtual ~Functor()
Destructor (no operations)
Definition Functor.h:448
FunctorImpl< IBaseFunctionMultiDim > Impl
Definition Functor.h:406
ImplBase * Clone() const
Clone a function.
Definition Functor.h:473
Functor & operator=(const Functor &rhs)
Assignment operator.
Definition Functor.h:465
double DoEval(const double *x) const
Implementation of the evaluation function.
Definition Functor.h:481
Functor(const Func &f, unsigned int dim)
construct from a callable object of multi-dimension with the right signature (implementing operator()...
Definition Functor.h:430
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...
Definition Functor.h:441
std::unique_ptr< Impl > fImpl
Definition Functor.h:486
IBaseFunctionMultiDim::BaseFunc ImplBase
Definition Functor.h:407
Functor(const PtrObj &p, MemFn memFn, unsigned int dim)
construct from a pointer to member function (multi-dim type)
Definition Functor.h:419
GradFunctor1D class for one-dimensional gradient functions.
Definition Functor.h:730
IGradientFunctionOneDim::BaseFunc ImplBase
Definition Functor.h:736
GradFunctor1D(const Func &f, const GradFunc &g)
construct from two 1D function objects
Definition Functor.h:771
ImplBase * Clone() const
Clone a function.
Definition Functor.h:815
FunctorImpl< IGradientFunctionOneDim > Impl
Definition Functor.h:735
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:761
GradFunctor1D(const Func &f)
construct from an object with the right signature implementing both operator() (double x) and Derivat...
Definition Functor.h:750
std::unique_ptr< Impl > fImpl
Definition Functor.h:830
GradFunctor1D()
Default constructor.
Definition Functor.h:742
GradFunctor1D & operator=(const GradFunctor1D &rhs)
Assignment operator.
Definition Functor.h:807
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes
Definition Functor.h:821
virtual ~GradFunctor1D()
Destructor (no operations)
Definition Functor.h:789
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).
Definition Functor.h:782
double DoDerivative(double x) const
function to evaluate the derivative with respect each coordinate.
Definition Functor.h:826
GradFunctor1D(const GradFunctor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGradFunction.
Definition Functor.h:795
GradFunctor class for Multidimensional gradient functions.
Definition Functor.h:604
GradFunctor & operator=(const GradFunctor &rhs)
Assignment operator.
Definition Functor.h:680
GradFunctor(const Func &f, const GradFunc &g, int dim)
construct for Gradient Functions of multi-dimension Func gives the function evaluatiion,...
Definition Functor.h:642
virtual ~GradFunctor()
Destructor (no operations)
Definition Functor.h:664
IGradientFunctionMultiDim::BaseFunc ImplBase
Definition Functor.h:610
double DoDerivative(const double *x, unsigned int icoord) const
Definition Functor.h:701
ImplBase * Clone() const
Clone a function.
Definition Functor.h:688
GradFunctor(const GradFunctor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGradFunction.
Definition Functor.h:670
GradFunctor()
Default constructor.
Definition Functor.h:616
std::unique_ptr< Impl > fImpl
Definition Functor.h:705
unsigned int NDim() const
Retrieve the dimension of the function.
Definition Functor.h:691
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:624
FunctorImpl< IGradientFunctionMultiDim > Impl
Definition Functor.h:609
double DoEval(const double *x) const
Definition Functor.h:696
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...
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:632
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:343
Interface (abstract class) for one-dimensional functions providing a gradient calculation.
Definition IFunction.h:409
Functor Handler to Wrap pointers to member functions The member function type must be (XXX means any ...
Definition Functor.h:234
ImplFunc::BaseFunc BaseFunc
Definition Functor.h:237
BaseFunc * Clone() const
Definition Functor.h:257
ParentFunctor::Impl ImplFunc
Definition Functor.h:236
PointerToMemFn fMemFn
Definition Functor.h:276
unsigned int NDim() const
Definition Functor.h:260
MemFunHandler(const PointerToObj &pObj, PointerToMemFn pMemFn)
constructor from a pointer to the class and a pointer to the function
Definition Functor.h:242
ImplFunc * Copy() const
Definition Functor.h:254
double DoEval(const double *x) const
Definition Functor.h:270
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:247
double DoEval(double x) const
Definition Functor.h:266
Functor Handler to Wrap pointers to member functions for the evaluation of the function and the gradi...
Definition Functor.h:294
double DoEval(double x) const
Definition Functor.h:335
BaseFunc * Clone() const
Definition Functor.h:326
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:310
double DoDerivative(double x) const
Definition Functor.h:343
double DoDerivative(const double *x, unsigned int icoord) const
Definition Functor.h:347
ImplFunc::BaseFunc BaseFunc
Definition Functor.h:296
ParentFunctor::Impl ImplFunc
Definition Functor.h:295
PointerToGradMemFn fGradMemFn
Definition Functor.h:354
unsigned int NDim() const
Definition Functor.h:329
ImplFunc * Copy() const
Definition Functor.h:323
double DoEval(const double *x) const
Definition Functor.h:339
MemGradFunHandler(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_t x[n]
Definition legend1.C:17
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...