line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
5879
|
use strict; |
|
15
|
|
|
|
|
84
|
|
|
15
|
|
|
|
|
318
|
|
2
|
15
|
|
|
15
|
|
61
|
use warnings; |
|
15
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
2928
|
|
3
|
|
|
|
|
|
|
package Math::Complex_C::L; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
require Exporter; |
6
|
|
|
|
|
|
|
*import = \&Exporter::import; |
7
|
|
|
|
|
|
|
require DynaLoader; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use overload |
10
|
15
|
|
|
|
|
251
|
'**' => \&_overload_pow, |
11
|
|
|
|
|
|
|
'*' => \&_overload_mul, |
12
|
|
|
|
|
|
|
'+' => \&_overload_add, |
13
|
|
|
|
|
|
|
'/' => \&_overload_div, |
14
|
|
|
|
|
|
|
'-' => \&_overload_sub, |
15
|
|
|
|
|
|
|
'**=' => \&_overload_pow_eq, |
16
|
|
|
|
|
|
|
'*=' => \&_overload_mul_eq, |
17
|
|
|
|
|
|
|
'+=' => \&_overload_add_eq, |
18
|
|
|
|
|
|
|
'/=' => \&_overload_div_eq, |
19
|
|
|
|
|
|
|
'-=' => \&_overload_sub_eq, |
20
|
|
|
|
|
|
|
'sqrt' => \&_overload_sqrt, |
21
|
|
|
|
|
|
|
'==' => \&_overload_equiv, |
22
|
|
|
|
|
|
|
'!=' => \&_overload_not_equiv, |
23
|
|
|
|
|
|
|
'!' => \&_overload_not, |
24
|
|
|
|
|
|
|
'bool' => \&_overload_true, |
25
|
|
|
|
|
|
|
'=' => \&_overload_copy, |
26
|
|
|
|
|
|
|
'""' => \&_overload_string, |
27
|
|
|
|
|
|
|
'abs' => \&_overload_abs, |
28
|
|
|
|
|
|
|
'exp' => \&_overload_exp, |
29
|
|
|
|
|
|
|
'log' => \&_overload_log, |
30
|
|
|
|
|
|
|
'sin' => \&_overload_sin, |
31
|
|
|
|
|
|
|
'cos' => \&_overload_cos, |
32
|
|
|
|
|
|
|
'atan2' => \&_overload_atan2, |
33
|
15
|
|
|
15
|
|
12908
|
; |
|
15
|
|
|
|
|
12218
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
DynaLoader::bootstrap Math::Complex_C::L $VERSION; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
@Math::Complex_C::L::EXPORT = (); |
40
|
|
|
|
|
|
|
@Math::Complex_C::L::EXPORT_OK = qw( |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
create_cl assign_cl mul_cl mul_c_nvl mul_c_ivl mul_c_uvl div_cl div_c_nvl div_c_ivl div_c_uvl add_cl |
43
|
|
|
|
|
|
|
add_c_nvl add_c_ivl add_c_uvl sub_cl sub_c_nvl sub_c_ivl sub_c_uvl real_cl real_cl2LD imag_cl2LD |
44
|
|
|
|
|
|
|
LD2cl cl2LD real_cl2str imag_cl2str arg_cl2LD arg_cl2str abs_cl2LD abs_cl2str |
45
|
|
|
|
|
|
|
imag_cl arg_cl abs_cl conj_cl acos_cl asin_cl atan_cl cos_cl sin_cl tan_cl acosh_cl asinh_cl atanh_cl |
46
|
|
|
|
|
|
|
cosh_cl sinh_cl tanh_cl exp_cl log_cl sqrt_cl proj_cl pow_cl |
47
|
|
|
|
|
|
|
get_nanl get_neg_infl get_infl is_nanl is_infl MCL |
48
|
|
|
|
|
|
|
add_c_pvl sub_c_pvl mul_c_pvl div_c_pvl |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
str_to_l l_to_str l_to_strp l_set_prec l_get_prec set_real_cl set_imag_cl |
51
|
|
|
|
|
|
|
ld_to_str ld_to_strp long_set_prec long_get_prec |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
%Math::Complex_C::L::EXPORT_TAGS = (all => [qw( |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
create_cl assign_cl mul_cl mul_c_nvl mul_c_ivl mul_c_uvl div_cl div_c_nvl div_c_ivl div_c_uvl add_cl |
57
|
|
|
|
|
|
|
add_c_nvl add_c_ivl add_c_uvl sub_cl sub_c_nvl sub_c_ivl sub_c_uvl real_cl real_cl2LD imag_cl2LD |
58
|
|
|
|
|
|
|
LD2cl cl2LD real_cl2str imag_cl2str arg_cl2LD arg_cl2str abs_cl2LD abs_cl2str |
59
|
|
|
|
|
|
|
imag_cl arg_cl abs_cl conj_cl acos_cl asin_cl atan_cl cos_cl sin_cl tan_cl acosh_cl asinh_cl atanh_cl |
60
|
|
|
|
|
|
|
cosh_cl sinh_cl tanh_cl exp_cl log_cl sqrt_cl proj_cl pow_cl |
61
|
|
|
|
|
|
|
get_nanl get_neg_infl get_infl is_nanl is_infl MCL |
62
|
|
|
|
|
|
|
add_c_pvl sub_c_pvl mul_c_pvl div_c_pvl |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
str_to_l l_to_str l_to_strp l_set_prec l_get_prec set_real_cl set_imag_cl |
65
|
|
|
|
|
|
|
ld_to_str ld_to_strp long_set_prec long_get_prec |
66
|
|
|
|
|
|
|
)]); |
67
|
|
|
|
|
|
|
|
68
|
15
|
|
|
15
|
0
|
5520
|
sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub l_to_str { |
71
|
5
|
|
|
5
|
0
|
67
|
return join ' ', _l_to_str($_[0]); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub l_to_strp { |
75
|
3
|
|
|
3
|
0
|
27
|
return join ' ', _l_to_strp($_[0], $_[1]); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub str_to_l { |
79
|
1
|
|
|
1
|
0
|
10
|
my($re, $im) = split /\s+/, $_[0]; |
80
|
1
|
50
|
|
|
|
5
|
$im = 0 if !defined($im); |
81
|
|
|
|
|
|
|
|
82
|
1
|
50
|
|
|
|
7
|
$re = get_nanl() if $re =~ /^(\+|\-)?nan/i; |
83
|
1
|
50
|
|
|
|
5
|
$im = get_nanl() if $im =~ /^(\+|\-)?nan/i; |
84
|
|
|
|
|
|
|
|
85
|
1
|
50
|
|
|
|
6
|
if($re =~ /^(\+|\-)?inf/i) { |
86
|
0
|
0
|
|
|
|
0
|
if($re =~ /^\-inf/i) {$re = get_neg_infl()} |
|
0
|
|
|
|
|
0
|
|
87
|
0
|
|
|
|
|
0
|
else {$re = get_infl()} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
1
|
50
|
|
|
|
5
|
if($im =~ /^(\+|\-)?inf/i) { |
91
|
0
|
0
|
|
|
|
0
|
if($re =~ /^\-inf/i) {$im = get_neg_infl()} |
|
0
|
|
|
|
|
0
|
|
92
|
0
|
|
|
|
|
0
|
else {$im = get_infl()} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
4
|
return MCL($re, $im); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _overload_string { |
99
|
7
|
|
|
7
|
|
184
|
my($real, $imag) = (real_cl($_[0]), imag_cl($_[0])); |
100
|
7
|
|
|
|
|
63
|
my($r, $i) = _l_to_str($_[0]); |
101
|
|
|
|
|
|
|
|
102
|
7
|
50
|
|
|
|
36
|
if($real == 0) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
0
|
$r = $real =~ /^\-/ ? '-0' : '0'; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
elsif($real != $real) { |
106
|
4
|
|
|
|
|
10
|
$r = 'NaN'; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
elsif(($real / $real) != ($real / $real)) { |
109
|
0
|
0
|
|
|
|
0
|
$r = $real < 0 ? '-Inf' : 'Inf'; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
else { |
112
|
3
|
|
|
|
|
15
|
my @re = split /e/i, $r; |
113
|
3
|
|
33
|
|
|
34
|
while(substr($re[0], -1, 1) eq '0' && substr($re[0], -2, 1) ne '.') { |
114
|
0
|
|
|
|
|
0
|
chop $re[0]; |
115
|
|
|
|
|
|
|
} |
116
|
3
|
|
|
|
|
11
|
$r = $re[0] . 'e' . $re[1]; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
7
|
50
|
|
|
|
27
|
if($imag == 0) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
0
|
$i = $imag =~ /^\-/ ? '-0' : '0'; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
elsif($imag != $imag) { |
123
|
4
|
|
|
|
|
6
|
$i = 'NaN'; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
elsif(($imag / $imag) != ($imag / $imag)) { |
126
|
0
|
0
|
|
|
|
0
|
$i = $imag < 0 ? '-Inf' : 'Inf'; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
else { |
129
|
3
|
|
|
|
|
19
|
my @im = split /e/i, $i; |
130
|
3
|
|
33
|
|
|
12
|
while(substr($im[0], -1, 1) eq '0' && substr($im[0], -2, 1) ne '.') { |
131
|
0
|
|
|
|
|
0
|
chop $im[0]; |
132
|
|
|
|
|
|
|
} |
133
|
3
|
|
|
|
|
10
|
$i = $im[0] . 'e' . $im[1]; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
7
|
|
|
|
|
48
|
return "(" . $r . " " . $i . ")"; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub new { |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# This function caters for 2 possibilities: |
143
|
|
|
|
|
|
|
# 1) that 'new' has been called OOP style - in which |
144
|
|
|
|
|
|
|
# case there will be a maximum of 3 args |
145
|
|
|
|
|
|
|
# 2) that 'new' has been called as a function - in |
146
|
|
|
|
|
|
|
# which case there will be a maximum of 2 args. |
147
|
|
|
|
|
|
|
# If there are no args, then we just want to return a |
148
|
|
|
|
|
|
|
# Math::Complex_C::L object |
149
|
|
|
|
|
|
|
|
150
|
62
|
100
|
|
62
|
0
|
1531
|
if(!@_) {return create_cl()} |
|
9
|
|
|
|
|
67
|
|
151
|
|
|
|
|
|
|
|
152
|
53
|
50
|
|
|
|
103
|
if(@_ > 3) {die "Too many arguments supplied to new()"} |
|
0
|
|
|
|
|
0
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# If 'new' has been called OOP style, the first arg is the string |
155
|
|
|
|
|
|
|
# "Math::Complex_C::L" which we don't need - so let's remove it. |
156
|
|
|
|
|
|
|
|
157
|
53
|
100
|
66
|
|
|
204
|
if(!ref($_[0]) && $_[0] eq "Math::Complex_C::L") { |
158
|
10
|
|
|
|
|
13
|
shift; |
159
|
10
|
100
|
|
|
|
22
|
if(!@_) {return create_cl()} |
|
2
|
|
|
|
|
25
|
|
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
51
|
50
|
|
|
|
95
|
if(@_ > 2) {die "Bad argument list supplied to new()"} |
|
0
|
|
|
|
|
0
|
|
163
|
|
|
|
|
|
|
|
164
|
51
|
|
|
|
|
52
|
my $ret; |
165
|
|
|
|
|
|
|
|
166
|
51
|
50
|
|
|
|
85
|
if(@_ == 2) { |
167
|
51
|
|
|
|
|
295
|
$ret = create_cl(); |
168
|
51
|
|
|
|
|
212
|
assign_cl($ret, $_[0], $_[1]); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
else { |
171
|
0
|
0
|
|
|
|
0
|
return $_[0] if _itsa($_[0]) == 226; |
172
|
0
|
|
|
|
|
0
|
$ret = create_cl(); |
173
|
0
|
|
|
|
|
0
|
assign_cl($ret, $_[0], 0.0); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
51
|
|
|
|
|
208
|
return $ret; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
*MCL = \&Math::Complex_C::L::new; |
180
|
|
|
|
|
|
|
*long_get_prec = \&l_get_prec; # for backwards-compatibility |
181
|
|
|
|
|
|
|
*long_set_prec = \&l_set_prec; # for backwards-compatibility |
182
|
|
|
|
|
|
|
*ld_to_str = \&l_to_str; # for backwards-compatibility |
183
|
|
|
|
|
|
|
*ld_to_strp = \&l_to_strp; # for backwards-compatibility |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
1; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
__END__ |