line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Fibonacci::Phi; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
57332
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
4485
|
use Math::Fibonacci; |
|
1
|
|
|
|
|
27932
|
|
|
1
|
|
|
|
|
746
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( Phi phi series_Phi series_phi term_Phi term_phi super_series ) ] ); |
11
|
|
|
|
|
|
|
our @EXPORT_OK = @{ $EXPORT_TAGS{'all'} } ; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $max_prec = 14; |
14
|
|
|
|
|
|
|
our $Precision = 0; |
15
|
|
|
|
|
|
|
our $TrailingZeros = 0; |
16
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub Phi { |
19
|
0
|
|
|
0
|
1
|
|
my $fn = Math::Fibonacci::isfibonacci(shift()); |
20
|
0
|
0
|
|
|
|
|
return undef if !$fn; |
21
|
0
|
|
|
|
|
|
my $prev = $fn - 1; |
22
|
0
|
0
|
|
|
|
|
return 1 if !$prev; # handle number 1 special, 1/1 |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
0
|
|
|
|
return Math::Fibonacci::term($fn) / Math::Fibonacci::term($prev) unless $Precision >= 1 && $Precision <= $max_prec; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $gold = sprintf ('%.' . $Precision . 'f', Math::Fibonacci::term($fn) / Math::Fibonacci::term($prev) ); |
27
|
0
|
0
|
|
|
|
|
$gold =~ s/\.?0*$// unless $TrailingZeros; |
28
|
0
|
|
|
|
|
|
return $gold; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub phi { |
32
|
0
|
|
|
0
|
1
|
|
my $fn = Math::Fibonacci::isfibonacci(shift()); |
33
|
0
|
0
|
|
|
|
|
return undef if !$fn; |
34
|
0
|
|
|
|
|
|
my $next = $fn + 1; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
0
|
|
|
|
return Math::Fibonacci::term($next) / Math::Fibonacci::term($fn) unless $Precision >= 1 && $Precision <= $max_prec; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $gold = sprintf ('%.' . $Precision . 'f', Math::Fibonacci::term($next) / Math::Fibonacci::term($fn) ); |
39
|
0
|
0
|
|
|
|
|
$gold =~ s/\.?0*$// unless $TrailingZeros; |
40
|
0
|
|
|
|
|
|
return $gold; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub series_Phi { |
44
|
0
|
|
|
0
|
1
|
|
my %Fibo; |
45
|
0
|
|
|
|
|
|
for(Math::Fibonacci::series(shift())) { |
46
|
0
|
|
|
|
|
|
$Fibo{$_} = Phi($_); |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
return \%Fibo; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub series_phi { |
52
|
0
|
|
|
0
|
1
|
|
my %Fibo; |
53
|
0
|
|
|
|
|
|
for(Math::Fibonacci::series(shift())) { |
54
|
0
|
|
|
|
|
|
$Fibo{$_} = phi($_); |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
return \%Fibo; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
1
|
|
sub term_Phi { Phi(Math::Fibonacci::term(shift())); } |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
0
|
1
|
|
sub term_phi { phi(Math::Fibonacci::term(shift())); } |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub super_series { |
64
|
0
|
|
|
0
|
1
|
|
my %Fibo; |
65
|
0
|
|
|
|
|
|
my $posi = 1; |
66
|
0
|
|
|
|
|
|
for(Math::Fibonacci::series(shift())) { |
67
|
0
|
|
|
|
|
|
$Fibo{$_} = { |
68
|
|
|
|
|
|
|
position => $posi, |
69
|
|
|
|
|
|
|
Phi => Phi($_), |
70
|
|
|
|
|
|
|
phi => phi($_) |
71
|
|
|
|
|
|
|
}; |
72
|
0
|
|
|
|
|
|
$posi++; |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
return \%Fibo; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |