GSL Interpolator randomly crashes?

I am using this to interpolate function values:

[code] const double max = 2147483648;
double nu = rand()/max;

double y[41];
for(int i = 0; i < 41; i++) {
y[i] = (double)i;
}

double m1ty2[41];
m1ty2[0] = 0;
for(int i = 0; i < 40; i++) {
m1ty2[i+1] = m1ty[i];
}

ROOT::Math::Interpolator vfind(41, ROOT::Math::Interpolation::kAKIMA);
vfind.SetData(41, m1ty2, y);
double t;

t = vfind.Eval(nu);
[/code]

Here are the values:

i,y[0],m1ty2[0] = 0,0.000000,0.000000
i,y[1],m1ty2[1] = 1,1.000000,0.001090
i,y[2],m1ty2[2] = 2,2.000000,0.002652
i,y[3],m1ty2[3] = 3,3.000000,0.012321
i,y[4],m1ty2[4] = 4,4.000000,0.027259
i,y[5],m1ty2[5] = 5,5.000000,0.047992
i,y[6],m1ty2[6] = 6,6.000000,0.074795
i,y[7],m1ty2[7] = 7,7.000000,0.107240
i,y[8],m1ty2[8] = 8,8.000000,0.143878
i,y[9],m1ty2[9] = 9,9.000000,0.182101
i,y[10],m1ty2[10] = 10,10.000000,0.222717
i,y[11],m1ty2[11] = 11,11.000000,0.264620
i,y[12],m1ty2[12] = 12,12.000000,0.306531
i,y[13],m1ty2[13] = 13,13.000000,0.347742
i,y[14],m1ty2[14] = 14,14.000000,0.387842
i,y[15],m1ty2[15] = 15,15.000000,0.426756
i,y[16],m1ty2[16] = 16,16.000000,0.465835
i,y[17],m1ty2[17] = 17,17.000000,0.504637
i,y[18],m1ty2[18] = 18,18.000000,0.542549
i,y[19],m1ty2[19] = 19,19.000000,0.579252
i,y[20],m1ty2[20] = 20,20.000000,0.614601
i,y[21],m1ty2[21] = 21,21.000000,0.648580
i,y[22],m1ty2[22] = 22,22.000000,0.681212
i,y[23],m1ty2[23] = 23,23.000000,0.712527
i,y[24],m1ty2[24] = 24,24.000000,0.742553
i,y[25],m1ty2[25] = 25,25.000000,0.771321
i,y[26],m1ty2[26] = 26,26.000000,0.798865
i,y[27],m1ty2[27] = 27,27.000000,0.825224
i,y[28],m1ty2[28] = 28,28.000000,0.850439
i,y[29],m1ty2[29] = 29,29.000000,0.874554
i,y[30],m1ty2[30] = 30,30.000000,0.897593
i,y[31],m1ty2[31] = 31,31.000000,0.919548
i,y[32],m1ty2[32] = 32,32.000000,0.940238
i,y[33],m1ty2[33] = 33,33.000000,0.958804
i,y[34],m1ty2[34] = 34,34.000000,0.973965
i,y[35],m1ty2[35] = 35,35.000000,0.985286
i,y[36],m1ty2[36] = 36,36.000000,0.992806
i,y[37],m1ty2[37] = 37,37.000000,0.996974
i,y[38],m1ty2[38] = 38,38.000000,0.998795
i,y[39],m1ty2[39] = 39,39.000000,0.999568
i,y[40],m1ty2[40] = 40,40.000000,1.000000

This randomly crashes after a thousand or so loops. I get this error message:

Error in <GSLError>: Error 4 in interp.c at 83 : x values must be monotonically increasing variance7: /tmp/root/math/mathmore/src/GSLInterpolator.h:75: double ROOT::Math::GSLInterpolator::Eval(double) const: Assertion `fAccel' failed.

The x values are monotonically increasing. The random numbers it crashes on vary, well, randomly. What is causing this?

Hi,

I do not have any problem executing your code, with the data you have shown. Pleas epos a full running macro that gives you this error, so it can be understood

Lorenzo