Hi Yuri, Thanks for the interesting question, and also for providing a comparison of the result with different OS, GSL, and PDL versions. That was very helpful. In particular, the difference between your current Slackware setup (with PDL 2.021 and GSL 2.6) and your old Slackware setup (with PDL 2.021 and GSL 1.14) suggests that the change is due to GSL, not PDL. Indeed, the changelog for GSL 1.15 shows exactly the problem:
http://git.savannah.gnu.org/cgit/gsl.git/tree/NEWS#n470 "The interpolation functions now return NaN " … "when x is out of range, instead of extrapolating." https://lists.gnu.org/archive/html/help-gsl/2011-12/msg00024.html <https://lists.gnu.org/archive/html/help-gsl/2011-12/msg00024.html> and the links there show the change and the train of thought. Clearly PDL::GSL::INTERP needs to be updated to reflect this reality. If you would like to open a bug report on GitHub, that would be great. As to your immediate problem, I've used PDL::Func to achieve this. Picking up from your example: use PDL::Func; $obj = PDL::Func->init(Interpolate=>"Linear", x=>$x, y=>$y); $yy = $obj->interpolate($xx); print $yy; [0.555 0.566 0.567 0.567 0.569 0.572 0.577 0.584 0.591 0.598 0.605] If you install Slatec then PDL::Func will give you access to the Hermite interpolation scheme, and then you can do differentiation and integration. cheers, Derek > On Jun 17, 2020, at 10:39 AM, Yury Pakhomov <[email protected]> wrote: > > Hello all! > > I faced with a problem in the module PDL::GSL::INTERP. > I want to extrapolate data which out of range using option {Extrapolate=>1} > This is code: > > #_________________ > use PDL; > use PDL::GSL::INTERP; > > $x=sequence(9)*0.5; > $y=pdl(qw( 0.555 0.566 0.567 0.567 0.569 0.572 0.577 0.584 0.591)); > > $spl=PDL::GSL::INTERP->init('akima',$x,$y); > > $xx=sequence(11)*0.5; > $yy=$spl->eval($xx,{Extrapolate=>1}); > > print $yy; > #__________________ > > My computer give me result > [0.555 0.566 0.567 0.567 0.569 0.572 0.577 0.584 0.591 NaN NaN] > > Why NaN? The function is very smooth. I use Slackware Linux (current update) > with gsl-2.6 and PDL-2.021 compiled from sources. I try to recompile gsl and > PDL. No changes. > One different computer (Fedora core 22, gsl-1.16, > perl-PDL-2.7.0-8.fc22.x86_64) also shows this result. However, computer with > old Slackware Linux 13.37, gsl-1.14 and PDL-2.021 compiled from sources works > fine > [0.555 0.566 0.567 0.567 0.569 0.572 0.577 0.584 0.591 0.598 0.605] > > Where the root of the problem? > > Bw, Yuri > > > _______________________________________________ > pdl-general mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/pdl-general >
_______________________________________________ pdl-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pdl-general
