Re: pointer to real function

Rene Brun (Rene.Brun@cern.ch)
Mon, 21 Jul 1997 18:31:57 +0200


Marc Mueller wrote:
>
> Hi,
> I can't use the pointer to a real function in class TF2.
> There occurs always the report
> *ERROR 26 :
> Unknown name : "dmodel"
> but the function dmodel is correct defined.
> Who can give me support?
>
> Thanks in advance,
> Marc Mueller
>
> Double_t dmodel(Double_t *x,Double_t *par)
> {
> Double_t A=par[0];
> Double_t B=par[1];
> Double_t Lmax=par[2];
> Double_t g=par[3];
> Double_t c=par[4];
> Double_t tax=par[5];
> Double_t M=par[6];
> Double_t p=x[0];
> Double_t w=x[1];
> Double_t Y,Ymax,YS,YD;
> Ymax=(A/B)*pow(Lmax,B);
> YS=(A/B)*pow((w/(A*p)),(B/(B-1)));
> YD=((M/p)+g)/(1-c*(1-tax));
> Y=Ymax;
> if(Y>YS) Y=YS;
> if(Y>YD) Y=YD;
> return Y;
> }
> void bo()
> {
> gROOT->Reset();
> Double_t x[2];
> Double_t params[7];
> params[0]=1.0; // A
> params[1]=0.5; // B
> params[2]=16; // Lmax
> params[3]=1.5; // g
> params[4]=0.5; // c
> params[5]=0.25;// tax
> params[6]=1.0; // M
> c1 = new TCanvas("Y_p_w","Y_p_w Surface",200,100,600,500);
> TF2 *f2 = new TF2("dm",dmodel,7);
> f2->InitArgs(x,params);
> f2->SetRange(0.1,0.1,1,1);
> f2->Draw("surf2");
> }

The class TF2 had only one valid constructor so far (online formula).
I have now implemented two additional constructors in TF2 (see Web pages)
to support pointers to interpreted or compiled functions.
With the new version, the last few lines of your macro should be replaced
by :
TF2 *f2 = new TF2("dm",dmodel,0.1,1,0.1,1,7);
f2->SetParameters(params);
f2->Draw("surf2");

The changes will appear in the released version at the end of this week.

Rene Brun