line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ToolSet::Math; |
2
|
1
|
|
|
1
|
|
537
|
use base qw(ToolSet); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
604
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1356
|
use 5.008_005; |
|
1
|
|
|
|
|
4
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use List::Util qw(reduce); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
204
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
1
|
|
|
1
|
|
5
|
our $VERSION = "1.002"; |
12
|
1
|
|
|
|
|
72
|
$VERSION = eval $VERSION; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
90
|
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
|
|
9
|
use constant E => exp(1); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
126
|
|
33
|
1
|
|
|
1
|
|
8
|
use constant LN2 => log(2); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
34
|
1
|
|
|
1
|
|
7
|
use constant LN10 => log(10); |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
76
|
|
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
7
|
use constant PI => 4 * CORE::atan2(1, 1); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
71
|
|
37
|
1
|
|
|
1
|
|
7
|
use constant PI2 => PI * 2; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
38
|
1
|
|
|
1
|
|
6
|
use constant PI4 => PI * 4; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
57
|
|
39
|
1
|
|
|
1
|
|
8
|
use constant PIP2 => PI / 2; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
40
|
1
|
|
|
1
|
|
7
|
use constant PIP4 => PI / 4; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
7
|
use constant SQRT2 => sqrt(2); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
43
|
1
|
|
|
1
|
|
7
|
use constant SQRT5 => sqrt(5); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
44
|
1
|
|
|
1
|
|
7
|
use constant SQRT1_2 => sqrt(1 / 2); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
45
|
1
|
|
|
1
|
|
6
|
use constant GOLDENR => (1 + SQRT5) / 2; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
193
|
|
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
4
|
0
|
1981
|
sub log2 { Math::Complex::log($_[0]) / LN2 } |
48
|
|
|
|
|
|
|
|
49
|
13
|
100
|
|
13
|
0
|
29
|
sub fac { !$_[0] ? 1 : reduce { $a * $b } 1 .. $_[0] } |
|
5
|
|
|
5
|
|
585
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |