Debian Codegraph @

t/poly.t

raw symbols SCIP
1 use strict;
2 use warnings;
3 use Test::More;
4 use PDL::LiteF;
5 use PDL::Fit::Polynomial;
6
7 my $x = sequence(20)-10;
8 my $y = 30-2*$x+3*$x**2-2*$x**3;
9
10 # Random numbers, generated by grandom($y)*100
11 # Hard-wired to avoid OS seed variations barfing test
12
13 my $rand = pdl qw/65.735917 -40.510143 -122.07767 -19.591344 -139.76362
14 106.44639 -0.30094068 -5.3129683 49.815455 97.247868 -9.3130775
15 19.585472 8.5260268 -194.49596 73.822799 25.628967 133.36015 -2.6611465
16 9.0335632 -0.82946383/;
17
18 $y += $rand;
19
20 #points $x,$y;
21
22 my $yfit = fitpoly1d($x,$y,4);
23
24 #hold; line $x, $yfit;
25
26 ok(max(abs($y-$yfit)) < 220); # need to add 10 for windows
27
28 done_testing;