TSpline::GetCoeff delivers wrong results (by a factor)

From: Stephan Schlee <sas_at_hll.mpg.de>
Date: Tue, 6 Dec 2011 09:54:01 +0100


Hi,

sorry, if this is a double- (or even a triple-)post, but my subscription didn't work at all.

Already posted this on the forum a week ago, but never got any reply. Any help would be appreciated!

The class TSpline3 seems to work quite fine, but when I call TSpline->GetCoeff, I get funny results.

The coefficients b,c and d are documented to be the first, second and third derivative at the node - but only b is of the stated behaviour. Unfortunately, I get values differing by a constant factor for c and d.

e.g. for the second derivative of x^3 i get 1 (instead of 6).

This issue seems to be in both TSpline3 and TSpline5.

Here is a short code example to resemble the problem:

     {
     TF1 *f1 = new TF1("f1","x*x",0,2);
     Double_t *a = new Double_t[5];
     Double_t *b = new Double_t[5];

     a[0]=0;
     a[1]=0.5;
     a[2]=1;
     a[3]=1.5;
     a[4]=2;

     for (Int_t i=0; i<5; i++){b[i] = f1->Eval(a[i]);}

     TGraph *g = new TGraph(5,a,b);
     TSpline3 *s = new TSpline3("spline",g);

     for (Int_t i=0; i<4; i++){
     Double_t *x = new Double_t;
     Double_t *y = new Double_t;
     Double_t *b = new Double_t;
     Double_t *c = new Double_t;
     Double_t *d = new Double_t;

     s->GetCoeff(i,*x,*y,*b,*c,*d);
     printf("%e,%e,%e,%e,%e\n",*x,*y,*b,*c,*d);

}
}

Best regards,
Stephan



ROOT 5.30
Linux 2.6.18-238.9.1.el5.centos.plus
g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50) Received on Tue Dec 06 2011 - 09:54:32 CET

This archive was generated by hypermail 2.2.0 : Wed Dec 07 2011 - 05:50:01 CET