~ubuntu-branches/ubuntu/lucid/pdl/lucid

« back to all changes in this revision

Viewing changes to t/clump.t

  • Committer: Bazaar Package Importer
  • Author(s): Ben Gertzfield
  • Date: 2002-04-08 18:47:16 UTC
  • Revision ID: james.westby@ubuntu.com-20020408184716-0hf64dc96kin3htp
Tags: upstream-2.3.2
ImportĀ upstreamĀ versionĀ 2.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Test ->clump(). This is not yet good enough: we need
 
2
# nasty test cases
 
3
 
 
4
use PDL::LiteF;
 
5
 
 
6
$|=1;
 
7
 
 
8
#  PDL::Core::set_debugging(1);
 
9
kill INT,$$  if $ENV{UNDER_DEBUGGER}; # Useful for debugging.
 
10
 
 
11
 
 
12
#$a = zeroes(4,4) * zeroes(4,4);
 
13
# $a = zeroes(4,4) ;
 
14
 
 
15
#print $a;
 
16
#
 
17
#print $a->at(3,3);
 
18
#
 
19
#exit 4;
 
20
 
 
21
 
 
22
sub ok {
 
23
        my $no = shift ;
 
24
        my $result = shift ;
 
25
        print "not " unless $result ;
 
26
        print "ok $no\n" ;
 
27
}
 
28
 
 
29
sub tapprox {
 
30
        my($a,$b) = @_;
 
31
        my $c = abs($a-$b);
 
32
        my $d = max($c);
 
33
        print "C AND D: $a,$b,$c,$d\n";
 
34
        $d < 0.01;
 
35
}
 
36
 
 
37
if(0) {
 
38
        $a0 = zeroes(3,3);
 
39
        print $a0;
 
40
        $b0 = 10 * $a0;
 
41
        print $b0;
 
42
}
 
43
 
 
44
$a0 = zeroes(3,3);
 
45
# $a = $a0->PDL::Core::new_or_inplace($a0);
 
46
$a = $a0->copy;
 
47
$b = $a->xchg(0,1);
 
48
print $a;
 
49
# PDL::Primitive::axisvalues($b);
 
50
# print $a;
 
51
 
 
52
print "1..3\n";
 
53
 
 
54
$a0 = xvals(zeroes(3,3));
 
55
 
 
56
print $a0;
 
57
 
 
58
$a1 = yvals(zeroes(3,3));
 
59
 
 
60
print $a1;
 
61
 
 
62
$a2 = 10*$a1;
 
63
 
 
64
print $a2;
 
65
 
 
66
$a3 = $a0 + $a1;
 
67
 
 
68
print $a3;
 
69
 
 
70
$a = xvals(zeroes(3,3)) + 10*yvals(zeroes(3,3));
 
71
 
 
72
 print $a;
 
73
 
 
74
$b = $a->clump(-1);
 
75
 
 
76
# $b->make_physical();
 
77
 
 
78
# $a->jdump();
 
79
# $b->jdump();
 
80
 
 
81
print $b;
 
82
 
 
83
ok(1,tapprox($b,pdl [0,1,2,10,11,12,20,21,22]));
 
84
 
 
85
# print $b;
 
86
 
 
87
$c = $a->slice('0:2:2,:');
 
88
 
 
89
$d = $c->clump(-1);
 
90
 
 
91
$e = $d->slice("2:4");
 
92
 
 
93
$f = ""; # Warning eater
 
94
 
 
95
$f= $e->copy();;
 
96
 
 
97
kill INT,$$  if $ENV{UNDER_DEBUGGER}; # Useful for debugging.
 
98
# ok(2,$@ =~ /^clump: Increments do not match/);
 
99
# Clump supports this now.
 
100
ok(2,tapprox($d,pdl [0,2,10,12,20,22]));
 
101
 
 
102
ok(3,tapprox($e,pdl [10,12,20]));