Debian Codegraph @

t/t10.t

raw symbols SCIP
1 use strict; use warnings;
2 use Test::More;
3 use Config;
4 # Stop f77-linking causing spurious undefined symbols (alpha)
5 $ENV{'PERL_DL_NONLAZY'}=0 if $Config{'osname'} eq "dec_osf";
6 require PGPLOT;
7
8 my $dev = $ENV{PGPLOT_DEV} || '/NULL';
9
10 $ENV{PGPLOT_XW_WIDTH}=0.3;
11
12 note "Testing multiple ways of passing things";
13
14 # Create 138x128 image - note must use transpose as
15 # perl is column major like C (see docs)
16
17 my $k=0;
18 my (@img1D, @img2D);
19 for(my $i=0; $i<128; $i++) { for(my $j=0; $j<138; $j++) {
20 $img2D[$i][$j] = sqrt($i*$j) / 128;
21 $img1D[$k] = $img2D[$i][$j]; $k++; # For 1D test
22 }}
23
24 my $imgchar = pack("f*",@img1D);
25
26 PGPLOT::pgbegin(0,$dev,2,2); # Open plot device
27
28 note "Plotting...";
29
30 my @tr=(0,1,0,0,0,1);
31
32 my @x=(10,20,30,40,50,60,70,80,90,100,110);
33 my @y=(30,35,40,45,50,55,60,65,70,75, 80);
34
35 nextplot('Points: scalars passed one by one','Image: packed char string');
36
37 PGPLOT::pggray($imgchar,138,128,1,138,1,128,1,0,\@tr);
38 for(my $i=0; $i<11; $i++){ PGPLOT::pgpt(1,$x[$i],$y[$i],17) }
39
40 nextplot('Points: 1D array passed by glob','Image: 1D array passed by glob');
41
42 PGPLOT::pggray(\@img1D,138,128,1,138,1,128,1,0,\@tr);
43 PGPLOT::pgpt(11,\@x,\@y,17);
44
45 nextplot('Points: 1D array passed by reference','Image: 1D array passed by reference');
46
47 PGPLOT::pggray(\@img1D,138,128,1,138,1,128,1,0,\@tr);
48 PGPLOT::pgpt(11,\@x,\@y,17);
49
50 nextplot('Line: 1D cross-section of 2D array','Image: 2D array passed by reference');
51
52 PGPLOT::pggray(\@img2D,138,128,1,138,1,128,1,0,\@tr);
53 PGPLOT::pgwindow(0,128,0,1);
54 PGPLOT::pgline(128, [0..127], $img2D[127]);
55
56 PGPLOT::pgend();
57
58 pass;
59 done_testing;
60
61 sub nextplot {
62 note $_[0];
63 note $_[1];
64 note "--------------------------------------";
65 PGPLOT::pgpage(); PGPLOT::pgwnad(0,128,0,128); PGPLOT::pgsci(3); PGPLOT::pgsch(1.3);
66 PGPLOT::pgbox("BCST",0,0,"BCST",0,0);
67 if ($^O ne 'freebsd') {
68 # blows up for some reason
69 PGPLOT::pgmtext('T',1.0,0.2,0,$_[0]);
70 PGPLOT::pgmtext('T',2.4,0.2,0,$_[1]);
71 }
72 PGPLOT::pgsci(4);
73 }