line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2011-2020 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
|
|
|
|
|
|
# This code is part of distribution POSIX-1003. Meta-POD processed with |
6
|
|
|
|
|
|
|
# OODoc into POD and HTML manual-pages. See README.md |
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package POSIX::1003::Math; |
10
|
3
|
|
|
3
|
|
73254
|
use vars '$VERSION'; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
167
|
|
11
|
|
|
|
|
|
|
$VERSION = '1.02'; |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
16
|
use base 'POSIX::1003::Module'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
559
|
|
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
85
|
|
16
|
3
|
|
|
3
|
|
14
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
843
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my @constants; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Only from math.h. The first block are defined in POSIX.xs, the |
21
|
|
|
|
|
|
|
# second block present in Core. The last is from string.h |
22
|
|
|
|
|
|
|
our @IN_CORE = qw/abs exp log sqrt sin cos atan2 rand srand int/; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my @functions = qw/ |
25
|
|
|
|
|
|
|
acos asin atan ceil cosh floor fmod frexp |
26
|
|
|
|
|
|
|
ldexp log10 modf sinh tan tanh |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
div rint pow |
29
|
|
|
|
|
|
|
strtod strtol strtoul |
30
|
|
|
|
|
|
|
/; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
push @functions, @IN_CORE; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our %EXPORT_TAGS = |
35
|
|
|
|
|
|
|
( constants => \@constants |
36
|
|
|
|
|
|
|
, functions => \@functions |
37
|
|
|
|
|
|
|
, tables => [ '%math' ] |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $math; |
41
|
|
|
|
|
|
|
our %math; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
BEGIN { |
44
|
3
|
|
|
3
|
|
318
|
$math = math_table; |
45
|
3
|
|
|
|
|
68
|
push @constants, keys %$math; |
46
|
3
|
|
|
|
|
30
|
tie %math, 'POSIX::1003::ReadOnlyTable', $math; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# the argument to be optional is important for expression priority! |
51
|
0
|
|
|
0
|
1
|
0
|
sub acos(_) { goto &POSIX::acos } |
52
|
0
|
|
|
0
|
1
|
0
|
sub asin(_) { goto &POSIX::asin } |
53
|
0
|
|
|
0
|
1
|
0
|
sub atan(_) { goto &POSIX::atan } |
54
|
0
|
|
|
0
|
1
|
0
|
sub ceil(_) { goto &POSIX::ceil } |
55
|
0
|
|
|
0
|
1
|
0
|
sub cosh(_) { goto &POSIX::cosh } |
56
|
2
|
|
|
2
|
1
|
2278
|
sub floor(_) { goto &POSIX::floor } |
57
|
0
|
|
|
0
|
1
|
0
|
sub frexp(_) { goto &POSIX::frexp } |
58
|
0
|
|
|
0
|
1
|
0
|
sub ldexp(_) { goto &POSIX::ldexp } |
59
|
0
|
|
|
0
|
1
|
0
|
sub log10(_) { goto &POSIX::log10 } |
60
|
0
|
|
|
0
|
1
|
0
|
sub sinh(_) { goto &POSIX::sinh } |
61
|
0
|
|
|
0
|
1
|
0
|
sub tan(_) { goto &POSIX::tan } |
62
|
0
|
|
|
0
|
1
|
0
|
sub tanh(_) { goto &POSIX::tanh } |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
1
|
0
|
sub modf($$) { goto &POSIX::modf } |
65
|
0
|
|
|
0
|
1
|
0
|
sub fmod($$) { goto &POSIX::fmod } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# All provided by POSIX.xs |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
0
|
1
|
0
|
sub div($$) { ( int($_[0]/$_[1]), ($_[0] % $_[1]) ) } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
0
|
1
|
0
|
sub rint(;$) { my $v = @_ ? shift : $_; int($v + 0.5) } |
|
0
|
|
|
|
|
0
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
1
|
0
|
sub pow($$) { $_[0] ** $_[1] } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#------------------------------ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _create_constant($) |
83
|
92
|
|
|
92
|
|
128
|
{ my ($class, $name) = @_; |
84
|
92
|
|
|
|
|
127
|
my $val = $math->{$name}; |
85
|
92
|
|
|
0
|
|
480
|
sub () {$val}; |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |