| 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 | 5 | ▶ | use vars '$VERSION'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 5 | $VERSION = '1.02'; | |||||||||
| 12 | |||||||||||
| 13 | 5 | ▶ | use base 'POSIX::1003::Module'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 5 | 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 | 5 | our @IN_CORE = qw/abs exp log sqrt sin cos atan2 rand srand int/; | |||||||||
| 23 | |||||||||||
| 24 | 5 | 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 | 5 | push @functions, @IN_CORE; | |||||||||
| 33 | |||||||||||
| 34 | 5 | our %EXPORT_TAGS = | |||||||||
| 35 | ( constants => \@constants | ||||||||||
| 36 | , functions => \@functions | ||||||||||
| 37 | , tables => [ '%math' ] | ||||||||||
| 38 | ); | ||||||||||
| 39 | |||||||||||
| 40 | 5 | my $math; | |||||||||
| 41 | 5 | our %math; | |||||||||
| 42 | |||||||||||
| 43 | 5 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 44 | 5 | $math = math_table; | |||||||||
| 45 | 5 | push @constants, keys %$math; | |||||||||
| 46 | 5 | tie %math, 'POSIX::1003::ReadOnlyTable', $math; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | |||||||||||
| 50 | # the argument to be optional is important for expression priority! | ||||||||||
| 51 | 0 | ▶ | sub acos(_) { goto &POSIX::acos } | ||||||||
|
Subroutine
acos: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 52 | 0 | ▶ | sub asin(_) { goto &POSIX::asin } | ||||||||
|
Subroutine
asin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 53 | 0 | ▶ | sub atan(_) { goto &POSIX::atan } | ||||||||
|
Subroutine
atan: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 54 | 0 | ▶ | sub ceil(_) { goto &POSIX::ceil } | ||||||||
|
Subroutine
ceil: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 55 | 0 | ▶ | sub cosh(_) { goto &POSIX::cosh } | ||||||||
|
Subroutine
cosh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 56 | 2 | ▶ | sub floor(_) { goto &POSIX::floor } | ||||||||
|
Subroutine
floor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 57 | 0 | ▶ | sub frexp(_) { goto &POSIX::frexp } | ||||||||
|
Subroutine
frexp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 58 | 0 | ▶ | sub ldexp(_) { goto &POSIX::ldexp } | ||||||||
|
Subroutine
ldexp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | 0 | ▶ | sub log10(_) { goto &POSIX::log10 } | ||||||||
|
Subroutine
log10: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 60 | 0 | ▶ | sub sinh(_) { goto &POSIX::sinh } | ||||||||
|
Subroutine
sinh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | 0 | ▶ | sub tan(_) { goto &POSIX::tan } | ||||||||
|
Subroutine
tan: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 62 | 0 | ▶ | sub tanh(_) { goto &POSIX::tanh } | ||||||||
|
Subroutine
tanh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub modf($$) { goto &POSIX::modf } | ||||||||
|
Subroutine
modf: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 65 | 0 | ▶ | sub fmod($$) { goto &POSIX::fmod } | ||||||||
|
Subroutine
fmod: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 66 | |||||||||||
| 67 | # All provided by POSIX.xs | ||||||||||
| 68 | |||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub div($$) { ( int($_[0]/$_[1]), ($_[0] % $_[1]) ) } | ||||||||
|
Subroutine
div: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 71 | |||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | sub rint(;$) { my $v = @_ ? shift : $_; int($v + 0.5) } | ||||||||
|
Subroutine
rint: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 74 | |||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub pow($$) { $_[0] ** $_[1] } | ||||||||
|
Subroutine
pow: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 77 | |||||||||||
| 78 | |||||||||||
| 79 | #------------------------------ | ||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | sub _create_constant($) | ||||||||||
| 83 | 92 | ▶ | { my ($class, $name) = @_; | ||||||||
|
Subroutine
_create_constant: called CC=1 SCAR=0.2
| |||||||||||
| 84 | 92 | my $val = $math->{$name}; | |||||||||
| 85 | 0 | ▶ | sub () {$val}; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 5 | 1; | |||||||||