Skip to content
Snippets Groups Projects
Commit 4328348b authored by Lorenzo Moneta's avatar Lorenzo Moneta
Browse files

- add a template TF1::SetFunction from a C++ callable object and a member function.

  This follows a request by Mike Marino (see https://savannah.cern.ch/bugs/?34430 )

 This fixes also previous SetFunction method, which was not working if the previously created function was 
   not of the right type.


git-svn-id: http://root.cern.ch/svn/root/trunk@23730 27541ba8-7e3a-0410-8455-c3a389f83636
parent cad763ab
No related branches found
No related tags found
No related merge requests found
......@@ -254,7 +254,11 @@ public:
virtual void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax);
virtual void SavePrimitive(ostream &out, Option_t *option = "");
virtual void SetChisquare(Double_t chi2) {fChisquare = chi2;}
virtual void SetFunction(Double_t (*fcn)(Double_t *, Double_t *)) { fFunctor = ROOT::Math::ParamFunctor(fcn);}
template <class PtrObj, typename MemFn>
void SetFunction( PtrObj& p, MemFn memFn );
template <typename Func>
void SetFunction( Func f );
//virtual void SetFunction(Double_t (*fcn)(Double_t *, Double_t *));
virtual void SetMaximum(Double_t maximum=-1111); // *MENU*
virtual void SetMinimum(Double_t minimum=-1111); // *MENU*
virtual void SetNDF(Int_t ndf);
......@@ -296,4 +300,22 @@ inline void TF1::SetRange(Double_t xmin, Double_t, Double_t xmax, Double_t)
inline void TF1::SetRange(Double_t xmin, Double_t, Double_t, Double_t xmax, Double_t, Double_t)
{ TF1::SetRange(xmin, xmax); }
template <typename Func>
void TF1::SetFunction( Func f ) {
// set function from a generic C++ callable object
fType = 1;
fFunctor = ROOT::Math::ParamFunctor(f);
}
// void TF1::SetFunction(Double_t (*fcn)(Double_t *, Double_t *)) {
// // specialization for free functions
// fType = 1;
// fFunctor = ROOT::Math::ParamFunctor(fcn);
// }
template <class PtrObj, typename MemFn>
void TF1::SetFunction( PtrObj& p, MemFn memFn ) {
// set from a pointer to a member function
fType = 1;
fFunctor = ROOT::Math::ParamFunctor(p,memFn);
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment