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