line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Testing the Math::VectorReal module |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# location of my libraries (I normally set this via PERL5LIB) |
6
|
|
|
|
|
|
|
#use lib '/home/anthony/lib/perl5'; # location of my libraries |
7
|
1
|
|
|
1
|
|
964
|
use FindBin; |
|
1
|
|
|
|
|
1234
|
|
|
1
|
|
|
|
|
52
|
|
8
|
1
|
|
|
1
|
|
995
|
use lib "$FindBin::Bin/blib/lib"; |
|
1
|
|
|
|
|
838
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
974
|
use Math::VectorReal qw( :all ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3521
|
|
11
|
|
|
|
|
|
|
#$Math::VectorReal::TRACE = 1; # Tracing of overload operators on/off |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
11
|
print "Stringify output testing (MatrixReal default)\n"; |
14
|
1
|
|
|
|
|
7
|
print 'O->stringify => ', O->stringify; |
15
|
1
|
|
|
|
|
20
|
print "\n"; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
3
|
print "Changing default vector to string format\n"; |
18
|
1
|
|
|
|
|
3
|
print '$Math::VectorReal::FORMAT = "[ %g %g %g ]";', "\n"; |
19
|
1
|
|
|
|
|
2
|
$Math::VectorReal::FORMAT = "[ %g %g %g ]"; |
20
|
1
|
|
|
|
|
2
|
print "\n"; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
3
|
print "Axis functions, assign to constants\n"; |
23
|
1
|
|
|
|
|
5
|
print ' $o = O => ', $o=O, "\n"; |
24
|
1
|
|
|
|
|
6
|
print ' $x = X => ', $x=X, "\n"; |
25
|
1
|
|
|
|
|
6
|
print ' $y = Y => ', $y=Y, "\n"; |
26
|
1
|
|
|
|
|
5
|
print ' $z = Z => ', $z=Z, "\n"; |
27
|
1
|
|
|
|
|
4
|
print "\n"; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
3
|
print "String conversion operation testing\n"; |
30
|
1
|
|
|
|
|
2
|
print "Note: this include some automatic stringify concat ('.') operations\n"; |
31
|
1
|
|
|
|
|
4
|
print ' "$o" => ', "$o", "\n"; |
32
|
1
|
|
|
|
|
34
|
print '""$x =>', " $x", "\n"; |
33
|
1
|
|
|
|
|
5
|
print ' $y"" => ', "$y\n"; |
34
|
1
|
|
|
|
|
5
|
print ' $z => ', $z, "\n"; |
35
|
1
|
|
|
|
|
6
|
print 'vector(1,2,3) => ', vector(1,2,3), "\n"; |
36
|
1
|
|
|
|
|
4
|
print "\n"; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
2
|
print "Addition\n"; |
39
|
1
|
|
|
|
|
12
|
$a = $x + Y; |
40
|
1
|
|
|
|
|
6
|
print '$a = $x + Y => ', $a, "\n"; |
41
|
1
|
|
|
|
|
15
|
$a += $y ; |
42
|
1
|
|
|
|
|
6
|
print '$a += $y => ', $a, "\n"; |
43
|
1
|
|
|
|
|
2
|
print "\n"; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
2
|
print "Clone and Addition Tests\n"; |
46
|
1
|
|
|
|
|
2
|
$b = $y; |
47
|
1
|
|
|
|
|
4
|
print '$b = $y => ', $b, "\n"; |
48
|
1
|
|
|
|
|
4
|
$b += Z; |
49
|
1
|
|
|
|
|
5
|
print '$b += Z => ', $b, "\n"; |
50
|
1
|
|
|
|
|
4
|
print ' $y => ', $y, "\n"; |
51
|
1
|
|
|
|
|
3
|
print "\n"; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
2
|
print "Subtraction\n"; |
54
|
1
|
|
|
|
|
4
|
$b -= $z ; |
55
|
1
|
|
|
|
|
5
|
print '$b -= $z => ', $b, "\n"; |
56
|
1
|
|
|
|
|
4
|
$b = $b - Z ; |
57
|
1
|
|
|
|
|
6
|
print '$b = $b - Z => ', $b, "\n"; |
58
|
1
|
|
|
|
|
2
|
print "\n"; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
2
|
print "Scalar Multiply\n"; |
62
|
1
|
|
|
|
|
5
|
$a = $z * 2; |
63
|
1
|
|
|
|
|
5
|
print '$a = $z * 2 => ', $a, "\n"; |
64
|
1
|
|
|
|
|
5
|
$a = 2 * Z; |
65
|
1
|
|
|
|
|
7
|
print '$a = 2 * Z => ', $a, "\n"; |
66
|
1
|
|
|
|
|
10
|
$a *= 2.5; |
67
|
1
|
|
|
|
|
5
|
print '$a *= 2.5 => ', $a, "\n"; |
68
|
1
|
|
|
|
|
3
|
print "\n"; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
2
|
print "Scalar Divide\n"; |
71
|
1
|
|
|
|
|
4
|
$a = $b / 2; |
72
|
1
|
|
|
|
|
6
|
print '$a = $b / 2 => ', $a, "\n"; |
73
|
1
|
|
|
|
|
4
|
$a /= 3e14; |
74
|
1
|
|
|
|
|
5
|
print '$a /= 3e14 => ', $a, "\n"; |
75
|
1
|
|
|
|
|
3
|
print "\n"; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
2
|
print "Unary - and more subtraction\n"; |
79
|
1
|
|
|
|
|
4
|
$b = -$b; |
80
|
1
|
|
|
|
|
5
|
print '$b = -$b => ', $b, "\n"; |
81
|
1
|
|
|
|
|
3
|
$b -= Z; |
82
|
1
|
|
|
|
|
5
|
print '$b -= Z => ', $b, "\n"; |
83
|
1
|
|
|
|
|
4
|
$b -= $z - -$y; |
84
|
1
|
|
|
|
|
7
|
print '$b -= $z - -$y => ', $b, "\n"; |
85
|
1
|
|
|
|
|
5
|
$b = $o - $b; |
86
|
1
|
|
|
|
|
6
|
print '$b = $o - $b => ', $b, "\n"; |
87
|
1
|
|
|
|
|
3
|
print "\n"; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
2
|
print "Cross Product\n"; |
91
|
1
|
|
|
|
|
12
|
$a = $b x X; |
92
|
1
|
|
|
|
|
7
|
print '$a = $b x X => ', $a, "\n"; |
93
|
1
|
|
|
|
|
3
|
$a = $b x $y; |
94
|
1
|
|
|
|
|
5
|
print '$a = $b x $y => ', $a, "\n"; |
95
|
1
|
|
|
|
|
5
|
$a = $b x $z; |
96
|
1
|
|
|
|
|
5
|
print '$a = $b x $z => ', $a, "\n"; |
97
|
1
|
|
|
|
|
3
|
print "\n"; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
2
|
print "Dot Product / String Concatenation\n"; |
101
|
1
|
|
|
|
|
570
|
$a = Z . $b; |
102
|
1
|
|
|
|
|
9
|
print '$a = Z . $b => ', $a, "\n"; |
103
|
1
|
|
|
|
|
3
|
$a = $b . -$y; |
104
|
1
|
|
|
|
|
6
|
print '$a = $b . -$y => ', $a, "\n"; |
105
|
1
|
|
|
|
|
3
|
$s = $b . "!"; |
106
|
1
|
|
|
|
|
3
|
print '$s = $b . "!" => ', $s, "\n"; |
107
|
1
|
|
|
|
|
4
|
$s = "!" . $b; |
108
|
1
|
|
|
|
|
2
|
print '$s = "!" . $b => ', $s, "\n"; |
109
|
1
|
|
|
|
|
3
|
$a .= $b; |
110
|
1
|
|
|
|
|
3
|
print '$a .= $b => ', $a, "\n"; |
111
|
1
|
|
|
|
|
2
|
print "\n"; |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
1
|
print "Special Functions (length, norm, plane)\n"; |
114
|
1
|
|
|
|
|
5
|
print '$b->length => ', $b->length, "\n"; |
115
|
1
|
|
|
|
|
5
|
print '$b->norm => ', $b->norm, "\n"; |
116
|
1
|
|
|
|
|
9
|
@a = plane(X,Y,Z); |
117
|
1
|
|
|
|
|
10
|
print '@a = plane(X,Y,Z) => ', "\n @a\n"; |
118
|
1
|
|
|
|
|
3
|
print "check output from plane() function\n"; |
119
|
1
|
|
|
|
|
3
|
$a = X+Y+Z; |
120
|
1
|
|
|
|
|
7
|
print 'normal => ', $a->norm, "\n"; |
121
|
1
|
|
|
|
|
5
|
print 'distance => ', ($a/3)->length, "\n"; |
122
|
1
|
|
|
|
|
3
|
print "\n"; |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
2
|
print "Are defined constants still OK\n"; |
125
|
1
|
|
|
|
|
3
|
print '$o => ', $o, "\n"; |
126
|
1
|
|
|
|
|
4
|
print '$x => ', $x, "\n"; |
127
|
1
|
|
|
|
|
4
|
print '$y => ', $y, "\n"; |
128
|
1
|
|
|
|
|
4
|
print '$z => ', $z, "\n"; |
129
|
1
|
|
|
|
|
0
|
print "\n"; |
130
|
|
|
|
|
|
|
|