ROOT  6.06/09
Reference Guide
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 #ifndef ROOT_Math_IFunction
17 #include "Math/IFunction.h"
18 #endif
19 #ifndef ROOT_Rtypes
20 #include "Rtypes.h"
21 #endif
22 
23 // Python
24 struct _object;
25 typedef _object PyObject;
26 
27 
29 public:
30 // ctor/dtor, and assignment
31  TPyMultiGenFunction( PyObject* self = 0 );
32  virtual ~TPyMultiGenFunction();
33 
34 // Math::IMultiGenFunction implementation
36  { return new TPyMultiGenFunction( fPySelf ); }
37  virtual unsigned int NDim() const;
38  virtual double DoEval( const double* x ) const;
39 
40  ClassDef( TPyMultiGenFunction, 1 ); //Python for Math::IMultiGenFunction equivalent
41 
42 private:
43 // to prevent confusion when handing 'self' from python
45  TPyMultiGenFunction& operator=( const TPyMultiGenFunction& ) { return *this; }
46 
47 private:
48  PyObject* fPySelf; //! actual python object
49 };
50 
51 
53 public:
54 // ctor/dtor, and assignment
55  TPyMultiGradFunction( PyObject* self = 0 );
56  virtual ~TPyMultiGradFunction();
57 
58 // Math::IMultiGenFunction implementation
60  { return new TPyMultiGradFunction( fPySelf ); }
61  virtual unsigned int NDim() const;
62  virtual double DoEval( const double* x ) const;
63 
64  virtual void Gradient( const double* x, double* grad ) const;
65  virtual void FdF( const double* x, double& f, double* df ) const;
66  virtual double DoDerivative( const double * x, unsigned int icoord ) const;
67 
68  ClassDef( TPyMultiGradFunction, 1 ); //Python for Math::IMultiGradFunction equivalent
69 
70 private:
71 // to prevent confusion when handing 'self' from python
75 
76 private:
77  PyObject* fPySelf; //! actual python object
78 };
79 
80 #endif
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition: IFunction.h:322
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
virtual ROOT::Math::IBaseFunctionMultiDim * Clone() const
Clone a function.
ClassDef(TPyMultiGradFunction, 1)
virtual void FdF(const double *x, double &f, double *df) const
Simply forward the call to python self.
_object PyObject
TPyMultiGenFunction(const TPyMultiGenFunction &src)
TPyMultiGenFunction & operator=(const TPyMultiGenFunction &)
Double_t x[n]
Definition: legend1.C:17
virtual double DoEval(const double *x) const
Simply forward the call to python self.
virtual double DoDerivative(const double *x, unsigned int icoord) const
Simply forward the call to python self.
TPyMultiGenFunction(PyObject *self=0)
TPyMultiGradFunction & operator=(const TPyMultiGradFunction &)
TPyMultiGradFunction(const TPyMultiGradFunction &src)
virtual ~TPyMultiGradFunction()
Destructor. Only deref if still holding on to Py_None (circular otherwise).
IGradientFunctionMultiDim IMultiGradFunction
Definition: IFunctionfwd.h:31
virtual unsigned int NDim() const
Retrieve the dimension of the function.
virtual unsigned int NDim() const
Retrieve the dimension of the function.
ClassDef(TPyMultiGenFunction, 1)
double f(double x)
IBaseFunctionMultiDim IMultiGenFunction
Definition: IFunctionfwd.h:28
virtual double DoEval(const double *x) const
Simply forward the call to python self.
Namespace for new Math classes and functions.
virtual ROOT::Math::IBaseFunctionMultiDim * Clone() const
Clone a function.
virtual ~TPyMultiGenFunction()
Destructor. Only deref if still holding on to Py_None (circular otherwise).
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:63
_object PyObject
Definition: TPyArg.h:22
TPyMultiGradFunction(PyObject *self=0)
virtual void Gradient(const double *x, double *grad) const
Simply forward the call to python self.