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
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> a member function with the correct signature like Foo::Eval(const double * ).
393 In this case one pass the object pointer and a pointer to the member function (&Foo::Eval)
394 </ul>
395 The function dimension is required when constructing the functor.
396
397 @ingroup GenFunc
398
399 */
401
402
403public:
404
407
408 /**
409 Default constructor
410 */
412
413
414 /**
415 construct from a pointer to member function (multi-dim type)
416 */
417 template <class PtrObj, typename MemFn>
418 Functor(const PtrObj& p, MemFn memFn, unsigned int dim )
419 : fImpl(new MemFunHandler<Functor, PtrObj, MemFn>(dim, p, memFn))
420 {}
421
422
423
424 /**
425 construct from a callable object of multi-dimension
426 with the right signature (implementing operator()(double *x)
427 */
428 template <typename Func>
429 Functor( const Func & f, unsigned int dim ) :
430 fImpl(new FunctorHandler<Functor,Func>(dim,f) )
431 {}
432
433
434 /**
435 Destructor (no operations)
436 */
437 virtual ~Functor () {}
438
439 /**
440 Copy constructor for functor based on ROOT::Math::IMultiGenFunction
441 */
442 Functor(const Functor & rhs) :
443 ImplBase()
444 {
445 if (rhs.fImpl)
446 fImpl = std::unique_ptr<Impl>((rhs.fImpl)->Copy());
447 }
448 // need a specialization in order to call base classes and use clone
449
450
451 /**
452 Assignment operator
453 */
454 Functor & operator = (const Functor & rhs) {
455 Functor copy(rhs);
456 fImpl.swap(copy.fImpl);
457 return *this;
458 }
459
460
461 // clone of the function handler (use copy-ctor)
462 ImplBase * Clone() const { return new Functor(*this); }
463
464 // for multi-dimensional functions
465 unsigned int NDim() const { return fImpl->NDim(); }
466
467private :
468
469
470 inline double DoEval (const double * x) const {
471 return (*fImpl)(x);
472 }
473
474
475 std::unique_ptr<Impl> fImpl; // pointer to base functor handler
476
477
478};
479
480/**
481 Functor1D class for one-dimensional functions.
482 It is used to wrap in a very simple and convenient way:
483 <ul>
484 <li> any C++ callable object implemention double operator()( double )
485 <li> a free C function of type double ()(double )
486 <li> a member function with the correct signature like Foo::Eval(double ).
487 In this case one pass the object pointer and a pointer to the member function (&Foo::Eval)
488 </ul>
489
490
491 @ingroup GenFunc
492
493 */
494
496
497
498public:
499
502
503 /**
504 Default constructor
505 */
507
508 /**
509 construct from a callable object with the right signature
510 implementing operator() (double x)
511 */
512 template <typename Func>
513 Functor1D(const Func & f) :
514 fImpl(new FunctorHandler<Functor1D,Func>(f))
515 {}
516
517
518 /**
519 construct from a pointer to member function (1D type)
520 */
521 template <class PtrObj, typename MemFn>
522 Functor1D(const PtrObj& p, MemFn memFn)
523 : fImpl(new MemFunHandler<Functor1D, PtrObj, MemFn>(p, memFn))
524 {}
525
526
527 /**
528 Destructor (no operations)
529 */
530 virtual ~Functor1D () {}
531
532
533 /**
534 Copy constructor for Functor based on ROOT::Math::IGenFunction
535 */
536 Functor1D(const Functor1D & rhs) :
537 // strange that this is required eventhough ImplBase is an abstract class
538 ImplBase()
539 {
540 if (rhs.fImpl)
541 fImpl = std::unique_ptr<Impl>( (rhs.fImpl)->Copy() );
542 }
543
544
545 /**
546 Assignment operator
547 */
549 Functor1D copy(rhs);
550 fImpl.swap(copy.fImpl);
551 return *this;
552 }
553
554 // clone of the function handler (use copy-ctor)
555 ImplBase * Clone() const { return new Functor1D(*this); }
556
557private :
558
559 inline double DoEval (double x) const {
560 return (*fImpl)(x);
561 }
562
563 std::unique_ptr<Impl> fImpl; // pointer to base functor handler
564};
565
566/**
567 GradFunctor class for Multidimensional gradient functions.
568 It is used to wrap in a very C++ callable object to make gradient functions.
569 It can be constructed in three different way:
570 <ol>
571 <li> from an object implementing both
572 double operator()( const double * ) for the function evaluation and
573 double Derivative(const double *, int icoord) for the partial derivatives
574 <li>from an object implementing any member function like Foo::XXX(const double *) for the function evaluation
575 and any member function like Foo::XXX(const double *, int icoord) for the partial derivatives
576 <li>from an function object implementing
577 double operator()( const double * ) for the function evaluation and another function object implementing
578 double operator() (const double *, int icoord) for the partial derivatives
579 </ol>
580 The function dimension is required when constructing the functor.
581
582 @ingroup GenFunc
583
584 */
586
587
588public:
589
592
593
594 /**
595 Default constructor
596 */
598
599 /**
600 construct from a callable object of multi-dimension
601 implementing operator()(const double *x) and
602 Derivative(const double * x,icoord)
603 */
604 template <typename Func>
605 GradFunctor( const Func & f, unsigned int dim ) :
606 fImpl(new FunctorHandler<GradFunctor,Func>(dim,f) )
607 {}
608
609 /**
610 construct from a pointer to member function and member function types for function and derivative evaluations
611 */
612 template <class PtrObj, typename MemFn, typename GradMemFn>
613 GradFunctor(const PtrObj& p, MemFn memFn, GradMemFn gradFn, unsigned int dim )
614 : fImpl(new MemGradFunHandler<GradFunctor, PtrObj, MemFn, GradMemFn>(dim, p, memFn, gradFn))
615 {}
616
617 /**
618 construct for Gradient Functions of multi-dimension
619 Func gives the function evaluatiion, GradFunc the partial derivatives
620 The function dimension is required
621 */
622 template <typename Func, typename GradFunc>
623 GradFunctor(const Func & f, const GradFunc & g, int dim ) :
624 fImpl(new FunctorGradHandler<GradFunctor,Func,GradFunc>(dim, f, g) )
625 { }
626
627
628 /**
629 Destructor (no operations)
630 */
631 virtual ~GradFunctor () {}
632
633
634 /**
635 Copy constructor for functor based on ROOT::Math::IMultiGradFunction
636 */
638 ImplBase()
639 {
640 if (rhs.fImpl)
641 fImpl = std::unique_ptr<Impl>(rhs.fImpl->Copy());
642 }
643
644 /**
645 Assignment operator
646 */
648 GradFunctor copy(rhs);
649 fImpl.swap(copy.fImpl);
650 return *this;
651 }
652
653
654 // clone of the function handler (use copy-ctor)
655 ImplBase * Clone() const { return new GradFunctor(*this); }
656
657 // for multi-dimensional functions
658 unsigned int NDim() const { return fImpl->NDim(); }
659
660private :
661
662
663 inline double DoEval (const double * x) const {
664 return (*fImpl)(x);
665 }
666
667
668 inline double DoDerivative (const double * x, unsigned int icoord ) const {
669 return fImpl->Derivative(x,icoord);
670 }
671
672 std::unique_ptr<Impl> fImpl; // pointer to base grad functor handler
673
674
675};
676
677
678//_______________________________________________________________________________________________
679/**
680 GradFunctor1D class for one-dimensional gradient functions.
681 It is used to wrap in a very C++ callable object to make a 1D gradient functions.
682 It can be constructed in three different way:
683 <ol>
684 <li> from an object implementing both
685 double operator()( double ) for the function evaluation and
686 double Derivative(double ) for the partial derivatives
687 <li>from an object implementing any member function like Foo::XXX(double ) for the function evaluation
688 and any other member function like Foo::YYY(double ) for the derivative.
689 <li>from an 2 function objects implementing
690 double operator()( double ) . One object provides the function evaluation, the other the derivative.
691 </ol>
692
693 @ingroup GenFunc
694
695 */
696
698
699
700public:
701
704
705
706 /**
707 Default constructor
708 */
710
711
712 /**
713 construct from an object with the right signature
714 implementing both operator() (double x) and Derivative(double x)
715 */
716 template <typename Func>
717 GradFunctor1D(const Func & f) :
719 {}
720
721
722 /**
723 construct from a pointer to class and two pointers to member functions, one for
724 the function evaluation and the other for the derivative.
725 The member functions must take a double as argument and return a double
726 */
727 template <class PtrObj, typename MemFn, typename GradMemFn>
728 GradFunctor1D(const PtrObj& p, MemFn memFn, GradMemFn gradFn)
729 : fImpl(new MemGradFunHandler<GradFunctor1D, PtrObj, MemFn, GradMemFn>(p, memFn, gradFn))
730 {}
731
732
733
734 /**
735 construct from two 1D function objects
736 */
737 template <typename Func, typename GradFunc>
738 GradFunctor1D(const Func & f, const GradFunc & g ) :
739 fImpl(new FunctorGradHandler<GradFunctor1D,Func, GradFunc>(f, g) )
740 {}
741
742 /**
743 Destructor (no operations)
744 */
745 virtual ~GradFunctor1D () {}
746
747
748 /**
749 Copy constructor for Functor based on ROOT::Math::IGradFunction
750 */
752 // strange that this is required eventhough Impl is an abstract class
753 ImplBase()
754 {
755 if (rhs.fImpl)
756 fImpl = std::unique_ptr<Impl>( rhs.fImpl->Copy() );
757 }
758
759
760 /**
761 Assignment operator
762 */
764 GradFunctor1D copy(rhs);
765 fImpl.swap(copy.fImpl);
766 return *this;
767 }
768
769
770 // clone of the function handler (use copy-ctor)
771 ImplBase * Clone() const { return new GradFunctor1D(*this); }
772
773
774private :
775
776
777 inline double DoEval (double x) const {
778 return (*fImpl)(x);
779 }
780
781
782 inline double DoDerivative (double x) const {
783 return fImpl->Derivative(x);
784 }
785
786 std::unique_ptr<Impl> fImpl; // pointer to base gradient functor handler
787
788};
789
790
791
792 } // end namespace Math
793
794} // end namespace ROOT
795
796
797#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:495
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes
Definition Functor.h:559
IBaseFunctionOneDim::BaseFunc ImplBase
Definition Functor.h:501
virtual ~Functor1D()
Destructor (no operations)
Definition Functor.h:530
Functor1D & operator=(const Functor1D &rhs)
Assignment operator.
Definition Functor.h:548
FunctorImpl< IBaseFunctionOneDim > Impl
Definition Functor.h:500
Functor1D(const Functor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGenFunction.
Definition Functor.h:536
ImplBase * Clone() const
Clone a function.
Definition Functor.h:555
Functor1D(const PtrObj &p, MemFn memFn)
construct from a pointer to member function (1D type)
Definition Functor.h:522
Functor1D(const Func &f)
construct from a callable object with the right signature implementing operator() (double x)
Definition Functor.h:513
std::unique_ptr< Impl > fImpl
Definition Functor.h:563
Functor1D()
Default constructor.
Definition Functor.h:506
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:400
Functor(const Functor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGenFunction.
Definition Functor.h:442
Functor()
Default constructor.
Definition Functor.h:411
unsigned int NDim() const
Retrieve the dimension of the function.
Definition Functor.h:465
virtual ~Functor()
Destructor (no operations)
Definition Functor.h:437
FunctorImpl< IBaseFunctionMultiDim > Impl
Definition Functor.h:405
ImplBase * Clone() const
Clone a function.
Definition Functor.h:462
Functor & operator=(const Functor &rhs)
Assignment operator.
Definition Functor.h:454
double DoEval(const double *x) const
Implementation of the evaluation function.
Definition Functor.h:470
Functor(const Func &f, unsigned int dim)
construct from a callable object of multi-dimension with the right signature (implementing operator()...
Definition Functor.h:429
std::unique_ptr< Impl > fImpl
Definition Functor.h:475
IBaseFunctionMultiDim::BaseFunc ImplBase
Definition Functor.h:406
Functor(const PtrObj &p, MemFn memFn, unsigned int dim)
construct from a pointer to member function (multi-dim type)
Definition Functor.h:418
GradFunctor1D class for one-dimensional gradient functions.
Definition Functor.h:697
IGradientFunctionOneDim::BaseFunc ImplBase
Definition Functor.h:703
GradFunctor1D(const Func &f, const GradFunc &g)
construct from two 1D function objects
Definition Functor.h:738
ImplBase * Clone() const
Clone a function.
Definition Functor.h:771
FunctorImpl< IGradientFunctionOneDim > Impl
Definition Functor.h:702
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:728
GradFunctor1D(const Func &f)
construct from an object with the right signature implementing both operator() (double x) and Derivat...
Definition Functor.h:717
std::unique_ptr< Impl > fImpl
Definition Functor.h:786
GradFunctor1D()
Default constructor.
Definition Functor.h:709
GradFunctor1D & operator=(const GradFunctor1D &rhs)
Assignment operator.
Definition Functor.h:763
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes
Definition Functor.h:777
virtual ~GradFunctor1D()
Destructor (no operations)
Definition Functor.h:745
double DoDerivative(double x) const
function to evaluate the derivative with respect each coordinate.
Definition Functor.h:782
GradFunctor1D(const GradFunctor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGradFunction.
Definition Functor.h:751
GradFunctor class for Multidimensional gradient functions.
Definition Functor.h:585
GradFunctor & operator=(const GradFunctor &rhs)
Assignment operator.
Definition Functor.h:647
GradFunctor(const Func &f, const GradFunc &g, int dim)
construct for Gradient Functions of multi-dimension Func gives the function evaluatiion,...
Definition Functor.h:623
virtual ~GradFunctor()
Destructor (no operations)
Definition Functor.h:631
IGradientFunctionMultiDim::BaseFunc ImplBase
Definition Functor.h:591
double DoDerivative(const double *x, unsigned int icoord) const
Definition Functor.h:668
ImplBase * Clone() const
Clone a function.
Definition Functor.h:655
GradFunctor(const GradFunctor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGradFunction.
Definition Functor.h:637
GradFunctor()
Default constructor.
Definition Functor.h:597
std::unique_ptr< Impl > fImpl
Definition Functor.h:672
unsigned int NDim() const
Retrieve the dimension of the function.
Definition Functor.h:658
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:605
FunctorImpl< IGradientFunctionMultiDim > Impl
Definition Functor.h:590
double DoEval(const double *x) const
Definition Functor.h:663
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:613
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: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...