Hi, I also stumbled on this problem. The overprotective approach of gsl when dealing with extrapolations was a pain in several portions of my code. I eventually found an obscure workaround in a web page (I am sorry that I cannot give proper credit, I lost the web page address). In the code below I have defined XX and YY as std::vector with a number of points of the order of the interpolation and loaded them with the proper values ------- #include <gsl/gsl_interp.h> gsl_interp_accel *acc = gsl_interp_accel_alloc(); gsl_interp *poly = gsl_interp_alloc(gsl_interp_polynomial, XX.size()); gsl_interp_init(poly, &XX[0], &YY[0], XX.size()); // THIS IS THE WORK AROUND THAT ALLOWS EXTRAPOLATION poly->type->eval(poly->state, &XX[0], &YY[0], poly->size, x, acc, &yy); gsl_interp_free(poly); gsl_interp_accel_free(acc);
------ The above seems to work fine. But I found this so much obscure that I ended up rewriting the interpolation functions I needed myself. Cheers, Ric. ________________________________ From: jeremy theler <[email protected]> To: [email protected] Sent: Friday, May 3, 2013 2:10 AM Subject: Re: [Help-gsl] GSL1.15: interp.c: 150: ERROR: interpolation error Yanna, I have stumbled with the same issue when upgrading from 1.14 to 1.15. My fix consisted in checking if the argument was located in the proper range (i.e. between xmin and xmax) before calling gsl_interp_eval(). If it not, I just compute a simple linear extrapolation with the last two values of the function definition. I also miss the good old days when extrapolation was automatically computed using the chosen interpolation scheme. Can this behavior be added as a flag or as a new function? BTW, of course you are allowed to change the code. It seems to me that you are not re-compiling the library after modifying the source file. Regards -- jeremy On Thursday 02 May 2013 10:13:37 CRUZ-CAVALCANTI, Yanna wrote: > Hello again, > > I understand this change is an improvement to gsl, but for now I would Just > like to make my code work. Although, when I change the code interp.c back > to its ancient state is like the change is never saved, even if I saved > it. Am I allowed to do that, that is, change this code? > > Thank you for the help. > > Yanna > > -----Message d'origine----- > De : Rhys Ulerich [mailto:[email protected]] > Envoyé : jeudi 2 mai 2013 14:13 > À : CRUZ-CAVALCANTI, Yanna > Cc : GSL Help Mailing List > Objet : Re: [Help-gsl] GSL1.15: interp.c: 150: ERROR: interpolation error > > > if (x < interp->xmin || x > interp->xmax) > > > > { > > > > GSL_ERROR_VAL("interpolation error", GSL_EDOM, GSL_NAN); > > > > } > > That is exactly the line to which I was referring. If you are > extrapolating using the interpolation routines (x < xmin || x > xmax), > you get an "interpolation error" from the line in your original bug > report. > > The changeset I mentioned was made because accidentally extrapolating > when you meant to interpolate is wildly dangerous. I suspect your > code has been extrapolating all these years, and it is this recent > defensive fix that now causes it to report an error. > > - Rhys >
