1#!perl -T
2use 5.008003;
3use strict;
4use warnings FATAL => 'all';
5use Math::Derivative qw(forwarddiff);
6use Math::Utils qw(:compare);
7use Test::More tests => 1;
8
9
10my($fltcmp) = generate_fltcmp();
11
12my @temperature = (
13	16.4, 16.46, 16.52,
14	16.58, 16.65, 16.71,
15	16.79, 16.87, 16.94 );
16my @height = (
17	5000.4, 5007.2, 5014.0,
18	5021.7, 5029.8, 5037.9,
19	5046.2, 5053.7, 5061.7);
20
21my @expected = (
22	0.008823529, 0.008823529, 0.007792208,
23	0.008641975, 0.007407407, 0.009638554,
24	0.010666667, 0.00875, 0.009345794);
25
26my @first_derivative = forwarddiff(\@height, \@temperature);
27
28my $msg = "";
29
30for my $j (0 .. $#expected - 1)
31{
32	if (&$fltcmp($first_derivative[$j], $expected[$j]) != 0)
33	{
34		$msg .= sprintf("%g returned at index %d; expected %g\n",
35				$first_derivative[$j],
36				$j,
37				$expected[$j]);
38	}
39}
40
41ok($msg eq "", $msg);
42
43