line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ToolSet::Math; |
2
|
1
|
|
|
1
|
|
532
|
use base qw(ToolSet); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
558
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1165
|
use 5.008_005; |
|
1
|
|
|
|
|
4
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use List::Util qw(reduce); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
183
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
1
|
|
|
1
|
|
4
|
our $VERSION = "1.001"; |
12
|
1
|
|
|
|
|
55
|
$VERSION = eval $VERSION; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
87
|
our @EXPORT = qw( |
15
|
|
|
|
|
|
|
E LN2 LN10 PI PI2 PI4 PIP2 PIP4 SQRT2 SQRT5 SQRT1_2 GOLDENR |
16
|
|
|
|
|
|
|
log2 fac |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
ToolSet->export( |
21
|
|
|
|
|
|
|
"List::Util" => [qw(max min sum sum0)], |
22
|
|
|
|
|
|
|
"Math::Trig" => undef, |
23
|
|
|
|
|
|
|
"Math::Complex" => undef, |
24
|
|
|
|
|
|
|
"Math::Complex" => [qw(:pi)], |
25
|
|
|
|
|
|
|
"POSIX" => [qw( |
26
|
|
|
|
|
|
|
ceil floor modf pow round |
27
|
|
|
|
|
|
|
isfinite isinf isnan |
28
|
|
|
|
|
|
|
FLT_EPSILON DBL_EPSILON nan NaN NAN |
29
|
|
|
|
|
|
|
)], # use int() for trunc() |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
6
|
use constant E => exp(1); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
139
|
|
33
|
1
|
|
|
1
|
|
7
|
use constant LN2 => log(2); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
34
|
1
|
|
|
1
|
|
6
|
use constant LN10 => log(10); |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
65
|
|
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
6
|
use constant PI => 4 * CORE::atan2(1, 1); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
37
|
1
|
|
|
1
|
|
6
|
use constant PI2 => PI * 2; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
38
|
1
|
|
|
1
|
|
5
|
use constant PI4 => PI * 4; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
39
|
1
|
|
|
1
|
|
16
|
use constant PIP2 => PI / 2; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
40
|
1
|
|
|
1
|
|
6
|
use constant PIP4 => PI / 4; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
6
|
use constant SQRT2 => sqrt(2); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
54
|
|
43
|
1
|
|
|
1
|
|
6
|
use constant SQRT5 => sqrt(5); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
44
|
1
|
|
|
1
|
|
5
|
use constant SQRT1_2 => sqrt(1 / 2); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
74
|
|
45
|
1
|
|
|
1
|
|
6
|
use constant GOLDENR => (1 + SQRT5) / 2; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
153
|
|
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
4
|
0
|
1953
|
sub log2 { Math::Complex::log($_[0]) / LN2 } |
48
|
|
|
|
|
|
|
|
49
|
13
|
100
|
|
13
|
0
|
28
|
sub fac { !$_[0] ? 1 : reduce { $a * $b } 1 .. $_[0] } |
|
5
|
|
|
5
|
|
597
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |