Hello all, I tried to define a fit function to a Landau distribution using denlan from the Cernlib. To do this I recompile the root application linking denlan. It works fine if I define my fit function fitlan.C with a macro. If I try to link it also I cannot use it in a TF1 definition. (I'm running on a PC-Linux Debian 1.3 with root 2.02) Any Ideas ? Best regards Laurent Exemple: [/users/delphi/mirabito/root/me] myroot 0.039163 ******************************************* * * * W E L C O M E to R O O T * * * * Version 2.00/02 23 March 1998 * * * * You are welcome to visit our Web site * * http://root.cern.ch * * * ******************************************* CINT/ROOT C/C++ Interpreter version 5.13.45, Mar 17 1998 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }. root [0] Double_t x[1]={200.}; root [1] Double_t par[3]={1000.,200.,50.}; root [2] printf("%f \n",fitlan(x,par)); 178.854167 root [3] TF1* l = new TF1("fitlan",fitlan,0,2000,3); root [4] l->SetParameters(1000.,200.,50.) root [5] l->SetParNames("Sum","Maximum of Probability","Width") root [6] l->Draw() Warning in <MakeDefCanvas>: creating a default canvas with name c1 *** Break *** segmentation violation *** Break *** segmentation violation -- myroot.h extern "C" Double_t denlan_(Float_t *x); extern Double_t fitlan(Double_t *x,Double_t *par); -- myroot.C /////////////////////////////////////////////////////////////////////////////////////////////////////// // // // RMain // // // // Main program used to create ROOT application. // // // ////////////////////////////////////////////////////////////////////////// #include "TROOT.h" #include "TRint.h" #include "myroot.h" #include <TApplication.h> #include <TGClient.h> extern void InitGui(); VoidFuncPtr_t initfuncs[] = { InitGui, 0 }; TROOT root("Rint","The ROOT Interactive Interface", initfuncs); //______________________________________________________________________________ int main(int argc, char **argv) { Float_t tt = 5.0; printf("%f \n",denlan_(&tt)); TRint *theApp = new TRint("Rint", &argc, argv, 0, 0); // TApplication *theApp= new TApplication("App", &argc, argv); // Init Intrinsics, build all windows, and enter event loop theApp->Run(); delete theApp; return(0); } -- fitlan.C //extern Double_t denlan(Double_t*); #include "TROOT.h" #include "TMath.h" #include "myroot.h" Double_t fitlan(Double_t *x,Double_t *par) { /* System generated locals */ Float_t r__1; Double_t ret_val; /* Local variables */ ret_val = 0.; r__1 = (x[0] - TMath::Abs(par[1])) / TMath::Abs(par[2]); ret_val = par[0] * (denlan_(&r__1)); return ret_val; } /* fitlan*/ Laurent Mirabito IPN Lyon
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:31 MET