1 2# Test Script for the PDL interface to the GSL library 3# This tests mainly that the interface is working, i.e. that the 4# functions can be called. 5# The GSL library already has a extensive test suite, and we 6# do not want to duplicate that effort here. 7 8use PDL; 9use Test::More; 10 11BEGIN 12{ 13 use PDL::Config; 14 if ( $PDL::Config{WITH_GSL} ) { 15 eval " use PDL::GSL::DIFF; "; 16 unless ($@) { 17 plan tests => 4; 18 } else { 19 plan skip_all => "PDL::GSL::DIFF not installed."; 20 } 21 } else { 22 plan skip_all => "PDL::GSL::DIFF not compiled."; 23 } 24} 25 26@res = gsldiff(\&myf,1.5); 27 28ok(abs($res[0]- 28.4632075095177) < 1e-6 ); 29 30@res = gsldiff(\&myf,1.5,{Method => 'central'}); 31 32ok(abs($res[0]- 28.4632075095177) < 1e-6 ); 33 34@res = gsldiff(\&myf,1.5,{Method => 'forward'}); 35 36ok(abs($res[0]- 28.4632852673531) < 1e-6 ); 37 38@res = gsldiff(\&myf,1.5,{Method => 'backward'}); 39 40ok(abs($res[0]-28.4631297516823 ) < 1e-6 ); 41 42 43sub myf{ 44 my ($x) = @_; 45 return exp($x**2); 46} 47