File: interp.t

package info (click to toggle)
pdl 1%3A2.4.7%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,128 kB
  • ctags: 5,821
  • sloc: perl: 26,328; fortran: 13,113; ansic: 9,378; makefile: 71; sh: 50; sed: 6
file content (51 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (7)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# NOTE: 
#  currently not in use anymore
#  - see PDL::Func (in Lib/) and t/func.t
print "1..1\nok 1 # Skipped: see PDL::Func\n";
exit;

use PDL::LiteF;

use strict;

my $ctr = 0;
sub ok {
    $ctr++;
    my $result = shift ;
    print "not " unless $result ;
    print "ok $ctr\n" ;
}

print "1..5\n";

##########################################################

eval "use PDL::Interpolate;";

my $x = float( 1, 2, 3, 4, 5, 6, 8, 10 );
my $y = ($x * 3) * ($x - 2);

my $obj = new PDL::Interpolate( x => $x, y => $y );
ok( UNIVERSAL::isa( $obj, 'PDL::Interpolate' ) );
ok( $obj->library eq "PDL" );

my $xi = $x - 0.5;
my $yi = $obj->interpolate( $xi );
ok( $obj->status == -1 );

# compare to direct version
my ( $ans, $err ) = PDL::Primitive::interpolate( $xi, $x, $y );
my $d = abs( $ans - $yi ); 
ok( all $d < 1.0e-5 );

my $oerr = $obj->get( 'err' );
ok( all ($oerr-$err) == 0 );

#print "x:  ", $x, "\n";
#print "xi: ", $xi, "\n";
#print "$oerr\n";

# end