PlanePath.pm

filter: Statementstmt 69.3% 247 / 356 Branchbran 36.1% 39 / 108 Conditioncond 21.5% 19 / 88 MC/DCmcdc 10.9% 6 / 55 Subroutinesub 78.7% 74 / 94 Podpod 97.5% 40 / 41 totaltotal 57.2% 425 / 742 CC 90 SCAR 25.7
CC
90
Cov
55%
rsquared_minimum
90.0
sumabsxy_minimum
56.0
tree_n_root
42.0
CRAP 13.1
« PlanePath/UlamWarburtonQuarter.pm ↑ Summary PlanePath/HeptSpiralSkewed.pm »
1 # Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin Ryde
2  
3 # This file is part of Math-PlanePath.
4 #
5 # Math-PlanePath is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Math-PlanePath is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
17  
18 package Math::PlanePath;
19 101 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 101 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 101 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 101 $VERSION = 128;
24  
25 # uncomment this to run the ### lines
26 # use Smart::Comments;
27  
28  
29 # defaults
30 101 ▶use constant figure => 'square';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 101 ▶use constant default_n_start => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 sub n_start {
33 376 ▶ my ($self) = @_;
Subroutine n_start: called CC=3 SCAR=11.0
Pod documented
34 376 ▶ if (ref $self && defined $self->{'n_start'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self and defined $self->{'n_start'}) { } 352 24 376
Condition66%2/3
ref $self and defined $self->{"n_start"}
!ll&&!rl&&r
024352
MC/DC50%1/2
ref $self and defined $self->{"n_start"}
ref $self defined $self->{"n_start"}
Truth table66%2/3
A and B
A= ref $selfB= defined $self->{"n_start"}
ABresult
0X0
100
111
35 352 return $self->{'n_start'};
36 } else {
37 24 return $self->default_n_start;
38 }
39 }
40 sub arms_count {
41 7518 ▶ my ($self) = @_;
Subroutine arms_count: called CC=2 SCAR=6.9
Pod documented
42 7518 ▶ return $self->{'arms'} || 1;
Condition100%2/2
$self->{'arms'} || 1
l!l
25065012
MC/DC100%1/1
$self->{'arms'} || 1
$self->{'arms'}
Truth table100%2/2
A
A= $self->{'arms'}
Aresult
11
00
43 }
44  
45 101 ▶use constant class_x_negative => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 101 ▶use constant class_y_negative => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 91 ▶sub x_negative { $_[0]->class_x_negative }
Subroutine x_negative: called CC=1 SCAR=0.0
Pod documented
48 346 ▶sub y_negative { $_[0]->class_y_negative }
Subroutine y_negative: called CC=1 SCAR=0.0
Pod documented
49 101 ▶use constant x_negative_at_n => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 101 ▶use constant y_negative_at_n => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 101 ▶use constant n_frac_discontinuity => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 101 ▶use constant parameter_info_array => [];
Subroutine BEGIN: called CC=1 SCAR=0.0
54 sub parameter_info_list {
55 64 ▶ return @{$_[0]->parameter_info_array};
Subroutine parameter_info_list: called CC=1 SCAR=0.0
Pod documented
56 }
57  
58 # x_negative(),y_negative() existed before x_minimum(),y_minimum(), so
59 # default x_minimum(),y_minimum() from those.
60 sub x_minimum {
61 2 ▶ my ($self) = @_;
Subroutine x_minimum: called CC=2 SCAR=6.9
Pod documented
62 2 ▶ return ($self->x_negative ? undef : 0);
Branch: 1 branch
BranchTrueFalseTotal
$self->x_negative ? : 1 1 2
63 }
64 sub y_minimum {
65 6 ▶ my ($self) = @_;
Subroutine y_minimum: called CC=2 SCAR=6.9
Pod documented
66 6 ▶ return ($self->y_negative ? undef : 0);
Branch: 1 branch
BranchTrueFalseTotal
$self->y_negative ? : 2 4 6
67 }
68 101 ▶use constant x_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 101 ▶use constant y_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
70  
71 sub sumxy_minimum {
72 2 ▶ my ($self) = @_;
Subroutine sumxy_minimum: called CC=3 SCAR=13.3
Pod documented
73 ### PlanePath sumxy_minimum() ...
74 2 ▶ if (defined (my $x_minimum = $self->x_minimum)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $x_minimum = $self->x_minimum) and defined(my $y_minimum = $self->y_minimum)) 2 0 2
Condition33%1/3
defined(my $x_minimum = $self->x_minimum) and defined(my $y_minimum = $self->y_minimum)
!ll&&!rl&&r
002
MC/DC0%0/2
defined(my $x_minimum = $self->x_minimum) and defined(my $y_minimum = $self->y_minimum)
defined(my $x_minimum = $self->x_minimum) defined(my $y_minimum = $self->y_minimum)
Truth table33%1/3
A and B
A= defined(my $x_minimum = $self->x_minimum)B= defined(my $y_minimum = $self->y_minimum)
ABresult
0X0
100
111
75 && defined (my $y_minimum = $self->y_minimum)) {
76 ### $x_minimum
77 ### $y_minimum
78 2 return $x_minimum + $y_minimum;
79 }
80 0 return undef;
81 }
82 101 ▶use constant sumxy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
83  
84 sub sumabsxy_minimum {
85 0 ▶ my ($self) = @_;
Subroutine sumabsxy_minimum: not called CC=7 SCAR=40.3
Pod documented
86 0 my $x_minimum = $self->x_minimum;
87 0 my $y_minimum = $self->y_minimum;
88 0 ▶ if (defined $x_minimum && $x_minimum >= 0
Branch: 1 branch
BranchTrueFalseTotal
if (defined $x_minimum and $x_minimum >= 0 and defined $y_minimum and $y_minimum >= 0) 0 0 0
Condition0%0/9
defined $x_minimum and $x_minimum >= 0 and defined $y_minimum and $y_minimum >= 0
!ll&&!rl&&r
000
defined $x_minimum and $x_minimum >= 0 and defined $y_minimum
!ll&&!rl&&r
000
defined $x_minimum and $x_minimum >= 0
!ll&&!rl&&r
000
MC/DC0%0/4
defined $x_minimum and $x_minimum >= 0 and defined $y_minimum and $y_minimum >= 0
defined $x_minimum $x_minimum >= 0 defined $y_minimum $y_minimum >= 0
Truth table0%0/5
A and B and C and D
A= defined $x_minimumB= $x_minimum >= 0C= defined $y_minimumD= $y_minimum >= 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
89 && defined $y_minimum && $y_minimum >= 0) {
90 # X>=0 and Y>=0 so abs(X)+abs(Y) == X+Y
91 0 return $self->sumxy_minimum;
92 }
93 0 ▶ return _max($x_minimum||0,0) + _max($y_minimum||0,0);
Condition0%0/4
$x_minimum || 0
l!l
00
$y_minimum || 0
l!l
00
MC/DC0%0/1
$x_minimum || 0
$x_minimum
MC/DC0%0/1
$y_minimum || 0
$y_minimum
Truth table0%0/2
A
A= $x_minimum
Aresult
11
00
Truth table0%0/2
A
A= $y_minimum
Aresult
11
00
94 }
95 101 ▶use constant sumabsxy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
96  
97 101 ▶use constant diffxy_minimum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
98 #
99 # If the path is confined to the fourth quadrant, so X>=something and
100 # Y<=something then a minimum X-Y exists. But fourth-quadrant-only path is
101 # unusual, so don't bother with code checking that.
102 # sub diffxy_minimum {
103 # my ($self) = @_;
104 # if (defined (my $y_maximum = $self->y_maximum)
105 # && defined (my $x_minimum = $self->x_minimum)) {
106 # return $x_minimum - $y_maximum;
107 # } else {
108 # return undef;
109 # }
110 # }
111  
112 # If the path is confined to the second quadrant, so X<=something and
113 # Y>=something, then has a maximum X-Y. Presume that the x_maximum() and
114 # y_minimum() occur together.
115 #
116 sub diffxy_maximum {
117 0 ▶ my ($self) = @_;
Subroutine diffxy_maximum: not called CC=3 SCAR=24.8
Pod documented
118 0 ▶ if (defined (my $y_minimum = $self->y_minimum)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $y_minimum = $self->y_minimum) and defined(my $x_max = $self->x_maximum)) { } 0 0 0
Condition0%0/3
defined(my $y_minimum = $self->y_minimum) and defined(my $x_max = $self->x_maximum)
!ll&&!rl&&r
000
MC/DC0%0/2
defined(my $y_minimum = $self->y_minimum) and defined(my $x_max = $self->x_maximum)
defined(my $y_minimum = $self->y_minimum) defined(my $x_max = $self->x_maximum)
Truth table0%0/3
A and B
A= defined(my $y_minimum = $self->y_minimum)B= defined(my $x_max = $self->x_maximum)
ABresult
0X0
100
111
119 && defined (my $x_max = $self->x_maximum)) {
120 0 return $x_max - $y_minimum;
121 } else {
122 0 return undef;
123 }
124 }
125  
126 # absdiffxy = abs(X-Y)
127 sub absdiffxy_minimum {
128 0 ▶ my ($self) = @_;
Subroutine absdiffxy_minimum: not called CC=5 SCAR=34.0
Pod documented
129 # if X-Y all one sign, so X-Y>=0 or X-Y<=0, then abs(X-Y) from that
130 0 my $m;
131 0 ▶ if (defined($m = $self->diffxy_minimum) && $m >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($m = $self->diffxy_minimum) and $m >= 0) 0 0 0
Condition0%0/3
defined($m = $self->diffxy_minimum) and $m >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined($m = $self->diffxy_minimum) and $m >= 0
defined($m = $self->diffxy_minimum) $m >= 0
Truth table0%0/3
A and B
A= defined($m = $self->diffxy_minimum)B= $m >= 0
ABresult
0X0
100
111
132 0 return $m;
133 }
134 0 ▶ if (defined($m = $self->diffxy_maximum) && $m <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($m = $self->diffxy_maximum) and $m <= 0) 0 0 0
Condition0%0/3
defined($m = $self->diffxy_maximum) and $m <= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined($m = $self->diffxy_maximum) and $m <= 0
defined($m = $self->diffxy_maximum) $m <= 0
Truth table0%0/3
A and B
A= defined($m = $self->diffxy_maximum)B= $m <= 0
ABresult
0X0
100
111
135 0 return - $m;
136 }
137 0 return 0;
138 }
139 sub absdiffxy_maximum {
140 0 ▶ my ($self) = @_;
Subroutine absdiffxy_maximum: not called CC=3 SCAR=24.8
Pod documented
141 # if X-Y constrained so min<=X-Y<=max then max abs(X-Y) one of the two ends
142 0 ▶ if (defined (my $min = $self->diffxy_minimum)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $min = $self->diffxy_minimum) and defined(my $max = $self->diffxy_maximum)) 0 0 0
Condition0%0/3
defined(my $min = $self->diffxy_minimum) and defined(my $max = $self->diffxy_maximum)
!ll&&!rl&&r
000
MC/DC0%0/2
defined(my $min = $self->diffxy_minimum) and defined(my $max = $self->diffxy_maximum)
defined(my $min = $self->diffxy_minimum) defined(my $max = $self->diffxy_maximum)
Truth table0%0/3
A and B
A= defined(my $min = $self->diffxy_minimum)B= defined(my $max = $self->diffxy_maximum)
ABresult
0X0
100
111
143 && defined (my $max = $self->diffxy_maximum)) {
144 0 return _max(abs($min),abs($max));
145 }
146 0 return undef;
147 }
148  
149  
150 # experimental default from x_minimum(),y_minimum()
151 # FIXME: should use absx_minimum, absy_minimum, for paths outside first quadrant
152 sub rsquared_minimum {
153 0 ▶ my ($self) = @_;
Subroutine rsquared_minimum: not called CC=9 SCAR=45.0
Pod documented
154  
155 # The X and Y each closest to the origin. This assumes that point is
156 # actually visited, but is likely to be close.
157 0 my $x_minimum = $self->x_minimum;
158 0 my $x_maximum = $self->x_maximum;
159 0 my $y_minimum = $self->y_minimum;
160 0 my $y_maximum = $self->y_maximum;
161 0 ▶ my $x = (( defined $x_minimum && $x_minimum) > 0 ? $x_minimum
Branch: 2 branches
BranchTrueFalseTotal
(defined $x_minimum && $x_minimum) > 0 ? : 0 0 0
(defined $x_maximum && $x_maximum) < 0 ? : 0 0 0
Condition0%0/6
defined $x_minimum && $x_minimum
!ll&&!rl&&r
000
defined $x_maximum && $x_maximum
!ll&&!rl&&r
000
MC/DC0%0/2
defined $x_minimum && $x_minimum
defined $x_minimum $x_minimum
MC/DC0%0/2
defined $x_maximum && $x_maximum
defined $x_maximum $x_maximum
Truth table0%0/3
A && B
A= defined $x_minimumB= $x_minimum
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= defined $x_maximumB= $x_maximum
ABresult
0X0
100
111
162 : (defined $x_maximum && $x_maximum) < 0 ? $x_maximum
163 : 0);
164 0 ▶ my $y = (( defined $y_minimum && $y_minimum) > 0 ? $y_minimum
Branch: 2 branches
BranchTrueFalseTotal
(defined $y_minimum && $y_minimum) > 0 ? : 0 0 0
(defined $y_maximum && $y_maximum) < 0 ? : 0 0 0
Condition0%0/6
defined $y_minimum && $y_minimum
!ll&&!rl&&r
000
defined $y_maximum && $y_maximum
!ll&&!rl&&r
000
MC/DC0%0/2
defined $y_minimum && $y_minimum
defined $y_minimum $y_minimum
MC/DC0%0/2
defined $y_maximum && $y_maximum
defined $y_maximum $y_maximum
Truth table0%0/3
A && B
A= defined $y_minimumB= $y_minimum
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= defined $y_maximumB= $y_maximum
ABresult
0X0
100
111
165 : (defined $y_maximum && $y_maximum) < 0 ? $y_maximum
166 : 0);
167 0 return ($x*$x + $y*$y);
168  
169 # # Maybe initial point $self->n_to_xy($self->n_start)) as the default,
170 # # but that's not the minimum on "wider" paths.
171 # return 0;
172 }
173 101 ▶use constant rsquared_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
174  
175 sub gcdxy_minimum {
176 1 ▶ my ($self) = @_;
Subroutine gcdxy_minimum: called CC=2 SCAR=7.2
Pod undocumented
177 ### gcdxy_minimum(): "visited=".($self->xy_is_visited(0,0)||0)
178 1 ▶ return ($self->xy_is_visited(0,0)
Branch: 1 branch
BranchTrueFalseTotal
$self->xy_is_visited(0, 0) ? : 1 0 1
179 ? 0 # gcd(0,0)=0
180 : 1); # any other has gcd>=1
181 }
182 101 ▶use constant gcdxy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
183  
184 101 ▶use constant turn_any_left => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
185 101 ▶use constant turn_any_right => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
186 101 ▶use constant turn_any_straight => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
187  
188  
189 #------------------------------------------------------------------------------
190  
191 101 ▶use constant dir_minimum_dxdy => (1,0); # East
Subroutine BEGIN: called CC=1 SCAR=0.0
192 101 ▶use constant dir_maximum_dxdy => (0,0); # supremum all angles
Subroutine BEGIN: called CC=1 SCAR=0.0
193  
194 101 ▶use constant dx_minimum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
195 101 ▶use constant dy_minimum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
196 101 ▶use constant dx_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
197 101 ▶use constant dy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
198 #
199 # =item C<$n = $path-E<gt>_UNDOCUMENTED__dxdy_list_at_n()>
200 #
201 # Return the N at which all possible dX,dY will have been seen. If there is
202 # not a finite set of possible dX,dY steps then return C<undef>.
203 #
204 101 ▶use constant 1.02;
Subroutine BEGIN: called CC=1 SCAR=0.0
205 101 ▶use constant _UNDOCUMENTED__dxdy_list => (); # default empty for not a finite list
Subroutine BEGIN: called CC=1 SCAR=0.0
206 101 ▶use constant _UNDOCUMENTED__dxdy_list_at_n => undef; # maybe dxdy_at_n()
Subroutine BEGIN: called CC=1 SCAR=0.0
207 101 use constant _UNDOCUMENTED__dxdy_list_three => (2,0, # E
208 -1,1, # NW
209 101 ▶ -1,-1); # SW
Subroutine BEGIN: called CC=1 SCAR=0.0
210 101 use constant _UNDOCUMENTED__dxdy_list_six => (2,0, # E
211 1,1, # NE
212 -1,1, # NW
213 -2,0, # W
214 -1,-1, # SW
215 101 ▶ 1,-1); # SE
Subroutine BEGIN: called CC=1 SCAR=0.0
216 101 use constant _UNDOCUMENTED__dxdy_list_eight => (1,0, # E
217 1,1, # NE
218 0,1, # N
219 -1,1, # NW
220 -1,0, # W
221 -1,-1, # SW
222 0,-1, # S
223 101 ▶ 1,-1); # SE
Subroutine BEGIN: called CC=1 SCAR=0.0
224  
225 sub absdx_minimum {
226 0 ▶ my ($self) = @_;
Subroutine absdx_minimum: not called CC=3 SCAR=24.8
Pod documented
227 # If dX>=0 then abs(dX)=dX always and absdx_minimum()==dx_minimum().
228 # This happens for column style paths like CoprimeColumns.
229 # dX>0 is only for line paths so not very interesting.
230 0 ▶ if (defined (my $dx_minimum = $self->dx_minimum)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $dx_minimum = $self->dx_minimum)) 0 0 0
231 0 ▶ if ($dx_minimum >= 0) { return $dx_minimum; }
Branch: 1 branch
BranchTrueFalseTotal
if ($dx_minimum >= 0) 0 0 0
232 }
233 0 return 0;
234 }
235 sub absdx_maximum {
236 0 ▶ my ($self) = @_;
Subroutine absdx_maximum: not called CC=3 SCAR=24.8
Pod documented
237 0 ▶ if (defined (my $dx_minimum = $self->dx_minimum)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $dx_minimum = $self->dx_minimum) and defined(my $dx_maximum = $self->dx_maximum)) 0 0 0
Condition0%0/3
defined(my $dx_minimum = $self->dx_minimum) and defined(my $dx_maximum = $self->dx_maximum)
!ll&&!rl&&r
000
MC/DC0%0/2
defined(my $dx_minimum = $self->dx_minimum) and defined(my $dx_maximum = $self->dx_maximum)
defined(my $dx_minimum = $self->dx_minimum) defined(my $dx_maximum = $self->dx_maximum)
Truth table0%0/3
A and B
A= defined(my $dx_minimum = $self->dx_minimum)B= defined(my $dx_maximum = $self->dx_maximum)
ABresult
0X0
100
111
238 && defined (my $dx_maximum = $self->dx_maximum)) {
239 0 return _max(abs($dx_minimum),abs($dx_maximum));
240 }
241 0 return undef;
242 }
243  
244 sub absdy_minimum {
245 0 ▶ my ($self) = @_;
Subroutine absdy_minimum: not called CC=3 SCAR=24.8
Pod documented
246 # if dY>=0 then abs(dY)=dY always and absdy_minimum()==dy_minimum()
247 0 ▶ if (defined (my $dy_minimum = $self->dy_minimum)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $dy_minimum = $self->dy_minimum)) 0 0 0
248 0 ▶ if ($dy_minimum >= 0) { return $dy_minimum; }
Branch: 1 branch
BranchTrueFalseTotal
if ($dy_minimum >= 0) 0 0 0
249 }
250 0 return 0;
251 }
252 sub absdy_maximum {
253 0 ▶ my ($self) = @_;
Subroutine absdy_maximum: not called CC=3 SCAR=24.8
Pod documented
254 0 ▶ if (defined (my $dy_minimum = $self->dy_minimum)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $dy_minimum = $self->dy_minimum) and defined(my $dy_maximum = $self->dy_maximum)) { } 0 0 0
Condition0%0/3
defined(my $dy_minimum = $self->dy_minimum) and defined(my $dy_maximum = $self->dy_maximum)
!ll&&!rl&&r
000
MC/DC0%0/2
defined(my $dy_minimum = $self->dy_minimum) and defined(my $dy_maximum = $self->dy_maximum)
defined(my $dy_minimum = $self->dy_minimum) defined(my $dy_maximum = $self->dy_maximum)
Truth table0%0/3
A and B
A= defined(my $dy_minimum = $self->dy_minimum)B= defined(my $dy_maximum = $self->dy_maximum)
ABresult
0X0
100
111
255 && defined (my $dy_maximum = $self->dy_maximum)) {
256 0 return _max(abs($dy_minimum),abs($dy_maximum));
257 } else {
258 0 return undef;
259 }
260 }
261  
262 101 ▶use constant dsumxy_minimum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
263 101 ▶use constant dsumxy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
264 101 ▶use constant ddiffxy_minimum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
265 101 ▶use constant ddiffxy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
266  
267 #------------------------------------------------------------------------------
268  
269 sub new {
270 1929 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
271 1929 return bless { @_ }, $class;
272 }
273  
274 {
275 101 my %parameter_info_hash;
276 sub parameter_info_hash {
277 3 ▶ my ($class_or_self) = @_;
Subroutine parameter_info_hash: called CC=3 SCAR=12.0
Pod documented
278 3 ▶ my $class = (ref $class_or_self || $class_or_self);
Condition33%1/3
ref $class_or_self || $class_or_self
l!l&&r!l&&!r
030
MC/DC0%0/2
ref $class_or_self || $class_or_self
ref $class_or_self $class_or_self
Truth table33%1/3
A || B
A= ref $class_or_selfB= $class_or_self
ABresult
1X1
011
000
279 return ($parameter_info_hash{$class}
280 3 ▶ ||= { map { $_->{'name'} => $_ }
Condition50%1/2
$parameter_info_hash{$class} ||= {map({$_->{"name"}, $_;} $class_or_self->parameter_info_list)}
l!l
03
MC/DC0%0/1
$parameter_info_hash{$class} ||= {map({$_->{"name"}, $_;} $class_or_self->parameter_info_list)}
$parameter_info_hash{$class}
Truth table50%1/2
A
A= $parameter_info_hash{$class}
Aresult
11
00
281 $class_or_self->parameter_info_list });
282 }
283 }
284  
285 101 sub xy_to_n_list {
286 ### xy_to_n_list() ...
287 9404 ▶ if (defined (my $n = shift->xy_to_n(@_))) {
Subroutine xy_to_n_list: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $n = (shift())->xy_to_n(@_))) 5028 4376 9404
288 ### $n
289 5028 return $n;
290 }
291 ### empty ...
292 4376 return;
293 }
294 sub xy_is_visited {
295 7 ▶ my ($self, $x, $y) = @_;
Subroutine xy_is_visited: called CC=1 SCAR=0.0
Pod documented
296 ### xy_is_visited(): "$x,$y is ndefined=".defined($self->xy_to_n($x,$y))
297 7 return defined($self->xy_to_n($x,$y));
298 }
299  
300 sub n_to_n_list {
301 0 ▶ my ($self, $n) = @_;
Subroutine n_to_n_list: not called CC=2 SCAR=17.9
Pod documented
302 0 ▶ my ($x,$y) = $self->n_to_xy($n) or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->n_to_xy($n) or return 0 0 0
303 0 return $self->xy_to_n_list($x,$y);
304 }
305  
306 sub n_to_dxdy {
307 5008 ▶ my ($self, $n) = @_;
Subroutine n_to_dxdy: called CC=3 SCAR=11.0
Pod documented
308 ### n_to_dxdy(): $n
309 5008 ▶ my ($x,$y) = $self->n_to_xy ($n)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->n_to_xy($n) or return 4 5004 5008
310 or return;
311 5004 ▶ my ($next_x,$next_y) = $self->n_to_xy ($n + $self->arms_count)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->n_to_xy($n + $self->arms_count) or return 0 5004 5004
312 or return;
313 ### points: "$x,$y $next_x,$next_y"
314 5004 return ($next_x - $x,
315 $next_y - $y);
316 }
317 sub n_to_rsquared {
318 31 ▶ my ($self, $n) = @_;
Subroutine n_to_rsquared: called CC=2 SCAR=7.1
Pod documented
319 31 ▶ my ($x,$y) = $self->n_to_xy($n) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->n_to_xy($n) or return undef 0 31 31
320 31 return $x*$x + $y*$y;
321 }
322 sub n_to_radius {
323 0 ▶ my ($self, $n) = @_;
Subroutine n_to_radius: not called CC=2 SCAR=17.9
Pod documented
324 0 my $rsquared = $self->n_to_rsquared($n);
325 0 ▶ return (defined $rsquared ? sqrt($rsquared) : undef);
Branch: 1 branch
BranchTrueFalseTotal
defined $rsquared ? : 0 0 0
326 }
327  
328 sub xyxy_to_n_list {
329 8 ▶ my ($self, $x1,$y1, $x2,$y2) = @_;
Subroutine xyxy_to_n_list: called CC=3 SCAR=11.1
Pod documented
330 8 ▶ my @n1 = $self->xy_to_n_list($x1,$y1) or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@n1) = $self->xy_to_n_list($x1, $y1) or return 0 8 8
331 8 ▶ my @n2 = $self->xy_to_n_list($x2,$y2) or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@n2) = $self->xy_to_n_list($x2, $y2) or return 0 8 8
332 8 my $arms = $self->arms_count;
333 8 return grep { my $want_n2 = $_ + $arms;
334 11 grep {$_ == $want_n2} @n2 # seek $n2 which is this $n1+$arms
335 } @n1;
336 }
337 sub xyxy_to_n {
338 6 ▶ my $self = shift;
Subroutine xyxy_to_n: called CC=1 SCAR=0.0
Pod documented
339 6 my @n_list = $self->xyxy_to_n_list(@_);
340 6 return $n_list[0];
341 }
342  
343 sub xyxy_to_n_list_either {
344 6258 ▶ my ($self, $x1,$y1, $x2,$y2) = @_;
Subroutine xyxy_to_n_list_either: called CC=6 SCAR=17.9
Pod documented
345 6258 ▶ my @n1 = $self->xy_to_n_list($x1,$y1) or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@n1) = $self->xy_to_n_list($x1, $y1) or return 3125 3133 6258
346 3133 ▶ my @n2 = $self->xy_to_n_list($x2,$y2) or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@n2) = $self->xy_to_n_list($x2, $y2) or return 1251 1882 3133
347 1882 my $arms = $self->arms_count;
348 1882 my @n_list;
349 1882 foreach my $n1 (@n1) {
350 1885 foreach my $n2 (@n2) {
351 1888 ▶ if (abs($n1 - $n2) == $arms) {
Branch: 1 branch
BranchTrueFalseTotal
if (abs $n1 - $n2 == $arms) 1888 0 1888
352 1888 push @n_list, _min($n1,$n2);
353 }
354 }
355 }
356 1882 @n_list = sort {$a<=>$b} @n_list;
357 1882 return @n_list;
358 }
359 sub xyxy_to_n_either {
360 6256 ▶ my $self = shift;
Subroutine xyxy_to_n_either: called CC=1 SCAR=0.0
Pod documented
361 6256 my @n_list = $self->xyxy_to_n_list_either(@_);
362 6256 return $n_list[0];
363 }
364  
365 #------------------------------------------------------------------------------
366 # turns
367  
368 sub _UNDOCUMENTED__n_to_turn_LSR {
369 16 ▶ my ($self, $n) = @_;
Subroutine _UNDOCUMENTED__n_to_turn_LSR: called CC=4 SCAR=13.9
370 ### _UNDOCUMENTED__n_to_turn_LSR(): $n
371  
372 16 ▶ my ($dx,$dy) = $self->n_to_dxdy($n - $self->arms_count)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->n_to_dxdy($n - $self->arms_count) or return undef 8 8 16
373 or return undef;
374 8 ▶ my ($next_dx,$next_dy) = $self->n_to_dxdy($n)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->n_to_dxdy($n) or return undef 0 8 8
375 or return undef;
376  
377 ### dxdy: "$dx,$dy and $next_dx,$next_dy arms=".$self->arms_count
378  
379 8 ▶ return (($next_dy * $dx <=> $next_dx * $dy) || 0); # 1,0,-1
Condition100%2/2
$next_dy * $dx <=> $next_dx * $dy || 0
l!l
62
MC/DC100%1/1
$next_dy * $dx <=> $next_dx * $dy || 0
$next_dy * $dx <=> $next_dx * $dy
Truth table100%2/2
A
A= $next_dy * $dx <=> $next_dx * $dy
Aresult
11
00
380 }
381  
382 #------------------------------------------------------------------------------
383 # tree
384  
385 sub is_tree {
386 0 ▶ my ($self) = @_;
Subroutine is_tree: not called CC=1 SCAR=6.9
Pod documented
387 0 return $self->tree_n_num_children($self->n_start);
388 }
389  
390 101 ▶use constant tree_n_parent => undef; # default always no parent
Subroutine BEGIN: called CC=1 SCAR=0.0
391  
392 101 ▶use constant tree_n_children => (); # default no children
Subroutine BEGIN: called CC=1 SCAR=0.0
393 sub tree_n_num_children {
394 0 ▶ my ($self, $n) = @_;
Subroutine tree_n_num_children: not called CC=2 SCAR=17.9
Pod documented
395 0 ▶ if ($n >= $self->n_start) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n >= $self->n_start) { } 0 0 0
396 0 my @n_list = $self->tree_n_children($n);
397 0 return scalar(@n_list);
398 } else {
399 0 return undef;
400 }
401 }
402  
403 # For non-trees n_num_children() always returns 0 so that's the single
404 # return here.
405 101 ▶use constant tree_num_children_list => (0);
Subroutine BEGIN: called CC=1 SCAR=0.0
406 sub tree_num_children_minimum {
407 2 ▶ my ($self) = @_;
Subroutine tree_num_children_minimum: called CC=1 SCAR=0.0
Pod documented
408 2 return ($self->tree_num_children_list)[0];
409 }
410 sub tree_num_children_maximum {
411 2 ▶ my ($self) = @_;
Subroutine tree_num_children_maximum: called CC=1 SCAR=0.0
Pod documented
412 2 return ($self->tree_num_children_list)[-1];
413 }
414 sub tree_any_leaf {
415 0 ▶ my ($self) = @_;
Subroutine tree_any_leaf: not called CC=1 SCAR=6.9
Pod documented
416 0 return ($self->tree_num_children_minimum == 0);
417 }
418  
419 101 ▶use constant tree_n_to_subheight => 0; # default all leaf node
Subroutine BEGIN: called CC=1 SCAR=0.0
420  
421 101 ▶use constant tree_n_to_depth => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
422 101 ▶use constant tree_depth_to_n => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
423 sub tree_depth_to_n_end {
424 117 ▶ my ($self, $depth) = @_;
Subroutine tree_depth_to_n_end: called CC=3 SCAR=13.3
Pod documented
425 117 ▶ if ($depth >= 0
Branch: 1 branch
BranchTrueFalseTotal
if ($depth >= 0 and defined(my $n = $self->tree_depth_to_n($depth + 1))) { } 117 0 117
Condition33%1/3
$depth >= 0 and defined(my $n = $self->tree_depth_to_n($depth + 1))
!ll&&!rl&&r
00117
MC/DC0%0/2
$depth >= 0 and defined(my $n = $self->tree_depth_to_n($depth + 1))
$depth >= 0 defined(my $n = $self->tree_depth_to_n($depth + 1))
Truth table33%1/3
A and B
A= $depth >= 0B= defined(my $n = $self->tree_depth_to_n($depth + 1))
ABresult
0X0
100
111
426 && defined (my $n = $self->tree_depth_to_n($depth+1))) {
427 ### tree_depth_to_n_end(): $depth, $n
428 117 return $n-1;
429 } else {
430 0 return undef;
431 }
432 }
433 sub tree_depth_to_n_range {
434 0 ▶ my ($self, $depth) = @_;
Subroutine tree_depth_to_n_range: not called CC=3 SCAR=24.8
Pod documented
435 0 ▶ if (defined (my $n = $self->tree_depth_to_n($depth))
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $n = $self->tree_depth_to_n($depth)) and defined(my $n_end = $self->tree_depth_to_n_end($depth))) 0 0 0
Condition0%0/3
defined(my $n = $self->tree_depth_to_n($depth)) and defined(my $n_end = $self->tree_depth_to_n_end($depth))
!ll&&!rl&&r
000
MC/DC0%0/2
defined(my $n = $self->tree_depth_to_n($depth)) and defined(my $n_end = $self->tree_depth_to_n_end($depth))
defined(my $n = $self->tree_depth_to_n($depth)) defined(my $n_end = $self->tree_depth_to_n_end($depth))
Truth table0%0/3
A and B
A= defined(my $n = $self->tree_depth_to_n($depth))B= defined(my $n_end = $self->tree_depth_to_n_end($depth))
ABresult
0X0
100
111
436 && defined (my $n_end = $self->tree_depth_to_n_end($depth))) {
437 0 return ($n, $n_end);
438 }
439 0 return;
440 }
441  
442 sub tree_depth_to_width {
443 0 ▶ my ($self, $depth) = @_;
Subroutine tree_depth_to_width: not called CC=3 SCAR=24.8
Pod documented
444 0 ▶ if (defined (my $n = $self->tree_depth_to_n($depth))
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $n = $self->tree_depth_to_n($depth)) and defined(my $n_end = $self->tree_depth_to_n_end($depth))) 0 0 0
Condition0%0/3
defined(my $n = $self->tree_depth_to_n($depth)) and defined(my $n_end = $self->tree_depth_to_n_end($depth))
!ll&&!rl&&r
000
MC/DC0%0/2
defined(my $n = $self->tree_depth_to_n($depth)) and defined(my $n_end = $self->tree_depth_to_n_end($depth))
defined(my $n = $self->tree_depth_to_n($depth)) defined(my $n_end = $self->tree_depth_to_n_end($depth))
Truth table0%0/3
A and B
A= defined(my $n = $self->tree_depth_to_n($depth))B= defined(my $n_end = $self->tree_depth_to_n_end($depth))
ABresult
0X0
100
111
445 && defined (my $n_end = $self->tree_depth_to_n_end($depth))) {
446 0 return $n_end - $n + 1;
447 }
448 0 return undef;
449 }
450  
451 sub tree_num_roots {
452 0 ▶ my ($self) = @_;
Subroutine tree_num_roots: not called CC=1 SCAR=6.9
Pod documented
453 0 my @root_n_list = $self->tree_root_n_list;
454 0 return scalar(@root_n_list);
455 }
456 sub tree_root_n_list {
457 0 ▶ my ($self) = @_;
Subroutine tree_root_n_list: not called CC=3 SCAR=24.8
Pod documented
458 0 my $n_start = $self->n_start;
459 0 my @ret;
460 0 for (my $n = $n_start; ; $n++) {
461 # stop on finding a non-root (has a parent), or a non-tree path has no
462 # children at all
463 0 ▶ if (defined($self->tree_n_parent($n))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->tree_n_parent($n) or not $self->tree_n_num_children($n)) 0 0 0
Condition0%0/3
defined $self->tree_n_parent($n) or not $self->tree_n_num_children($n)
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self->tree_n_parent($n) or not $self->tree_n_num_children($n)
defined $self->tree_n_parent($n) not $self->tree_n_num_children($n)
Truth table0%0/3
A or not(B)
A= defined $self->tree_n_parent($n)B= not $self->tree_n_num_children($n)
ABresult
1X1
011
000
464 || ! $self->tree_n_num_children($n)) {
465 0 last;
466 }
467 0 push @ret, $n;
468 }
469 0 return @ret;
470 }
471  
472 # Generic search upwards. Not fast, but works with past Toothpick or
473 # anything slack which doesn't have own tree_n_root(). When only one root
474 # there's no search.
475 sub tree_n_root {
476 0 ▶ my ($self, $n) = @_;
Subroutine tree_n_root: not called CC=6 SCAR=37.4
Pod documented
477 0 my $num_roots = $self->tree_num_roots;
478 0 ▶ if ($num_roots == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num_roots == 0) 0 0 0
479 0 return undef; # not a tree
480 }
481 0 my $n_start = $self->n_start;
482 0 ▶ unless ($n >= $n_start) { # and warn if $n==undef
Branch: 1 branch
BranchTrueFalseTotal
unless ($n >= $n_start) 0 0 0
483 0 return undef; # -inf or NaN
484 }
485 0 ▶ if ($num_roots == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num_roots == 1) 0 0 0
486 0 return $n_start; # only one root, no search
487 }
488  
489 0 for (;;) {
490 0 my $n_parent = $self->tree_n_parent($n);
491 0 ▶ if (! defined $n_parent) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $n_parent) 0 0 0
492 0 return $n; # found root
493 }
494 0 ▶ unless ($n_parent < $n) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($n_parent < $n) 0 0 0
495 0 return undef; # +inf or something bad not making progress
496 }
497 0 $n = $n_parent;
498 }
499 }
500  
501 # Generic search for where no more children.
502 # But must watch out for infinite lets, and might also watch out for
503 # rounding or overflow.
504 #
505 # sub path_tree_n_to_subheight {
506 # my ($path, $n) = @_;
507 # ### path_tree_n_to_subheight(): "$n"
508 #
509 # if (is_infinite($n)) {
510 # return $n;
511 # }
512 # my $max = $path->tree_n_to_depth($n) + 10;
513 # my @n = ($n);
514 # my $height = 0;
515 # do {
516 # @n = map {$path->tree_n_children($_)} @n
517 # or return $height;
518 # $height++;
519 # } while (@n && $height < $max);
520 #
521 # ### height infinite ...
522 # return undef;
523 # }
524  
525 #------------------------------------------------------------------------------
526 # levels
527  
528 101 ▶use constant level_to_n_range => ();
Subroutine BEGIN: called CC=1 SCAR=0.0
529 101 ▶use constant n_to_level => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
530  
531  
532 #------------------------------------------------------------------------------
533 # shared undocumented internals
534  
535 sub _max {
536 78366 ▶ my $max = 0;
Subroutine _max: called CC=3 SCAR=11.0
537 78366 foreach my $i (1 .. $#_) {
538 180268 ▶ if ($_[$i] > $_[$max]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[$i] > $_[$max]) 51741 128527 180268
539 51741 $max = $i;
540 }
541 }
542 78366 return $_[$max];
543 }
544 sub _min {
545 61785 ▶ my $min = 0;
Subroutine _min: called CC=3 SCAR=11.0
546 61785 foreach my $i (1 .. $#_) {
547 161146 ▶ if ($_[$i] < $_[$min]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[$i] < $_[$min]) 25446 135700 161146
548 25446 $min = $i;
549 }
550 }
551 61785 return $_[$min];
552 }
553 # Return square root of $x, rounded towards zero.
554 # Recent BigFloat and BigRat need explicit conversion to BigInt, they no
555 # longer do that in int().
556 sub _sqrtint {
557 167471 ▶ my ($x) = @_;
Subroutine _sqrtint: called CC=4 SCAR=13.9
558 167471 ▶ if (ref $x) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $x) 16 167455 167471
559 16 ▶ if ($x->isa('Math::BigFloat') || $x->isa('Math::BigRat')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x->isa("Math::BigFloat") or $x->isa("Math::BigRat")) 5 11 16
Condition66%2/3
$x->isa("Math::BigFloat") or $x->isa("Math::BigRat")
l!l&&r!l&&!r
5011
MC/DC50%1/2
$x->isa("Math::BigFloat") or $x->isa("Math::BigRat")
$x->isa("Math::BigFloat") $x->isa("Math::BigRat")
Truth table66%2/3
A or B
A= $x->isa("Math::BigFloat")B= $x->isa("Math::BigRat")
ABresult
1X1
011
000
560 5 $x = $x->copy->as_int;
561 }
562 }
563 167471 return int(sqrt($x));
564 }
565  
566 101 ▶use Math::PlanePath::Base::Generic 'round_nearest';
Subroutine BEGIN: called CC=1 SCAR=0.0
567 sub _rect_for_first_quadrant {
568 0 ▶ my ($self, $x1,$y1, $x2,$y2) = @_;
Subroutine _rect_for_first_quadrant: not called CC=5 SCAR=34.0
569 0 $x1 = round_nearest($x1);
570 0 $y1 = round_nearest($y1);
571 0 $x2 = round_nearest($x2);
572 0 $y2 = round_nearest($y2);
573 0 ▶ ($x1,$x2) = ($x2,$x1) if $x1 > $x2;
Branch: 1 branch
BranchTrueFalseTotal
if $x1 > $x2 0 0 0
574 0 ▶ ($y1,$y2) = ($y2,$y1) if $y1 > $y2;
Branch: 1 branch
BranchTrueFalseTotal
if $y1 > $y2 0 0 0
575 0 ▶ if ($x2 < 0 || $y2 < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x2 < 0 or $y2 < 0) 0 0 0
Condition0%0/3
$x2 < 0 or $y2 < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$x2 < 0 or $y2 < 0
$x2 < 0 $y2 < 0
Truth table0%0/3
A or B
A= $x2 < 0B= $y2 < 0
ABresult
1X1
011
000
576 0 return;
577 }
578 0 return ($x1,$y1, $x2,$y2);
579 }
580  
581 # return ($quotient, $remainder)
582 sub _divrem {
583 85741 ▶ my ($n, $d) = @_;
Subroutine _divrem: called CC=5 SCAR=16.3
584 85741 ▶ if (ref $n && $n->isa('Math::BigInt')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $n and $n->isa("Math::BigInt")) 1008 84733 85741
Condition66%2/3
ref $n and $n->isa("Math::BigInt")
!ll&&!rl&&r
8473301008
MC/DC50%1/2
ref $n and $n->isa("Math::BigInt")
ref $n $n->isa("Math::BigInt")
Truth table66%2/3
A and B
A= ref $nB= $n->isa("Math::BigInt")
ABresult
0X0
100
111
585 1008 my ($quot,$rem) = $n->copy->bdiv($d);
586 1008 ▶ if (! ref $d || $d < 1_000_000) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $d or $d < 1000000) 1008 0 1008
Condition66%2/3
not ref $d or $d < 1000000
l!l&&r!l&&!r
4935150
MC/DC0%0/2
not ref $d or $d < 1000000
not ref $d $d < 1000000
Truth table66%2/3
not(A) or B
A= not ref $dB= $d < 1000000
ABresult
1X1
011
000
587 1008 $rem = $rem->numify; # plain remainder if fits
588 }
589 1008 return ($quot, $rem);
590 }
591 84733 my $rem = $n % $d;
592 84733 return (int(($n-$rem)/$d), # exact division stays in UV
593 $rem);
594 }
595  
596 # return $remainder, modify $n
597 # the scalar $_[0] is modified, but if it's a BigInt then a new BigInt is made
598 # and stored there, the bigint value is not changed
599 sub _divrem_mutate {
600 146367 ▶ my $d = $_[1];
Subroutine _divrem_mutate: called CC=5 SCAR=16.6
601 146367 my $rem;
602 146367 ▶ if (ref $_[0] && $_[0]->isa('Math::BigInt')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] and $_[0]->isa('Math::BigInt')) { } 1 146366 146367
Condition66%2/3
ref $_[0] and $_[0]->isa("Math::BigInt")
!ll&&!rl&&r
14636601
MC/DC50%1/2
ref $_[0] and $_[0]->isa("Math::BigInt")
ref $_[0] $_[0]->isa("Math::BigInt")
Truth table66%2/3
A and B
A= ref $_[0]B= $_[0]->isa("Math::BigInt")
ABresult
0X0
100
111
603 1 ($_[0], $rem) = $_[0]->copy->bdiv($d); # quot,rem in array context
604 1 ▶ if (! ref $d || $d < 1_000_000) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $d or $d < 1000000) 1 0 1
Condition33%1/3
not ref $d or $d < 1000000
l!l&&r!l&&!r
100
MC/DC0%0/2
not ref $d or $d < 1000000
not ref $d $d < 1000000
Truth table33%1/3
not(A) or B
A= not ref $dB= $d < 1000000
ABresult
1X1
011
000
605 1 return $rem->numify; # plain remainder if fits
606 }
607 } else {
608 146366 $rem = $_[0] % $d;
609 146366 $_[0] = int(($_[0]-$rem)/$d); # exact division stays in UV
610 }
611 146366 return $rem;
612 }
613  
614 101 1;
615 __END__
« PlanePath/UlamWarburtonQuarter.pm ↑ Summary PlanePath/HeptSpiralSkewed.pm »