PlanePath.pm

filter: Statementstmt 69.1% 244 / 353 Branchbran 36.1% 39 / 108 Conditioncond 21.5% 19 / 88 MC/DCmcdc 10.9% 6 / 55 Subroutinesub 78.4% 73 / 93 Podpod 97.5% 40 / 41 totaltotal 57.0% 421 / 738 SCAR 67.2
CC
90
Cov
55%
rsquared_minimum
90.0
sumabsxy_minimum
56.0
tree_n_root
42.0
CRAP 827.7
« PlanePath/WunderlichSerpentine.pm ↑ Summary PlanePath/AlternatePaper.pm »
1 # Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 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 99 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 99 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 99 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 99 $VERSION = 127;
24  
25 # uncomment this to run the ### lines
26 # use Smart::Comments;
27  
28  
29 # defaults
30 99 ▶use constant figure => 'square';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 99 ▶use constant default_n_start => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 sub n_start {
33 375 ▶ my ($self) = @_;
Subroutine n_start: called CC=3 SCAR=11.0
Pod documented
34 375 ▶ if (ref $self && defined $self->{'n_start'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self and defined $self->{'n_start'}) { } 351 24 375
Condition66%2/3
ref $self and defined $self->{"n_start"}
!ll&&!rl&&r
024351
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 351 return $self->{'n_start'};
36 } else {
37 24 return $self->default_n_start;
38 }
39 }
40 sub arms_count {
41 7521 ▶ my ($self) = @_;
Subroutine arms_count: called CC=2 SCAR=6.9
Pod documented
42 7521 ▶ return $self->{'arms'} || 1;
Condition100%2/2
$self->{'arms'} || 1
l!l
25105011
MC/DC100%1/1
$self->{'arms'} || 1
$self->{'arms'}
Truth table100%2/2
A
A= $self->{'arms'}
Aresult
11
00
43 }
44  
45 99 ▶use constant class_x_negative => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 99 ▶use constant class_y_negative => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 89 ▶sub x_negative { $_[0]->class_x_negative }
Subroutine x_negative: called CC=1 SCAR=0.0
Pod documented
48 344 ▶sub y_negative { $_[0]->class_y_negative }
Subroutine y_negative: called CC=1 SCAR=0.0
Pod documented
49 99 ▶use constant x_negative_at_n => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 99 ▶use constant y_negative_at_n => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 99 ▶use constant n_frac_discontinuity => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 99 ▶use constant parameter_info_array => [];
Subroutine BEGIN: called CC=1 SCAR=0.0
54 sub parameter_info_list {
55 63 ▶ 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 99 ▶use constant x_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 99 ▶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 99 ▶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 99 ▶use constant sumabsxy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
96  
97 99 ▶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 99 ▶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 99 ▶use constant gcdxy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
183  
184 99 ▶use constant turn_any_left => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
185 99 ▶use constant turn_any_right => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
186 99 ▶use constant turn_any_straight => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
187  
188  
189 #------------------------------------------------------------------------------
190  
191 99 ▶use constant dir_minimum_dxdy => (1,0); # East
Subroutine BEGIN: called CC=1 SCAR=0.0
192 99 ▶use constant dir_maximum_dxdy => (0,0); # supremum all angles
Subroutine BEGIN: called CC=1 SCAR=0.0
193  
194 99 ▶use constant dx_minimum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
195 99 ▶use constant dy_minimum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
196 99 ▶use constant dx_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
197 99 ▶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 99 ▶use constant _UNDOCUMENTED__dxdy_list => (); # default empty for not a finite list
Subroutine BEGIN: called CC=1 SCAR=0.0
205 99 ▶use constant _UNDOCUMENTED__dxdy_list_at_n => undef; # maybe dxdy_at_n()
Subroutine BEGIN: called CC=1 SCAR=0.0
206 99 use constant _UNDOCUMENTED__dxdy_list_three => (2,0, # E
207 -1,1, # NW
208 99 ▶ -1,-1); # SW
Subroutine BEGIN: called CC=1 SCAR=0.0
209 99 use constant _UNDOCUMENTED__dxdy_list_six => (2,0, # E
210 1,1, # NE
211 -1,1, # NW
212 -2,0, # W
213 -1,-1, # SW
214 99 ▶ 1,-1); # SE
Subroutine BEGIN: called CC=1 SCAR=0.0
215 99 use constant _UNDOCUMENTED__dxdy_list_eight => (1,0, # E
216 1,1, # NE
217 0,1, # N
218 -1,1, # NW
219 -1,0, # W
220 -1,-1, # SW
221 0,-1, # S
222 99 ▶ 1,-1); # SE
Subroutine BEGIN: called CC=1 SCAR=0.0
223  
224 sub absdx_minimum {
225 0 ▶ my ($self) = @_;
Subroutine absdx_minimum: not called CC=3 SCAR=24.8
Pod documented
226 # If dX>=0 then abs(dX)=dX always and absdx_minimum()==dx_minimum().
227 # This happens for column style paths like CoprimeColumns.
228 # dX>0 is only for line paths so not very interesting.
229 0 ▶ if (defined (my $dx_minimum = $self->dx_minimum)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $dx_minimum = $self->dx_minimum)) 0 0 0
230 0 ▶ if ($dx_minimum >= 0) { return $dx_minimum; }
Branch: 1 branch
BranchTrueFalseTotal
if ($dx_minimum >= 0) 0 0 0
231 }
232 0 return 0;
233 }
234 sub absdx_maximum {
235 0 ▶ my ($self) = @_;
Subroutine absdx_maximum: not called CC=3 SCAR=24.8
Pod documented
236 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
237 && defined (my $dx_maximum = $self->dx_maximum)) {
238 0 return _max(abs($dx_minimum),abs($dx_maximum));
239 }
240 0 return undef;
241 }
242  
243 sub absdy_minimum {
244 0 ▶ my ($self) = @_;
Subroutine absdy_minimum: not called CC=3 SCAR=24.8
Pod documented
245 # if dY>=0 then abs(dY)=dY always and absdy_minimum()==dy_minimum()
246 0 ▶ if (defined (my $dy_minimum = $self->dy_minimum)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $dy_minimum = $self->dy_minimum)) 0 0 0
247 0 ▶ if ($dy_minimum >= 0) { return $dy_minimum; }
Branch: 1 branch
BranchTrueFalseTotal
if ($dy_minimum >= 0) 0 0 0
248 }
249 0 return 0;
250 }
251 sub absdy_maximum {
252 0 ▶ my ($self) = @_;
Subroutine absdy_maximum: not called CC=3 SCAR=24.8
Pod documented
253 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
254 && defined (my $dy_maximum = $self->dy_maximum)) {
255 0 return _max(abs($dy_minimum),abs($dy_maximum));
256 } else {
257 0 return undef;
258 }
259 }
260  
261 99 ▶use constant dsumxy_minimum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
262 99 ▶use constant dsumxy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
263 99 ▶use constant ddiffxy_minimum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
264 99 ▶use constant ddiffxy_maximum => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
265  
266 #------------------------------------------------------------------------------
267  
268 sub new {
269 1866 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
270 1866 return bless { @_ }, $class;
271 }
272  
273 {
274 99 my %parameter_info_hash;
275 sub parameter_info_hash {
276 3 ▶ my ($class_or_self) = @_;
Subroutine parameter_info_hash: called CC=3 SCAR=12.0
Pod documented
277 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
278 return ($parameter_info_hash{$class}
279 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
280 $class_or_self->parameter_info_list });
281 }
282 }
283  
284 99 sub xy_to_n_list {
285 ### xy_to_n_list() ...
286 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
287 ### $n
288 5028 return $n;
289 }
290 ### empty ...
291 4376 return;
292 }
293 sub xy_is_visited {
294 7 ▶ my ($self, $x, $y) = @_;
Subroutine xy_is_visited: called CC=1 SCAR=0.0
Pod documented
295 ### xy_is_visited(): "$x,$y is ndefined=".defined($self->xy_to_n($x,$y))
296 7 return defined($self->xy_to_n($x,$y));
297 }
298  
299 sub n_to_n_list {
300 0 ▶ my ($self, $n) = @_;
Subroutine n_to_n_list: not called CC=2 SCAR=17.9
Pod documented
301 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
302 0 return $self->xy_to_n_list($x,$y);
303 }
304  
305 sub n_to_dxdy {
306 5006 ▶ my ($self, $n) = @_;
Subroutine n_to_dxdy: called CC=3 SCAR=11.0
Pod documented
307 ### n_to_dxdy(): $n
308 5006 ▶ my ($x,$y) = $self->n_to_xy ($n)
Branch: 1 branch
BranchTrueFalseTotal
() = $self->n_to_xy($n) or return 3 5003 5006
309 or return;
310 5003 ▶ 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 5003 5003
311 or return;
312 ### points: "$x,$y $next_x,$next_y"
313 5003 return ($next_x - $x,
314 $next_y - $y);
315 }
316 sub n_to_rsquared {
317 31 ▶ my ($self, $n) = @_;
Subroutine n_to_rsquared: called CC=2 SCAR=7.1
Pod documented
318 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
319 31 return $x*$x + $y*$y;
320 }
321 sub n_to_radius {
322 0 ▶ my ($self, $n) = @_;
Subroutine n_to_radius: not called CC=2 SCAR=17.9
Pod documented
323 0 my $rsquared = $self->n_to_rsquared($n);
324 0 ▶ return (defined $rsquared ? sqrt($rsquared) : undef);
Branch: 1 branch
BranchTrueFalseTotal
defined $rsquared ? : 0 0 0
325 }
326  
327 sub xyxy_to_n_list {
328 8 ▶ my ($self, $x1,$y1, $x2,$y2) = @_;
Subroutine xyxy_to_n_list: called CC=3 SCAR=11.1
Pod documented
329 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
330 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
331 8 my $arms = $self->arms_count;
332 8 return grep { my $want_n2 = $_ + $arms;
333 11 grep {$_ == $want_n2} @n2 # seek $n2 which is this $n1+$arms
334 } @n1;
335 }
336 sub xyxy_to_n {
337 6 ▶ my $self = shift;
Subroutine xyxy_to_n: called CC=1 SCAR=0.0
Pod documented
338 6 my @n_list = $self->xyxy_to_n_list(@_);
339 6 return $n_list[0];
340 }
341  
342 sub xyxy_to_n_list_either {
343 6258 ▶ my ($self, $x1,$y1, $x2,$y2) = @_;
Subroutine xyxy_to_n_list_either: called CC=6 SCAR=17.9
Pod documented
344 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
345 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
346 1882 my $arms = $self->arms_count;
347 1882 my @n_list;
348 1882 foreach my $n1 (@n1) {
349 1885 foreach my $n2 (@n2) {
350 1888 ▶ if (abs($n1 - $n2) == $arms) {
Branch: 1 branch
BranchTrueFalseTotal
if (abs $n1 - $n2 == $arms) 1888 0 1888
351 1888 push @n_list, _min($n1,$n2);
352 }
353 }
354 }
355 1882 @n_list = sort {$a<=>$b} @n_list;
356 1882 return @n_list;
357 }
358 sub xyxy_to_n_either {
359 6256 ▶ my $self = shift;
Subroutine xyxy_to_n_either: called CC=1 SCAR=0.0
Pod documented
360 6256 my @n_list = $self->xyxy_to_n_list_either(@_);
361 6256 return $n_list[0];
362 }
363  
364 #------------------------------------------------------------------------------
365 # turns
366  
367 sub _UNDOCUMENTED__n_to_turn_LSR {
368 13 ▶ my ($self, $n) = @_;
Subroutine _UNDOCUMENTED__n_to_turn_LSR: called CC=4 SCAR=13.9
369 ### _UNDOCUMENTED__n_to_turn_LSR(): $n
370  
371 13 ▶ my ($dx,$dy) = $self->n_to_dxdy($n - $self->arms_count) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->n_to_dxdy($n - $self->arms_count) or return undef 6 7 13
372 7 ▶ my ($next_dx,$next_dy) = $self->n_to_dxdy($n) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->n_to_dxdy($n) or return undef 0 7 7
373  
374 ### dxdy: "$dx,$dy and $next_dx,$next_dy arms=".$self->arms_count
375  
376 7 ▶ return (($next_dy * $dx <=> $next_dx * $dy) || 0); # 1,0,-1
Condition100%2/2
$next_dy * $dx <=> $next_dx * $dy || 0
l!l
52
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
377 }
378  
379 #------------------------------------------------------------------------------
380 # tree
381  
382 sub is_tree {
383 0 ▶ my ($self) = @_;
Subroutine is_tree: not called CC=1 SCAR=6.9
Pod documented
384 0 return $self->tree_n_num_children($self->n_start);
385 }
386  
387 99 ▶use constant tree_n_parent => undef; # default always no parent
Subroutine BEGIN: called CC=1 SCAR=0.0
388  
389 99 ▶use constant tree_n_children => (); # default no children
Subroutine BEGIN: called CC=1 SCAR=0.0
390 sub tree_n_num_children {
391 0 ▶ my ($self, $n) = @_;
Subroutine tree_n_num_children: not called CC=2 SCAR=17.9
Pod documented
392 0 ▶ if ($n >= $self->n_start) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n >= $self->n_start) { } 0 0 0
393 0 my @n_list = $self->tree_n_children($n);
394 0 return scalar(@n_list);
395 } else {
396 0 return undef;
397 }
398 }
399  
400 # For non-trees n_num_children() always returns 0 so that's the single
401 # return here.
402 99 ▶use constant tree_num_children_list => (0);
Subroutine BEGIN: called CC=1 SCAR=0.0
403 sub tree_num_children_minimum {
404 2 ▶ my ($self) = @_;
Subroutine tree_num_children_minimum: called CC=1 SCAR=0.0
Pod documented
405 2 return ($self->tree_num_children_list)[0];
406 }
407 sub tree_num_children_maximum {
408 2 ▶ my ($self) = @_;
Subroutine tree_num_children_maximum: called CC=1 SCAR=0.0
Pod documented
409 2 return ($self->tree_num_children_list)[-1];
410 }
411 sub tree_any_leaf {
412 0 ▶ my ($self) = @_;
Subroutine tree_any_leaf: not called CC=1 SCAR=6.9
Pod documented
413 0 return ($self->tree_num_children_minimum == 0);
414 }
415  
416 99 ▶use constant tree_n_to_subheight => 0; # default all leaf node
Subroutine BEGIN: called CC=1 SCAR=0.0
417  
418 99 ▶use constant tree_n_to_depth => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
419 99 ▶use constant tree_depth_to_n => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
420 sub tree_depth_to_n_end {
421 117 ▶ my ($self, $depth) = @_;
Subroutine tree_depth_to_n_end: called CC=3 SCAR=13.3
Pod documented
422 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
423 && defined (my $n = $self->tree_depth_to_n($depth+1))) {
424 ### tree_depth_to_n_end(): $depth, $n
425 117 return $n-1;
426 } else {
427 0 return undef;
428 }
429 }
430 sub tree_depth_to_n_range {
431 0 ▶ my ($self, $depth) = @_;
Subroutine tree_depth_to_n_range: not called CC=3 SCAR=24.8
Pod documented
432 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
433 && defined (my $n_end = $self->tree_depth_to_n_end($depth))) {
434 0 return ($n, $n_end);
435 }
436 0 return;
437 }
438  
439 sub tree_depth_to_width {
440 0 ▶ my ($self, $depth) = @_;
Subroutine tree_depth_to_width: not called CC=3 SCAR=24.8
Pod documented
441 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
442 && defined (my $n_end = $self->tree_depth_to_n_end($depth))) {
443 0 return $n_end - $n + 1;
444 }
445 0 return undef;
446 }
447  
448 sub tree_num_roots {
449 0 ▶ my ($self) = @_;
Subroutine tree_num_roots: not called CC=1 SCAR=6.9
Pod documented
450 0 my @root_n_list = $self->tree_root_n_list;
451 0 return scalar(@root_n_list);
452 }
453 sub tree_root_n_list {
454 0 ▶ my ($self) = @_;
Subroutine tree_root_n_list: not called CC=3 SCAR=24.8
Pod documented
455 0 my $n_start = $self->n_start;
456 0 my @ret;
457 0 for (my $n = $n_start; ; $n++) {
458 # stop on finding a non-root (has a parent), or a non-tree path has no
459 # children at all
460 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
461 || ! $self->tree_n_num_children($n)) {
462 0 last;
463 }
464 0 push @ret, $n;
465 }
466 0 return @ret;
467 }
468  
469 # Generic search upwards. Not fast, but works with past Toothpick or
470 # anything slack which doesn't have own tree_n_root(). When only one root
471 # there's no search.
472 sub tree_n_root {
473 0 ▶ my ($self, $n) = @_;
Subroutine tree_n_root: not called CC=6 SCAR=37.4
Pod documented
474 0 my $num_roots = $self->tree_num_roots;
475 0 ▶ if ($num_roots == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num_roots == 0) 0 0 0
476 0 return undef; # not a tree
477 }
478 0 my $n_start = $self->n_start;
479 0 ▶ unless ($n >= $n_start) { # and warn if $n==undef
Branch: 1 branch
BranchTrueFalseTotal
unless ($n >= $n_start) 0 0 0
480 0 return undef; # -inf or NaN
481 }
482 0 ▶ if ($num_roots == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num_roots == 1) 0 0 0
483 0 return $n_start; # only one root, no search
484 }
485  
486 0 for (;;) {
487 0 my $n_parent = $self->tree_n_parent($n);
488 0 ▶ if (! defined $n_parent) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $n_parent) 0 0 0
489 0 return $n; # found root
490 }
491 0 ▶ unless ($n_parent < $n) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($n_parent < $n) 0 0 0
492 0 return undef; # +inf or something bad not making progress
493 }
494 0 $n = $n_parent;
495 }
496 }
497  
498 # Generic search for where no more children.
499 # But must watch out for infinite lets, and might also watch out for
500 # rounding or overflow.
501 #
502 # sub path_tree_n_to_subheight {
503 # my ($path, $n) = @_;
504 # ### path_tree_n_to_subheight(): "$n"
505 #
506 # if (is_infinite($n)) {
507 # return $n;
508 # }
509 # my $max = $path->tree_n_to_depth($n) + 10;
510 # my @n = ($n);
511 # my $height = 0;
512 # do {
513 # @n = map {$path->tree_n_children($_)} @n
514 # or return $height;
515 # $height++;
516 # } while (@n && $height < $max);
517 #
518 # ### height infinite ...
519 # return undef;
520 # }
521  
522 #------------------------------------------------------------------------------
523 # levels
524  
525 99 ▶use constant level_to_n_range => ();
Subroutine BEGIN: called CC=1 SCAR=0.0
526 99 ▶use constant n_to_level => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
527  
528  
529 #------------------------------------------------------------------------------
530 # shared undocumented internals
531  
532 sub _max {
533 78947 ▶ my $max = 0;
Subroutine _max: called CC=3 SCAR=11.0
534 78947 foreach my $i (1 .. $#_) {
535 180849 ▶ if ($_[$i] > $_[$max]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[$i] > $_[$max]) 52163 128686 180849
536 52163 $max = $i;
537 }
538 }
539 78947 return $_[$max];
540 }
541 sub _min {
542 63218 ▶ my $min = 0;
Subroutine _min: called CC=3 SCAR=11.0
543 63218 foreach my $i (1 .. $#_) {
544 162579 ▶ if ($_[$i] < $_[$min]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[$i] < $_[$min]) 25837 136742 162579
545 25837 $min = $i;
546 }
547 }
548 63218 return $_[$min];
549 }
550 # Return square root of $x, rounded towards zero.
551 # Recent BigFloat and BigRat need explicit conversion to BigInt, they no
552 # longer do that in int().
553 sub _sqrtint {
554 167473 ▶ my ($x) = @_;
Subroutine _sqrtint: called CC=4 SCAR=13.9
555 167473 ▶ if (ref $x) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $x) 16 167457 167473
556 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
557 5 $x = $x->copy->as_int;
558 }
559 }
560 167473 return int(sqrt($x));
561 }
562  
563 99 ▶use Math::PlanePath::Base::Generic 'round_nearest';
Subroutine BEGIN: called CC=1 SCAR=0.0
564 sub _rect_for_first_quadrant {
565 0 ▶ my ($self, $x1,$y1, $x2,$y2) = @_;
Subroutine _rect_for_first_quadrant: not called CC=5 SCAR=34.0
566 0 $x1 = round_nearest($x1);
567 0 $y1 = round_nearest($y1);
568 0 $x2 = round_nearest($x2);
569 0 $y2 = round_nearest($y2);
570 0 ▶ ($x1,$x2) = ($x2,$x1) if $x1 > $x2;
Branch: 1 branch
BranchTrueFalseTotal
if $x1 > $x2 0 0 0
571 0 ▶ ($y1,$y2) = ($y2,$y1) if $y1 > $y2;
Branch: 1 branch
BranchTrueFalseTotal
if $y1 > $y2 0 0 0
572 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
573 0 return;
574 }
575 0 return ($x1,$y1, $x2,$y2);
576 }
577  
578 # return ($quotient, $remainder)
579 sub _divrem {
580 85769 ▶ my ($n, $d) = @_;
Subroutine _divrem: called CC=5 SCAR=16.3
581 85769 ▶ if (ref $n && $n->isa('Math::BigInt')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $n and $n->isa("Math::BigInt")) 1008 84761 85769
Condition66%2/3
ref $n and $n->isa("Math::BigInt")
!ll&&!rl&&r
8476101008
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
582 1008 my ($quot,$rem) = $n->copy->bdiv($d);
583 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
584 1008 $rem = $rem->numify; # plain remainder if fits
585 }
586 1008 return ($quot, $rem);
587 }
588 84761 my $rem = $n % $d;
589 84761 return (int(($n-$rem)/$d), # exact division stays in UV
590 $rem);
591 }
592  
593 # return $remainder, modify $n
594 # the scalar $_[0] is modified, but if it's a BigInt then a new BigInt is made
595 # and stored there, the bigint value is not changed
596 sub _divrem_mutate {
597 149729 ▶ my $d = $_[1];
Subroutine _divrem_mutate: called CC=5 SCAR=16.6
598 149729 my $rem;
599 149729 ▶ if (ref $_[0] && $_[0]->isa('Math::BigInt')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] and $_[0]->isa('Math::BigInt')) { } 1 149728 149729
Condition66%2/3
ref $_[0] and $_[0]->isa("Math::BigInt")
!ll&&!rl&&r
14972801
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
600 1 ($_[0], $rem) = $_[0]->copy->bdiv($d); # quot,rem in array context
601 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
602 1 return $rem->numify; # plain remainder if fits
603 }
604 } else {
605 149728 $rem = $_[0] % $d;
606 149728 $_[0] = int(($_[0]-$rem)/$d); # exact division stays in UV
607 }
608 149728 return $rem;
609 }
610  
611 99 1;
612 __END__
« PlanePath/WunderlichSerpentine.pm ↑ Summary PlanePath/AlternatePaper.pm »