Hi Anton, I have implemented your suggestion as a new TF1 constructor: TF1::TF1(const char *name, Float_t xmin, Float_t xmax, Int_t npar) where name is the name of a preloaded CINT function. In this particular case, one single name is sufficient (the TF1 name is the CINT function name) Rene Brun Anton Fokin wrote: > > Hi Rene, > > that's exactly how I handle this now, but whay don't you want to have TF1 > constructor which takes const char* FunctionName as the second argument and > assigns fMethodCall in TF1 according to this preloaded function? I think > many user may would like to work with prloaded user defined functions in > compiled code and be able to wrap TF1 nice facility on top of them. > > Best, > Anton > > -----Original Message----- > From: brun@pcbrun.cern.ch [mailto:brun@pcbrun.cern.ch]On Behalf Of Rene > Brun > Sent: Monday, February 28, 2000 4:34 PM > To: Anton Fokin > Cc: roottalk@pcroot.cern.ch > Subject: Re: TF1 with CINT preloaded function > > Hi Anton, > > I suggest to create a compiled function like > Double_t(*func)(double *, double *) { > Double_t result; > fMethodCall->Execute(result); > return result; > } > > where fMethodCall points to the preloaded CINT function. > > Rene Brun > > Anton Fokin wrote: > > > > Hi Rene, > > > > I am a bit confused. In the stress example it says > > > > #ifndef __CINT__ > > func = f1int; > > TF1 *f1int = new TF1("f1int",func,-10,10,9); // this one will be > > compiled > > #else > > TF1 *f1int = new TF1("f1int",f1int,-10,10,9); // this one will be > > interpreted > > #endif > > > > Of course it will work in the compiled code because #ifndef __CINT__ it > will > > produce correct TF1 constructor call with real pointer to a function func. > > To get this pointer you have > > > > func = f1int > > > > with Double_t(*func)(double *, double *); > > > > In case of CINT it will also produce correct code because CINT will > > recognise f1int as a name of predefined function and use it as a pointer > to > > a function. > > > > What I am asking is how to construct TF1 in the compiled code with a > > function from preloaded CINT macro? I need to have Double_t(*func)(double > *, > > double *) to produce correct constructor call and I can not use the name > of > > a function from preloaded macro just because I am in the program, not in > > CINT! > > > > Best, > > Anton > > > > -----Original Message----- > > From: brun@pcbrun.cern.ch [mailto:brun@pcbrun.cern.ch]On Behalf Of Rene > > Brun > > Sent: Monday, February 28, 2000 3:50 PM > > To: Anton Fokin > > Cc: Rene Brun; roottalk@pcroot.cern.ch > > Subject: Re: TF1 with CINT preloaded function > > > > Hi Anton, > > Look at the small example stress1 in $ROOTSYS/test/stress.cxx > > > > Rene Brun > > > > Anton Fokin wrote: > > > > > > Hi Rene, > > > > > > One of TF1 constructors is to create TF1 from a user defined function > > > > > > TF1 TF1(const char* name, void* fcn, Float_t xmin, Float_t xmax, Int_t > > npar) > > > > > > It works fine in case of CINT > > > > > > Double_t myfunction(Double_t *x, Double_t *par) > > > { > > > Float_t xx =x[0]; > > > Double_t f = TMath::Abs(par[0]*sin(par[1]*xx)/xx); > > > return f; > > > } > > > void myfunc() > > > { > > > TF1 *f1 = new TF1("myfunc",myfunction,0,10,2); > > > f1->SetParameters(2,1); > > > f1->SetParNames("constant","coefficient"); > > > f1->Draw(); > > > } > > > > > > Now if I want to create TF1 in my compiled code with myfunction defined > in > > a > > > macro loaded via gROOT->LoadMacro() ... where can I get a pointer (void* > > > fcn) to myfunction for TF1 constructor? > > > > > > Best regards, > > > Anton
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:20 MET