1use Test::More; 2use PDL::LiteF; 3 4use strict; 5use warnings; 6 7BEGIN { 8 eval { 9 require PDL::Fit::Polynomial; 10 PDL::Fit::Polynomial->import(); 11 1; 12 } or plan skip_all => "PDL::Fit::Polynomial: $@"; 13} 14 15kill 'INT',$$ if $ENV{UNDER_DEBUGGER}; # Useful for debugging. 16plan tests => 1; 17 18my $x = sequence(20)-10; 19my $y = 30-2*$x+3*$x**2-2*$x**3; 20 21# Random numbers, generated by grandom($y)*100 22# Hard-wired to avoid OS seed variations barfing test 23 24my $rand = pdl qw/65.735917 -40.510143 -122.07767 -19.591344 -139.76362 25106.44639 -0.30094068 -5.3129683 49.815455 97.247868 -9.3130775 2619.585472 8.5260268 -194.49596 73.822799 25.628967 133.36015 -2.6611465 279.0335632 -0.82946383/; 28 29$y += $rand; 30 31#points $x,$y; 32 33my $yfit = fitpoly1d($x,$y,4); 34 35#hold; line $x, $yfit; 36 37ok(max(abs($y-$yfit)) < 220); # need to add 10 for windows 38