line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
John M. Gamble B (current maintainer) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
package Math::Fortran; |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
3
|
|
49440
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
91
|
|
42
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
83
|
|
43
|
3
|
|
|
3
|
|
32
|
use 5.8.3; |
|
3
|
|
|
|
|
13
|
|
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
3
|
|
13
|
use Exporter; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
24938
|
|
46
|
|
|
|
|
|
|
our (@ISA, @EXPORT_OK, %EXPORT_TAGS); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
51
|
|
|
|
|
|
|
all => [qw(sign log10)], |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
@EXPORT_OK = ( |
55
|
|
|
|
|
|
|
@{ $EXPORT_TAGS{all} } |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
our $VERSION = 0.03; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub log10 |
61
|
|
|
|
|
|
|
{ |
62
|
6
|
|
|
6
|
1
|
1797
|
log($_[0])/log(10); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub sign |
66
|
|
|
|
|
|
|
{ |
67
|
6
|
|
|
6
|
1
|
3286
|
my ($a1, $a2) = @_; |
68
|
|
|
|
|
|
|
|
69
|
6
|
100
|
|
|
|
21
|
if (defined $a2) |
70
|
|
|
|
|
|
|
{ |
71
|
3
|
100
|
|
|
|
16
|
return $a2 >= 0 ? abs($a1): -abs($a1); |
72
|
|
|
|
|
|
|
} |
73
|
3
|
100
|
|
|
|
15
|
return $a1 >= 0 ? +1 : -1; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |