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