Re: TF1 with CINT preloaded function

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Feb 28 2000 - 16:33:44 MET


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