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