Logo ROOT   6.10/00
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  // swap the poiter
449  fImpl.swap( copy.fImpl);
450  // // swap unique_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::unique_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 () {}
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)
538  fImpl = std::unique_ptr<Impl>( (rhs.fImpl)->Copy() );
539  }
540 
541 
542  /**
543  Assignment operator
544  */
545  Functor1D & operator = (const Functor1D & rhs) {
546  Functor1D copy(rhs);
547  fImpl.swap( copy.fImpl);
548  // swap auto_ptr by hand
549  // Impl * p = fImpl.release();
550  // fImpl.reset(copy.fImpl.release());
551  // copy.fImpl.reset(p);
552  return *this;
553  }
554 
555 
556  // clone of the function handler (use copy-ctor)
557  ImplBase * Clone() const { return new Functor1D(*this); }
558 
559 
560 private :
561 
562  inline double DoEval (double x) const {
563  return (*fImpl)(x);
564  }
565 
566 
567  std::unique_ptr<Impl> fImpl; // pointer to base functor handler
568 
569 
570 };
571 
572 /**
573  GradFunctor class for Multidimensional gradient functions.
574  It is used to wrap in a very C++ callable object to make gradient functions.
575  It can be constructed in three different way:
576  <ol>
577  <li> from an object implementing both
578  double operator()( const double * ) for the function evaluation and
579  double Derivative(const double *, int icoord) for the partial derivatives
580  <li>from an object implementing any member function like Foo::XXX(const double *) for the function evaluation
581  and any member function like Foo::XXX(const double *, int icoord) for the partial derivatives
582  <li>from an function object implementing
583  double operator()( const double * ) for the function evaluation and another function object implementing
584  double operator() (const double *, int icoord) for the partial derivatives
585  </ol>
586  The function dimension is required when constructing the functor.
587 
588  @ingroup GenFunc
589 
590  */
592 
593 
594 public:
595 
598 
599 
600  /**
601  Default constructor
602  */
604 
605  /**
606  construct from a callable object of multi-dimension
607  implementing operator()(const double *x) and
608  Derivative(const double * x,icoord)
609  */
610  template <typename Func>
611  GradFunctor( const Func & f, unsigned int dim ) :
612  fImpl(new FunctorHandler<GradFunctor,Func>(dim,f) )
613  {}
614 
615  /**
616  construct from a pointer to member function and member function types for function and derivative evaluations
617  */
618  template <class PtrObj, typename MemFn, typename GradMemFn>
619  GradFunctor(const PtrObj& p, MemFn memFn, GradMemFn gradFn, unsigned int dim )
620  : fImpl(new MemGradFunHandler<GradFunctor, PtrObj, MemFn, GradMemFn>(dim, p, memFn, gradFn))
621  {}
622 
623  /**
624  construct for Gradient Functions of multi-dimension
625  Func gives the function evaluatiion, GradFunc the partial derivatives
626  The function dimension is required
627  */
628  template <typename Func, typename GradFunc>
629  GradFunctor(const Func & f, const GradFunc & g, int dim ) :
630  fImpl(new FunctorGradHandler<GradFunctor,Func,GradFunc>(dim, f, g) )
631  { }
632 
633 
634  /**
635  Destructor (no operations)
636  */
637  virtual ~GradFunctor () {}
638 
639 
640  /**
641  Copy constructor for functor based on ROOT::Math::IMultiGradFunction
642  */
643  GradFunctor(const GradFunctor & rhs) :
644  ImplBase()
645  {
646  if (rhs.fImpl)
647  fImpl = std::unique_ptr<Impl>( rhs.fImpl->Copy() );
648  }
649 
650  /**
651  Assignment operator
652  */
654  GradFunctor copy(rhs);
655  fImpl.swap(copy.fImpl);
656  // swap auto_ptr by hand
657  // Impl * p = fImpl.release();
658  // fImpl.reset(copy.fImpl.release());
659  // copy.fImpl.reset(p);
660  return *this;
661  }
662 
663 
664  // clone of the function handler (use copy-ctor)
665  ImplBase * Clone() const { return new GradFunctor(*this); }
666 
667  // for multi-dimensional functions
668  unsigned int NDim() const { return fImpl->NDim(); }
669 
670 private :
671 
672 
673  inline double DoEval (const double * x) const {
674  return (*fImpl)(x);
675  }
676 
677 
678  inline double DoDerivative (const double * x, unsigned int icoord ) const {
679  return fImpl->Derivative(x,icoord);
680  }
681 
682  std::unique_ptr<Impl> fImpl; // pointer to base grad functor handler
683 
684 
685 };
686 
687 
688 //_______________________________________________________________________________________________
689 /**
690  GradFunctor1D class for one-dimensional gradient functions.
691  It is used to wrap in a very C++ callable object to make a 1D gradient functions.
692  It can be constructed in three different way:
693  <ol>
694  <li> from an object implementing both
695  double operator()( double ) for the function evaluation and
696  double Derivative(double ) for the partial derivatives
697  <li>from an object implementing any member function like Foo::XXX(double ) for the function evaluation
698  and any other member function like Foo::YYY(double ) for the derivative.
699  <li>from an 2 function objects implementing
700  double operator()( double ) . One object provides the function evaluation, the other the derivative.
701  </ol>
702 
703  @ingroup GenFunc
704 
705  */
706 
708 
709 
710 public:
711 
714 
715 
716  /**
717  Default constructor
718  */
720 
721 
722  /**
723  construct from an object with the right signature
724  implementing both operator() (double x) and Derivative(double x)
725  */
726  template <typename Func>
727  GradFunctor1D(const Func & f) :
729  {}
730 
731 
732  /**
733  construct from a pointer to class and two pointers to member functions, one for
734  the function evaluation and the other for the derivative.
735  The member functions must take a double as argument and return a double
736  */
737  template <class PtrObj, typename MemFn, typename GradMemFn>
738  GradFunctor1D(const PtrObj& p, MemFn memFn, GradMemFn gradFn)
739  : fImpl(new MemGradFunHandler<GradFunctor1D, PtrObj, MemFn, GradMemFn>(p, memFn, gradFn))
740  {}
741 
742 
743 
744  /**
745  construct from two 1D function objects
746  */
747  template <typename Func, typename GradFunc>
748  GradFunctor1D(const Func & f, const GradFunc & g ) :
749  fImpl(new FunctorGradHandler<GradFunctor1D,Func, GradFunc>(f, g) )
750  {}
751 
752  /**
753  Destructor (no operations)
754  */
755  virtual ~GradFunctor1D () {}
756 
757 
758  /**
759  Copy constructor for Functor based on ROOT::Math::IGradFunction
760  */
762  // strange that this is required eventhough Impl is an abstract class
763  ImplBase()
764  {
765  if (rhs.fImpl)
766  fImpl = std::unique_ptr<Impl>( rhs.fImpl->Copy() );
767  }
768 
769 
770  /**
771  Assignment operator
772  */
774  GradFunctor1D copy(rhs);
775  fImpl.swap(copy.fImpl);
776  // swap auto_ptr by hand
777  // Impl * p = fImpl.release();
778  // fImpl.reset(copy.fImpl.release());
779  // copy.fImpl.reset(p);
780  return *this;
781  }
782 
783 
784  // clone of the function handler (use copy-ctor)
785  ImplBase * Clone() const { return new GradFunctor1D(*this); }
786 
787 
788 private :
789 
790 
791  inline double DoEval (double x) const {
792  return (*fImpl)(x);
793  }
794 
795 
796  inline double DoDerivative (double x) const {
797  return fImpl->Derivative(x);
798  }
799 
800  std::unique_ptr<Impl> fImpl; // pointer to base gradient functor handler
801 
802 };
803 
804 
805 
806  } // end namespace Math
807 
808 } // end namespace ROOT
809 
810 
811 #endif /* ROOT_Math_Functor */
FunctorHandler(const Func &fun)
Definition: Functor.h:86
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition: IFunction.h:330
GradFunctor1D(const Func &f, const GradFunc &g)
construct from two 1D function objects
Definition: Functor.h:748
Functor & operator=(const Functor &rhs)
Assignment operator.
Definition: Functor.h:446
FunctorImpl< IBaseFunctionMultiDim > Impl
Definition: Functor.h:397
Functor Handler class is responsible for wrapping any other functor and pointer to free C functions...
Definition: Functor.h:76
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition: IFunction.h:134
FunctorImpl< IGradientFunctionMultiDim > Impl
Definition: Functor.h:596
double DoEval(const double *x) const
Definition: Functor.h:194
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
GradFunctor class for Multidimensional gradient functions.
Definition: Functor.h:591
double DoEval(const double *x) const
Definition: Functor.h:673
double DoEval(const double *x) const
Definition: Functor.h:119
GradFunctor1D class for one-dimensional gradient functions.
Definition: Functor.h:707
FunctorImpl< IGradientFunctionOneDim > Impl
Definition: Functor.h:712
GradFunctor1D(const GradFunctor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGradFunction.
Definition: Functor.h:761
Documentation for class Functor class.
Definition: Functor.h:392
unsigned int NDim() const
Retrieve the dimension of the function.
Definition: Functor.h:668
virtual FunctorImpl * Copy() const =0
double DoEval(const double *x) const
Definition: Functor.h:331
ImplFunc * Copy() const
Definition: Functor.h:246
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:727
double DoEval(double x) const
Definition: Functor.h:190
unsigned int NDim() const
Definition: Functor.h:252
GradFunctor()
Default constructor.
Definition: Functor.h:603
Functor1D & operator=(const Functor1D &rhs)
Assignment operator.
Definition: Functor.h:545
double DoDerivative(const double *x, unsigned int icoord) const
Definition: Functor.h:339
std::unique_ptr< Impl > fImpl
Definition: Functor.h:800
GradFunctor & operator=(const GradFunctor &rhs)
Assignment operator.
Definition: Functor.h:653
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:392
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:629
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:611
Double_t x[n]
Definition: legend1.C:17
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:637
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
ImplBase * Clone() const
Clone a function.
Definition: Functor.h:665
double DoEval(const double *x) const
Definition: Functor.h:262
ParentFunctor::Impl ImplFunc
Definition: Functor.h:228
Functor1D(const Functor1D &rhs)
Copy constructor for Functor based on ROOT::Math::IGenFunction.
Definition: Functor.h:533
ParentFunctor::Impl ImplFunc
Definition: Functor.h:78
GradFunctor1D & operator=(const GradFunctor1D &rhs)
Assignment operator.
Definition: Functor.h:773
GradFunctor1D()
Default constructor.
Definition: Functor.h:719
Functor Handler to Wrap pointers to member functions The member function type must be (XXX means any ...
Definition: Functor.h:225
BaseFunc * Clone() const
Definition: Functor.h:318
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:410
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:62
ImplBase * Clone() const
Clone a function.
Definition: Functor.h:785
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
ImplFunc * Copy() const
Definition: Functor.h:315
double DoDerivative(const double *x, unsigned int icoord) const
function to evaluate the derivative with respect each coordinate.
Definition: Functor.h:678
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
Functor1D()
Default constructor.
Definition: Functor.h:503
GradFunctor(const GradFunctor &rhs)
Copy constructor for functor based on ROOT::Math::IMultiGradFunction.
Definition: Functor.h:643
std::unique_ptr< Impl > fImpl
Definition: Functor.h:472
unsigned int NDim() const
Definition: Functor.h:109
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:619
virtual ~FunctorImpl()
Definition: Functor.h:52
double DoDerivative(double x) const
Definition: Functor.h:335
Functor()
Default constructor.
Definition: Functor.h:403
virtual ~FunctorHandler()
Definition: Functor.h:95
std::unique_ptr< Impl > fImpl
Definition: Functor.h:682
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:738
ImplFunc * Copy() const
Definition: Functor.h:178
void Copy(void *source, void *dest)
double f(double x)
IGradientFunctionOneDim::BaseFunc ImplBase
Definition: Functor.h:713
double DoEval(double x) const
Definition: Functor.h:115
BaseFunc * Clone() const
Definition: Functor.h:249
ImplBase * Clone() const
Clone a function.
Definition: Functor.h:459
double DoDerivative(const double *x, unsigned int icoord) const
Definition: Functor.h:127
double DoDerivative(double x) const
function to evaluate the derivative with respect each coordinate.
Definition: Functor.h:796
double DoEval(double x) const
Definition: Functor.h:327
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:123
virtual ~Functor()
Destructor (no operations)
Definition: Functor.h:429
PointerToGradMemFn fGradMemFn
Definition: Functor.h:346
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
double DoEval(const double *x) const
Definition: Functor.h:467
unsigned int NDim() const
Definition: Functor.h:321
double DoDerivative(const double *x, unsigned int icoord) const
Definition: Functor.h:202
virtual ~GradFunctor1D()
Destructor (no operations)
Definition: Functor.h:755
ParentFunctor::Impl ImplFunc
Definition: Functor.h:154
std::unique_ptr< Impl > fImpl
Definition: Functor.h:567
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
ImplBase * Clone() const
Clone a function.
Definition: Functor.h:557
ImplFunc * Copy() const
Definition: Functor.h:98
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes ...
Definition: Functor.h:562
unsigned int NDim() const
Definition: Functor.h:184
double DoEval(double x) const
implementation of the evaluation function. Must be implemented by derived classes ...
Definition: Functor.h:791
Functor1D class for one-dimensional functions.
Definition: Functor.h:492
IGradientFunctionMultiDim::BaseFunc ImplBase
Definition: Functor.h:597
unsigned int NDim() const
Retrieve the dimension of the function.
Definition: Functor.h:462
ImplFunc::BaseFunc BaseFunc
Definition: Functor.h:155
PointerToMemFn fMemFn
Definition: Functor.h:268
BaseFunc * Clone() const
Definition: Functor.h:103
ImplFunc::BaseFunc BaseFunc
Definition: Functor.h:79
IBaseFunctionMultiDim::BaseFunc ImplBase
Definition: Functor.h:398
BaseFunc * Clone() const
Definition: Functor.h:181
double DoDerivative(double x) const
Definition: Functor.h:198
double DoEval(double x) const
Definition: Functor.h:258
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:152