Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TPyFitFunction.h
Go to the documentation of this file.
1 // Author: Wim Lavrijsen November 2010
2 
3 #ifndef ROOT_TPyFitFunction
4 #define ROOT_TPyFitFunction
5 
6 //////////////////////////////////////////////////////////////////////////////
7 // //
8 // TPyFitFunction //
9 // //
10 // Python base class to work with Math::IMultiGenFunction //
11 // //
12 //////////////////////////////////////////////////////////////////////////////
13 
14 
15 //- ROOT
16 #include "Math/IFunction.h"
17 #include "Rtypes.h"
18 
19 // Python
20 struct _object;
21 typedef _object PyObject;
22 
23 
24 class TPyMultiGenFunction : public ROOT::Math::IMultiGenFunction {
25 public:
26 // ctor/dtor, and assignment
27  TPyMultiGenFunction( PyObject* self = 0 );
28  virtual ~TPyMultiGenFunction();
29 
30 // Math::IMultiGenFunction implementation
31  virtual ROOT::Math::IBaseFunctionMultiDim* Clone() const
32  { return new TPyMultiGenFunction( fPySelf ); }
33  virtual unsigned int NDim() const;
34  virtual double DoEval( const double* x ) const;
35 
36  ClassDef( TPyMultiGenFunction, 1 ); //Python for Math::IMultiGenFunction equivalent
37 
38 private:
39 // to prevent confusion when handing 'self' from python
40  TPyMultiGenFunction( const TPyMultiGenFunction& src ) : ROOT::Math::IMultiGenFunction( src ) {}
41  TPyMultiGenFunction& operator=( const TPyMultiGenFunction& ) { return *this; }
42 
43 private:
44  PyObject* fPySelf; //! actual python object
45 };
46 
47 
48 class TPyMultiGradFunction : public ROOT::Math::IMultiGradFunction {
49 public:
50 // ctor/dtor, and assignment
51  TPyMultiGradFunction( PyObject* self = 0 );
52  virtual ~TPyMultiGradFunction();
53 
54 // Math::IMultiGenFunction implementation
55  virtual ROOT::Math::IBaseFunctionMultiDim* Clone() const
56  { return new TPyMultiGradFunction( fPySelf ); }
57  virtual unsigned int NDim() const;
58  virtual double DoEval( const double* x ) const;
59 
60  virtual void Gradient( const double* x, double* grad ) const;
61  virtual void FdF( const double* x, double& f, double* df ) const;
62  virtual double DoDerivative( const double * x, unsigned int icoord ) const;
63 
64  ClassDef( TPyMultiGradFunction, 1 ); //Python for Math::IMultiGradFunction equivalent
65 
66 private:
67 // to prevent confusion when handing 'self' from python
68  TPyMultiGradFunction( const TPyMultiGradFunction& src ) :
69  ROOT::Math::IMultiGenFunction( src ), ROOT::Math::IMultiGradFunction( src ) {}
70  TPyMultiGradFunction& operator=( const TPyMultiGradFunction& ) { return *this; }
71 
72 private:
73  PyObject* fPySelf; //! actual python object
74 };
75 
76 #endif