blib/lib/Math/Fortran.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 37 / 37 CC 4 SCAR 8.5
CC
4
Cov
100%
sign
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
↑ Summary
1 =head1 NAME
2  
3 Math::Fortran - Perl implementations of Fortran's sign() and log10()
4  
5 =head1 SYNOPSIS
6  
7 use Math::Fortran qw(log10 sign);
8 $v = log10($x);
9 $v = sign($y);
10 $v = sign($x, $y);
11  
12 =head1 DESCRIPTION
13  
14 This module provides and exports some mathematical functions which are
15 built in in Fortran but not in Perl. Currently there are only 2 included.
16  
17 =head2 FUNCTIONS
18  
19 =head3 log10()
20  
21 Log to the base of 10
22  
23 =head3 sign()
24  
25 With 1 parameter, +1 if $y >= 0, -1 otherwise. With 2 parameters +abs($x) if $y >= 0, -abs($x) otherwise.
26  
27 =head1 BUGS
28  
29 I welcome other entries for this module and bug reports.
30  
31 =head1 AUTHOR
32  
33 John A.R. Williams B<J.A.R.Williams@aston.ac.uk>
34  
35 John M. Gamble B<jgamble@cpan.org> (current maintainer)
36  
37 =cut
38  
39 package Math::Fortran;
40  
41 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 3 ▶use 5.8.3;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 3 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 3 our (@ISA, @EXPORT_OK, %EXPORT_TAGS);
47  
48 3 @ISA = qw(Exporter);
49  
50 3 %EXPORT_TAGS = (
51 all => [qw(sign log10)],
52 );
53  
54 @EXPORT_OK = (
55 3 @{ $EXPORT_TAGS{all} }
56 );
57  
58 3 our $VERSION = 0.03;
59  
60 sub log10
61 6 ▶{
Subroutine log10: called CC=1 SCAR=0.0
Pod documented
62 6 log($_[0])/log(10);
63 }
64  
65 sub sign
66 6 ▶{
Subroutine sign: called CC=4 SCAR=13.9
Pod documented
67 6 my ($a1, $a2) = @_;
68  
69 6 ▶ if (defined $a2)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $a2) 3 3 6
70 {
71 3 ▶ return $a2 >= 0 ? abs($a1): -abs($a1);
Branch: 1 branch
BranchTrueFalseTotal
$a2 >= 0 ? : 2 1 3
72 }
73 3 ▶ return $a1 >= 0 ? +1 : -1;
Branch: 1 branch
BranchTrueFalseTotal
$a1 >= 0 ? : 2 1 3
74 }
75  
76 3 1;
↑ Summary