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