File: poly.t

package info (click to toggle)
libpdl-fit-perl 2.100-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 164 kB
  • sloc: ansic: 249; perl: 179; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 652 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use strict;
use warnings;
use Test::More;
use PDL::LiteF;
use PDL::Fit::Polynomial;

my $x = sequence(20)-10;
my $y = 30-2*$x+3*$x**2-2*$x**3;

# Random numbers, generated by  grandom($y)*100
# Hard-wired to avoid OS seed variations barfing test

my $rand = pdl qw/65.735917 -40.510143 -122.07767 -19.591344 -139.76362  
106.44639 -0.30094068 -5.3129683  49.815455  97.247868 -9.3130775  
19.585472  8.5260268 -194.49596  73.822799  25.628967  133.36015 -2.6611465  
9.0335632 -0.82946383/;

$y += $rand;

#points $x,$y;

my $yfit = fitpoly1d($x,$y,4);

#hold; line $x, $yfit;

ok(max(abs($y-$yfit)) < 220); # need to add 10 for windows

done_testing;