Hi,
I have a problem with using a compiled version of a function in
combination with CINT.
Taking the example in TF1 for type C:
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();
}
void myfit()
{
TH1F *h1=new TH1F("h1","test",100,0,10);
h1->FillRandom("myfunc",20000);
TF1 *f1=gROOT->GetFunction("myfunc");
f1->SetParameters(800,1);
h1.Fit("myfunc");
}
This works fine if all is within one macro. Now, of course in reality my
real function ('myfunction') does more work and to not slow down because
of interpreter I compile the function and link it. So I create a
shared-lib, and use rootcint with a Linkdef.h with a line:
#pragma link C++ function myfunction(double *x, double *par);
If I now execute my macro (ofcourse without the defition/declaration of
myfunction) I get a segm fault in myfunction. Looking further I see
that the function is called but once I use the arguments, i.e.
Float_t xx =x[0];
I get a crash. So it seems the argumenst are not passed correctly. Looking
further in TF1 constructor I see there is a constructor for CINT as well
as compiled mode. Now I suspect that something goes wrong there. Probably
CINT calls in both above case the same constructor. However I think it
should call tge 'compiled mode' constructor in the second case.
Am I doing something trivial wrong?
Rutger
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET