NumSeq/PlanePathCoord.pm untested

filter: Statementstmt 0.0% 0 / 2720 Branchbran 0.0% 0 / 552 Conditioncond 0.0% 0 / 443 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 681 Podpod 0.0% 0 / 304 totaltotal 0.0% 0 / 4700 SCAR 112.3
CC
274
Cov
0%
_kronecker_symbol
306.0
oeis_anum
240.0
_coordinate_func_GCD
90.0
CRAP 75350.0
1 # Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
6 # it under the terms of the GNU General Public License as published by the
7 # Free 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  
19 package Math::NumSeq::PlanePathCoord;
20 use 5.004;
21 use strict;
22 use Carp 'croak';
23 use constant 1.02; # various underscore constants below
24 use List::Util;
25  
26 #use List::Util 'max','min';
27 *max = \&Math::PlanePath::_max;
28 *min = \&Math::PlanePath::_min;
29  
30 use vars '$VERSION','@ISA';
31 $VERSION = 127;
32 use Math::NumSeq;
33 @ISA = ('Math::NumSeq');
34  
35 use Math::PlanePath 124; # v.124 for n_to_n_list()
36 *_divrem_mutate = \&Math::PlanePath::_divrem_mutate;
37  
38 use Math::PlanePath::Base::Generic
39 'is_infinite';
40  
41 # uncomment this to run the ### lines
42 # use Smart::Comments;
43  
44  
45 sub description {
46 my ($self) = @_;
47 if (ref $self) {
48 return "Coordinate $self->{'coordinate_type'} values from path $self->{'planepath'}";
49 } else {
50 # class method
51 return 'Coordinate values from a PlanePath';
52 }
53 }
54  
55 use constant::defer parameter_info_array =>
56 sub {
57 my $choices = [
58 'X', 'Y',
59 'Sum', 'SumAbs',
60 'Product',
61 'DiffXY', 'DiffYX', 'AbsDiff',
62 'Radius', 'RSquared',
63 'TRadius', 'TRSquared',
64 'IntXY', 'FracXY',
65 'BitAnd', 'BitOr', 'BitXor',
66 'Min','Max',
67 'MinAbs','MaxAbs',
68 'GCD',
69 'Depth', 'SubHeight',
70 'NumChildren','NumSiblings',
71 'RootN',
72 'IsLeaf','IsNonLeaf',
73  
74 # Maybe:
75 # 'ExperimentalRowOffset',
76 # 'ExperimentalMinAbsTri','ExperimentalMaxAbsTri',
77 # 'ExperimentalAbsX',
78 # 'ExperimentalAbsY',
79 # 'DiffXY/2',
80 # 'ExperimentalDiffXYsquared',
81 # 'ExperimentalDiffYXsquares',
82 # 'ExperimentalParity',
83 # 'ExperimentalNumerator','ExperimentalDenominator',
84 # 'ExperimentalLeafDistance',
85 # 'ExperimentalGcdDivisions',
86 # 'ExperimentalKroneckerSymbol',
87 # 'ExperimentalMulDist',
88 # 'ExperimentalHammingDist',
89 # 'ExperimentalNumOverlap',
90 #
91 # 'ExperimentalNeighbours3', # NumNeighbours
92 # 'ExperimentalNeighbours4',
93 # 'ExperimentalNeighbours4d',
94 # 'ExperimentalNeighbours6',
95 # 'ExperimentalNeighbours8',
96 #
97 # 'ExperimentalVisitNum',
98 # 'ExperimentalVisitCount',
99 # 'ExperimentalRevisit',
100 'ExperimentalPairsXY','ExperimentalPairsYX',
101 ];
102 return [
103 _parameter_info_planepath(),
104 { name => 'coordinate_type',
105 display => 'Coordinate Type',
106 type => 'enum',
107 default => 'X',
108 choices => $choices,
109 choices_display => $choices,
110 description => 'The coordinate or combination to take from the path.',
111 },
112 ];
113 };
114  
115 use constant::defer _parameter_info_planepath => sub {
116 # require Module::Util;
117 # cf ...::Generator->path_choices() order
118 # my @choices = sort map { s/.*:://;
119 # if (length() > $width) { $width = length() }
120 # $_ }
121 # Module::Util::find_in_namespace('Math::PlanePath');
122  
123 # my @choices = Module::Find::findsubmod('Math::PlanePath');
124 # @choices = grep {$_ ne 'Math::PlanePath'} @choices;
125  
126 # my $choices = ...::Generator->path_choices_array;
127 # foreach (@$choices) {
128 # if (length() > $width) { $width = length() }
129 # }
130  
131 require File::Spec;
132 require Scalar::Util;
133 my $width = 0;
134 my %names;
135  
136 foreach my $dir (@INC) {
137 next if ! defined $dir || ref $dir;
138 # next if ref $dir eq 'CODE' # subr
139 # || ref $dir eq 'ARRAY' # array of subr and more
140 # || Scalar::Util::blessed($dir);
141  
142 opendir DIR, File::Spec->catdir ($dir, 'Math', 'PlanePath') or next;
143 while (my $name = readdir DIR) {
144 # basename of .pm files, and not emacs .#Foo.pm lockfiles
145 $name =~ s/^([^.].*)\.pm$/$1/
146 or next;
147 if (length($name) > $width) { $width = length($name) }
148 $names{$name} = 1;
149 }
150 closedir DIR;
151 }
152 my $choices = [ sort keys %names ];
153  
154 return { name => 'planepath',
155 display => 'PlanePath Class',
156 type => 'string',
157 default => $choices->[0],
158 choices => $choices,
159 width => $width + 5,
160 description => 'PlanePath module name.',
161 };
162 };
163  
164 #------------------------------------------------------------------------------
165  
166 sub oeis_anum {
167 my ($self) = @_;
168 ### PlanePathCoord oeis_anum() ...
169  
170 my $planepath_object = $self->{'planepath_object'};
171 my $coordinate_type = $self->{'coordinate_type'};
172  
173 if ($coordinate_type eq 'ExperimentalAbsX') {
174 if (! $planepath_object->x_negative) { $coordinate_type = 'X'; }
175 } elsif ($coordinate_type eq 'ExperimentalAbsY') {
176 if (! $planepath_object->y_negative) { $coordinate_type = 'Y'; }
177 }
178  
179 if ($planepath_object->isa('Math::PlanePath::Rows')) {
180 if ($coordinate_type eq 'X') {
181 return _oeis_anum_modulo($planepath_object->{'width'});
182 }
183  
184 } elsif ($planepath_object->isa('Math::PlanePath::Columns')) {
185 if ($coordinate_type eq 'Y') {
186 return _oeis_anum_modulo($planepath_object->{'height'});
187 }
188 }
189  
190 {
191 my $key = Math::NumSeq::PlanePathCoord::_planepath_oeis_anum_key($self->{'planepath_object'});
192 my $i_start = $self->i_start;
193 if ($i_start != $self->default_i_start) {
194 ### $i_start
195 ### cf n_start: $planepath_object->n_start
196 $key .= ",i_start=$i_start";
197 }
198  
199 ### planepath: ref $planepath_object
200 ### $key
201 ### whole table: $planepath_object->_NumSeq_Coord_oeis_anum
202 ### key href: $planepath_object->_NumSeq_Coord_oeis_anum->{$key}
203  
204 if (my $anum = $planepath_object->_NumSeq_Coord_oeis_anum->{$key}->{$coordinate_type}) {
205 return $anum;
206 }
207 }
208  
209 # all-zeros
210 if (defined (my $values_min = $self->values_min)) {
211 if (defined (my $values_max = $self->values_max)) {
212 if ($values_min == 0 && $values_max == 0) {
213 return 'A000004'; # all 0s
214 }
215 if ($values_min == 2 && $values_max == 2) {
216 return 'A007395'; # all 2s
217 }
218 }
219 }
220  
221 return undef;
222 }
223 sub _oeis_anum_modulo {
224 my ($modulus) = @_;
225 require Math::NumSeq::Modulo;
226 return Math::NumSeq::Modulo->new(modulus=>$modulus)->oeis_anum;
227 }
228  
229 sub _planepath_oeis_key {
230 my ($path) = @_;
231 ### PlanePathCoord _planepath_oeis_key() ...
232  
233 return join(',',
234 ref($path),
235  
236 (map {
237 # nasty hack to exclude SierpinskiCurveStair diagonal_length
238 $_->{'name'} eq 'diagonal_length'
239 ? ()
240 : do {
241 my $value = $path->{$_->{'name'}};
242 if ($_->{'type'} eq 'boolean') {
243 $value = ($value ? 1 : 0);
244 }
245 ### $_
246 ### $value
247 ### gives: "$_->{'name'}=$value"
248 (defined $value ? "$_->{'name'}=$value" : ())
249 }
250 }
251 _planepath_oeis_anum_parameter_info_list($path)));
252 }
253 sub _planepath_oeis_anum_key {
254 my ($path) = @_;
255 ### PlanePathCoord _planepath_oeis_key() ...
256 return join(',',
257 (map {
258 # nasty hack to exclude SierpinskiCurveStair diagonal_length
259 $_->{'name'} eq 'diagonal_length'
260 ? ()
261 : do {
262 my $value = $path->{$_->{'name'}};
263 if ($_->{'type'} eq 'boolean') {
264 $value = ($value ? 1 : 0);
265 }
266 ### $_
267 ### $value
268 ### gives: "$_->{'name'}=$value"
269 (defined $value ? "$_->{'name'}=$value" : ())
270 }
271 }
272 _planepath_oeis_anum_parameter_info_list($path)));
273 }
274  
275 sub _planepath_oeis_anum_parameter_info_list {
276 my ($path) = @_;
277 my @parameter_info_list = $path->_NumSeq_override_parameter_info_list;
278 unless (@parameter_info_list) {
279 @parameter_info_list = ($path->parameter_info_list,
280 $path->_NumSeq_extra_parameter_info_list);
281 }
282 return @parameter_info_list;
283 }
284  
285 #------------------------------------------------------------------------------
286  
287 sub new {
288 my $self = shift->SUPER::new(@_);
289  
290 my $planepath_object = ($self->{'planepath_object'}
291 ||= _planepath_name_to_object($self->{'planepath'}));
292  
293 ### coordinate func: '_coordinate_func_'.$self->{'coordinate_type'}
294 {
295 my $key = $self->{'coordinate_type'};
296 $key =~ s{/}{div};
297 $self->{'coordinate_func'}
298 = $planepath_object->can("_NumSeq_Coord_${key}_func")
299 || $self->can("_coordinate_func_$key")
300 || croak "Unrecognised coordinate_type: ",$self->{'coordinate_type'};
301 }
302 $self->rewind;
303  
304 ### $self
305 return $self;
306 }
307  
308 sub _planepath_name_to_object {
309 my ($name) = @_;
310 ### PlanePathCoord _planepath_name_to_object(): $name
311 ($name, my @args) = split /,+/, $name;
312 unless ($name =~ /^Math::PlanePath::/) {
313 $name = "Math::PlanePath::$name";
314 }
315 ### $name
316 require Module::Load;
317 Module::Load::load ($name);
318 return $name->new (map {/(.*?)=(.*)/} @args);
319  
320 # width => $options{'width'},
321 # height => $options{'height'},
322 }
323  
324 sub default_i_start {
325 my ($self) = @_;
326 my $planepath_object = $self->{'planepath_object'}
327 # nasty hack allow no 'planepath_object' when SUPER::new() calls rewind()
328 || return 0;
329 return $planepath_object->n_start;
330 }
331 sub i_start {
332 my ($self) = @_;
333 return (defined $self->{'i_start'}
334 ? $self->{'i_start'}
335 # nasty hack allow no 'planepath_object' when SUPER::new() calls
336 # rewind()
337 : $self->{'planepath_object'} &&
338 $self->{'planepath_object'}->n_start);
339 }
340 sub rewind {
341 my ($self) = @_;
342 $self->{'i'} = $self->i_start;
343 }
344 sub next {
345 my ($self) = @_;
346 ### NumSeq-PlanePathCoord next(): "i=$self->{'i'}"
347 my $i = $self->{'i'}++;
348 if (defined (my $value = &{$self->{'coordinate_func'}}($self, $i))) {
349 return ($i, $value);
350 } else {
351 return;
352 }
353 }
354 sub ith {
355 my ($self, $i) = @_;
356 ### NumSeq-PlanePathCoord ith(): $i
357 return &{$self->{'coordinate_func'}}($self,$i);
358 }
359  
360 use constant _INFINITY => do {
361 my $x = 999;
362 foreach (1 .. 20) {
363 $x *= $x;
364 }
365 $x;
366 };
367 sub _coordinate_func_X {
368 my ($self, $n) = @_;
369 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
370 or return undef;
371 return $x;
372 }
373 sub _coordinate_func_Y {
374 my ($self, $n) = @_;
375 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
376 or return undef;
377 return $y;
378 }
379 sub _coordinate_func_Sum {
380 my ($self, $n) = @_;
381 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
382 or return undef;
383 return $x + $y;
384 }
385 sub _coordinate_func_SumAbs {
386 my ($self, $n) = @_;
387 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
388 or return undef;
389 return abs($x) + abs($y);
390 }
391 sub _coordinate_func_Product {
392 my ($self, $n) = @_;
393 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
394 or return undef;
395 return $x * $y;
396 }
397 sub _coordinate_func_DiffXY {
398 my ($self, $n) = @_;
399 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
400 or return undef;
401 return $x - $y;
402 }
403 sub _coordinate_func_DiffXYdiv2 {
404 my ($self, $n) = @_;
405 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
406 or return undef;
407 return ($x - $y) / 2;
408 }
409 sub _coordinate_func_DiffYX {
410 my ($self, $n) = @_;
411 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
412 or return undef;
413 return $y - $x;
414 }
415 sub _coordinate_func_AbsDiff {
416 my ($self, $n) = @_;
417 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
418 or return undef;
419 return abs($x - $y);
420 }
421 sub _coordinate_func_Radius {
422 my ($self, $n) = @_;
423 return $self->{'planepath_object'}->n_to_radius($n);
424 }
425 sub _coordinate_func_RSquared {
426 my ($self, $n) = @_;
427 return $self->{'planepath_object'}->n_to_rsquared($n);
428 }
429  
430 sub _coordinate_func_TRadius {
431 my ($self, $n) = @_;
432 return _path_n_to_tradius ($self->{'planepath_object'}, $n);
433 }
434 sub _coordinate_func_TRSquared {
435 my ($self, $n) = @_;
436 return _path_n_to_trsquared ($self->{'planepath_object'}, $n);
437 }
438 sub _path_n_to_tradius {
439 my ($path, $n) = @_;
440 # TRadius = sqrt(x^2+3*y^2)
441 my $trsquared = _path_n_to_trsquared($path,$n);
442 return (defined $trsquared ? sqrt($trsquared) : undef);
443 }
444 sub _path_n_to_trsquared {
445 my ($path, $n) = @_;
446 # TRSquared = x^2+3*y^2
447 my ($x, $y) = $path->n_to_xy($n)
448 or return undef;
449 return $x*$x + $y*$y*3;
450 }
451  
452 sub _coordinate_func_Depth {
453 my ($self, $n) = @_;
454 return $self->{'planepath_object'}->tree_n_to_depth($n);
455 }
456 sub _coordinate_func_NumChildren {
457 my ($self, $n) = @_;
458 return $self->{'planepath_object'}->tree_n_num_children($n);
459 }
460 sub _coordinate_func_IsLeaf {
461 my ($self, $n) = @_;
462 ### _coordinate_func_IsLeaf(): $n
463 my $num_children = $self->{'planepath_object'}->tree_n_num_children($n);
464 # undef, 0 or 1
465 return (defined $num_children ? ($num_children == 0 ? 1 : 0) : undef);
466 }
467 sub _coordinate_func_IsNonLeaf {
468 my ($self, $n) = @_;
469 ### _coordinate_func_IsLeaf(): $n
470 my $num_children = $self->{'planepath_object'}->tree_n_num_children($n);
471 # undef, 0 or 1
472 return (defined $num_children ? ($num_children == 0 ? 0 : 1) : undef);
473 }
474  
475 use Math::PlanePath::GcdRationals;
476 use POSIX 'fmod';
477 sub _coordinate_func_GCD {
478 my ($self, $n) = @_;
479  
480 # FIXME: Maybe re-run with bigrat if X or Y not integers.
481 if ($self->{'planepath_object'}->isa('Math::PlanePath::KochSnowflakes')
482 && $n <= 3) {
483 return 1/3;
484 }
485  
486 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
487 or return undef;
488  
489 $x = abs($x);
490 $y = abs($y);
491 if (is_infinite($x)) { return $x; }
492 if (is_infinite($y)) { return $y; }
493  
494 if ($x == int($x) && $y == int($y)) {
495 return Math::PlanePath::GcdRationals::_gcd($x,$y);
496 }
497  
498 if ($x == 0) {
499 return $y;
500 }
501 if ($y > $x) {
502 $y = fmod($y,$x);
503 }
504 for (;;) {
505 ### assert: $x >= 1
506 if ($y == 0) {
507 return $x; # gcd(x,0)=x
508 }
509 if ($y < 0.00001) {
510 return 0;
511 }
512 ($x,$y) = ($y, fmod($x,$y));
513 }
514 }
515  
516 sub _coordinate_func_RootN {
517 my ($self, $n) = @_;
518 return $self->{'planepath_object'}->tree_n_root($n);
519 }
520  
521 # math-image --values=PlanePathCoord,coordinate_type=SubHeight,planepath=ThisPath --path=SierpinskiTriangle --scale=10
522 sub _coordinate_func_SubHeight {
523 my ($self, $n) = @_;
524 ### _coordinate_func_SubHeight(): $n
525 my $height = $self->{'planepath_object'}->tree_n_to_subheight($n);
526 return (defined $height ? $height : _INFINITY);
527 }
528  
529 # rounding towards zero
530 sub _coordinate_func_IntXY {
531 my ($self, $n) = @_;
532 ### _coordinate_func_IntXY(): $n
533 if (my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)) {
534 return _xy_to_IntXY($x,$y);
535 }
536 return undef;
537 }
538 sub _xy_to_IntXY {
539 my ($x, $y) = @_;
540 ### xy: "x=$x y=$y"
541 if ($y < 0) {
542 $y = -$y;
543 $x = -$x;
544 }
545 if ($y == 0) {
546 return _INFINITY; # X/0 = infinity
547 }
548 if ($y == int($y)) {
549 ### done in integers, no floating point ...
550 my $r = $x % $y;
551 ### $r
552 if ($x < 0 && $r > 0) {
553 $r -= $y;
554 }
555 ### assert: (($x>=0)&&($r>=0)) || (($x<=0)&&($r<=0))
556 $x -= $r;
557 ### assert: ($x % $y) == 0
558 return int($x / $y);
559 }
560 return int($x/$y);
561 }
562 sub _coordinate_func_FracXY {
563 my ($self, $n) = @_;
564 ### _coordinate_func_FracXY(): $n
565  
566 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
567 or return undef;
568 ### xy: "x=$x y=$y"
569 if ($y < 0) {
570 $y = -$y;
571 $x = -$x;
572 }
573 if ($y == 0) {
574 return 0; # X/0 = infinity + frac=0
575 }
576 if ($y == int($y)) {
577 ### done in integers ...
578 my $r = $x % $y;
579 if ($x < 0 && $r > 0) {
580 $r -= $y;
581 }
582 # EXPERIMENTAL:
583 # bigint/bigint as bigrat, otherwise promote to bigfloat
584 if (ref $r && $r->isa('Math::BigInt')) {
585 if (ref $y && $y->isa('Math::BigInt')) {
586 require Math::BigRat;
587 return Math::BigRat->new($r) / $y;
588 }
589 $r = $r->as_float;
590 } else {
591 if (ref $y && $y->isa('Math::BigInt')) { $y = $y->as_float; }
592 }
593 return $r/$y;
594 } else {
595 my $f = $x/$y;
596 return $f - int($x/$y);
597 }
598 }
599  
600 # Math::BigInt in perl 5.6.0 has and/or/xor
601 sub _op_and { $_[0] & $_[1] }
602 sub _op_or { $_[0] | $_[1] }
603 sub _op_xor { $_[0] ^ $_[1] }
604 sub _coordinate_func_BitAnd {
605 my ($self, $n) = @_;
606 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
607 or return undef;
608 return _bitwise_by_parts($x,$y, \&_op_and);
609 }
610 sub _coordinate_func_BitOr {
611 my ($self, $n) = @_;
612 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
613 or return undef;
614 return _bitwise_by_parts($x,$y, \&_op_or);
615 }
616 sub _coordinate_func_BitXor {
617 my ($self, $n) = @_;
618 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
619 or return undef;
620 return _bitwise_by_parts($x,$y, \&_op_xor);
621 }
622 use constant 1.02 _UV_MAX_PLUS_1 => do {
623 my $pow = 1.0;
624 my $uv = ~0;
625 while ($uv) {
626 $uv >>= 1;
627 $pow *= 2.0;
628 }
629 $pow
630 };
631 sub _bitwise_by_parts {
632 my ($x, $y, $opfunc) = @_;
633 ### _bitwise_by_parts(): $x, $y
634  
635 if (is_infinite($x)) { return $x; }
636 if (is_infinite($y)) { return $y; }
637  
638 # Positive integers in UV range plain operator.
639 # Any ref is Math::BigInt or whatever left to its operator overloads.
640 if (ref $x || ref $y
641 || ($x == int($x) && $y == int($y)
642 && $x >= 0 && $y >= 0
643 && $x < _UV_MAX_PLUS_1 && $x < _UV_MAX_PLUS_1)) {
644 return &$opfunc($x,$y);
645 }
646  
647 $x *= 65536.0;
648 $x *= 65536.0;
649 $x = int($x);
650 $y *= 65536.0;
651 $y *= 65536.0;
652 $y = int($y);
653  
654 my @ret; # low to high
655 while ($x >= 1 || $x < -1 || $y >= 1 || $y < -1) {
656 ### $x
657 ### $y
658  
659 my $xpart = $x % 65536.0;
660 if ($xpart < 0) { $xpart += 65536.0; }
661 $x = ($x - $xpart) / 65536.0;
662  
663 my $ypart = $y % 65536.0;
664 if ($ypart < 0) { $ypart += 65536.0; }
665 $y = ($y - $ypart) / 65536.0;
666  
667 ### xpart: $xpart . sprintf(' %04X',$xpart)
668 ### ypart: $ypart . sprintf(' %04X',$ypart)
669 push @ret, &$opfunc($xpart,$ypart);
670 }
671 my $ret = (&$opfunc($x<0,$y<0) ? -1 : 0);
672 ### @ret
673 ### $x
674 ### $y
675 ### $ret
676 foreach my $rpart (reverse @ret) { # high to low
677 $ret = 65536.0*$ret + $rpart;
678 }
679 ### ret joined: $ret
680 $ret /= 65536.0;
681 $ret /= 65536.0;
682 ### ret final: $ret
683 return $ret;
684 }
685 use constant 1.02 _IV_MIN => - (~0 >> 1) - 1;
686 sub _sign_extend {
687 my ($n) = @_;
688 return ($n - (- _IV_MIN)) + _IV_MIN;
689 }
690 use constant 1.02 _UV_NUMBITS => do {
691 my $uv = ~0;
692 my $count = 0;
693 while ($uv) {
694 $uv >>= 1;
695 $count++;
696 last if $count >= 1024;
697 }
698 $count
699 };
700 sub _frac_to_int {
701 my ($x) = @_;
702 $x -= int($x);
703 return int(abs($x)*(2**_UV_NUMBITS()));
704 }
705 sub _int_to_frac {
706 my ($x) = @_;
707 return $x / (2**_UV_NUMBITS());
708 }
709  
710 sub _coordinate_func_Min {
711 my ($self, $n) = @_;
712 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
713 or return undef;
714 return min($x,$y);
715 }
716 sub _coordinate_func_Max {
717 my ($self, $n) = @_;
718 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
719 or return undef;
720 return max($x,$y);
721 }
722  
723 sub _coordinate_func_MinAbs {
724 my ($self, $n) = @_;
725 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
726 or return undef;
727 return min(abs($x),abs($y));
728 }
729 sub _coordinate_func_MaxAbs {
730 my ($self, $n) = @_;
731 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
732 or return undef;
733 return max(abs($x),abs($y));
734 }
735  
736 sub _coordinate_func_NumSiblings {
737 my ($self, $n) = @_;
738 return path_tree_n_num_siblings($self->{'planepath_object'}, $n);
739 }
740 # ENHANCE-ME: if $n==NaN would like to return NaN, maybe
741 sub path_tree_n_num_siblings {
742 my ($path, $n) = @_;
743 $n = $path->tree_n_parent($n);
744 return (defined $n
745 ? $path->tree_n_num_children($n) - 1 # not including self
746 : 0); # any tree root considered to have no siblings
747 }
748  
749 #------------------------------------------------------------------------------
750 # UNTESTED/EXPERIMENTAL
751  
752 # n_start = i_start is X(n)
753 # n_start + 1 is Y(n) etc
754 #
755 # floor((n - nstart)/2) + nstart
756 # = floor((n - nstart)/2 + nstart)
757 # = floor((n + nstart)/2)
758 # xy = n - nstart mod 2
759 # = n - nstart + 2*nstart mod 2
760 # = n + nstart mod 2
761 #
762 # GP-Test my(nstart=0,n=0); floor((n+nstart)/2)==0 && (n+nstart)%2==0
763 # GP-Test my(nstart=0,n=1); floor((n+nstart)/2)==0 && (n+nstart)%2==1
764 #
765 # GP-Test my(nstart=3,n=3); floor((n+nstart)/2)==3 && (n+nstart)%2==0
766 # GP-Test my(nstart=3,n=4); floor((n+nstart)/2)==3 && (n+nstart)%2==1
767 # GP-Test my(nstart=3,n=5); floor((n+nstart)/2)==4 && (n+nstart)%2==0
768 # GP-Test my(nstart=3,n=6); floor((n+nstart)/2)==4 && (n+nstart)%2==1
769 #
770 sub _coordinate_func_ExperimentalPairsXY {
771 my ($self, $n) = @_;
772 my $path = $self->{'planepath_object'};
773 $n += $path->n_start;
774 my $xy = _divrem_mutate($n,2);
775 my ($x, $y) = $path->n_to_xy($n) or return undef;
776 return ($xy ? $y : $x);
777 }
778 sub _coordinate_func_ExperimentalPairsYX {
779 my ($self, $n) = @_;
780 my $path = $self->{'planepath_object'};
781 $n += $path->n_start;
782 my $xy = _divrem_mutate($n,2);
783 my ($x, $y) = $path->n_to_xy($n) or return undef;
784 return ($xy ? $x : $y);
785 }
786  
787 sub _coordinate_func_ExperimentalAbsX {
788 my ($self, $n) = @_;
789 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
790 or return undef;
791 return abs($x);
792 }
793 sub _coordinate_func_ExperimentalAbsY {
794 my ($self, $n) = @_;
795 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
796 or return undef;
797 return abs($y);
798 }
799  
800 # DiffXYsquared = X^2 - Y^2
801 sub _coordinate_func_ExperimentalDiffXYsquared {
802 my ($self, $n) = @_;
803 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
804 or return undef;
805 return $x*$x - $y*$y;
806 }
807 # DiffYXsquared = Y^2 - X^2
808 sub _coordinate_func_ExperimentalDiffYXsquares {
809 my ($self, $n) = @_;
810 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
811 or return undef;
812 return $y*$y - $x*$x;
813 }
814  
815 sub _coordinate_func_ExperimentalLeafDistance {
816 my ($self, $n) = @_;
817 if (my $coderef = $self->{'planepath_object'}
818 ->can('_EXPERIMENTAL__tree_n_to_leafdist')) {
819 return $self->{'planepath_object'}->$coderef($n);
820 }
821 return path_tree_n_to_leafdist_by_search($self->{'planepath_object'},$n);
822 }
823 sub path_tree_n_to_leafdist_by_search {
824 my ($path, $n) = @_;
825 ### path_tree_n_to_leafdist(): $n
826  
827 if ($n < $path->n_start || ! $path->tree_any_leaf($path)) {
828 return undef;
829 }
830 if (is_infinite($n)) {
831 return $n;
832 }
833 my @pending = ($n);
834 for (my $distance = 0; ; $distance++) {
835 ### $distance
836 ### @pending
837  
838 @pending = map {
839 my @children = $path->tree_n_children($_)
840 or return $distance;
841 ### @children
842 @children
843 } @pending;
844 }
845 }
846  
847 sub _coordinate_func_ExperimentalNumOverlap {
848 my ($self, $n) = @_;
849 my ($x,$y) = $self->{'planepath_object'}->n_to_xy($n)
850 or return undef;
851 return _path_xy_num_overlaps($self->{'planepath_object'}, $x,$y);
852 }
853 # $path->xy_num_overlaps($x,$y)
854 # Return the number of ...
855 sub _path_xy_num_overlaps {
856 my ($path, $x,$y) = @_;
857 my @n_list = $path->xy_to_n_list($x,$y);
858 return scalar(@n_list) - 1;
859 }
860  
861 # math-image --values=PlanePathCoord,coordinate_type=ExperimentalNeighbours4,planepath=DragonCurve --path=DragonCurve --scale=10
862 my $neighbours3 = [ 2,0, -1,1, -1,-1 ];
863 sub _coordinate_func_ExperimentalNeighbours3 {
864 my ($self, $n) = @_;
865 return _path_n_neighbours_count ($self->{'planepath_object'}, $n, $neighbours3);
866 }
867 my $neighbours4 = [ 1,0, 0,1, -1,0, 0,-1 ];
868 sub _coordinate_func_ExperimentalNeighbours4 {
869 my ($self, $n) = @_;
870 return _path_n_neighbours_count ($self->{'planepath_object'}, $n, $neighbours4);
871 }
872 my $neighbours4d = [ 1,1, -1,1, -1,-1, 1,-1 ];
873 sub _coordinate_func_ExperimentalNeighbours4d {
874 my ($self, $n) = @_;
875 return _path_n_neighbours_count ($self->{'planepath_object'}, $n, $neighbours4d);
876 }
877 my $neighbours8 = [ 1,0, 0,1, -1,0, 0,-1,
878 1,1, -1,1, 1,-1, -1,-1 ];
879 sub _coordinate_func_ExperimentalNeighbours8 {
880 my ($self, $n) = @_;
881 return _path_n_neighbours_count ($self->{'planepath_object'}, $n, $neighbours8);
882 }
883 # ExperimentalNeighbours6v triangular vertical
884 my $neighbours6 = [ 2,0, 1,1, -1,1,
885 -2,0, -1,-1, 1,-1 ];
886 sub _coordinate_func_ExperimentalNeighbours6 {
887 my ($self, $n) = @_;
888 return _path_n_neighbours_count ($self->{'planepath_object'}, $n, $neighbours6);
889 }
890 sub _path_n_neighbours_count {
891 my ($path, $n, $neighbours_aref) = @_;
892 # my $aref = $surround[$num_points]
893 # || croak "_path_n_neighbours_count() unrecognised number of points ",$num_points;
894 my ($x, $y) = $path->n_to_xy($n) or return undef;
895 my $count = 0;
896 for (my $i = 0; $i < @$neighbours_aref; $i+=2) {
897 $count += $path->xy_is_visited($x + $neighbours_aref->[$i],
898 $y + $neighbours_aref->[$i+1]);
899 }
900 return $count;
901 }
902  
903 sub _coordinate_func_ExperimentalGcdDivisions {
904 my ($self, $n) = @_;
905 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
906 or return undef;
907 $x = abs(int($x));
908 $y = abs(int($y));
909 if ($x == 0) {
910 return $y;
911 }
912 if (is_infinite($x)) { return $x; }
913 if (is_infinite($y)) { return $y; }
914  
915 if ($x < $y) { ($x,$y) = ($y,$x); }
916 my $count = 0;
917 for (;;) {
918 if ($y <= 1) {
919 return $count;
920 }
921 ($x,$y) = ($y, $x % $y);
922 $count++;
923 }
924 }
925  
926 # 1 for first visit, 2, 3, ... for subsequent
927 sub _coordinate_func_ExperimentalVisitNum {
928 my ($self, $n) = @_;
929 my $path = $self->{'planepath_object'};
930 if (my ($x,$y) = $path->n_to_xy($n)) {
931 my @n_list = grep {$_<=$n} $path->n_to_n_list($n);
932 return scalar(@n_list);
933 }
934 return undef;
935 }
936  
937 # number of visits ever made to location of $n, including $n itself so >=1
938 sub _coordinate_func_ExperimentalVisitCount {
939 my ($self, $n) = @_;
940 return path_n_num_visits($self->{'planepath_object'}, $n);
941 }
942 # $path->n_to_visit_count($n)
943 # Return the number of visits to the curve at point C<$n>, including C<$n>
944 # itself. If there is no C<$n> in the path then return C<undef>.
945 sub path_n_num_visits {
946 my ($path, $n) = @_;
947 my ($x,$y) = $path->n_to_xy($n) or return undef;
948 my @n_list = $path->xy_to_n_list($x,$y);
949 return scalar(@n_list);
950 }
951  
952 # number of revisits ever made to location of $n, so 0 if never
953 sub _coordinate_func_ExperimentalRevisit {
954 my ($self, $n) = @_;
955 return path_n_to_revisit($self->{'planepath_object'}, $n);
956 }
957 # $path->path_n_to_revisit($n)
958 # Return the number of other N which visit point C<$n>.
959 # If point C<$n> is visited only by that C<$n> then the return is 0.
960 sub path_n_to_revisit {
961 my ($path, $n) = @_;
962 if (my ($x, $y) = $path->n_to_xy($n)) {
963 my $ret = 0;
964 foreach my $n_list ($path->n_to_n_list($n)) {
965 if ($n == $n_list) { return $ret; }
966 $ret++;
967 }
968 }
969 return undef;
970 }
971  
972 # A215200 Triangle read by rows, Kronecker symbol (n-k|k) for n>=1, 1<=k<=n.
973  
974 # cf A005825 ExperimentalNumerators in a worst case of a Jacobi symbol algorithm.
975 # A005826 Worst case of a Jacobi symbol algorithm.
976 # A005827 Worst case of a Jacobi symbol algorithm.
977 # A157415 Triangle t(n,m) = Jacobi(prime(n) / prime(m)) + Jacobi( prime(n)/ prime(n-m+2)), 2<=m<=n.
978  
979 sub _coordinate_func_ExperimentalKroneckerSymbol {
980 my ($self, $n) = @_;
981 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
982 or return undef;
983 return _kronecker_symbol($x,$y);
984 }
985 sub _kronecker_symbol {
986 my ($x, $y) = @_;
987 ### _kronecker_symbol(): "x=$x y=$y"
988 $x = int($x);
989 $y = int($y);
990 if (is_infinite($x)) { return $x; }
991 if (is_infinite($y)) { return $y; }
992  
993 if ($x == 0) {
994 # (0/b)=1 if b=+/-1, (0/b)=0 otherwise
995 return ($y == 1 || $y == -1 ? 1 : 0);
996 }
997  
998 if ($y == 0) {
999 # (a/0)=1 if a=+/-1, (a/0)=0 otherwise
1000 return ($x == 1 || $x == -1 ? 1 : 0);
1001 }
1002  
1003 my $ret = 0;
1004  
1005 # (a/-1)=1 if a>=0, (a/-1)=-1 if a<0
1006 if ($y < 0) {
1007 $y = abs($y);
1008 if ($x < 0) {
1009 ### (a/-1) = -1 when a<0 ...
1010 $ret = 2;
1011 }
1012 }
1013  
1014 if ($y % 2 == 0) {
1015 if ($x % 2 == 0) {
1016 return 0; # (even/even)=0
1017 }
1018 # (a/2) = (2/a)
1019 while ($y && $y % 4 == 0) { # (a/2)*(a/2)=1
1020 ### initial y multiple of 4 ...
1021 $y /= 4;
1022 }
1023 # (b/2)=(2/b) for b odd
1024 # (2/b) = (-1)^((b^2-1)/8) which is 1 if b==1,7mod8 or -1 if b==3,5mod8
1025 if ($y % 2 == 0) {
1026 ### initial y even, xor: (($x+1)/2) & 2
1027 ### assert: $x % 2 != 0
1028 $ret ^= ($x+1)/2;
1029 $y /= 2;
1030 }
1031 }
1032  
1033 for (;;) {
1034 ### at: "x=$x y=$y"
1035 ### assert: $y%2 != 0
1036  
1037 if ($y <= 1) {
1038 ### y=1 stop (a/1)=1 ...
1039 last;
1040 }
1041 ### assert: $y > 1
1042  
1043 $x %= $y;
1044 ### remainder to: "x=$x"
1045 if ($x <= 1) {
1046 ### stop, (1/b) = 1 ...
1047 last;
1048 }
1049  
1050 # (2/b) with b odd is (-1)^((b^2-1)/8)
1051 # is (2/b)=1 if b==1,7mod8 or (2/b)=-1 if b==3,5mod8
1052 while ($x && $x % 4 == 0) {
1053 ### x multiple of 4 ...
1054 $x /= 4;
1055 }
1056 if ($x % 2 == 0) {
1057 # (2/b) = (-1)^((b^2-1)/8) which is 1 if b==1,7mod8 or -1 if b==3,5mod8
1058 ### x even, xor: (($y+1)/2) & 2
1059 $ret ^= ($y+1)/2;
1060 $x /= 2;
1061 }
1062  
1063 ### reciprocity, xor: ($x % 4) & ($y % 4) & 2
1064 $ret ^= ($x % 4) & ($y % 4);
1065 ($x,$y) = ($y,$x);
1066 }
1067  
1068 if ($x == 0) {
1069 ### (0/b)=0 ...
1070 return 0;
1071 }
1072  
1073 ### final ret: ($ret & 2)
1074 return ($ret & 2 ? -1 : 1);
1075 }
1076  
1077 sub _coordinate_func_ExperimentalMaxAbsTri {
1078 my ($self, $n) = @_;
1079 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
1080 or return undef;
1081 return max(abs($x+$y),abs($x-$y),abs(2*$y));
1082 }
1083 sub _coordinate_func_ExperimentalMinAbsTri {
1084 my ($self, $n) = @_;
1085 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
1086 or return undef;
1087 return min(abs($x+$y),abs($x-$y),abs(2*$y));
1088 }
1089  
1090 sub _coordinate_func_ExperimentalRowOffset {
1091 my ($self, $n) = @_;
1092 return path_n_to_row_offset ($self->{'planepath_object'}, $n);
1093 }
1094 sub path_n_to_row_offset {
1095 my ($path, $n) = @_;
1096 my $depth = $path->tree_n_to_depth($n);
1097 if (! defined $depth) { return undef; }
1098  
1099 my ($n_row, $n_end) = $path->tree_depth_to_n_range($depth);
1100 if ($n_end - $n_row + 1 == $path->tree_depth_to_width($depth)) {
1101 return $n - $n_row;
1102 }
1103 my $ret = 0;
1104 foreach my $i ($n_row .. $n - 1) {
1105 if ($path->tree_n_to_depth($i) == $depth) {
1106 $ret++;
1107 }
1108 }
1109 return $ret;
1110 }
1111  
1112 use Math::PlanePath::GcdRationals;
1113 sub _coordinate_func_ExperimentalMulDist {
1114 my ($self, $n) = @_;
1115 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
1116 or return undef;
1117 $x = int(abs($x));
1118 $y = int(abs($y));
1119 if (my $g = Math::PlanePath::GcdRationals::_gcd($x,$y)) {
1120 $x /= $g;
1121 $y /= $g;
1122 }
1123 unless ($x < (2.0**32) && $y < (2.0**32)) {
1124 return undef;
1125 }
1126 require Math::Factor::XS;
1127 return Math::Factor::XS::count_prime_factors($x) + Math::Factor::XS::count_prime_factors($y);
1128 }
1129  
1130 # Count of differing bit positions.
1131 # Infinite if twos-comp negative.
1132 # 1111 -1 1
1133 # 1101 -2 10
1134 # 1110 -3 11
1135 #
1136 use Math::PlanePath::Base::Digits
1137 'bit_split_lowtohigh';
1138 sub _coordinate_func_ExperimentalHammingDist {
1139 my ($self, $n) = @_;
1140 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
1141 or return undef;
1142 if (is_infinite($x)) { return $x; }
1143 if (is_infinite($y)) { return $y; }
1144  
1145 # twos complement
1146 if ($x<0) {
1147 if ($y >= 0) { return _INFINITY; }
1148 $x = -$x;
1149 $y = -$y;
1150 } else {
1151 if ($y < 0) { return _INFINITY; }
1152 }
1153  
1154 # abs values
1155 # $x = abs(int($x));
1156 # $y = abs(int($y));
1157  
1158 my @xbits = bit_split_lowtohigh($x);
1159 my @ybits = bit_split_lowtohigh($y);
1160 my $ret = 0;
1161 while (@xbits || @ybits) {
1162 $ret += (shift @xbits ? 1 : 0) ^ (shift @ybits ? 1 : 0);
1163 }
1164 return $ret;
1165 }
1166  
1167 sub _coordinate_func_ExperimentalParity {
1168 my ($self, $n) = @_;
1169 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
1170 or return undef;
1171 $x += $y;
1172 $y = _floor($x);
1173 $y -= ($y % 2);
1174 return $x - $y;
1175 }
1176 sub _floor {
1177 my ($x) = @_;
1178 my $int = int($x);
1179 return ($x < $int ? $int-1 : $int);
1180 }
1181  
1182 sub _coordinate_func_ExperimentalNumerator {
1183 my ($self, $n) = @_;
1184 ### _coordinate_func_ExperimentalNumerator(): $n
1185 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
1186 or return undef;
1187 ### $x
1188 ### $y
1189 if ($y < 0) { $x = -$x; }
1190 if (is_infinite($x)) { return $x; }
1191 if (is_infinite($y)) { return $y; }
1192 my $g = Math::PlanePath::GcdRationals::_gcd(abs($x),abs($y));
1193 return ($g == 0
1194 ? 0 :
1195 $x/$g);
1196 }
1197 sub _coordinate_func_ExperimentalDenominator {
1198 my ($self, $n) = @_;
1199 my ($x, $y) = $self->{'planepath_object'}->n_to_xy($n)
1200 or return undef;
1201 if ($y < 0) {
1202 $x = -$x;
1203 $y = -$y;
1204 }
1205 if ($y == 0) {
1206 # +-any/0 reckoned as 1/0
1207 return $y;
1208 }
1209 if (is_infinite($x)) {
1210 return $x; # +-inf/nonzero = +-inf
1211 }
1212  
1213 if ($x == 0 # 0/nonzero reckoned as 0/1
1214 || is_infinite($y)) { # +-finite/+inf reckoned as 0/1
1215 return 1;
1216 }
1217  
1218 my $g = Math::PlanePath::GcdRationals::_gcd(abs($x),$y);
1219 if ($g == 0) {
1220 # X/0 reckoned as 1/0
1221 return 0;
1222 }
1223 return abs($y)/$g;
1224 }
1225  
1226  
1227 #------------------------------------------------------------------------------
1228  
1229 sub characteristic_integer {
1230 my ($self) = @_;
1231 ### PlanePathCoord characteristic_integer() ...
1232  
1233 my $planepath_object = $self->{'planepath_object'};
1234 if (my $func = $planepath_object->can("_NumSeq_Coord_$self->{'coordinate_type'}_integer")) {
1235 return $planepath_object->$func();
1236 }
1237 if (defined (my $values_min = $self->values_min)
1238 && defined (my $values_max = $self->values_max)) {
1239 if ($values_min == int($values_min)
1240 && $values_max == int($values_max)
1241 && $values_min == $values_max) {
1242 return 1;
1243 }
1244 }
1245 return undef;
1246 }
1247  
1248 sub characteristic_smaller {
1249 my ($self) = @_;
1250 ### characteristic_smaller() ...
1251 my $planepath_object = $self->{'planepath_object'};
1252 my $func;
1253 return
1254 (($func = ($planepath_object->can("_NumSeq_Coord_$self->{'coordinate_type'}_smaller")))
1255 ? $planepath_object->$func()
1256 : 1); # default is smaller
1257 }
1258  
1259 {
1260 my %coordinate_to_d_minimum_method
1261 = (X => 'dx_minimum',
1262 Y => 'dy_minimum',
1263 Sum => 'dsumxy_minimum',
1264 DiffXY => 'ddiffxy_minimum',
1265 DiffYX => \&path_ddiffyx_minimum,
1266 );
1267 sub path_ddiffyx_minimum {
1268 my ($path) = @_;
1269 my $ddiffxy_maximum = $path->ddiffxy_maximum();
1270 return (defined $ddiffxy_maximum ? - $ddiffxy_maximum : undef);
1271 }
1272  
1273 my %coordinate_type_monotonic_use
1274 = (RSquared => 'Radius',
1275 TRSquared => 'TRadius',
1276 );
1277  
1278 sub characteristic_increasing {
1279 my ($self) = @_;
1280 ### PlanePathCoord characteristic_increasing() ...
1281 my $planepath_object = $self->{'planepath_object'};
1282 my $coordinate_type = $self->{'coordinate_type'};
1283  
1284 # eg. if dx_minimum() > 0 then X is increasing
1285 if (my $method = $coordinate_to_d_minimum_method{$coordinate_type}) {
1286 my $d_minimum = $planepath_object->$method();
1287 ### delta method: $method
1288 ### $d_minimum
1289 return (defined $d_minimum && $d_minimum > 0);
1290 }
1291  
1292 $coordinate_type = ($coordinate_type_monotonic_use{$coordinate_type}
1293 || $coordinate_type);
1294 if (my $coderef = $planepath_object->can("_NumSeq_Coord_${coordinate_type}_increasing")) {
1295 ### dispatch to: $coderef
1296 return $planepath_object->$coderef();
1297 }
1298 ### unknown ...
1299 return undef;
1300 }
1301  
1302 sub characteristic_non_decreasing {
1303 my ($self) = @_;
1304 ### PlanePathCoord characteristic_non_decreasing() ...
1305 my $planepath_object = $self->{'planepath_object'};
1306 my $coordinate_type = $self->{'coordinate_type'};
1307  
1308 # eg. if dx_minimum() >= 0 then X is non-decreasing
1309 if (my $method = $coordinate_to_d_minimum_method{$coordinate_type}) {
1310 my $d_minimum = $planepath_object->$method();
1311 ### delta method: $method
1312 ### $d_minimum
1313 return (defined $d_minimum && $d_minimum >= 0);
1314 }
1315  
1316 if (defined (my $values_min = $self->values_min)) {
1317 if (defined (my $values_max = $self->values_max)) {
1318 if ($values_min == $values_max) {
1319 ### constant seq is non-decreasing ...
1320 return 1;
1321 }
1322 }
1323 }
1324 $coordinate_type = ($coordinate_type_monotonic_use{$coordinate_type}
1325 || $coordinate_type);
1326 if (my $coderef = $planepath_object->can("_NumSeq_Coord_${coordinate_type}_non_decreasing")) {
1327 ### dispatch to: $coderef
1328 return $planepath_object->$coderef();
1329 }
1330 ### if increasing then non_decreasing too ...
1331 return $self->characteristic_increasing;
1332 }
1333 }
1334  
1335 {
1336 my %values_min = (X => 'x_minimum',
1337 Y => 'y_minimum',
1338 Sum => 'sumxy_minimum',
1339 SumAbs => 'sumabsxy_minimum',
1340 DiffXY => 'diffxy_minimum',
1341 AbsDiff => 'absdiffxy_minimum',
1342 RSquared => 'rsquared_minimum',
1343 GCD => 'gcdxy_minimum',
1344 NumChildren => 'tree_num_children_minimum',
1345 );
1346  
1347 sub values_min {
1348 my ($self) = @_;
1349 ### PlanePathCoord values_min() ...
1350 my $planepath_object = $self->{'planepath_object'};
1351 if (my $method = ($values_min{$self->{'coordinate_type'}}
1352 || $planepath_object->can("_NumSeq_Coord_$self->{'coordinate_type'}_min"))) {
1353 ### $method
1354 return $planepath_object->$method();
1355 }
1356 return undef;
1357 }
1358 }
1359 {
1360 my %values_max = (X => 'x_maximum',
1361 Y => 'y_maximum',
1362 Sum => 'sumxy_maximum',
1363 SumAbs => 'sumabsxy_maximum',
1364 DiffXY => 'diffxy_maximum',
1365 AbsDiff => 'absdiffxy_maximum',
1366 GCD => 'gcdxy_maximum',
1367 NumChildren => 'tree_num_children_maximum',
1368 );
1369 sub values_max {
1370 my ($self) = @_;
1371 my $planepath_object = $self->{'planepath_object'};
1372 if (my $method = ($values_max{$self->{'coordinate_type'}}
1373 || $planepath_object->can("_NumSeq_Coord_$self->{'coordinate_type'}_max"))) {
1374 return $planepath_object->$method();
1375 }
1376 return undef;
1377 }
1378 }
1379  
1380 { package Math::PlanePath;
1381 use constant _NumSeq_override_parameter_info_list => ();
1382 use constant _NumSeq_extra_parameter_info_list => ();
1383 use constant _NumSeq_Coord_oeis_anum => {};
1384  
1385 #-------------
1386 sub _NumSeq_Coord_neighbours_min {
1387 my ($self, $neighbours_aref) = @_;
1388 my %hash;
1389 for (my $i = 0; $i < $#$neighbours_aref; $i+=2) {
1390 $hash{"$neighbours_aref->[$i],$neighbours_aref->[$i+1]"} = 1;
1391 }
1392 my @dxdy_list = $self->_UNDOCUMENTED__dxdy_list;
1393 for (my $i = 0; $i < $#dxdy_list; $i += 2) {
1394 if ($hash{"$dxdy_list[$i],dxdy_list[$i+1]"}) {
1395 return 1;
1396 }
1397 }
1398 return 0;
1399 }
1400 use constant _NumSeq_Coord_filling_type => 'plane';
1401 {
1402 my %_NumSeq_Coord_ExperimentalNeighbours3_min
1403 = (plane => 3,
1404 triangular => 3,
1405 quadrant => 1,
1406 half => 2,
1407 );
1408 sub _NumSeq_Coord_ExperimentalNeighbours3_min {
1409 my ($self) = @_;
1410 if (my $filling_type = $self->_NumSeq_Coord_filling_type) {
1411 return $_NumSeq_Coord_ExperimentalNeighbours3_min{$filling_type};
1412 }
1413 _NumSeq_Coord_neighbours_min($self,$neighbours3);
1414 }
1415 }
1416 {
1417 my %_NumSeq_Coord_ExperimentalNeighbours4_min
1418 = (plane => 4,
1419 triangular => 0,
1420 quadrant => 2,
1421 half => 3,
1422 );
1423 sub _NumSeq_Coord_ExperimentalNeighbours4_min {
1424 my ($self) = @_;
1425 if (my $filling_type = $self->_NumSeq_Coord_filling_type) {
1426 return $_NumSeq_Coord_ExperimentalNeighbours4_min{$filling_type};
1427 }
1428 _NumSeq_Coord_neighbours_min($self,$neighbours3);
1429 }
1430 }
1431 {
1432 my %_NumSeq_Coord_ExperimentalNeighbours4d_min
1433 = (plane => 4,
1434 triangular => 4,
1435 quadrant => 1,
1436 half => 2,
1437 );
1438 sub _NumSeq_Coord_ExperimentalNeighbours4d_min {
1439 my ($self) = @_;
1440 if (my $filling_type = $self->_NumSeq_Coord_filling_type) {
1441 return $_NumSeq_Coord_ExperimentalNeighbours4d_min{$filling_type};
1442 }
1443 _NumSeq_Coord_neighbours_min($self,$neighbours3);
1444 }
1445 }
1446 {
1447 my %_NumSeq_Coord_ExperimentalNeighbours6_min
1448 = (plane => 6,
1449 triangular => 6,
1450 quadrant => 1,
1451 half => 4,
1452 );
1453 sub _NumSeq_Coord_ExperimentalNeighbours6_min {
1454 my ($self) = @_;
1455 if (my $filling_type = $self->_NumSeq_Coord_filling_type) {
1456 return $_NumSeq_Coord_ExperimentalNeighbours6_min{$filling_type};
1457 }
1458 _NumSeq_Coord_neighbours_min($self,$neighbours3);
1459 }
1460 }
1461 {
1462 my %_NumSeq_Coord_ExperimentalNeighbours8_min
1463 = (plane => 8,
1464 triangular => 4,
1465 quadrant => 3,
1466 half => 5,
1467 );
1468 sub _NumSeq_Coord_ExperimentalNeighbours8_min {
1469 my ($self) = @_;
1470 if (my $filling_type = $self->_NumSeq_Coord_filling_type) {
1471 return $_NumSeq_Coord_ExperimentalNeighbours8_min{$filling_type};
1472 }
1473 _NumSeq_Coord_neighbours_min($self,$neighbours3);
1474 }
1475 }
1476  
1477 use constant _NumSeq_Coord_ExperimentalNeighbours3_max => 3;
1478 use constant _NumSeq_Coord_ExperimentalNeighbours4d_max => 4;
1479 use constant _NumSeq_Coord_ExperimentalNeighbours6_max => 6;
1480 use constant _NumSeq_Coord_ExperimentalNeighbours8_max => 8;
1481  
1482 sub _NumSeq_Coord_ExperimentalNeighbours4_max {
1483 my ($self) = @_;
1484 if (my $filling_type = $self->_NumSeq_Coord_filling_type) {
1485 if ($filling_type eq 'triangular') { return 0; }
1486 }
1487 return 4;
1488 }
1489  
1490 use constant _NumSeq_Coord_ExperimentalNeighbours3_integer => 1; # counts
1491 use constant _NumSeq_Coord_ExperimentalNeighbours4_integer => 1;
1492 use constant _NumSeq_Coord_ExperimentalNeighbours4d_integer => 1;
1493 use constant _NumSeq_Coord_ExperimentalNeighbours6_integer => 1;
1494 use constant _NumSeq_Coord_ExperimentalNeighbours8_integer => 1;
1495  
1496  
1497 #------
1498 # X
1499 use constant _NumSeq_Coord_X_integer => 1; # usually
1500 use constant _NumSeq_Coord_X_increasing => undef;
1501 use constant _NumSeq_Coord_X_non_decreasing => undef;
1502  
1503 #------
1504 # Y
1505 use constant _NumSeq_Coord_Y_integer => 1; # usually
1506 use constant _NumSeq_Coord_Y_increasing => undef;
1507 use constant _NumSeq_Coord_Y_non_decreasing => undef;
1508  
1509  
1510 #------
1511 # Sum
1512  
1513 sub _NumSeq_Coord_Sum_integer {
1514 my ($self) = @_;
1515 ### _NumSeq_Coord_Sum_integer() ...
1516 return ($self->_NumSeq_Coord_X_integer
1517 && $self->_NumSeq_Coord_Y_integer);
1518 }
1519 *_NumSeq_Coord_SumAbs_integer = \&_NumSeq_Coord_Sum_integer;
1520 *_NumSeq_Coord_Product_integer = \&_NumSeq_Coord_Sum_integer;
1521 *_NumSeq_Coord_DiffXY_integer = \&_NumSeq_Coord_Sum_integer;
1522 *_NumSeq_Coord_AbsDiff_integer = \&_NumSeq_Coord_Sum_integer;
1523 *_NumSeq_Coord_RSquared_integer = \&_NumSeq_Coord_Sum_integer;
1524 *_NumSeq_Coord_TRSquared_integer = \&_NumSeq_Coord_Sum_integer;
1525 *_NumSeq_Coord_ExperimentalDiffXYsquared_integer = \&_NumSeq_Coord_Sum_integer;
1526 *_NumSeq_Coord_ExperimentalDiffYXsquares_integer = \&_NumSeq_Coord_Sum_integer;
1527  
1528 sub _NumSeq_Coord_Product_min {
1529 my ($self) = @_;
1530 my ($x_minimum, $y_minimum);
1531 if (defined ($x_minimum = $self->x_minimum)
1532 && defined ($y_minimum = $self->y_minimum)
1533 && $x_minimum >= 0
1534 && $y_minimum >= 0) {
1535 return $x_minimum * $y_minimum;
1536 }
1537 return undef;
1538 }
1539 sub _NumSeq_Coord_Product_max {
1540 my ($self) = @_;
1541 my ($x_max, $y_minimum);
1542 ### X_max: $self->x_maximum
1543 ### Y_min: $self->y_minimum
1544 if (defined ($x_max = $self->x_maximum)
1545 && defined ($y_minimum = $self->y_minimum)
1546 && $x_max <= 0
1547 && $y_minimum >= 0) {
1548 # X all negative, Y all positive
1549 return $y_minimum * $x_max;
1550 }
1551 return undef;
1552 }
1553  
1554 #----------
1555 # DiffYX opposite of DiffXY
1556 sub _NumSeq_Coord_DiffYX_min {
1557 my ($self) = @_;
1558 if (defined (my $m = $self->diffxy_maximum)) {
1559 return - $m;
1560 } else {
1561 return undef;
1562 }
1563 }
1564 sub _NumSeq_Coord_DiffYX_max {
1565 my ($self) = @_;
1566 if (defined (my $m = $self->diffxy_minimum)) {
1567 return - $m;
1568 } else {
1569 return undef;
1570 }
1571 }
1572 sub _NumSeq_Coord_DiffYX_integer {
1573 my ($self) = @_;
1574 return $self->_NumSeq_Coord_DiffXY_integer;
1575 }
1576  
1577 #----------
1578 # Radius
1579  
1580 sub _NumSeq_Coord_Radius_min {
1581 my ($path) = @_;
1582 return sqrt($path->rsquared_minimum);
1583 }
1584 sub _NumSeq_Coord_Radius_max {
1585 my ($path) = @_;
1586 my $rsquared_maximum = $path->rsquared_maximum;
1587 return (defined $rsquared_maximum ? sqrt($rsquared_maximum) : undef);
1588 }
1589  
1590 #----------
1591 # TRadius
1592  
1593 sub _NumSeq_Coord_TRadius_min {
1594 my ($path) = @_;
1595 return sqrt($path->_NumSeq_Coord_TRSquared_min);
1596 }
1597 sub _NumSeq_Coord_TRSquared_min {
1598 my ($self) = @_;
1599  
1600 # The X and Y each closest to the origin. This assumes that point is
1601 # actually visited, but is likely to be close.
1602 my $x_minimum = $self->x_minimum;
1603 my $x_maximum = $self->x_maximum;
1604 my $y_minimum = $self->y_minimum;
1605 my $y_maximum = $self->y_maximum;
1606 my $x = (( defined $x_minimum && $x_minimum) > 0 ? $x_minimum
1607 : (defined $x_maximum && $x_maximum) < 0 ? $x_maximum
1608 : 0);
1609 my $y = (( defined $y_minimum && $y_minimum) > 0 ? $y_minimum
1610 : (defined $y_maximum && $y_maximum) < 0 ? $y_maximum
1611 : 0);
1612 return ($x*$x + 3*$y*$y);
1613 }
1614  
1615 sub _NumSeq_Coord_IntXY_min {
1616 my ($self) = @_;
1617 if (defined(my $x = $self->x_minimum)
1618 && defined(my $y = $self->y_minimum)) {
1619 if ($y >= 0) {
1620 if ($y == 0) {
1621 $y = 1;
1622 }
1623 if ($x >= 0 && $y <= $x) {
1624 $y = 2*$x;
1625 if (defined (my $y_maximum = $self->y_maximum)) {
1626 $y = List::Util::min($y, $y_maximum);
1627 }
1628 }
1629 ### using: "x=$x y=$y"
1630 # presume that point x_minimum(),y_minimum() occurs
1631 return Math::NumSeq::PlanePathCoord::_xy_to_IntXY($x,$y);
1632 }
1633 }
1634 return undef;
1635 }
1636 use constant _NumSeq_Coord_IntXY_max => undef;
1637 use constant _NumSeq_Coord_IntXY_integer => 1;
1638  
1639 use constant _NumSeq_Coord_FracXY_max => 1;
1640 use constant _NumSeq_FracXY_max_is_supremum => 1;
1641 sub _NumSeq_Coord_FracXY_min {
1642 my ($self) = @_;
1643 if (! $self->x_negative && ! $self->y_negative) {
1644 return 0;
1645 } else {
1646 return -1;
1647 }
1648 }
1649 *_NumSeq_FracXY_min_is_infimum = \&_NumSeq_Coord_FracXY_min; # if non-zero
1650 use constant _NumSeq_Coord_FracXY_integer => 0;
1651  
1652 use constant _NumSeq_Coord_ExperimentalParity_min => 0;
1653 sub _NumSeq_Coord_ExperimentalParity_integer { $_[0]->_NumSeq_Coord_Sum_integer }
1654 sub _NumSeq_Coord_ExperimentalParity_max {
1655 my ($self) = @_;
1656 return ($self->_NumSeq_Coord_ExperimentalParity_integer
1657 ? 1
1658 : 2);
1659 }
1660 sub _NumSeq_ExperimentalParity_max_is_supremum {
1661 my ($self) = @_;
1662 return ($self->_NumSeq_Coord_ExperimentalParity_integer ? 0 : 1);
1663 }
1664  
1665 sub _NumSeq_Coord_ExperimentalNumerator_min {
1666 my ($self) = @_;
1667 if (defined (my $gcd_maximum = $self->gcdxy_maximum)) {
1668 if ($gcd_maximum == 1) {
1669 return $self->x_minimum; # X,Y no common factor, so ExperimentalNumerator==X
1670 }
1671 }
1672 if (! $self->y_negative
1673 && defined (my $x_minimum = $self->x_minimum)) {
1674 ### $x_minimum
1675 if ($x_minimum >= 1) {
1676 return 1; # somewhere X/Y dividing out to 1/Z
1677 }
1678 if ($x_minimum >= 0) {
1679 return 0; # 0/Y
1680 }
1681 }
1682 return undef;
1683 }
1684 use constant _NumSeq_Coord_ExperimentalNumerator_integer => 1;
1685  
1686 sub _NumSeq_Coord_ExperimentalDenominator_min {
1687 my ($self) = @_;
1688 if (defined (my $y_minimum = $self->y_minimum)) {
1689 if ($y_minimum > 0) {
1690 return 1; # X/0=1/0 doesn't occur, so den>=1
1691 }
1692 if ($y_minimum == 0) {
1693 return 0; # X/0=1/0
1694 }
1695 }
1696 return 0;
1697 }
1698 use constant _NumSeq_Coord_ExperimentalDenominator_integer => 1;
1699  
1700 # fractional part treated bitwise
1701 *_NumSeq_Coord_BitAnd_integer = \&_NumSeq_Coord_Sum_integer;
1702 *_NumSeq_Coord_BitOr_integer = \&_NumSeq_Coord_Sum_integer;
1703 *_NumSeq_Coord_BitXor_integer = \&_NumSeq_Coord_Sum_integer;
1704  
1705 #-------------
1706 # GCD
1707  
1708 use constant _NumSeq_Coord_GCD_integer => 1;
1709  
1710 use constant _NumSeq_Coord_ExperimentalGcdDivisions_min => 0;
1711 use constant _NumSeq_Coord_ExperimentalGcdDivisions_max => undef;
1712 use constant _NumSeq_Coord_ExperimentalGcdDivisions_integer => 1;
1713  
1714 #-------------
1715  
1716 use constant _NumSeq_Coord_ExperimentalKroneckerSymbol_min => -1;
1717 use constant _NumSeq_Coord_ExperimentalKroneckerSymbol_max => 1;
1718 use constant _NumSeq_Coord_ExperimentalKroneckerSymbol_integer => 1;
1719  
1720 sub _NumSeq_Coord_BitAnd_min {
1721 my ($self) = @_;
1722 # if one of X,Y always >=0 then BitAnd >= 0
1723 my $max_min = $self->_NumSeq_Coord_Max_min;
1724 if (defined $max_min && $max_min >= 0) {
1725 return 0;
1726 }
1727 return undef;
1728 }
1729 sub _NumSeq_Coord_BitOr_min {
1730 my ($self) = @_;
1731 my $x_minimum = $self->x_minimum;
1732 my $y_minimum = $self->y_minimum;
1733 if (defined $x_minimum && defined $y_minimum) {
1734 return ($x_minimum > 0
1735 ? ($y_minimum > 0
1736 ? List::Util::min($x_minimum, $y_minimum) # +X,+Y
1737 : $x_minimum) # +X,-Y
1738 : ($y_minimum > 0
1739 ? $y_minimum # -X,+Y
1740 : List::Util::min($x_minimum, $y_minimum))); # -X,-Y
1741  
1742 } else {
1743 return undef;
1744 }
1745 }
1746 sub _NumSeq_Coord_BitXor_min {
1747 my ($self) = @_;
1748 my $x_minimum = $self->x_minimum;
1749 my $y_minimum = $self->y_minimum;
1750 if ($self->x_negative || $self->y_negative) {
1751 return undef;
1752 } else {
1753 return 0; # no negatives
1754 }
1755 }
1756  
1757 #-------------
1758 # Min
1759  
1760 # Return the minimum value taken by min(X,Y) at integer N.
1761 # This is simply the smaller of x_minimum() or y_minimum().
1762 # If either X or Y is unbounded below then min(X,Y) is unbounded below too
1763 # and minxy_minimum() returns undef.
1764 #
1765 sub _NumSeq_Coord_Min_min {
1766 my ($self) = @_;
1767 # min(X,Y) has a minimum iff both X and Y have a minimum.
1768 if (defined (my $x_minimum = $self->x_minimum)
1769 && defined (my $y_minimum = $self->y_minimum)) {
1770 return Math::NumSeq::PlanePathCoord::min($x_minimum, $y_minimum);
1771 }
1772 return undef;
1773 }
1774 sub _NumSeq_Coord_Min_max {
1775 my ($self) = @_;
1776 # If there's a maximum X or Y then that will be the maximum for Min.
1777 # If there's both maximum X and Y then the bigger of the two.
1778 my $x_maximum = $self->x_maximum;
1779 my $y_maximum = $self->y_maximum;
1780 if (defined $x_maximum || defined $y_maximum) {
1781 return Math::NumSeq::PlanePathCoord::max
1782 (defined $x_maximum ? $x_maximum : (),
1783 defined $y_maximum ? $y_maximum : ());
1784 }
1785 return undef;
1786 }
1787  
1788 #-------------
1789 # Max
1790  
1791 sub _NumSeq_Coord_Max_min {
1792 my ($self) = @_;
1793 my $x_minimum = $self->x_minimum;
1794 my $y_minimum = $self->y_minimum;
1795 # or empty max is undef if neither minimum
1796 return Math::NumSeq::PlanePathCoord::max
1797 (defined $x_minimum ? $x_minimum : (),
1798 defined $y_minimum ? $y_minimum : ());
1799 }
1800 # Return the maximum value taken by max(X,Y) at integer N.
1801 # This is simply the smaller of x_maximum() or y_maximum().
1802 # If either X or Y is unbounded above then max(X,Y) is unbounded above too
1803 # and maxxy_maximum() returns undef.
1804 #
1805 sub _NumSeq_Coord_Max_max {
1806 my ($self) = @_;
1807 if (defined (my $x_maximum = $self->x_maximum)
1808 && defined (my $y_maximum = $self->y_maximum)) {
1809 return Math::NumSeq::PlanePathCoord::max($x_maximum, $y_maximum);
1810 }
1811 return undef;
1812 }
1813 *_NumSeq_Coord_Min_integer = \&_NumSeq_Coord_Sum_integer;
1814 *_NumSeq_Coord_Max_integer = \&_NumSeq_Coord_Sum_integer;
1815  
1816 sub _NumSeq_Coord_Max_is_always_X {
1817 my ($path) = @_;
1818 # if X-Y>=0 then X>=Y and max(X,Y)=X
1819 my $diffxy_minimum = $path->diffxy_minimum;
1820 return (defined $diffxy_minimum && $diffxy_minimum >= 0);
1821 }
1822 sub _NumSeq_Coord_Max_is_always_Y {
1823 my ($path) = @_;
1824 # if X-Y<=0 then X<=Y and max(X,Y)=Y
1825 my $diffxy_maximum = $path->diffxy_maximum;
1826 return (defined $diffxy_maximum && $diffxy_maximum <= 0);
1827 }
1828 sub _NumSeq_Coord_Max_increasing {
1829 my ($path) = @_;
1830 if ($path->_NumSeq_Coord_Max_is_always_X) {
1831 return $path->_NumSeq_Coord_X_increasing;
1832 }
1833 if ($path->_NumSeq_Coord_Max_is_always_Y) {
1834 return $path->_NumSeq_Coord_Y_increasing;
1835 }
1836 return undef;
1837 }
1838 sub _NumSeq_Coord_Max_non_decreasing {
1839 my ($path) = @_;
1840 if ($path->_NumSeq_Coord_Max_is_always_X) {
1841 return $path->_NumSeq_Coord_X_non_decreasing;
1842 }
1843 if ($path->_NumSeq_Coord_Max_is_always_Y) {
1844 return $path->_NumSeq_Coord_Y_non_decreasing;
1845 }
1846 return undef;
1847 }
1848  
1849 #------------
1850 # ExperimentalHammingDist
1851  
1852 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 0;
1853 use constant _NumSeq_Coord_ExperimentalHammingDist_integer => 1;
1854 # sub _NumSeq_Coord_ExperimentalHammingDist_min {
1855 # my ($self) = @_;
1856 # return ($self->x_negative || $self->y_negative ? undef : 0);
1857 # }
1858  
1859 #-------------
1860 # MinAbs
1861  
1862 sub _NumSeq_Coord_MinAbs_min {
1863 my ($self) = @_;
1864 return Math::NumSeq::PlanePathCoord::min
1865 ($self->_NumSeq_Coord_ExperimentalAbsX_min,
1866 $self->_NumSeq_Coord_ExperimentalAbsY_min);
1867 }
1868 sub _NumSeq_Coord_MinAbs_max {
1869 my ($self) = @_;
1870 my $absx_maximum = $self->_NumSeq_Coord_ExperimentalAbsX_max;
1871 my $absy_maximum = $self->_NumSeq_Coord_ExperimentalAbsY_max;
1872 # smaller of the two maxima, or undef if neither bounded
1873 return Math::NumSeq::PlanePathCoord::min
1874 ((defined $absx_maximum ? $absx_maximum : ()),
1875 (defined $absy_maximum ? $absy_maximum : ()));
1876 }
1877 *_NumSeq_Coord_MinAbs_integer = \&_NumSeq_Coord_Sum_integer;
1878  
1879 sub _NumSeq_Coord_MaxAbs_non_decreasing {
1880 my ($path) = @_;
1881 if (! $path->x_negative && ! $path->y_negative) {
1882 # X>0 and Y>0 so MaxAbs==Max
1883 return $path->_NumSeq_Coord_Max_non_decreasing;
1884 }
1885 return undef;
1886 }
1887 sub _NumSeq_Coord_MaxAbs_increasing {
1888 my ($path) = @_;
1889 if (! $path->x_negative && ! $path->y_negative) {
1890 # X>0 and Y>0 so MaxAbs==Max
1891 return $path->_NumSeq_Coord_Max_increasing;
1892 }
1893 return undef;
1894 }
1895  
1896 #-------------
1897 # MaxAbs
1898  
1899 sub _NumSeq_Coord_MaxAbs_min {
1900 my ($self) = @_;
1901 return Math::NumSeq::PlanePathCoord::max
1902 ($self->_NumSeq_Coord_ExperimentalAbsX_min,
1903 $self->_NumSeq_Coord_ExperimentalAbsY_min);
1904 }
1905 sub _NumSeq_Coord_MaxAbs_max {
1906 my ($self) = @_;
1907 if (defined (my $x_minimum = $self->x_minimum)
1908 && defined (my $y_minimum = $self->y_minimum)
1909 && defined (my $x_maximum = $self->x_maximum)
1910 && defined (my $y_maximum = $self->y_maximum)) {
1911 return Math::NumSeq::PlanePathCoord::max
1912 (-$x_minimum, -$y_minimum, $x_maximum, $y_maximum);
1913 }
1914 return undef;
1915 }
1916 *_NumSeq_Coord_MaxAbs_integer = \&_NumSeq_Coord_Sum_integer;
1917  
1918 #-------------
1919 # ExperimentalAbsX
1920  
1921 sub _NumSeq_Coord_ExperimentalAbsX_min {
1922 my ($self) = @_;
1923 # if positive min or negative max then 0 is not crossed and have an ExperimentalAbsX
1924 # min which is bigger than 0
1925 { my $x_minimum = $self->x_minimum;
1926 if (defined $x_minimum && $x_minimum > 0) { return $x_minimum; }
1927 }
1928 { my $x_maximum = $self->x_maximum;
1929 if (defined $x_maximum && $x_maximum < 0) { return - $x_maximum; }
1930 }
1931 return 0;
1932 }
1933 sub _NumSeq_Coord_ExperimentalAbsX_max {
1934 my ($self) = @_;
1935 # if bounded above and below then have an ExperimentalAbsX
1936 if (defined (my $x_minimum = $self->x_minimum)) {
1937 if (defined (my $x_maximum = $self->x_maximum)) {
1938 return Math::NumSeq::PlanePathCoord::max
1939 (abs($x_minimum), abs($x_maximum));
1940 }
1941 }
1942 return undef;
1943 }
1944  
1945 #-------------
1946 # ExperimentalAbsY
1947  
1948 sub _NumSeq_Coord_ExperimentalAbsY_min {
1949 my ($self) = @_;
1950 # if positive min or negative max then 0 is not crossed and have an ExperimentalAbsY
1951 # min which is bigger than 0
1952 { my $y_minimum = $self->y_minimum;
1953 if (defined $y_minimum && $y_minimum > 0) { return $y_minimum; }
1954 }
1955 { my $y_maximum = $self->y_maximum;
1956 if (defined $y_maximum && $y_maximum < 0) { return - $y_maximum; }
1957 }
1958 return 0;
1959 }
1960 sub _NumSeq_Coord_ExperimentalAbsY_max {
1961 my ($self) = @_;
1962 # if bounded above and below then have an ExperimentalAbsY
1963 if (defined (my $y_minimum = $self->y_minimum)) {
1964 if (defined (my $y_maximum = $self->y_maximum)) {
1965 return Math::NumSeq::PlanePathCoord::max
1966 (abs($y_minimum), abs($y_maximum));
1967 }
1968 }
1969 return undef;
1970 }
1971  
1972 #-------------
1973  
1974 sub _NumSeq_Coord_pred_X {
1975 my ($path, $value) = @_;
1976 return (($path->figure ne 'square' || $value == int($value))
1977 && ($path->x_negative || $value >= 0));
1978 }
1979 sub _NumSeq_Coord_pred_Y {
1980 my ($path, $value) = @_;
1981 return (($path->figure ne 'square' || $value == int($value))
1982 && ($path->y_negative || $value >= 0));
1983 }
1984 sub _NumSeq_Coord_pred_Sum {
1985 my ($path, $value) = @_;
1986 return (($path->figure ne 'square' || $value == int($value))
1987 && ($path->x_negative || $path->y_negative || $value >= 0));
1988 }
1989 sub _NumSeq_Coord_pred_SumAbs {
1990 my ($path, $value) = @_;
1991 return (($path->figure ne 'square' || $value == int($value))
1992 && $value >= 0);
1993 }
1994  
1995 #--------------------------
1996 sub _NumSeq_Coord_pred_Radius {
1997 my ($path, $value) = @_;
1998 return $path->_NumSeq_Coord_pred_RSquared($value*$value);
1999 }
2000 sub _NumSeq_Coord_pred_RSquared {
2001 my ($path, $value) = @_;
2002 # FIXME: this should be whether x^2+y^2 ever occurs, which is no prime
2003 # factor 4k+3 or some such
2004 return (($path->figure ne 'square' || $value == int($value))
2005 && $value >= 0);
2006 }
2007  
2008 #--------------------------
2009 sub _NumSeq_Coord_pred_TRadius {
2010 my ($path, $value) = @_;
2011 return $path->_NumSeq_Coord_pred_RSquared($value*$value);
2012 }
2013 sub _NumSeq_Coord_pred_TRSquared {
2014 my ($path, $value) = @_;
2015 # FIXME: this should be whether x^2+3*y^2 occurs ...
2016 return (($path->figure ne 'square' || $value == int($value))
2017 && $value >= 0);
2018 }
2019  
2020 #--------------------------
2021 use constant _NumSeq_Coord_Depth_min => 0;
2022 sub _NumSeq_Coord_Depth_max {
2023 my ($path, $value) = @_;
2024 return ($path->tree_n_num_children($path->n_start)
2025 ? undef # is a tree, default infinite max depth
2026 : 0); # not a tree, depth always 0
2027 }
2028 use constant _NumSeq_Coord_Depth_integer => 1;
2029 use constant _NumSeq_Coord_Depth_non_decreasing => 1; # usually
2030  
2031 #--------------------------
2032 use constant _NumSeq_Coord_NumChildren_integer => 1;
2033  
2034 # compare with "==" to be numeric style, just in case some overloaded
2035 # class stringizes to "1.0" or some such nonsense
2036 sub _NumSeq_Coord_pred_NumChildren {
2037 my ($self, $value) = @_;
2038 foreach my $num ($self->tree_num_children_list) {
2039 if ($value == $num) { return 1; }
2040 }
2041 return 0;
2042 }
2043  
2044 #--------------------------
2045 use constant _NumSeq_Coord_NumSiblings_min => 0; # root node no siblings
2046 sub _NumSeq_Coord_NumSiblings_max {
2047 my ($path) = @_;
2048 return List::Util::max(0,
2049 # not including self
2050 $path->tree_num_children_maximum - 1);
2051 }
2052 use constant _NumSeq_Coord_NumSiblings_integer => 1;
2053 # if NumChildren=const except for NumChildren=0 then have NumSiblings=const-1
2054 # so NumSiblings=0 at the root and thereafter non-decreasing
2055 sub _NumSeq_Coord_NumSiblings_non_decreasing {
2056 my ($path) = @_;
2057 my @num_children = $path->tree_num_children_list;
2058 if ($num_children[0] == 0) { shift @num_children; }
2059 return (scalar(@num_children) <= 1);
2060 }
2061  
2062 #--------------------------
2063 use constant _NumSeq_Coord_ExperimentalLeafDistance_integer => 1;
2064 use constant _NumSeq_Coord_ExperimentalLeafDistance_min => 0;
2065 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 0;
2066  
2067 #--------------------------
2068 sub _NumSeq_Coord_SubHeight_min {
2069 my ($path) = @_;
2070 if ($path->tree_any_leaf) {
2071 return 0; # height 0 at a leaf
2072 } else {
2073 return undef; # actually +infinity
2074 }
2075 }
2076 sub _NumSeq_Coord_SubHeight_max {
2077 my ($path) = @_;
2078 return ($path->tree_n_num_children($path->n_start)
2079 ? undef # is a tree, default infinite max height
2080 : 0); # not a tree, height always 0
2081 }
2082 use constant _NumSeq_Coord_SubHeight_integer => 1;
2083  
2084 #--------------------------
2085 sub _NumSeq_Coord_RootN_min {
2086 my ($path) = @_;
2087 return $path->n_start;
2088 }
2089 sub _NumSeq_Coord_RootN_max {
2090 my ($path) = @_;
2091 return $path->n_start
2092 + List::Util::max(0, $path->tree_num_roots()-1);
2093 }
2094 use constant _NumSeq_Coord_RootN_integer => 1;
2095  
2096 #--------------------------
2097 sub _NumSeq_Coord_IsLeaf_min {
2098 my ($path) = @_;
2099 # if num_children>0 occurs then that's a non-leaf node so IsLeaf=0 occurs
2100 return ($path->tree_num_children_maximum() > 0 ? 0 : 1);
2101 }
2102 sub _NumSeq_Coord_IsLeaf_max {
2103 my ($path) = @_;
2104 return ($path->tree_any_leaf() ? 1 : 0);
2105 }
2106 # IsNonLeaf is opposite of IsLeaf
2107 sub _NumSeq_Coord_IsNonLeaf_min {
2108 my ($path) = @_;
2109 return $path->_NumSeq_Coord_IsLeaf_max ? 0 : 1;
2110 }
2111 sub _NumSeq_Coord_IsNonLeaf_max {
2112 my ($path) = @_;
2113 return $path->_NumSeq_Coord_IsLeaf_min ? 0 : 1;
2114 }
2115 use constant _NumSeq_Coord_IsLeaf_integer => 1;
2116 use constant _NumSeq_Coord_IsNonLeaf_integer => 1;
2117  
2118 #--------------------------
2119 use constant _NumSeq_Coord_ExperimentalRowOffset_min => 0;
2120  
2121 #--------------------------
2122 use constant _NumSeq_Coord_n_list_max => 1;
2123  
2124 use constant _NumSeq_Coord_ExperimentalVisitCount_min => 1;
2125 sub _NumSeq_Coord_ExperimentalVisitCount_max {
2126 my ($path) = @_;
2127 return $path->_NumSeq_Coord_n_list_max;
2128 }
2129 use constant _NumSeq_Coord_ExperimentalVisitNum_min => 1;
2130 *_NumSeq_Coord_ExperimentalVisitNum_max
2131 = \&_NumSeq_Coord_ExperimentalVisitCount_max;
2132  
2133 use constant _NumSeq_Coord_ExperimentalRevisit_min => 0;
2134 sub _NumSeq_Coord_ExperimentalRevisit_max {
2135 my ($path) = @_;
2136 return $path->_NumSeq_Coord_n_list_max - 1;
2137 }
2138 }
2139  
2140 { package Math::PlanePath::SquareSpiral;
2141 use constant _NumSeq_Coord_filling_type => 'plane';
2142 sub _NumSeq_Coord_MaxAbs_non_decreasing {
2143 my ($self) = @_;
2144 return ($self->{'wider'} == 0);
2145 }
2146 use constant _NumSeq_Coord_oeis_anum =>
2147 { 'wider=0,n_start=1' =>
2148 { X => 'A174344',
2149 SumAbs => 'A214526', # "Manhattan" distance from n to 1
2150 # OEIS-Catalogue: A174344 planepath=SquareSpiral coordinate_type=X
2151 # OEIS-Catalogue: A214526 planepath=SquareSpiral coordinate_type=SumAbs
2152 },
2153 'wider=0,n_start=0' =>
2154 { Sum => 'A180714', # X+Y of square spiral
2155 AbsDiff => 'A053615', # n..0..n, distance to pronic
2156 # OEIS-Catalogue: A180714 planepath=SquareSpiral,n_start=0 coordinate_type=Sum
2157 # OEIS-Other: A053615 planepath=SquareSpiral,n_start=0 coordinate_type=AbsDiff
2158 },
2159 };
2160 }
2161 { package Math::PlanePath::GreekKeySpiral;
2162 use constant _NumSeq_Coord_filling_type => 'plane';
2163 sub _NumSeq_Coord_MaxAbs_non_decreasing {
2164 my ($self) = @_;
2165 return ($self->{'turns'} == 0); # when same as SquareSpiral
2166 }
2167 }
2168 { package Math::PlanePath::PyramidSpiral;
2169 use constant _NumSeq_Coord_filling_type => 'plane';
2170 use constant _NumSeq_Coord_oeis_anum =>
2171 { 'n_start=0' =>
2172 { ExperimentalAbsX => 'A053615', # runs n..0..n, OFFSET=0
2173 # OEIS-Catalogue: A053615 planepath=PyramidSpiral,n_start=0 coordinate_type=ExperimentalAbsX
2174 },
2175 };
2176 }
2177 { package Math::PlanePath::TriangleSpiral;
2178 use constant _NumSeq_Coord_filling_type => 'triangular';
2179 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
2180 }
2181 { package Math::PlanePath::TriangleSpiralSkewed;
2182 use constant _NumSeq_Coord_filling_type => 'plane';
2183 }
2184 { package Math::PlanePath::DiamondSpiral;
2185 use constant _NumSeq_Coord_filling_type => 'plane';
2186 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1; # diagonals pos,neg
2187 use constant _NumSeq_Coord_oeis_anum =>
2188 { 'n_start=0' =>
2189 { X => 'A010751', # up 1, down 2, up 3, down 4, etc
2190 ExperimentalAbsY => 'A053616',
2191 # OEIS-Catalogue: A010751 planepath=DiamondSpiral,n_start=0
2192 # OEIS-Other: A053616 planepath=DiamondSpiral,n_start=0 coordinate_type=ExperimentalAbsY
2193 },
2194 };
2195 }
2196 { package Math::PlanePath::AztecDiamondRings;
2197 use constant _NumSeq_Coord_filling_type => 'plane';
2198 }
2199 { package Math::PlanePath::PentSpiralSkewed;
2200 use constant _NumSeq_Coord_filling_type => 'plane';
2201 }
2202 { package Math::PlanePath::HexSpiral;
2203 use constant _NumSeq_Coord_filling_type => 'triangular';
2204 # origin 0,0 if wider even, otherwise only X=1,Y=0 if wider odd
2205 sub _NumSeq_Coord_TRSquared_min { $_[0]->rsquared_minimum }
2206  
2207 # always odd/even according to wider odd/even
2208 sub _NumSeq_Coord_ExperimentalParity_min {
2209 my ($self) = @_;
2210 return $self->{'wider'} & 1;
2211 }
2212 *_NumSeq_Coord_ExperimentalParity_max = \&_NumSeq_Coord_ExperimentalParity_min;
2213  
2214 # X!=Y when wider odd
2215 *_NumSeq_Coord_ExperimentalHammingDist_min = \&_NumSeq_Coord_ExperimentalParity_min;
2216 *_NumSeq_Coord_MaxAbs_min = \&_NumSeq_Coord_ExperimentalParity_min;
2217 }
2218 { package Math::PlanePath::HexSpiralSkewed;
2219 use constant _NumSeq_Coord_filling_type => 'plane';
2220 }
2221 { package Math::PlanePath::HexArms;
2222 use constant _NumSeq_Coord_filling_type => 'triangular';
2223 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
2224 }
2225 { package Math::PlanePath::HeptSpiralSkewed;
2226 use constant _NumSeq_Coord_filling_type => 'plane';
2227 }
2228 { package Math::PlanePath::AnvilSpiral;
2229 use constant _NumSeq_Coord_filling_type => 'plane';
2230 }
2231 { package Math::PlanePath::OctagramSpiral;
2232 use constant _NumSeq_Coord_filling_type => 'plane';
2233 }
2234 { package Math::PlanePath::KnightSpiral;
2235 use constant _NumSeq_Coord_filling_type => 'plane';
2236 }
2237 { package Math::PlanePath::CretanLabyrinth;
2238 use constant _NumSeq_Coord_filling_type => 'plane';
2239 }
2240 { package Math::PlanePath::SquareArms;
2241 use constant _NumSeq_Coord_filling_type => 'plane';
2242 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # successive squares
2243 }
2244 { package Math::PlanePath::DiamondArms;
2245 use constant _NumSeq_Coord_filling_type => 'plane';
2246 }
2247 { package Math::PlanePath::SacksSpiral;
2248 use constant _NumSeq_Coord_X_integer => 0;
2249 use constant _NumSeq_Coord_Y_integer => 0;
2250 use constant _NumSeq_Coord_Radius_increasing => 1; # Radius==sqrt($i)
2251 use constant _NumSeq_Coord_RSquared_smaller => 0; # RSquared==$i
2252 use constant _NumSeq_Coord_RSquared_integer => 1;
2253  
2254 use constant _NumSeq_Coord_oeis_anum =>
2255 { '' =>
2256 { RSquared => 'A001477', # integers 0,1,2,3,etc
2257 # OEIS-Other: A001477 planepath=SacksSpiral coordinate_type=RSquared
2258 },
2259 };
2260 }
2261 { package Math::PlanePath::VogelFloret;
2262 use constant _NumSeq_Coord_X_integer => 0;
2263 use constant _NumSeq_Coord_Y_integer => 0;
2264 use constant _NumSeq_AbsDiff_min_is_infimum => 1;
2265 use constant _NumSeq_MinAbs_min_is_infimum => 1;
2266 use constant _NumSeq_MaxAbs_min_is_infimum => 1;
2267  
2268 sub _NumSeq_Coord_Radius_min {
2269 my ($self) = @_;
2270 # starting N=1 at R=radius_factor*sqrt(1), theta=something
2271 return $self->{'radius_factor'};
2272 }
2273 sub _NumSeq_Coord_TRSquared_min {
2274 my ($self) = @_;
2275 # starting N=1 at R=radius_factor*sqrt(1), theta=something
2276 my ($x,$y) = $self->n_to_xy($self->n_start);
2277 return $x*$x + 3*$y*$y;
2278 }
2279 sub _NumSeq_Coord_Radius_func {
2280 my ($seq, $i) = @_;
2281 ### VogelFloret Radius: $i, $seq->{'planepath_object'}
2282 # R=radius_factor*sqrt($n)
2283 # avoid sin/cos in the main n_to_xy()
2284  
2285 my $path = $seq->{'planepath_object'};
2286 my $rf = $path->{'radius_factor'};
2287  
2288 # promote BigInt $i -> BigFloat so that sqrt() doesn't round, and in
2289 # case radius_factor is not an integer
2290 if (ref $i && $i->isa('Math::BigInt') && $rf != int($rf)) {
2291 require Math::BigFloat;
2292 $i = Math::BigFloat->new($i);
2293 }
2294  
2295 return sqrt($i) * $rf;
2296 }
2297 use constant _NumSeq_Coord_Radius_increasing => 1; # Radius==sqrt($i)
2298 use constant _NumSeq_Coord_RSquared_smaller => 0; # RSquared==$i
2299 }
2300 { package Math::PlanePath::TheodorusSpiral;
2301 use constant _NumSeq_Coord_X_integer => 0;
2302 use constant _NumSeq_Coord_Y_integer => 0;
2303 use constant _NumSeq_Coord_Radius_increasing => 1; # Radius==sqrt($i)
2304 use constant _NumSeq_Coord_RSquared_smaller => 0; # RSquared==$i
2305 use constant _NumSeq_Coord_RSquared_integer => 1;
2306  
2307 use constant _NumSeq_Coord_oeis_anum =>
2308 { '' =>
2309 { RSquared => 'A001477', # integers 0,1,2,3,etc
2310 # OEIS-Other: A001477 planepath=TheodorusSpiral coordinate_type=RSquared
2311 },
2312 };
2313 }
2314 { package Math::PlanePath::ArchimedeanChords;
2315 use constant _NumSeq_Coord_X_integer => 0;
2316 use constant _NumSeq_Coord_Y_integer => 0;
2317 use constant _NumSeq_Coord_Radius_increasing => 1; # spiralling outwards
2318 }
2319 { package Math::PlanePath::MultipleRings;
2320  
2321 #---------
2322 # X
2323 sub _NumSeq_Coord_X_increasing {
2324 my ($self) = @_;
2325 # step==0 trivial on X axis
2326 return ($self->{'step'} == 0 ? 1 : 0);
2327 }
2328 sub _NumSeq_Coord_X_integer {
2329 my ($self) = @_;
2330 return ($self->{'step'} == 0); # step==0 trivial on X axis
2331 }
2332  
2333 #---------
2334 # Y
2335 *_NumSeq_Coord_Y_integer = \&_NumSeq_Coord_X_increasing;
2336 *_NumSeq_Coord_Y_non_decreasing = \&_NumSeq_Coord_X_increasing;
2337  
2338 *_NumSeq_Coord_Sum_increasing = \&_NumSeq_Coord_X_increasing;
2339 *_NumSeq_Coord_DiffXY_increasing = \&_NumSeq_Coord_X_increasing;
2340 *_NumSeq_Coord_DiffXYdiv2_increasing = \&_NumSeq_Coord_X_increasing;
2341 *_NumSeq_Coord_TRSquared_integer = \&_NumSeq_Coord_X_increasing;
2342 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_X_increasing;
2343 *_NumSeq_Coord_Product_integer = \&_NumSeq_Coord_X_increasing;
2344 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_X_increasing;
2345 *_NumSeq_Coord_BitOr_increasing = \&_NumSeq_Coord_X_increasing;
2346 *_NumSeq_Coord_BitXor_increasing = \&_NumSeq_Coord_X_increasing;
2347 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_increasing;
2348 *_NumSeq_Coord_Max_increasing = \&_NumSeq_Coord_X_increasing;
2349  
2350 #---------
2351 # SumAbs
2352 sub _NumSeq_Coord_SumAbs_non_decreasing {
2353 my ($self) = @_;
2354 # step==0 trivial on X axis
2355 # polygon step=4 same x+y in ring, others vary
2356 return ($self->{'step'} == 0
2357 || ($self->{'ring_shape'} eq 'polygon' && $self->{'step'} == 4)
2358 ? 1
2359 : 0);
2360 }
2361 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_X_increasing;
2362  
2363 #---------
2364 # Product
2365 sub _NumSeq_Coord_Product_max {
2366 my ($self) = @_;
2367 # step==0 trivial on X axis
2368 # polygon step=4 same x+y in ring, others vary
2369 return ($self->{'step'} == 0 ? 0 # step=0 always Y=0 so X*Y=0
2370 : undef);
2371 }
2372 *_NumSeq_Coord_BitAnd_max = \&_NumSeq_Coord_Product_max;
2373  
2374 #---------
2375 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_X_increasing;
2376 sub _NumSeq_AbsDiff_min_is_infimum {
2377 my ($self) = @_;
2378 # step multiple of 4 always falls on X=Y, otherwise approaches 0 only
2379 return ($self->{'ring_shape'} eq 'polygon'
2380 && $self->{'step'} % 4);
2381 }
2382  
2383 #---------
2384 # RSquared
2385 sub _NumSeq_Coord_RSquared_smaller {
2386 my ($self) = @_;
2387 # step==0 on X axis RSquared is i^2, bigger than i.
2388 # step=1 is 0,1,1,4,4,4,9,9,9,9,16,16,16,16,16 etc k+1 repeats of k^2,
2389 # bigger than i from i=5 onwards
2390 return ($self->{'step'} <= 1 ? 0 : 1);
2391 }
2392 *_NumSeq_Coord_RSquared_integer = \&_NumSeq_Coord_Radius_integer;
2393 *_NumSeq_Coord_RSquared_non_decreasing = \&_NumSeq_Coord_Radius_non_decreasing;
2394  
2395 #---------
2396 # Radius
2397 sub _NumSeq_Coord_Radius_integer {
2398 my ($self) = @_;
2399 # step==0 on X axis R=N
2400 # step==1 start X=0,Y=0, spaced 1 apart on X axis, same radius for others
2401 # step==6 start X=1,Y=0, spaced 1 apart
2402 return ($self->{'step'} <= 1 || $self->{'step'} == 6);
2403 }
2404 sub _NumSeq_Coord_Radius_non_decreasing {
2405 my ($self) = @_;
2406 # circle is non-decreasing, polygon varies
2407 return ! ($self->{'ring_shape'} eq 'polygon' && $self->{'step'} >= 3);
2408 }
2409 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_X_increasing;
2410  
2411 #---------
2412 # TRadius
2413 sub _NumSeq_Coord_TRadius_min {
2414 my ($self) = @_;
2415 return $self->_NumSeq_Coord_Radius_min;
2416 }
2417 sub _NumSeq_Coord_TRSquared_min {
2418 my ($self) = @_;
2419 return $self->rsquared_minimum;
2420 }
2421 sub _NumSeq_Coord_TRadius_non_decreasing {
2422 my ($self) = @_;
2423 # step==0 trivial on X axis
2424 return ($self->{'step'} == 0 ? 1 : 0);
2425 }
2426 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_X_increasing;
2427 *_NumSeq_Coord_TRadius_integer = \&_NumSeq_Coord_X_increasing;
2428  
2429 #---------
2430 # GCD
2431 *_NumSeq_Coord_GCD_integer = \&_NumSeq_Coord_X_increasing;
2432 *_NumSeq_Coord_GCD_increasing = \&_NumSeq_Coord_X_increasing;
2433  
2434 #---------
2435 # IntXY
2436 # step=0 X/0 so IntXY=X
2437 *_NumSeq_Coord_IntXY_increasing = \&_NumSeq_Coord_X_increasing;
2438  
2439 #---------
2440 # FracXY
2441 sub _NumSeq_Coord_FracXY_max {
2442 my ($self) = @_;
2443 return ($self->{'step'} == 0 ? 0 : 1);
2444 }
2445 sub _NumSeq_FracXY_max_is_supremum {
2446 my ($self) = @_;
2447 return ($self->{'step'} == 0 ? 0 : 1);
2448 }
2449 *_NumSeq_Coord_FracXY_non_decreasing = \&_NumSeq_Coord_X_increasing;
2450 *_NumSeq_Coord_FracXY_integer = \&_NumSeq_Coord_X_increasing;
2451  
2452 sub _NumSeq_ExperimentalParity_min_is_infimum {
2453 my ($self) = @_;
2454 return $self->{'ring_shape'} eq 'polygon';
2455 }
2456  
2457 use constant _NumSeq_Coord_oeis_anum =>
2458 {
2459 # MultipleRings step=0 is trivial X=N,Y=0
2460 'step=0,ring_shape=circle' =>
2461 { Y => 'A000004', # all-zeros
2462 Product => 'A000004', # all-zeros
2463 # OEIS-Other: A000004 planepath=MultipleRings,step=0 coordinate_type=Y
2464 # OEIS-Other: A000004 planepath=MultipleRings,step=0 coordinate_type=Product
2465  
2466 # OFFSET
2467 # X => 'A001477', # integers 0 upwards
2468 # Sum => 'A001477', # integers 0 upwards
2469 # AbsDiff => 'A001477', # integers 0 upwards
2470 # Radius => 'A001477', # integers 0 upwards
2471 # DiffXY => 'A001477', # integers 0 upwards
2472 # DiffYX => 'A001489', # negative integers 0 downwards
2473 # RSquared => 'A000290', # squares 0 upwards
2474 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=X
2475 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=Sum
2476 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=AbsDiff
2477 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=Radius
2478 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=DiffXY
2479 # # OEIS-Other: A001489 planepath=MultipleRings,step=0 coordinate_type=DiffYX
2480 # # OEIS-Other: A000290 planepath=MultipleRings,step=0 coordinate_type=RSquared
2481 },
2482 };
2483 }
2484 # { package Math::PlanePath::PixelRings;
2485 # }
2486 { package Math::PlanePath::FilledRings;
2487 use constant _NumSeq_Coord_filling_type => 'plane';
2488 }
2489 { package Math::PlanePath::Hypot;
2490 use constant _NumSeq_Coord_filling_type => 'plane';
2491 sub _NumSeq_Coord_TRSquared_min { $_[0]->rsquared_minimum }
2492  
2493 # in order of radius so monotonic, but always have 4x duplicates or more
2494 use constant _NumSeq_Coord_Radius_non_decreasing => 1;
2495  
2496 sub _NumSeq_Coord_ExperimentalHammingDist_min {
2497 my ($self) = @_;
2498 return ($self->{'points'} eq 'odd' ? 1 : 0);
2499 }
2500 *_NumSeq_Coord_ExperimentalParity_min = \&_NumSeq_Coord_ExperimentalHammingDist_min;
2501 *_NumSeq_Coord_MaxAbs_min = \&_NumSeq_Coord_ExperimentalHammingDist_min;
2502  
2503 sub _NumSeq_Coord_ExperimentalParity_max {
2504 my ($self) = @_;
2505 return ($self->{'points'} eq 'even' ? 0 : 1);
2506 }
2507 }
2508 { package Math::PlanePath::HypotOctant;
2509 use constant _NumSeq_Coord_IntXY_min => 1; # triangular X>=Y so X/Y >= 1
2510  
2511 sub _NumSeq_Coord_TRSquared_min { $_[0]->rsquared_minimum }
2512 sub _NumSeq_Coord_BitXor_min {
2513 my ($self) = @_;
2514 # "odd" always has X!=Ymod2 so differ in low bit
2515 return ($self->{'points'} eq 'odd' ? 1 : 0);
2516 }
2517  
2518 # in order of radius so monotonic, but can have duplicates
2519 use constant _NumSeq_Coord_Radius_non_decreasing => 1;
2520  
2521 sub _NumSeq_Coord_ExperimentalHammingDist_min {
2522 my ($self) = @_;
2523 return ($self->{'points'} eq 'odd' ? 1 : 0);
2524 }
2525  
2526 sub _NumSeq_Coord_ExperimentalParity_min {
2527 my ($self) = @_;
2528 return ($self->{'points'} eq 'odd' ? 1 : 0);
2529 }
2530 sub _NumSeq_Coord_ExperimentalParity_max {
2531 my ($self) = @_;
2532 return ($self->{'points'} eq 'even' ? 0 : 1);
2533 }
2534 }
2535 { package Math::PlanePath::TriangularHypot;
2536 use constant _NumSeq_Coord_filling_type => 'triangular';
2537 sub _NumSeq_Coord_TRSquared_min {
2538 my ($self) = @_;
2539 return ($self->{'points'} eq 'odd'
2540 ? 1 # odd at X=1,Y=0
2541 : $self->{'points'} eq 'hex_centred'
2542 ? 4 # hex_centred at X=2,Y=0 or X=1,Y=1
2543 : 0); # even,all at X=0,Y=0
2544 }
2545  
2546 # in order of triangular radius so monotonic, but can have duplicates so
2547 # non-decreasing
2548 use constant _NumSeq_Coord_TRadius_non_decreasing => 1;
2549  
2550 sub _NumSeq_Coord_ExperimentalHammingDist_min {
2551 my ($self) = @_;
2552 return ($self->{'points'} eq 'odd' ? 1 : 0); # X!=Y when odd
2553 }
2554 *_NumSeq_Coord_ExperimentalParity_min = \&_NumSeq_Coord_ExperimentalHammingDist_min;
2555 sub _NumSeq_Coord_MaxAbs_min {
2556 my ($self) = @_;
2557 return ($self->{'points'} eq 'odd' || $self->{'points'} eq 'hex_centred'
2558 ? 1 : 0);
2559 }
2560  
2561 sub _NumSeq_Coord_ExperimentalParity_max {
2562 my ($self) = @_;
2563 return ($self->{'points'} eq 'odd' || $self->{'points'} eq 'all' ? 1 : 0);
2564 }
2565 }
2566 { package Math::PlanePath::PythagoreanTree;
2567 use constant _NumSeq_Coord_SubHeight_min => undef;
2568 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => undef;
2569  
2570 {
2571 my %_NumSeq_Coord_IntXY_min = (AB => 0, # A>=1,B>=1 so int(A/B)>=0
2572 AC => 0, # A<C so int(A/C)==0 always
2573 BC => 0, # B<C so int(A/C)==0 always
2574 PQ => 1, # octant X>=Y+1 so X/Y>1
2575 SM => 0, # A>=1,B>=1 so int(A/B)>=0
2576 SC => 0,
2577 MC => 0,
2578 );
2579 sub _NumSeq_Coord_IntXY_min {
2580 my ($self) = @_;
2581 return $_NumSeq_Coord_IntXY_min{$self->{'coordinates'}};
2582 }
2583 }
2584 {
2585 my %_NumSeq_Coord_IntXY_max = (AC => 0, # A<C so int(A/C)==0 always
2586 BC => 0, # B<C so int(A/C)==0 always
2587 SM => 0, # X<Y so int(X/Y)<1
2588 SC => 0, # X<Y so int(X/Y)<1
2589 MC => 0, # X<Y so int(X/Y)<1
2590 );
2591 sub _NumSeq_Coord_IntXY_max {
2592 my ($self) = @_;
2593 return $_NumSeq_Coord_IntXY_max{$self->{'coordinates'}};
2594 }
2595 }
2596  
2597 # P=2,Q=1 frac=0
2598 # otherwise A,B,C have no common factor and >1 so frac!=0
2599 sub _NumSeq_FracXY_min_is_infimum {
2600 my ($self) = @_;
2601 return $self->{'coordinates'} ne 'PQ';
2602 }
2603  
2604 {
2605 my %_NumSeq_Coord_ExperimentalDenominator_min = (AB => 4, # at A=3,B=4 no common factor
2606 AC => 5, # at A=3,B=5
2607 BC => 5, # at B=4,B=5
2608 PQ => 1, # at P=2,Q=1
2609 );
2610 sub _NumSeq_Coord_ExperimentalDenominator_min {
2611 my ($self) = @_;
2612 return $_NumSeq_Coord_ExperimentalDenominator_min{$self->{'coordinates'}};
2613 }
2614 }
2615  
2616 {
2617 my %_NumSeq_Coord_BitAnd_min = (AB => 0, # at X=3,Y=4
2618 AC => 1, # at X=3,Y=5
2619 BC => 0, # at X=8,Y=17
2620 PQ => 0, # at X=2,Y=1
2621 SM => 0, # at X=3,Y=4
2622 SC => 0, # at X=3,Y=5
2623 MC => 0, # at X=4,Y=5
2624 );
2625 sub _NumSeq_Coord_BitAnd_min {
2626 my ($self) = @_;
2627 return $_NumSeq_Coord_BitAnd_min{$self->{'coordinates'}};
2628 }
2629 }
2630 {
2631 my %_NumSeq_Coord_BitOr_min = (AB => 7, # at A=3,B=4
2632 AC => 7, # at A=3,C=5
2633 BC => 5, # at B=4,C=5
2634 PQ => 3, # at P=2,Q=1
2635 SM => 7, # at X=3,Y=4
2636 SC => 7, # at X=3,Y=5
2637 MC => 5, # at X=4,Y=5
2638 );
2639 sub _NumSeq_Coord_BitOr_min {
2640 my ($self) = @_;
2641 return $_NumSeq_Coord_BitOr_min{$self->{'coordinates'}};
2642 }
2643 }
2644 {
2645 my %_NumSeq_Coord_BitXor_min = (AB => 1, # at X=21,Y=20
2646 AC => 6, # at X=3,Y=5
2647 BC => 1, # at X=4,Y=5
2648 PQ => 1, # at X=3,Y=2
2649 SM => 1, # at X=3,Y=4
2650 SC => 6, # at X=3,Y=5
2651 MC => 1, # at X=4,Y=5
2652 );
2653 sub _NumSeq_Coord_BitXor_min {
2654 my ($self) = @_;
2655 return $_NumSeq_Coord_BitXor_min{$self->{'coordinates'}};
2656 }
2657 }
2658  
2659 sub _NumSeq_Coord_Radius_integer {
2660 my ($self) = @_;
2661 return ($self->{'coordinates'} eq 'AB' # hypot
2662 || $self->{'coordinates'} eq 'SM'); # hypot
2663 }
2664  
2665 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
2666  
2667 {
2668 my %_NumSeq_Coord_ExperimentalParity_min = (PQ => 1, # one odd one even, so odd always
2669 AB => 1, # odd,even so odd always
2670 BA => 1,
2671 BC => 1, # even,odd so odd always
2672 );
2673 sub _NumSeq_Coord_ExperimentalParity_min {
2674 my ($self) = @_;
2675 return $_NumSeq_Coord_ExperimentalParity_min{$self->{'coordinates'}} || 0;
2676 }
2677 }
2678 sub _NumSeq_Coord_ExperimentalParity_max {
2679 my ($self) = @_;
2680 return ($self->{'coordinates'} eq 'AC'
2681 ? 0 # odd,odd so even always
2682 : 1);
2683 }
2684  
2685 # Not quite right.
2686 # sub _NumSeq_Coord_pred_Radius {
2687 # my ($path, $value) = @_;
2688 # return ($value >= 0
2689 # && ($path->{'coordinate_type'} ne 'AB'
2690 # || $value == int($value)));
2691 # }
2692 }
2693 { package Math::PlanePath::RationalsTree;
2694 use constant _NumSeq_Coord_BitAnd_min => 0; # X=1,Y=2
2695 use constant _NumSeq_Coord_BitXor_min => 0; # X=1,Y=1
2696 use constant _NumSeq_Coord_SubHeight_min => undef;
2697 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => undef;
2698  
2699 use constant _NumSeq_Coord_oeis_anum =>
2700 { 'tree_type=SB' =>
2701 { IntXY => 'A153036',
2702 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2703 # OEIS-Catalogue: A153036 planepath=RationalsTree coordinate_type=IntXY
2704 # OEIS-Catalogue: A000523 planepath=RationalsTree coordinate_type=Depth
2705  
2706 # Not quite, OFFSET n=0 cf N=1 here
2707 # Y => 'A047679', # SB denominator
2708 # # OEIS-Catalogue: A047679 planepath=RationalsTree coordinate_type=Y
2709 #
2710 # X => 'A007305', # SB numerators but starting extra 0,1
2711 # Sum => 'A007306', # Farey/SB denominators, but starting extra 1,1
2712 # Product => 'A119272', # num*den, but starting extra 1,1
2713 # cf A054424 permutation
2714 },
2715 'tree_type=CW' =>
2716 {
2717 # A070871 Stern adjacent S(n)*S(n+1), or Conway's alimentary function,
2718 # cf A070872 where S(n)*S(n+1) = n
2719 # A070873 where S(n)*S(n+1) > n
2720 # A070874 where S(n)*S(n+1) < n
2721 Product => 'A070871',
2722 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2723 # OEIS-Catalogue: A070871 planepath=RationalsTree,tree_type=CW coordinate_type=Product
2724 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=CW coordinate_type=Depth
2725  
2726 # Not quite, A007814 has extra initial 0, OFFSET=0 "0,1,0,2,0"
2727 # whereas path CW IntXY starts N=1 "1,0,2,0,1"
2728 # IntXY => 'A007814', # countlow1bits(N)
2729 # # OEIS-Other: A007814 planepath=RationalsTree,tree_type=CW coordinate_type=IntXY
2730  
2731 # Not quite, CW X and Y is Stern diatomic A002487, but RationalsTree
2732 # starts N=0 X=1,1,2 or Y=1,2 rather than from 0
2733  
2734 # Not quite, CW DiffYX is A070990 stern diatomic first diffs, but
2735 # path starts N=1 diff="0,1,-1,2,-1,1,-2", whereas A070990 starts n=0
2736 # "1,-1,2,-1,1,-2" one less term and would be n_start=-1
2737 },
2738 'tree_type=AYT' =>
2739 { X => 'A020650', # AYT numerator
2740 Y => 'A020651', # AYT denominator
2741 Sum => 'A086592', # Kepler's tree denominators
2742 SumAbs => 'A086592', # Kepler's tree denominators
2743 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2744 IntXY => 'A135523',
2745 # OEIS-Catalogue: A020650 planepath=RationalsTree,tree_type=AYT coordinate_type=X
2746 # OEIS-Catalogue: A020651 planepath=RationalsTree,tree_type=AYT coordinate_type=Y
2747 # OEIS-Other: A086592 planepath=RationalsTree,tree_type=AYT coordinate_type=Sum
2748 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=AYT coordinate_type=Depth
2749 # OEIS-Catalogue: A135523 planepath=RationalsTree,tree_type=AYT coordinate_type=IntXY
2750  
2751 # Not quite, DiffYX almost A070990 Stern diatomic first differences,
2752 # but we have an extra 0 at the start, and we start i=1 rather than
2753 # n=0 too
2754 },
2755 'tree_type=HCS' =>
2756 {
2757 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2758 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=HCS coordinate_type=Depth
2759  
2760 # # Not quite, OFFSET=0 value=1/1 corresponding to N=0 X=0/Y=1 here
2761 # Sum => 'A071585', # rats>=1 is HCS num+den
2762 # Y => 'A071766', # rats>=1 HCS denominator
2763 # # OEIS-Catalogue: A071585 planepath=RationalsTree,tree_type=HCS coordinate_type=X
2764 # # OEIS-Catalogue: A071766 planepath=RationalsTree,tree_type=HCS coordinate_type=Y
2765 },
2766 'tree_type=Bird' =>
2767 { X => 'A162909', # Bird tree numerators
2768 Y => 'A162910', # Bird tree denominators
2769 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2770 # OEIS-Catalogue: A162909 planepath=RationalsTree,tree_type=Bird coordinate_type=X
2771 # OEIS-Catalogue: A162910 planepath=RationalsTree,tree_type=Bird coordinate_type=Y
2772 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=Bird coordinate_type=Depth
2773 },
2774 'tree_type=Drib' =>
2775 { X => 'A162911', # Drib tree numerators
2776 Y => 'A162912', # Drib tree denominators
2777 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2778 # OEIS-Catalogue: A162911 planepath=RationalsTree,tree_type=Drib coordinate_type=X
2779 # OEIS-Catalogue: A162912 planepath=RationalsTree,tree_type=Drib coordinate_type=Y
2780 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=Drib coordinate_type=Depth
2781 },
2782 'tree_type=L' =>
2783 {
2784 X => 'A174981', # numerator
2785 # OEIS-Catalogue: A174981 planepath=RationalsTree,tree_type=L coordinate_type=X
2786  
2787 # # Not quite, A002487 extra initial, so n=2 is denominator at N=0
2788 # Y => 'A002487', # denominator, stern diatomic
2789 # # OEIS-Catalogue: A071585 planepath=RationalsTree,tree_type=HCS coordinate_type=Y
2790  
2791 # Not quite, A000523 is OFFSET=1 path starts N=0
2792 # Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2793 },
2794 };
2795 }
2796 { package Math::PlanePath::FractionsTree;
2797 use constant _NumSeq_Coord_IntXY_max => 0; # X/Y<1 always
2798 use constant _NumSeq_Coord_IntXY_non_decreasing => 1;
2799 use constant _NumSeq_FracXY_min_is_infimum => 1; # no common factor
2800 use constant _NumSeq_Coord_BitXor_min => 1; # X=2,Y=3
2801 use constant _NumSeq_Coord_SubHeight_min => undef;
2802 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => undef;
2803 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
2804  
2805 use constant _NumSeq_Coord_oeis_anum =>
2806 { 'tree_type=Kepler' =>
2807 { X => 'A020651', # numerators, same as AYT denominators
2808 Y => 'A086592', # Kepler half-tree denominators
2809 DiffYX => 'A020650', # AYT numerators
2810 AbsDiff => 'A020650', # AYT numerators
2811 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2812 # OEIS-Other: A020651 planepath=FractionsTree coordinate_type=X
2813 # OEIS-Catalogue: A086592 planepath=FractionsTree coordinate_type=Y
2814 # OEIS-Other: A020650 planepath=FractionsTree coordinate_type=DiffYX
2815 # OEIS-Other: A020650 planepath=FractionsTree coordinate_type=AbsDiff
2816 # OEIS-Other: A000523 planepath=FractionsTree coordinate_type=Depth
2817  
2818 # Not quite, Sum is from 1/2 value=3 skipping the initial value=2 in
2819 # A086593 which would be 1/1. Also is every second denominator, but
2820 # again no initial value=2.
2821 # Sum => 'A086593',
2822 # Y_odd => 'A086593', # at N=1,3,5,etc
2823 },
2824 };
2825 }
2826 { package Math::PlanePath::CfracDigits;
2827 use constant _NumSeq_Coord_IntXY_max => 0; # upper octant 0 < X/Y < 1
2828 use constant _NumSeq_Coord_IntXY_non_decreasing => 1;
2829 use constant _NumSeq_FracXY_min_is_infimum => 1; # X,Y no common factor
2830  
2831 # X=Y doesn't occur so X,Y always differ by at least 1 bit. The smallest
2832 # two differing by 1 bit are X=1,Y=2.
2833 use constant _NumSeq_Coord_BitOr_min => 3; # X=1,Y=2
2834  
2835 use constant _NumSeq_Coord_BitXor_min => 1; # X=2,Y=3
2836 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
2837  
2838 # use constant _NumSeq_Coord_oeis_anum =>
2839 # { 'radix=2' =>
2840 # {
2841 # },
2842 # };
2843 }
2844 { package Math::PlanePath::ChanTree;
2845  
2846 sub _NumSeq_Coord_Max_min {
2847 my ($self) = @_;
2848 # except in k=2 Calkin-Wilf, point X=1,Y=1 doesn't occur, only X=1,Y=2
2849 # or X=2,Y=1
2850 return ($self->{'k'} == 2 ? 1 : 2);
2851 }
2852 *_NumSeq_Coord_MaxAbs_min = \&_NumSeq_Coord_Max_min;
2853  
2854 use constant _NumSeq_Coord_SubHeight_min => undef;
2855 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => undef;
2856  
2857 sub _NumSeq_Coord_Product_min {
2858 my ($self) = @_;
2859 return ($self->{'reduced'} || $self->{'k'} == 2
2860 ? 1 # X=1,Y=1 reduced or k=2 X=1,Y=1
2861 : 2); # X=1,Y=2
2862 }
2863 sub _NumSeq_Coord_TRSquared_min {
2864 my ($self) = @_;
2865 return ($self->{'k'} == 2
2866 || ($self->{'reduced'} && ($self->{'k'} & 1) == 0)
2867 ? 4 # X=1,Y=1 reduced k even, or k=2 top 1/1
2868 : 7); # X=2,Y=1
2869 }
2870  
2871 use constant _NumSeq_Coord_BitAnd_min => 0; # X=1,Y=2
2872 sub _NumSeq_Coord_BitOr_min {
2873 my ($self) = @_;
2874 return ($self->{'k'} == 2 || $self->{'reduced'} ? 1 # X=1,Y=1
2875 : $self->{'k'} & 1 ? 3 # k odd X=1,Y=2
2876 : 2); # k even X=2,Y=2
2877 }
2878 sub _NumSeq_Coord_BitXor_min {
2879 my ($self) = @_;
2880 return ($self->{'k'} == 2 || $self->{'reduced'} ? 0 # X=1,Y=1
2881 : $self->{'k'} & 1 ? 1 # k odd X=2,Y=3
2882 : 0); # k even X=2,Y=2
2883 }
2884  
2885 sub _NumSeq_Coord_ExperimentalParity_min {
2886 my ($self) = @_;
2887 return ($self->{'k'} % 2
2888 ? 1 # k odd has one odd, one even, so odd
2889 : 0);
2890 }
2891 # X!=Y when k odd
2892 *_NumSeq_Coord_ExperimentalHammingDist_min = \&_NumSeq_Coord_ExperimentalParity_min;
2893  
2894 use constant _NumSeq_Coord_oeis_anum =>
2895 {
2896 do { # k=2 same as CW
2897 my $cw = { Product => 'A070871',
2898 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2899 # OEIS-Other: A070871 planepath=ChanTree,k=2,n_start=1 coordinate_type=Product
2900 # OEIS-Other: A000523 planepath=ChanTree,k=2,n_start=1 coordinate_type=Depth
2901 };
2902 (
2903 'k=2,n_start=1' => $cw,
2904  
2905 # 'k=2,reduced=0,points=even,n_start=1' => $cw,
2906 # 'k=2,reduced=1,points=even,n_start=1' => $cw,
2907 # 'k=2,reduced=0,points=all,n_start=1' => $cw,
2908 # 'k=2,reduced=1,points=all,n_start=1' => $cw,
2909 ),
2910 },
2911 # 'k=3,reduced=0,points=even,n_start=0' =>
2912 'k=3,n_start=0' =>
2913 { X => 'A191379',
2914 # OEIS-Catalogue: A191379 planepath=ChanTree
2915 },
2916 };
2917 }
2918  
2919 { package Math::PlanePath::PeanoCurve;
2920 use constant _NumSeq_Coord_filling_type => 'quadrant';
2921 use constant _NumSeq_Coord_oeis_anum =>
2922 {
2923 # Same in GrayCode and WunderlichSerpentine
2924 'radix=3' =>
2925 { X => 'A163528',
2926 Y => 'A163529',
2927 Sum => 'A163530',
2928 SumAbs => 'A163530',
2929 RSquared => 'A163531',
2930 # OEIS-Catalogue: A163528 planepath=PeanoCurve coordinate_type=X
2931 # OEIS-Catalogue: A163529 planepath=PeanoCurve coordinate_type=Y
2932 # OEIS-Catalogue: A163530 planepath=PeanoCurve coordinate_type=Sum
2933 # OEIS-Other: A163530 planepath=PeanoCurve coordinate_type=SumAbs
2934 # OEIS-Catalogue: A163531 planepath=PeanoCurve coordinate_type=RSquared
2935 },
2936 };
2937 }
2938 { package Math::PlanePath::WunderlichSerpentine;
2939 use constant _NumSeq_Coord_filling_type => 'quadrant';
2940 use constant _NumSeq_Coord_oeis_anum =>
2941 {
2942 do {
2943 my $peano = { X => 'A163528',
2944 Y => 'A163529',
2945 Sum => 'A163530',
2946 SumAbs => 'A163530',
2947 RSquared => 'A163531',
2948 };
2949 # OEIS-Other: A163528 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=X
2950 # OEIS-Other: A163529 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=Y
2951 # OEIS-Other: A163530 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=Sum
2952 # OEIS-Other: A163530 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=SumAbs
2953 # OEIS-Other: A163531 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=RSquared
2954  
2955 # ENHANCE-ME: with serpentine_type by bits too
2956 ('serpentine_type=Peano,radix=3' => $peano,
2957 )
2958 },
2959 };
2960 }
2961 { package Math::PlanePath::HilbertCurve;
2962 use constant _NumSeq_Coord_filling_type => 'quadrant';
2963 use constant _NumSeq_Coord_oeis_anum =>
2964 { '' =>
2965 { X => 'A059253',
2966 Y => 'A059252',
2967 Sum => 'A059261',
2968 SumAbs => 'A059261',
2969 DiffXY => 'A059285',
2970 RSquared => 'A163547',
2971 BitXor => 'A059905', # alternate bits first (ZOrderCurve X)
2972 ExperimentalHammingDist => 'A139351', # count 1-bits at even bit positions
2973 # OEIS-Catalogue: A059253 planepath=HilbertCurve coordinate_type=X
2974 # OEIS-Catalogue: A059252 planepath=HilbertCurve coordinate_type=Y
2975 # OEIS-Catalogue: A059261 planepath=HilbertCurve coordinate_type=Sum
2976 # OEIS-Other: A059261 planepath=HilbertCurve coordinate_type=SumAbs
2977 # OEIS-Catalogue: A059285 planepath=HilbertCurve coordinate_type=DiffXY
2978 # OEIS-Catalogue: A163547 planepath=HilbertCurve coordinate_type=RSquared
2979 # OEIS-Other: A059905 planepath=HilbertCurve coordinate_type=BitXor
2980 # OEIS-Other: A139351 planepath=HilbertCurve coordinate_type=ExperimentalHammingDist
2981 },
2982 };
2983 }
2984 { package Math::PlanePath::HilbertSides;
2985 use constant _NumSeq_Coord_filling_type => 'quadrant';
2986 use constant _NumSeq_Coord_oeis_anum =>
2987 { '' =>
2988 {
2989 # 1 -1
2990 # / /
2991 # 0 3 0 X-Y = 0,1,0,-1
2992 # / | /
2993 # 3---2 -1 2 1
2994 # | / | /
2995 # 0---1 0---1
2996 DiffXY => 'A059285',
2997 # OEIS-Other: A059285 planepath=HilbertSides coordinate_type=DiffXY
2998 },
2999 };
3000 }
3001 { package Math::PlanePath::HilbertSpiral;
3002 use constant _NumSeq_Coord_filling_type => 'plane';
3003 use constant _NumSeq_Coord_oeis_anum =>
3004 { '' =>
3005 {
3006 # HilbertSpiral going negative is mirror on X=-Y line, which is
3007 # (-Y,-X), so DiffXY = -Y-(-X) = X-Y same diff as plain HilbertCurve.
3008 DiffXY => 'A059285',
3009 # OEIS-Other: A059285 planepath=HilbertSpiral coordinate_type=DiffXY
3010 },
3011 };
3012 }
3013 { package Math::PlanePath::ZOrderCurve;
3014 use constant _NumSeq_Coord_filling_type => 'quadrant';
3015 use constant _NumSeq_Coord_oeis_anum =>
3016 { 'radix=2' =>
3017 { X => 'A059905', # alternate bits first
3018 Y => 'A059906', # alternate bits second
3019 # OEIS-Catalogue: A059905 planepath=ZOrderCurve coordinate_type=X
3020 # OEIS-Catalogue: A059906 planepath=ZOrderCurve coordinate_type=Y
3021 },
3022 'radix=3' =>
3023 { X => 'A163325', # alternate ternary digits first
3024 Y => 'A163326', # alternate ternary digits second
3025 # OEIS-Catalogue: A163325 planepath=ZOrderCurve,radix=3 coordinate_type=X
3026 # OEIS-Catalogue: A163326 planepath=ZOrderCurve,radix=3 coordinate_type=Y
3027 },
3028 'radix=10,i_start=1' =>
3029 {
3030 # i_start=1 per A080463 offset=1, it skips initial zero
3031 Sum => 'A080463',
3032 SumAbs => 'A080463',
3033 # OEIS-Catalogue: A080463 planepath=ZOrderCurve,radix=10 coordinate_type=Sum i_start=1
3034 # OEIS-Other: A080463 planepath=ZOrderCurve,radix=10 coordinate_type=SumAbs i_start=1
3035 },
3036 'radix=10,i_start=10' =>
3037 {
3038 # i_start=10 per A080464 OFFSET=10, it skips all but one initial zeros
3039 Product => 'A080464',
3040 # OEIS-Catalogue: A080464 planepath=ZOrderCurve,radix=10 coordinate_type=Product i_start=10
3041  
3042 AbsDiff => 'A080465',
3043 # OEIS-Catalogue: A080465 planepath=ZOrderCurve,radix=10 coordinate_type=AbsDiff i_start=10
3044 },
3045 };
3046 }
3047 { package Math::PlanePath::GrayCode;
3048 use constant _NumSeq_Coord_filling_type => 'quadrant';
3049 use constant _NumSeq_Coord_oeis_anum =>
3050 {
3051 do {
3052 my $peano = { X => 'A163528',
3053 Y => 'A163529',
3054 Sum => 'A163530',
3055 SumAbs => 'A163530',
3056 RSquared => 'A163531',
3057 };
3058 my $z = { BitXor => 'A059905',
3059 };
3060 ('apply_type=TsF,gray_type=reflected,radix=3' => $peano,
3061 'apply_type=FsT,gray_type=reflected,radix=3' => $peano,
3062 # OEIS-Other: A163528 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=X
3063 # OEIS-Other: A163529 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=Y
3064 # OEIS-Other: A163530 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=Sum
3065 # OEIS-Other: A163530 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=SumAbs
3066 # OEIS-Other: A163531 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=RSquared
3067  
3068 # OEIS-Other: A163528 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=X
3069 # OEIS-Other: A163529 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=Y
3070 # OEIS-Other: A163530 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=Sum
3071 # OEIS-Other: A163530 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=SumAbs
3072 # OEIS-Other: A163531 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=RSquared
3073  
3074 'apply_type=TsF,gray_type=reflected,radix=2' => $z,
3075 'apply_type=TsF,gray_type=modular,radix=2' => $z,
3076 'apply_type=Fs,gray_type=reflected,radix=2' => $z,
3077 'apply_type=Fs,gray_type=modular,radix=2' => $z,
3078 # OEIS-Other: A059905 planepath=GrayCode,apply_type=TsF coordinate_type=BitXor
3079 # OEIS-Other: A059905 planepath=GrayCode,apply_type=TsF,gray_type=modular coordinate_type=BitXor
3080 # OEIS-Other: A059905 planepath=GrayCode,apply_type=Fs coordinate_type=BitXor
3081 # OEIS-Other: A059905 planepath=GrayCode,apply_type=Fs,gray_type=modular coordinate_type=BitXor
3082 ),
3083 },
3084 };
3085 }
3086 { package Math::PlanePath::ImaginaryBase;
3087 use constant _NumSeq_Coord_filling_type => 'plane';
3088 }
3089 { package Math::PlanePath::ImaginaryHalf;
3090 use constant _NumSeq_Coord_filling_type => 'half';
3091 }
3092 { package Math::PlanePath::CubicBase;
3093 use constant _NumSeq_Coord_filling_type => 'triangular';
3094 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3095 }
3096 { package Math::PlanePath::Flowsnake;
3097 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3098 }
3099 { package Math::PlanePath::FlowsnakeCentres;
3100 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3101 }
3102 { package Math::PlanePath::GosperIslands;
3103 use constant _NumSeq_Coord_TRSquared_min => 4; # minimum X=1,Y=1
3104 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3105 }
3106 { package Math::PlanePath::GosperReplicate;
3107 use constant _NumSeq_Coord_filling_type => 'triangular';
3108 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3109 }
3110 { package Math::PlanePath::GosperSide;
3111 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3112 }
3113 { package Math::PlanePath::KochCurve;
3114 use constant _NumSeq_Coord_IntXY_min => 3; # at X=3,Y=1 among the Y>0 points
3115 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3116 }
3117 { package Math::PlanePath::KochPeaks;
3118 use constant _NumSeq_Coord_MaxAbs_min => 1; # odd always
3119 use constant _NumSeq_Coord_TRSquared_min => 1; # minimum X=1,Y=0
3120 use constant _NumSeq_Coord_ExperimentalParity_min => 1; # odd always
3121 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
3122 }
3123 { package Math::PlanePath::KochSnowflakes;
3124 use constant _NumSeq_Coord_Y_integer => 0;
3125 use constant _NumSeq_Coord_BitAnd_integer => 1; # only Y non-integer
3126 use constant _NumSeq_Coord_TRSquared_min => 3*4/9; # minimum X=0,Y=2/3
3127 use constant _NumSeq_Coord_MaxAbs_min => 2/3; # at N=3
3128 use constant _NumSeq_Coord_TRadius_min => sqrt(_NumSeq_Coord_TRSquared_min);
3129 use constant _NumSeq_Coord_GCD_integer => 0;
3130 }
3131 { package Math::PlanePath::KochSquareflakes;
3132 use constant _NumSeq_Coord_X_integer => 0;
3133 use constant _NumSeq_Coord_Y_integer => 0;
3134 use constant _NumSeq_Coord_MaxAbs_min => 1/2; # at N=1
3135 use constant _NumSeq_Coord_Sum_integer => 1;
3136 use constant _NumSeq_Coord_SumAbs_integer => 1;
3137 use constant _NumSeq_Coord_DiffXY_integer => 1;
3138 use constant _NumSeq_Coord_DiffYX_integer => 1;
3139 use constant _NumSeq_Coord_AbsDiff_integer => 1;
3140 use constant _NumSeq_Coord_BitXor_integer => 1; # 0.5 xor 0.5 cancels out
3141 use constant _NumSeq_Coord_TRSquared_min => 1; # X=1/2, Y=1/2
3142 use constant _NumSeq_Coord_TRSquared_integer => 1;
3143 use constant _NumSeq_Coord_GCD_integer => 0; # GCD(1/2,1/2)=1/2
3144 }
3145 { package Math::PlanePath::QuadricCurve;
3146 use constant _NumSeq_Coord_IntXY_min => undef; # negatives
3147 }
3148 { package Math::PlanePath::QuadricIslands;
3149 use constant _NumSeq_Coord_X_integer => 0;
3150 use constant _NumSeq_Coord_Y_integer => 0;
3151 use constant _NumSeq_Coord_Sum_integer => 1; # 0.5 + 0.5 = integer
3152 use constant _NumSeq_Coord_SumAbs_integer => 1;
3153 use constant _NumSeq_Coord_DiffXY_integer => 1;
3154 use constant _NumSeq_Coord_DiffYX_integer => 1;
3155 use constant _NumSeq_Coord_AbsDiff_integer => 1;
3156 use constant _NumSeq_Coord_GCD_integer => 0; # GCD(1/2,1/2)=1/2
3157  
3158 # BitXor X=1/2=0.1 Y=-1/2=-0.1=...1111.0 BitXor=0
3159 use constant _NumSeq_Coord_BitXor_integer => 1;
3160  
3161 # TRSquared on X=1/2,Y=1/2 is TR^2 = (1/2)^2+3*(1/2)^2 = 1
3162 use constant _NumSeq_Coord_TRSquared_integer => 1;
3163 use constant _NumSeq_Coord_TRSquared_min => 1; # X=1/2,Y=1/2
3164 }
3165 { package Math::PlanePath::SierpinskiTriangle;
3166 sub _NumSeq_Coord_Y_non_decreasing {
3167 my ($self) = @_;
3168 return ($self->{'align'} ne 'diagonal'); # rows upwards, except diagonal
3169 }
3170 # Max==Y for align!=diagonal
3171 *_NumSeq_Coord_Max_non_decreasing = \&_NumSeq_Coord_Y_non_decreasing;
3172 *_NumSeq_Coord_MaxAbs_non_decreasing = \&_NumSeq_Coord_Y_non_decreasing;
3173  
3174 sub _NumSeq_Coord_Sum_non_decreasing {
3175 my ($self) = @_;
3176 return ($self->{'align'} eq 'diagonal'); # anti-diagonals
3177 }
3178 *_NumSeq_Coord_SumAbs_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3179  
3180 use constant _NumSeq_Coord_IntXY_min => -1; # wedge
3181  
3182 # align=diagonal has X,Y no 1-bits in common, so BitAnd==0
3183 sub _NumSeq_Coord_BitAnd_max {
3184 my ($self) = @_;
3185 return ($self->{'align'} eq 'diagonal' ? 0
3186 : undef);
3187 }
3188 sub _NumSeq_Coord_BitAnd_non_decreasing {
3189 my ($self) = @_;
3190 return ($self->{'align'} eq 'diagonal');
3191 }
3192  
3193 # align=right,diagonal has X,Y BitOr 1-bits accumulating ...
3194 sub _NumSeq_Coord_BitOr_non_decreasing {
3195 my ($self) = @_;
3196 return ($self->{'align'} eq 'right'
3197 || $self->{'align'} eq 'diagonal');
3198 }
3199  
3200 # align=diagonal has X,Y no bits in common so is same as BitOr 1-bits
3201 # accumulating ...
3202 sub _NumSeq_Coord_BitXor_non_decreasing {
3203 my ($self) = @_;
3204 return ($self->{'align'} eq 'diagonal');
3205 }
3206  
3207 sub _NumSeq_Coord_ExperimentalParity_max {
3208 my ($self) = @_;
3209 return ($self->{'align'} eq 'triangular'
3210 ? 0 # triangular always even points
3211 : 1);
3212 }
3213  
3214 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 4;
3215 }
3216 { package Math::PlanePath::SierpinskiArrowhead;
3217 use constant _NumSeq_Coord_IntXY_min => -1; # wedge
3218 *_NumSeq_Coord_ExperimentalParity_max
3219 = \&Math::PlanePath::SierpinskiTriangle::_NumSeq_Coord_ExperimentalParity_max;
3220 }
3221 { package Math::PlanePath::SierpinskiArrowheadCentres;
3222 use constant _NumSeq_Coord_IntXY_min => -1; # wedge
3223 *_NumSeq_Coord_BitAnd_max
3224 = \&Math::PlanePath::SierpinskiTriangle::_NumSeq_Coord_BitAnd_max;
3225 *_NumSeq_Coord_BitAnd_non_decreasing
3226 = \&Math::PlanePath::SierpinskiTriangle::_NumSeq_Coord_BitAnd_non_decreasing;
3227 *_NumSeq_Coord_ExperimentalParity_max
3228 = \&Math::PlanePath::SierpinskiTriangle::_NumSeq_Coord_ExperimentalParity_max;
3229 }
3230 { package Math::PlanePath::SierpinskiCurve;
3231 {
3232 my @Max_min = (undef,
3233 1, # 1 arm, octant X>Y and X>=1
3234 1, # 2 arms, quadrant X>=1 or Y>=1
3235 1, # 3 arms
3236 0, # 4 arms
3237 # more than 3 arm, Max goes negative unbounded
3238 );
3239 sub _NumSeq_Coord_Max_min {
3240 my ($self) = @_;
3241 return $Max_min[$self->arms_count];
3242 }
3243 }
3244 {
3245 my @IntXY_min = (undef,
3246 1, # octant X>Y so X/Y>1
3247 0, # quadrant X>=0 so X/Y>=0
3248 -1, # 3-oct X>=-Y so X/Y>=-1
3249 ); # arms>=4 has X unbounded negative
3250 sub _NumSeq_Coord_IntXY_min {
3251 my ($self) = @_;
3252 return $IntXY_min[$self->arms_count];
3253 }
3254 }
3255  
3256 use constant _NumSeq_Coord_TRSquared_min => 1; # minimum X=1,Y=0
3257 sub _NumSeq_Coord_BitOr_min {
3258 my ($self) = @_;
3259 return ($self->arms_count <= 2
3260 ? 1 # X=0,Y=0 not visited BitOr(X,Y)>=1
3261 : undef); # going X negative
3262 }
3263 sub _NumSeq_Coord_BitXor_min {
3264 my ($self) = @_;
3265 return ($self->arms_count <= 2
3266 ? 1 # X!=Y so BitXor(X,Y)>=1
3267 : undef); # going X negative
3268 }
3269 }
3270 { package Math::PlanePath::SierpinskiCurveStair;
3271 use constant _NumSeq_Coord_Max_min => 1;
3272 *_NumSeq_Coord_IntXY_min = \&Math::PlanePath::SierpinskiCurve::_NumSeq_Coord_IntXY_min;
3273 *_NumSeq_Coord_BitOr_min = \&Math::PlanePath::SierpinskiCurve::_NumSeq_Coord_BitOr_min;
3274 *_NumSeq_Coord_BitXor_min = \&Math::PlanePath::SierpinskiCurve::_NumSeq_Coord_BitXor_min;
3275 use constant _NumSeq_Coord_TRSquared_min => 1; # minimum X=1,Y=0
3276 }
3277 { package Math::PlanePath::HIndexing;
3278 use constant _NumSeq_Coord_filling_type => 'quadrant';
3279 # # except 0/0=inf
3280 # # use constant _NumSeq_Coord_IntXY_max => 1; # upper octant X<=Y so X/Y<=1
3281 }
3282 { package Math::PlanePath::DragonCurve;
3283 use constant _NumSeq_Coord_n_list_max => 2;
3284  
3285 # 4-arm plane filling if full grid
3286 sub _NumSeq_Coord_ExperimentalNeighbours4_min {
3287 my ($self) = @_;
3288 return $self->arms_count == 4 ? 4 : 2;
3289 }
3290 # use constant _NumSeq_Coord_ExperimentalNeighbours6_min => 0; # ???
3291 sub _NumSeq_Coord_ExperimentalNeighbours8_min {
3292 my ($self) = @_;
3293 return $self->arms_count == 4 ? 8 : 3;
3294 }
3295 }
3296 { package Math::PlanePath::DragonRounded;
3297 use constant _NumSeq_Coord_TRSquared_min => 1; # minimum X=1,Y=0
3298 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
3299 use constant _NumSeq_Coord_MaxAbs_min => 1; # X!=Y
3300 }
3301 # { package Math::PlanePath::DragonMidpoint;
3302 # }
3303 { package Math::PlanePath::AlternatePaper;
3304 use constant _NumSeq_Coord_n_list_max => 2;
3305 {
3306 my @_NumSeq_Coord_IntXY_min = (undef,
3307 1, # 1 arm, octant X+Y>=0
3308 0, # 2 arms, X>=0
3309 0, # 3 arms, X>-Y so X/Y>-1
3310 ); # more than 3 arm, X neg axis so undef
3311 sub _NumSeq_Coord_IntXY_min {
3312 my ($self) = @_;
3313 return $_NumSeq_Coord_IntXY_min[$self->arms_count];
3314 }
3315 }
3316  
3317 # 8-arm plane filling if full grid
3318 {
3319 # arms 1 2 3 4 5 6 7 8
3320 my @_NumSeq_Coord_ExperimentalNeighbours3_min = (undef, 1,1,2,2,3,3,3,3);
3321 sub _NumSeq_Coord_ExperimentalNeighbours3_min {
3322 my ($self) = @_;
3323 return $_NumSeq_Coord_ExperimentalNeighbours3_min[$self->arms_count];
3324 }
3325 }
3326 {
3327 # arms 1 2 3 4 5 6 7 8
3328 my @_NumSeq_Coord_ExperimentalNeighbours4_min = (undef, 1,2,2,3,3,3,3,4);
3329 sub _NumSeq_Coord_ExperimentalNeighbours4_min {
3330 my ($self) = @_;
3331 return $_NumSeq_Coord_ExperimentalNeighbours4_min[$self->arms_count];
3332 }
3333 }
3334 # use constant _NumSeq_Coord_ExperimentalNeighbours6_min => 0; # ???
3335 {
3336 # arms 1 2 3 4 5 6 7 8
3337 my @_NumSeq_Coord_ExperimentalNeighbours8_min = (undef, 2,3,4,5,6,7,7,8);
3338 sub _NumSeq_Coord_ExperimentalNeighbours8_min {
3339 my ($self) = @_;
3340 return $_NumSeq_Coord_ExperimentalNeighbours8_min[$self->arms_count];
3341 }
3342 }
3343  
3344 use constant _NumSeq_Coord_oeis_anum =>
3345 { 'i_start=1' =>
3346 { DiffXY => 'A020990', # GRS*(-1)^n cumulative
3347 AbsDiff => 'A020990',
3348  
3349 # Not quite Sum, OFFSET=0 value=1 corresponds to N=1 Sum=1, so
3350 # A020986 doesn't have N=0 Sum=0.
3351 # Sum => 'A020986', # GRS cumulative
3352 # # OEIS-Catalogue: A020986 planepath=AlternatePaper coordinate_type=Sum i_start=1
3353  
3354 # X_undoubled => 'A020986', # GRS cumulative
3355 # Y_undoubled => 'A020990', # GRS*(-1)^n cumulative
3356 },
3357 };
3358 }
3359 { package Math::PlanePath::AlternatePaperMidpoint;
3360 {
3361 my @_NumSeq_Coord_IntXY_min = (undef,
3362 1, # 1 arm, octant X+Y>=0
3363 0, # 2 arms, X>=0
3364 0, # 3 arms, X>-Y so X/Y>-1
3365 ); # more than 3 arm, X neg axis so undef
3366 sub _NumSeq_Coord_IntXY_min {
3367 my ($self) = @_;
3368 return $_NumSeq_Coord_IntXY_min[$self->arms_count];
3369 }
3370 }
3371 }
3372 { package Math::PlanePath::TerdragonCurve;
3373 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3374 use constant _NumSeq_Coord_n_list_max => 3;
3375 }
3376 { package Math::PlanePath::TerdragonRounded;
3377 use constant _NumSeq_Coord_TRSquared_min => 4; # either X=2,Y=0 or X=1,Y=1
3378 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3379 }
3380 { package Math::PlanePath::TerdragonMidpoint;
3381 use constant _NumSeq_Coord_TRSquared_min => 4; # either X=2,Y=0 or X=1,Y=1
3382 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3383 }
3384 { package Math::PlanePath::AlternateTerdragon;
3385 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3386 use constant _NumSeq_Coord_n_list_max => 3;
3387 }
3388 { package Math::PlanePath::R5DragonCurve;
3389 use constant _NumSeq_Coord_n_list_max => 2;
3390 }
3391 # { package Math::PlanePath::R5DragonMidpoint;
3392 # }
3393 { package Math::PlanePath::CCurve;
3394 use constant _NumSeq_Coord_n_list_max => 4;
3395 }
3396 # { package Math::PlanePath::ComplexPlus;
3397 # Sum X+Y < 0 at N=16
3398 # use constant _NumSeq_Coord_oeis_anum =>
3399 # { 'realpart=1,arms=1' =>
3400 # {
3401 # # not quite, OFFSET=1 but start N=0 here
3402 # # NegX => 'A290885',
3403 # # Y => 'A290884',
3404 # # RSquared => 'A290886',
3405 # # OEIS-Catalogue: A290884 planepath=ComplexPlus coordinate_type=Y
3406 # # OEIS-Catalogue: A290886 planepath=ComplexPlus coordinate_type=RSquared
3407 # },
3408 # };
3409 # }
3410 { package Math::PlanePath::ComplexMinus;
3411 use constant _NumSeq_Coord_filling_type => 'plane';
3412 use constant _NumSeq_Coord_oeis_anum =>
3413 { 'realpart=1' =>
3414 {X => 'A318438',
3415 Y => 'A318439',
3416 RSquared => 'A318479',
3417 # OEIS-Catalogue: A318438 planepath=ComplexMinus coordinate_type=X
3418 # OEIS-Catalogue: A318439 planepath=ComplexMinus coordinate_type=Y
3419 # OEIS-Catalogue: A318479 planepath=ComplexMinus coordinate_type=RSquared
3420 },
3421 };
3422 }
3423 { package Math::PlanePath::ComplexRevolving;
3424 use constant _NumSeq_Coord_filling_type => 'plane';
3425 }
3426 { package Math::PlanePath::Rows;
3427 use constant _NumSeq_extra_parameter_info_list =>
3428 { name => 'width',
3429 type => 'integer',
3430 };
3431  
3432 *_NumSeq_Coord_X_non_decreasing = \&_NumSeq_Coord_Y_increasing;
3433  
3434 sub _NumSeq_Coord_Y_increasing {
3435 my ($self) = @_;
3436 return ($self->{'width'} == 1
3437 ? 1 # X=N,Y=0 only
3438 : 0);
3439 }
3440  
3441 sub _NumSeq_Coord_Min_max { $_[0]->x_maximum }
3442 *_NumSeq_Coord_Max_increasing=\&_NumSeq_Coord_Y_increasing; # height=1 Max=Y
3443 sub _NumSeq_Coord_Max_non_decreasing {
3444 my ($self) = @_;
3445 return ($self->{'width'} <= 2);
3446 }
3447  
3448 sub _NumSeq_Coord_Sum_non_decreasing {
3449 my ($self) = @_;
3450 return ($self->{'width'} <= 2
3451 ? 1 # width=1 is X=0,Y=N only, or width=2 is X=0,1,Y=N/2
3452 : 0);
3453 }
3454 *_NumSeq_Coord_Sum_increasing = \&_NumSeq_Coord_Y_increasing;
3455  
3456 *_NumSeq_Coord_SumAbs_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3457 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Y_increasing;
3458  
3459 *_NumSeq_Coord_DiffYX_increasing = \&_NumSeq_Coord_Y_increasing;
3460  
3461 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_Y_increasing;
3462  
3463 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_Y_increasing;
3464  
3465 sub _NumSeq_Coord_BitAnd_max {
3466 my ($self) = @_;
3467 return $self->{'width'}-1; # at X=Y=width-1
3468 }
3469 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_Y_increasing;
3470  
3471 *_NumSeq_Coord_BitOr_increasing = \&_NumSeq_Coord_Y_increasing;
3472 *_NumSeq_Coord_BitXor_increasing = \&_NumSeq_Coord_Y_increasing;
3473  
3474 *_NumSeq_Coord_Radius_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3475 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Y_increasing;
3476 *_NumSeq_Coord_Radius_integer = \&_NumSeq_Coord_Y_increasing;
3477  
3478 *_NumSeq_Coord_GCD_increasing = \&_NumSeq_Coord_Y_increasing;
3479  
3480 # width <= 2 one or two columns is increasing
3481 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Sum_non_decreasing;
3482  
3483 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
3484  
3485 use constant _NumSeq_Coord_oeis_anum =>
3486 { 'n_start=1,width=1' =>
3487 { Product => 'A000004', # all zeros
3488 # OEIS-Other: A000004 planepath=Rows,width=1 coordinate_type=Product
3489  
3490 # OFFSET
3491 # Y => 'A001477', # integers 0 upwards
3492 # Sum => 'A001477', # integers 0 upwards
3493 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=Y
3494 # DiffXY => 'A001489', # negative integers 0 downwards
3495 # DiffYX => 'A001477', # integers 0 upwards
3496 # AbsDiff => 'A001477', # integers 0 upwards
3497 # Radius => 'A001477', # integers 0 upwards
3498 # RSquared => 'A000290', # squares 0 upwards
3499 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=Sum
3500 # # OEIS-Other: A001489 planepath=Rows,width=1 coordinate_type=DiffXY
3501 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=DiffYX
3502 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=AbsDiff
3503 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=Radius
3504 # # OEIS-Other: A000290 planepath=Rows,width=1 coordinate_type=RSquared
3505 },
3506  
3507 'n_start=0,width=2' =>
3508 { X => 'A000035', # 0,1 repeating OFFSET=0
3509 Y => 'A004526', # 0,0,1,1,2,2,etc cf Math::NumSeq::Runs
3510 # OEIS-Other: A000035 planepath=Rows,width=2,n_start=0 coordinate_type=X
3511 # OEIS-Other: A004526 planepath=Rows,width=2,n_start=0 coordinate_type=Y
3512  
3513 # # Not quite, A142150 OFFSET=0 starting 0,0,1,0,2 interleave integers
3514 # # and 0 but Product here extra 0 start 0,0,0,1,0,2,0
3515 # # Product => 'A142150'
3516 #
3517 # # Not quite, GCD=>'A057979' but A057979 extra initial 1
3518 },
3519 };
3520 }
3521 { package Math::PlanePath::Columns;
3522 use constant _NumSeq_extra_parameter_info_list =>
3523 { name => 'height',
3524 type => 'integer',
3525 };
3526  
3527 sub _NumSeq_Coord_X_increasing {
3528 my ($self) = @_;
3529 return ($self->{'height'} == 1
3530 ? 1 # X=N,Y=0 only
3531 : 0);
3532 }
3533 use constant _NumSeq_Coord_X_non_decreasing => 1; # columns across
3534  
3535 *_NumSeq_Coord_Y_non_decreasing = \&_NumSeq_Coord_X_increasing;
3536  
3537 sub _NumSeq_Coord_Min_max { $_[0]->y_maximum }
3538 *_NumSeq_Coord_Max_increasing=\&_NumSeq_Coord_X_increasing; # height=1 Max=X
3539 sub _NumSeq_Coord_Max_non_decreasing {
3540 my ($self) = @_;
3541 return ($self->{'height'} <= 2);
3542 }
3543  
3544 *_NumSeq_Coord_Sum_increasing = \&_NumSeq_Coord_X_increasing;
3545 sub _NumSeq_Coord_Sum_non_decreasing {
3546 my ($self) = @_;
3547 return ($self->{'height'} <= 2
3548 ? 1 # height=1 is X=N,Y=0 only, or height=2 is X=N/2,Y=0,1
3549 : 0);
3550 }
3551  
3552 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_X_increasing;
3553 *_NumSeq_Coord_SumAbs_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3554  
3555 *_NumSeq_Coord_DiffXY_increasing = \&_NumSeq_Coord_X_increasing;
3556 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_X_increasing;
3557  
3558 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_X_increasing;
3559 *_NumSeq_Coord_Radius_integer = \&_NumSeq_Coord_X_increasing;
3560 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_X_increasing;
3561 *_NumSeq_Coord_TRadius_integer = \&_NumSeq_Coord_X_increasing;
3562  
3563 sub _NumSeq_Coord_BitAnd_max {
3564 my ($self) = @_;
3565 return $self->{'height'}-1; # at X=Y=height-1
3566 }
3567 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_X_increasing;
3568  
3569 *_NumSeq_Coord_BitOr_increasing = \&_NumSeq_Coord_X_increasing;
3570 *_NumSeq_Coord_BitXor_increasing = \&_NumSeq_Coord_X_increasing;
3571 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_X_increasing;
3572 *_NumSeq_Coord_GCD_increasing = \&_NumSeq_Coord_X_increasing;
3573  
3574 *_NumSeq_Coord_Radius_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3575  
3576 use constant _NumSeq_Coord_oeis_anum =>
3577 { 'n_start=1,height=1' =>
3578 { Product => 'A000004', # all zeros
3579 # OEIS-Other: A000004 planepath=Columns,height=1 coordinate_type=Product
3580  
3581 # OFFSET
3582 # X => 'A001477', # integers 0 upwards
3583 # Sum => 'A001477', # integers 0 upwards
3584 # DiffXY => 'A001477', # integers 0 upwards
3585 # DiffYX => 'A001489', # negative integers 0 downwards
3586 # AbsDiff => 'A001477', # integers 0 upwards
3587 # Radius => 'A001477', # integers 0 upwards
3588 # RSquared => 'A000290', # squares 0 upwards
3589 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=X
3590 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=Sum
3591 # # OEIS-Other: A001489 planepath=Columns,height=1 coordinate_type=DiffYX
3592 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=DiffXY
3593 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=AbsDiff
3594 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=Radius
3595 # # OEIS-Other: A000290 planepath=Columns,height=1 coordinate_type=RSquared
3596 },
3597  
3598 'n_start=0,height=2' =>
3599 { X => 'A004526', # 0,0,1,1,2,2,etc, as per Math::NumSeq::Runs 2rep
3600 Y => 'A000035', # 0,1 repeating OFFSET=0
3601 # OEIS-Other: A004526 planepath=Columns,height=2,n_start=0 coordinate_type=X
3602 # OEIS-Other: A000035 planepath=Columns,height=2,n_start=0 coordinate_type=Y
3603 },
3604 };
3605 }
3606 { package Math::PlanePath::Diagonals;
3607 use constant _NumSeq_Coord_filling_type => 'quadrant';
3608 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # X+Y diagonals
3609  
3610 sub _NumSeq_Coord_SumAbs_non_decreasing {
3611 my ($self) = @_;
3612 return ($self->{'x_start'} >= 0 && $self->{'y_start'} >= 0);
3613 }
3614  
3615 # these irrespective where x_start,y_start make x_minimum(),y_minimum()
3616 use constant _NumSeq_Coord_BitAnd_min => 0; # when all diff bits
3617 use constant _NumSeq_Coord_BitXor_min => 0; # when X=Y
3618  
3619 use constant _NumSeq_Coord_oeis_anum =>
3620 {
3621 'direction=down,n_start=1,x_start=0,y_start=0' =>
3622 { ExperimentalPairsXY => 'A057554', # starting OFFSET=1 so the default n_start=1 here
3623 # OEIS-Catalogue: A057554 planepath=Diagonals coordinate_type=ExperimentalPairsXY
3624 },
3625 'direction=up,n_start=1,x_start=0,y_start=0' =>
3626 { ExperimentalPairsYX => 'A057554', # starting OFFSET=1 so the default n_start=1 here
3627 # OEIS-Other: A057554 planepath=Diagonals,direction=up coordinate_type=ExperimentalPairsYX
3628 },
3629  
3630 'direction=down,n_start=1,x_start=1,y_start=0' =>
3631 { ExperimentalNumerator => 'A164306', # T(n,k) = k/GCD(n,k) n,k>=1 offset=1
3632 ExperimentalDenominator => 'A167192', # T(n,k) = (n-k)/GCD(n,k) n,k>=1 offset=1
3633 # OEIS-Catalogue: A164306 planepath=Diagonals,x_start=1,y_start=0 coordinate_type=ExperimentalNumerator
3634 # OEIS-Catalogue: A167192 planepath=Diagonals,x_start=1,y_start=0 coordinate_type=ExperimentalDenominator
3635 },
3636  
3637 'direction=down,n_start=1,x_start=1,y_start=1' =>
3638 { Product => 'A003991', # X*Y starting (1,1) n=1
3639 GCD => 'A003989', # GCD by diagonals starting (1,1) n=1
3640 Min => 'A003983', # X,Y>=1
3641 MinAbs => 'A003983', # MinAbs=Min
3642 Max => 'A051125', # X,Y>=1
3643 MaxAbs => 'A051125', # MaxAbs=Max
3644 IntXY => 'A004199', # X>=0,Y>=0, X/Y round towards zero
3645 ExperimentalPairsXY => 'A057555', # starting OFFSET=1 so n_start=1 here
3646 # OEIS-Catalogue: A003991 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=Product
3647 # OEIS-Catalogue: A003989 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=GCD
3648 # OEIS-Catalogue: A003983 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=Min
3649 # OEIS-Other: A003983 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=MinAbs
3650 # OEIS-Catalogue: A051125 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=Max
3651 # OEIS-Other: A051125 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=MaxAbs
3652 # OEIS-Catalogue: A004199 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=IntXY
3653 # OEIS-Catalogue: A057555 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=ExperimentalPairsXY
3654  
3655 # cf A003990 LCM starting (1,1) n=1
3656 # A003992 X^Y power starting (1,1) n=1
3657 },
3658  
3659 'direction=up,n_start=1,x_start=1,y_start=1' =>
3660 { Product => 'A003991', # X*Y starting (1,1) n=1
3661 GCD => 'A003989', # GCD by diagonals starting (1,1) n=1
3662 IntXY => 'A003988', # Int(X/Y) starting (1,1) n=1
3663 ExperimentalPairsYX => 'A057555', # starting OFFSET=1 so n_start=1 here
3664 # OEIS-Other: A003991 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=Product
3665 # OEIS-Other: A003989 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=GCD
3666 # OEIS-Catalogue: A003988 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=IntXY
3667 # OEIS-Other: A057555 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=ExperimentalPairsYX
3668  
3669 # num,den of reduction of A004736/A002260 which is run1toK/runKto1.
3670 ExperimentalNumerator => 'A112543', # 1,2,1,3,1,1,4,3,2,1,5,2,1,1,1,6,
3671 ExperimentalDenominator => 'A112544', # 1,1,2,1,1,3,1,2,3,4,1,1,1,2,5,1,
3672 # OEIS-Catalogue: A112543 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=ExperimentalNumerator
3673 # OEIS-Catalogue: A112544 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=ExperimentalDenominator
3674 },
3675  
3676 #------------------
3677 # n_start=0 instead
3678  
3679 'direction=down,n_start=0,x_start=0,y_start=0' =>
3680 { X => 'A002262', # runs 0toN 0, 0,1, 0,1,2, etc
3681 Y => 'A025581', # runs Nto0 0, 1,0, 2,1,0, 3,2,1,0 descend
3682 Sum => 'A003056', # 0, 1,1, 2,2,2, 3,3,3,3
3683 SumAbs => 'A003056', # same
3684 Product => 'A004247', # 0, 0,0,0, 1, 0,0, 2,2, 0,0, 3,4,5, 0,0
3685 DiffYX => 'A114327', # Y-X by anti-diagonals
3686 AbsDiff => 'A049581', # abs(Y-X) by anti-diagonals
3687 RSquared => 'A048147', # x^2+y^2 by diagonals
3688 BitAnd => 'A004198', # X bitand Y
3689 BitOr => 'A003986', # X bitor Y, cf A006583 diagonal totals
3690 BitXor => 'A003987', # cf A006582 X xor Y diagonal totals
3691 GCD => 'A109004', # GCD(x,y) by diagonals, (0,0) at n=0
3692 Min => 'A004197', # X,Y>=0, runs 0toNto0,0toNNto0
3693 MinAbs => 'A004197', # MinAbs=Min
3694 Max => 'A003984',
3695 MaxAbs => 'A003984', # MaxAbs=Max
3696 ExperimentalHammingDist => 'A101080',
3697 # OEIS-Other: A002262 planepath=Diagonals,n_start=0 coordinate_type=X
3698 # OEIS-Other: A025581 planepath=Diagonals,n_start=0 coordinate_type=Y
3699 # OEIS-Other: A003056 planepath=Diagonals,n_start=0 coordinate_type=Sum
3700 # OEIS-Other: A003056 planepath=Diagonals,n_start=0 coordinate_type=SumAbs
3701 # OEIS-Catalogue: A004247 planepath=Diagonals,n_start=0 coordinate_type=Product
3702 # OEIS-Catalogue: A114327 planepath=Diagonals,n_start=0 coordinate_type=DiffYX
3703 # OEIS-Catalogue: A049581 planepath=Diagonals,n_start=0 coordinate_type=AbsDiff
3704 # OEIS-Catalogue: A048147 planepath=Diagonals,n_start=0 coordinate_type=RSquared
3705 # OEIS-Catalogue: A004198 planepath=Diagonals,n_start=0 coordinate_type=BitAnd
3706 # OEIS-Catalogue: A003986 planepath=Diagonals,n_start=0 coordinate_type=BitOr
3707 # OEIS-Catalogue: A003987 planepath=Diagonals,n_start=0 coordinate_type=BitXor
3708 # OEIS-Catalogue: A109004 planepath=Diagonals,n_start=0 coordinate_type=GCD
3709 # OEIS-Catalogue: A004197 planepath=Diagonals,n_start=0 coordinate_type=Min
3710 # OEIS-Other: A004197 planepath=Diagonals,n_start=0 coordinate_type=MinAbs
3711 # OEIS-Catalogue: A003984 planepath=Diagonals,n_start=0 coordinate_type=Max
3712 # OEIS-Other: A003984 planepath=Diagonals,n_start=0 coordinate_type=MaxAbs
3713 # OEIS-Catalogue: A101080 planepath=Diagonals,n_start=0 coordinate_type=ExperimentalHammingDist
3714 },
3715 'direction=up,n_start=0,x_start=0,y_start=0' =>
3716 { X => 'A025581', # \ opposite of direction="down"
3717 Y => 'A002262', # /
3718 Sum => 'A003056', # \
3719 SumAbs => 'A003056', # | same as direction="down'
3720 Product => 'A004247', # |
3721 AbsDiff => 'A049581', # |
3722 RSquared => 'A048147', # /
3723 DiffXY => 'A114327', # transposed from direction="down"
3724 BitAnd => 'A004198', # X bitand Y
3725 BitOr => 'A003986', # X bitor Y, cf A006583 diagonal totals
3726 BitXor => 'A003987', # cf A006582 X xor Y diagonal totals
3727 GCD => 'A109004', # GCD(x,y) by diagonals, (0,0) at n=0
3728 ExperimentalHammingDist => 'A101080',
3729 # OEIS-Other: A025581 planepath=Diagonals,direction=up,n_start=0 coordinate_type=X
3730 # OEIS-Other: A002262 planepath=Diagonals,direction=up,n_start=0 coordinate_type=Y
3731 # OEIS-Other: A003056 planepath=Diagonals,direction=up,n_start=0 coordinate_type=Sum
3732 # OEIS-Other: A003056 planepath=Diagonals,direction=up,n_start=0 coordinate_type=SumAbs
3733 # OEIS-Other: A004247 planepath=Diagonals,direction=up,n_start=0 coordinate_type=Product
3734 # OEIS-Other: A114327 planepath=Diagonals,direction=up,n_start=0 coordinate_type=DiffXY
3735 # OEIS-Other: A049581 planepath=Diagonals,direction=up,n_start=0 coordinate_type=AbsDiff
3736 # OEIS-Other: A048147 planepath=Diagonals,direction=up,n_start=0 coordinate_type=RSquared
3737 # OEIS-Other: A004198 planepath=Diagonals,direction=up,n_start=0 coordinate_type=BitAnd
3738 # OEIS-Other: A003986 planepath=Diagonals,direction=up,n_start=0 coordinate_type=BitOr
3739 # OEIS-Other: A003987 planepath=Diagonals,direction=up,n_start=0 coordinate_type=BitXor
3740 # OEIS-Other: A109004 planepath=Diagonals,direction=up,n_start=0 coordinate_type=GCD
3741 # OEIS-Other: A101080 planepath=Diagonals,direction=up,n_start=0 coordinate_type=ExperimentalHammingDist
3742 },
3743  
3744 };
3745 }
3746 { package Math::PlanePath::DiagonalsAlternating;
3747 use constant _NumSeq_Coord_filling_type => 'quadrant';
3748 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # X+Y diagonals
3749 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1; # X+Y diagonals
3750  
3751 use constant _NumSeq_Coord_oeis_anum =>
3752 { 'n_start=0' =>
3753 { Sum => 'A003056', # 0, 1,1, 2,2,2, 3,3,3,3
3754 SumAbs => 'A003056', # same
3755 Product => 'A004247', # 0, 0,0,0, 1, 0,0, 2,2, 0,0, 3,4,5, 0,0
3756 AbsDiff => 'A049581', # abs(Y-X) by anti-diagonals
3757 RSquared => 'A048147', # x^2+y^2 by diagonals
3758 BitAnd => 'A004198', # X bitand Y
3759 BitOr => 'A003986', # X bitor Y, cf A006583 diagonal totals
3760 BitXor => 'A003987', # cf A006582 X xor Y diagonal totals
3761 Min => 'A004197', # runs 0toNto0,0toNNto0
3762 MinAbs => 'A004197', # MinAbs=Min
3763 Max => 'A003984',
3764 MaxAbs => 'A003984', # MaxAbs=Max
3765 ExperimentalHammingDist => 'A101080',
3766 # OEIS-Other: A003056 planepath=DiagonalsAlternating,n_start=0 coordinate_type=Sum
3767 # OEIS-Other: A003056 planepath=DiagonalsAlternating,n_start=0 coordinate_type=SumAbs
3768 # OEIS-Other: A004247 planepath=DiagonalsAlternating,n_start=0 coordinate_type=Product
3769 # OEIS-Other: A049581 planepath=DiagonalsAlternating,n_start=0 coordinate_type=AbsDiff
3770 # OEIS-Other: A048147 planepath=DiagonalsAlternating,n_start=0 coordinate_type=RSquared
3771 # OEIS-Other: A004198 planepath=DiagonalsAlternating,n_start=0 coordinate_type=BitAnd
3772 # OEIS-Other: A003986 planepath=DiagonalsAlternating,n_start=0 coordinate_type=BitOr
3773 # OEIS-Other: A003987 planepath=DiagonalsAlternating,n_start=0 coordinate_type=BitXor
3774 # OEIS-Other: A004197 planepath=DiagonalsAlternating,n_start=0 coordinate_type=Min
3775 # OEIS-Other: A004197 planepath=DiagonalsAlternating,n_start=0 coordinate_type=MinAbs
3776 # OEIS-Other: A003984 planepath=DiagonalsAlternating,n_start=0 coordinate_type=Max
3777 # OEIS-Other: A003984 planepath=DiagonalsAlternating,n_start=0 coordinate_type=MaxAbs
3778 # OEIS-Other: A101080 planepath=DiagonalsAlternating,n_start=0 coordinate_type=ExperimentalHammingDist
3779 },
3780 };
3781 }
3782 { package Math::PlanePath::DiagonalsOctant;
3783 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # X+Y diagonals
3784 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1; # X+Y diagonals
3785  
3786 use constant _NumSeq_Coord_oeis_anum =>
3787 { 'direction=down,n_start=0' =>
3788 { X => 'A055087', # 0, 0,1, 0,1, 0,1,2, 0,1,2, etc
3789 Min => 'A055087', # X<=Y so Min=X
3790 MinAbs => 'A055087', # MinAbs=Min
3791 Sum => 'A055086', # reps floor(n/2)+1
3792 SumAbs => 'A055086', # same
3793 DiffYX => 'A082375', # step=2 k to 0
3794 # OEIS-Catalogue: A055087 planepath=DiagonalsOctant,n_start=0 coordinate_type=X
3795 # OEIS-Other: A055087 planepath=DiagonalsOctant,n_start=0 coordinate_type=Min
3796 # OEIS-Other: A055087 planepath=DiagonalsOctant,n_start=0 coordinate_type=MinAbs
3797 # OEIS-Catalogue: A055086 planepath=DiagonalsOctant,n_start=0 coordinate_type=Sum
3798 # OEIS-Other: A055086 planepath=DiagonalsOctant,n_start=0 coordinate_type=SumAbs
3799 # OEIS-Catalogue: A082375 planepath=DiagonalsOctant,n_start=0 coordinate_type=DiffYX
3800 },
3801 'direction=up,n_start=0' =>
3802 { Sum => 'A055086', # reps floor(n/2)+1
3803 SumAbs => 'A055086', # same
3804 # OEIS-Other: A055086 planepath=DiagonalsOctant,direction=up,n_start=0 coordinate_type=Sum
3805 # OEIS-Other: A055086 planepath=DiagonalsOctant,direction=up,n_start=0 coordinate_type=SumAbs
3806 },
3807 };
3808 }
3809 { package Math::PlanePath::MPeaks;
3810 use constant _NumSeq_Coord_filling_type => 'half';
3811 }
3812 { package Math::PlanePath::Staircase;
3813 use constant _NumSeq_Coord_filling_type => 'quadrant';
3814 }
3815 # { package Math::PlanePath::StaircaseAlternating;
3816 # }
3817 { package Math::PlanePath::Corner;
3818 use constant _NumSeq_Coord_filling_type => 'quadrant';
3819 sub _NumSeq_Coord_Max_non_decreasing {
3820 my ($self) = @_;
3821 # non-decreasing when wider=0 or 1
3822 return ($self->{'wider'} <= 1);
3823 }
3824 use constant _NumSeq_Coord_oeis_anum =>
3825 { 'wider=0,n_start=1' =>
3826 { Sum => 'A213088', # Manhattan X+Y
3827 SumAbs => 'A213088',
3828 # OEIS-Catalogue: A213088 planepath=Corner coordinate_type=Sum
3829 # OEIS-Other: A213088 planepath=Corner coordinate_type=SumAbs
3830 },
3831 'wider=0,n_start=0' =>
3832 { DiffXY => 'A196199', # runs -n to n
3833 AbsDiff => 'A053615', # runs n..0..n
3834 Max => 'A000196', # n repeated 2n+1 times, floor(sqrt(N))
3835 MaxAbs => 'A000196', # MaxAbs=Max
3836 # OEIS-Other: A196199 planepath=Corner,n_start=0 coordinate_type=DiffXY
3837 # OEIS-Other: A053615 planepath=Corner,n_start=0 coordinate_type=AbsDiff
3838 # OEIS-Other: A000196 planepath=Corner,n_start=0 coordinate_type=Max
3839 # OEIS-Other: A000196 planepath=Corner,n_start=0 coordinate_type=MaxAbs
3840  
3841 # Not quite, A053188 has extra initial 0
3842 # AbsDiff => 'A053188', # distance to nearest square
3843 },
3844 };
3845 }
3846 { package Math::PlanePath::PyramidRows;
3847  
3848 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_Y_increasing;
3849  
3850 # Max==Y and Y is non-decreasing when
3851 # step=0 align=any
3852 # step=1 align=any
3853 # step=2 align=left or centre
3854 # step>2 align=left
3855 sub _NumSeq_Coord_Max_non_decreasing {
3856 my ($self) = @_;
3857 return ($self->{'step'} <= 1
3858 || ($self->{'step'} == 2 && $self->{'align'} eq 'centre')
3859 || $self->{'align'} eq 'left');
3860 }
3861  
3862 sub _NumSeq_Coord_MaxAbs_non_decreasing {
3863 my ($self) = @_;
3864 return ($self->{'step'} <= 1
3865 || ($self->{'step'} == 2 && $self->{'align'} eq 'centre'));
3866 }
3867  
3868 *_NumSeq_Coord_Sum_increasing = \&_NumSeq_Coord_Y_increasing;
3869 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Y_increasing;
3870  
3871 sub _NumSeq_Coord_IntXY_min {
3872 my ($self) = @_;
3873 return ($self->{'align'} eq 'left' ? - $self->{'step'}
3874 : $self->{'align'} eq 'centre' ? - int($self->{'step'}/2)
3875 : 0); # right
3876 }
3877  
3878 sub _NumSeq_Coord_FracXY_max {
3879 my ($self) = @_;
3880 return ($self->{'step'} == 0 ? 0 : 1); # step=0 X=0 frac=0 always
3881 }
3882 *_NumSeq_FracXY_max_is_supremum = \&_NumSeq_Coord_FracXY_max;
3883 sub _NumSeq_Coord_FracXY_integer {
3884 my ($self) = @_;
3885 return ($self->{'step'} == 0 ? 1 : 0); # step=0 X=0 frac=0 always
3886 }
3887  
3888 sub _NumSeq_Coord_Radius_integer {
3889 my ($self) = @_;
3890 return ($self->{'step'} == 0);
3891 }
3892  
3893 sub _NumSeq_Coord_Y_increasing {
3894 my ($self) = @_;
3895 return ($self->{'step'} == 0
3896 ? 1 # column X=0,Y=N
3897 : 0);
3898 }
3899 *_NumSeq_Coord_DiffYX_increasing = \&_NumSeq_Coord_Y_increasing;
3900 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_Y_increasing;
3901 *_NumSeq_Coord_Max_increasing = \&_NumSeq_Coord_Y_increasing;
3902 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Y_increasing;
3903 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Y_increasing;
3904 *_NumSeq_Coord_BitOr_increasing = \&_NumSeq_Coord_Y_increasing;
3905 *_NumSeq_Coord_BitXor_increasing = \&_NumSeq_Coord_Y_increasing;
3906 *_NumSeq_Coord_GCD_increasing = \&_NumSeq_Coord_Y_increasing;
3907  
3908 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
3909 *_NumSeq_Coord_X_non_decreasing = \&_NumSeq_Coord_Y_increasing; # X=0 always
3910 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_Y_increasing; # N*0=0
3911  
3912 # step=0 constant ExperimentalNumerator=0
3913 sub _NumSeq_Coord_ExperimentalNumerator_max {
3914 my ($self) = @_;
3915 return ($self->{'step'} == 0 ? 0 : undef);
3916 }
3917  
3918 # step=0 has Y=0 so BitAnd=0 always
3919 *_NumSeq_Coord_BitAnd_max = \&_NumSeq_Coord_ExperimentalNumerator_max;
3920 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_Y_increasing;
3921  
3922 # cf A050873 GCD(X+1,Y+1) by rows n>=1 k=1..n, x_start=1,y_start=1
3923 # A051173 LCM(X+1,Y+1) by rows n>=1 k=1..n, x_start=1,y_start=1
3924 #
3925 # Maybe with x_start,y_start to go by rows starting from 1.
3926 # ExperimentalDenominator => 'A164306', # T(n,k) = k/GCD(n,k) n,k>=1 offset=1
3927 # # OEIS-Catalogue: A164306 planepath=PyramidRows,step=1,x_start=1,y_start=1 coordinate_type=ExperimentalDenominator
3928 # ExperimentalDenominator => 'A167192', # T(n,k) = (n-k)/GCD(n,k) n,k>=1 offset=1
3929 # # OEIS-Catalogue: A167192 planepath=PyramidRows,step=1,x_start=1,y_start=1,align=left coordinate_type=ExperimentalNumerator
3930 #
3931 use constant _NumSeq_Coord_oeis_anum =>
3932 {
3933 # PyramidRows step=0 is trivial X=0,Y=N
3934 do {
3935 my $href = { X => 'A000004', # all-zeros
3936 Product => 'A000004', # all-zeros
3937 # OEIS-Other: A000004 planepath=PyramidRows,step=0 coordinate_type=X
3938 # OEIS-Other: A000004 planepath=PyramidRows,step=0 coordinate_type=Product
3939 };
3940 ('step=0,align=centre' => $href,
3941 'step=0,align=right' => $href,
3942 'step=0,align=left' => $href,
3943 );
3944 },
3945 do {
3946 my $href = { X => 'A000004', # all zeros
3947 Min => 'A000004', # Min=X
3948 Y => 'A001477', # integers Y=0,1,2,etc
3949 Max => 'A001477', # Max=Y
3950 MaxAbs => 'A001477', # MaxAbs=Max
3951 Sum => 'A001477', # Sum=Y
3952 DiffYX => 'A001477', # DiffYX=Y
3953 DiffXY => 'A001489', # negatives 0,-1,-2,etc
3954 AbsDiff => 'A001477', # AbsDiff=Y
3955 Product => 'A000004', # Product=0
3956 Radius => 'A001477', # Radius=Y
3957 GCD => 'A001477', # GCD=Y
3958 RSquared => 'A000290', # n^2
3959 TRSquared => 'A033428', # 3*n^2
3960 BitAnd => 'A000004', # BitAnd=0
3961 BitOr => 'A001477', # BitOr=Y
3962 BitXor => 'A001477', # BitXor=Y
3963 # OEIS-Other: A000004 planepath=PyramidRows,step=0,n_start=0 coordinate_type=X
3964 # OEIS-Other: A000004 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Min
3965 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Y
3966 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Max
3967 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=MaxAbs
3968 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Sum
3969 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=DiffYX
3970 # OEIS-Other: A001489 planepath=PyramidRows,step=0,n_start=0 coordinate_type=DiffXY
3971 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=AbsDiff
3972 # OEIS-Other: A000004 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Product
3973 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Radius
3974 # OEIS-Other: A001489 planepath=PyramidRows,step=0,n_start=0 coordinate_type=DiffXY
3975 # OEIS-Other: A000290 planepath=PyramidRows,step=0,n_start=0 coordinate_type=RSquared
3976 # OEIS-Other: A033428 planepath=PyramidRows,step=0,n_start=0 coordinate_type=TRSquared
3977 # OEIS-Other: A000004 planepath=PyramidRows,step=0,n_start=0 coordinate_type=BitAnd
3978 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=BitOr
3979 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=BitXor
3980 };
3981 ('step=0,align=centre,n_start=0' => $href,
3982 'step=0,align=right,n_start=0' => $href,
3983 'step=0,align=left,n_start=0' => $href,
3984 );
3985 },
3986  
3987 # PyramidRows step=1
3988 # cf A050873 GCD triangle starting (1,1) n=1
3989 # A051173 LCM triangle starting (1,1) n=1
3990 # A003991 X*Y product starting (1,1) n=1
3991 # A001316 count of occurrences of n as BitOr
3992 do {
3993 my $href =
3994 { X => 'A002262', # 0, 0,1, 0,1,2, etc (Diagonals)
3995 Min => 'A002262', # X<=Y always
3996 Y => 'A003056', # 0, 1,1, 2,2,2, 3,3,3,3 (Diagonals)
3997 Max => 'A003056', # Max=Y as Y>=X always
3998 MaxAbs => 'A003056', # MaxAbs=Max as Y>=0 always
3999 DiffYX => 'A025581', # descending N to 0 (Diagonals)
4000 AbsDiff => 'A025581', # absdiff same
4001 Sum => 'A051162', # triangle X+Y for X=0 to Y inclusive
4002 SumAbs => 'A051162', # sumabs same
4003 Product => 'A079904',
4004 RSquared => 'A069011', # triangle X^2+Y^2 for X=0 to Y inclusive
4005 GCD => 'A109004', # same as by diagonals
4006 BitAnd => 'A080099',
4007 BitOr => 'A080098',
4008 BitXor => 'A051933',
4009 };
4010 ('step=1,align=centre,n_start=0' => $href,
4011 'step=1,align=right,n_start=0' => $href,
4012 );
4013 # OEIS-Other: A002262 planepath=PyramidRows,step=1,n_start=0 coordinate_type=X
4014 # OEIS-Other: A002262 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Min
4015 # OEIS-Other: A003056 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Y
4016 # OEIS-Other: A003056 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Max
4017 # OEIS-Other: A003056 planepath=PyramidRows,step=1,n_start=0 coordinate_type=MaxAbs
4018 # OEIS-Other: A025581 planepath=PyramidRows,step=1,n_start=0 coordinate_type=DiffYX
4019 # OEIS-Other: A025581 planepath=PyramidRows,step=1,n_start=0 coordinate_type=AbsDiff
4020 # OEIS-Other: A051162 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Sum
4021 # OEIS-Other: A051162 planepath=PyramidRows,step=1,n_start=0 coordinate_type=SumAbs
4022 # OEIS-Catalogue: A079904 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Product
4023 # OEIS-Catalogue: A069011 planepath=PyramidRows,step=1,n_start=0 coordinate_type=RSquared
4024 # OEIS-Other: A109004 planepath=PyramidRows,step=1,n_start=0 coordinate_type=GCD
4025 # OEIS-Catalogue: A080099 planepath=PyramidRows,step=1,n_start=0 coordinate_type=BitAnd
4026 # OEIS-Catalogue: A080098 planepath=PyramidRows,step=1,n_start=0 coordinate_type=BitOr
4027 # OEIS-Catalogue: A051933 planepath=PyramidRows,step=1,n_start=0 coordinate_type=BitXor
4028  
4029 # OEIS-Other: A002262 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=X
4030 # OEIS-Other: A003056 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=Y
4031 # OEIS-Other: A025581 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=DiffYX
4032 # OEIS-Other: A025581 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=AbsDiff
4033 # OEIS-Other: A051162 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=Sum
4034 # OEIS-Other: A051162 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=SumAbs
4035 # OEIS-Other: A079904 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=Product
4036 # OEIS-Other: A069011 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=RSquared
4037 # OEIS-Other: A080099 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=BitAnd
4038 # OEIS-Other: A080098 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=BitOr
4039 # OEIS-Other: A051933 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=BitXor
4040 },
4041  
4042 # 'step=1,align=left,n_start=0' =>
4043 # { ExperimentalAbsX => 'A025581', # descending runs n to 0
4044 # },
4045  
4046 # PyramidRows step=2
4047 'step=2,align=centre,n_start=0' =>
4048 { X => 'A196199', # runs -n to n
4049 Min => 'A196199', # X since X<Y
4050 Y => 'A000196', # n appears 2n+1 times, starting 0
4051 Max => 'A000196', # Y since X<Y
4052 Sum => 'A053186', # runs 0 to 2n
4053 ExperimentalAbsX => 'A053615', # runs n to 0 to n
4054 # OEIS-Catalogue: A196199 planepath=PyramidRows,n_start=0 coordinate_type=X
4055 # OEIS-Other: A196199 planepath=PyramidRows,n_start=0 coordinate_type=Min
4056 # OEIS-Catalogue: A000196 planepath=PyramidRows,n_start=0 coordinate_type=Y
4057 # OEIS-Other: A000196 planepath=PyramidRows,n_start=0 coordinate_type=Max
4058 # OEIS-Other: A053186 planepath=PyramidRows,n_start=0 coordinate_type=Sum
4059 # OEIS-Other: A053615 planepath=PyramidRows,n_start=0 coordinate_type=ExperimentalAbsX
4060  
4061 # # Not quite, extra initial 0
4062 # DiffYX => 'A068527', # dist to next square
4063 # AbsDiff => 'A068527', # same since Y-X>0
4064 },
4065 'step=2,align=right,n_start=0' =>
4066 { X => 'A053186', # runs 0 to 2n
4067 Y => 'A000196', # n appears 2n+1 times, starting 0
4068 DiffXY => 'A196199', # runs -n to n
4069 AbsDiff => 'A053615', # n..0..n, distance to pronic
4070 # OEIS-Other: A053186 planepath=PyramidRows,align=right,n_start=0 coordinate_type=X
4071 # OEIS-Other: A000196 planepath=PyramidRows,align=right,n_start=0 coordinate_type=Y
4072 # OEIS-Other: A196199 planepath=PyramidRows,align=right,n_start=0 coordinate_type=DiffXY
4073 # OEIS-Other: A053615 planepath=PyramidRows,align=right,n_start=0 coordinate_type=AbsDiff
4074 },
4075 'step=2,align=left,n_start=0' =>
4076 { X => '', # runs -2n+1 to 0
4077 Y => 'A000196', # n appears 2n+1 times, starting 0
4078 Sum => 'A196199', # -n to n
4079 # OEIS-Other: A000196 planepath=PyramidRows,align=left,n_start=0 coordinate_type=Y
4080 # OEIS-Other: A196199 planepath=PyramidRows,align=left,n_start=0 coordinate_type=Sum
4081  
4082 # Not quite, A068527 doesn't have two initial 0s
4083 # ExperimentalAbsX => 'A068527', # dist to next square
4084 # # OEIS-Other: A068527 planepath=PyramidRows,align=left,n_start=0 coordinate_type=ExperimentalAbsX
4085 },
4086  
4087 # PyramidRows step=3
4088 do {
4089 my $href =
4090 { Y => 'A180447', # n appears 3n+1 times, starting 0
4091 };
4092 ('step=3,align=centre,n_start=0' => $href,
4093 'step=3,align=right,n_start=0' => $href,
4094 );
4095 # OEIS-Catalogue: A180447 planepath=PyramidRows,step=3,n_start=0 coordinate_type=Y
4096 # OEIS-Other: A180447 planepath=PyramidRows,step=3,align=right,n_start=0 coordinate_type=Y
4097 },
4098 'step=3,align=left,n_start=0' =>
4099 { Y => 'A180447', # n appears 3n+1 times, starting 0
4100 Max => 'A180447', # Y since X<Y
4101 },
4102 # OEIS-Other: A180447 planepath=PyramidRows,step=3,align=left,n_start=0 coordinate_type=Y
4103 # OEIS-Other: A180447 planepath=PyramidRows,step=3,align=left,n_start=0 coordinate_type=Max
4104  
4105 # PyramidRows step=4
4106 'step=4,align=right,n_start=0' =>
4107 { X => 'A060511', # amount exceeding hexagonal number
4108 },
4109 # OEIS-Catalogue: A060511 planepath=PyramidRows,step=4,align=right,n_start=0 coordinate_type=X
4110 };
4111 }
4112 { package Math::PlanePath::PyramidSides;
4113 use constant _NumSeq_Coord_filling_type => 'half';
4114 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1;
4115  
4116 use constant _NumSeq_Coord_oeis_anum =>
4117 { 'n_start=0' =>
4118 { X => 'A196199', # runs -n to n
4119 SumAbs => 'A000196', # n appears 2n+1 times, starting 0
4120 # OEIS-Other: A196199 planepath=PyramidSides,n_start=0 coordinate_type=X
4121 # OEIS-Other: A000196 planepath=PyramidSides,n_start=0 coordinate_type=SumAbs
4122  
4123 ExperimentalAbsX => 'A053615', # runs n to 0 to n
4124 # OEIS-Other: A053615 planepath=PyramidSides,n_start=0 coordinate_type=ExperimentalAbsX
4125 },
4126 };
4127 }
4128 { package Math::PlanePath::CellularRule;
4129  
4130 # single cell
4131 # 111 -> any
4132 # 110 -> any
4133 # 101 -> any
4134 # 100 -> 0 initial
4135 # 011 -> any
4136 # 010 -> 0 initial
4137 # 001 -> 0 initial
4138 # 000 -> 0
4139 # so (rule & 0x17) == 0
4140 #
4141 # right 2 cell line 0x54,74,D4,F4
4142 # 111 -> any
4143 # 110 -> 1
4144 # 101 -> any
4145 # 100 -> 1
4146 # 011 -> 0
4147 # 010 -> 1
4148 # 001 -> 0
4149 # 000 -> 0
4150 # so (rule & 0x5F) == 0x54
4151 #
4152 sub _NumSeq_Coord_X_increasing {
4153 my ($self) = @_;
4154 ### CellularRule _NumSeq_Coord_X_increasing() rule: $self->{'rule'}
4155 return (($self->{'rule'} & 0x17) == 0 # single cell only
4156 ? 1
4157 : 0);
4158 }
4159 sub _NumSeq_Coord_Sum_increasing {
4160 my ($self) = @_;
4161 return (($self->{'rule'} & 0x17) == 0 # single cell only
4162 || ($self->{'rule'} & 0x5F) == 0x54 # right line 2
4163 ? 1
4164 : 0);
4165 }
4166 *_NumSeq_Coord_Min_increasing = \&_NumSeq_Coord_Sum_increasing; # Min=X
4167 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Sum_increasing;
4168 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Sum_increasing;
4169 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Radius_increasing;
4170  
4171 *_NumSeq_Coord_Y_increasing = \&_NumSeq_Coord_X_increasing;
4172 *_NumSeq_Coord_Max_increasing = \&_NumSeq_Coord_X_increasing; # Max==Y
4173 *_NumSeq_Coord_Product_increasing = \&_NumSeq_Coord_X_increasing;
4174 *_NumSeq_Coord_DiffXY_increasing = \&_NumSeq_Coord_X_increasing;
4175 *_NumSeq_Coord_DiffYX_increasing = \&_NumSeq_Coord_X_increasing;
4176 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_X_increasing;
4177 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4178  
4179 sub _NumSeq_Coord_X_non_decreasing {
4180 my ($self) = @_;
4181 return (($self->{'rule'} & 0x17) == 0 # single cell only
4182 || ($self->{'rule'} & 0x5F) == 0x54 # right line 2
4183 ? 1
4184 : 0);
4185 }
4186 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_non_decreasing; # Min=X
4187 sub _NumSeq_Coord_Product_non_decreasing {
4188 my ($self) = @_;
4189 return (($self->{'rule'} & 0x17) == 0 # single cell only
4190 || ($self->{'rule'} & 0x5F) == 0x54 # right line 2
4191 ? 1
4192 : 0);
4193 }
4194  
4195 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4196 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max==Y
4197  
4198 sub _NumSeq_Coord_BitAnd_max {
4199 my ($self) = @_;
4200 return (($self->{'rule'} & 0x17) == 0 # single cell only
4201 || ($self->{'rule'} & 0x5F) == 0x54 # right line 2
4202 ? 0
4203 : undef);
4204 }
4205  
4206 sub _NumSeq_Coord_ExperimentalParity_max {
4207 my ($self) = @_;
4208 return (($self->{'rule'} & 0x17) == 0 # single cell only
4209 ? 0 # X=0,Y=0 even
4210  
4211 : 1);
4212 }
4213 }
4214 { package Math::PlanePath::CellularRule::OneTwo;
4215 sub _NumSeq_Coord_Sum_increasing {
4216 my ($self) = @_;
4217 return ($self->{'sign'} > 0); # when to the right
4218 }
4219 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Sum_increasing;
4220 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Sum_increasing;
4221 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Radius_increasing;
4222  
4223 sub _NumSeq_Coord_X_non_decreasing {
4224 my ($self) = @_;
4225 return ($self->{'sign'} > 0); # yes when to the right
4226 }
4227 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_non_decreasing; # Min=X
4228 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4229 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4230 *_NumSeq_Coord_BitOr_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4231  
4232 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4233 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4234 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4235 sub _NumSeq_Coord_MinAbs_non_decreasing {
4236 my ($self) = @_;
4237 return ($self->{'sign'} > 0); # yes when to the right
4238 }
4239  
4240 sub _NumSeq_Coord_IntXY_min {
4241 my ($self) = @_;
4242 return ($self->{'align'} eq 'left' ? -1 : 0);
4243 }
4244  
4245 sub _NumSeq_Coord_BitOr_max {
4246 my ($self) = @_;
4247 return ($self->{'align'} eq 'left' ? 1 : undef);
4248 }
4249 use constant _NumSeq_Coord_BitXor_max => 1;
4250  
4251 use constant _NumSeq_Coord_oeis_anum =>
4252 { 'align=left,n_start=0' =>
4253 { Y => 'A004396', # one even two odd
4254 Max => 'A004396', # Max=Y
4255 SumAbs => 'A131452', # a(3n)=4n, a(3n+1)=4n+2, a(3n+2)=4n+1.
4256 DiffYX => 'A131452', # X<0 so Y-X=abs(Y)+abs(X)
4257 # OEIS-Catalogue: A004396 planepath=CellularRule,rule=6,n_start=0 coordinate_type=Y
4258 # OEIS-Other: A004396 planepath=CellularRule,rule=166,n_start=0 coordinate_type=Max
4259 # OEIS-Catalogue: A131452 planepath=CellularRule,rule=6,n_start=0 coordinate_type=SumAbs
4260 # OEIS-Other: A131452 planepath=CellularRule,rule=166,n_start=0 coordinate_type=SumAbs
4261  
4262 # Maybe, but OFFSET in fractions?
4263 # Sum => 'A022003', # 1/999 decimal 0,0,1,0,0,1
4264 # # OEIS-Other: A022003 planepath=CellularRule,rule=166,n_start=0 coordinate_type=Sum
4265 },
4266  
4267 'align=right,n_start=0' =>
4268 { X => 'A004523', # 0,0,1,2,2,3 two even, one odd
4269 Min => 'A004523', # Min=X
4270 BitAnd => 'A004523', # BitAnd=X
4271 Y => 'A004396', # one even two odd
4272 Max => 'A004396', # Max=Y
4273 BitOr => 'A004396', # BitOr=Y
4274 SumAbs => 'A004773', # 0,1,2 mod 4
4275 ExperimentalPairsXY => 'A002264', # triples 0,0,0, 1,1,1, etc
4276  
4277 # OEIS-Catalogue: A004523 planepath=CellularRule,rule=20,n_start=0 coordinate_type=X
4278 # OEIS-Other: A004523 planepath=CellularRule,rule=20,n_start=0 coordinate_type=Min
4279 # OEIS-Other: A004523 planepath=CellularRule,rule=20,n_start=0 coordinate_type=BitAnd
4280 # OEIS-Other: A004396 planepath=CellularRule,rule=20,n_start=0 coordinate_type=Y
4281 # OEIS-Other: A004396 planepath=CellularRule,rule=180,n_start=0 coordinate_type=Max
4282 # OEIS-Other: A004396 planepath=CellularRule,rule=180,n_start=0 coordinate_type=BitOr
4283 # OEIS-Catalogue: A004773 planepath=CellularRule,rule=20,n_start=0 coordinate_type=SumAbs
4284 # OEIS-Other: A004773 planepath=CellularRule,rule=180,n_start=0 coordinate_type=SumAbs
4285 # OEIS-Other: A002264 planepath=CellularRule,rule=20,n_start=0 coordinate_type=ExperimentalPairsXY
4286 },
4287 };
4288 }
4289 { package Math::PlanePath::CellularRule::Two;
4290 sub _NumSeq_Coord_Sum_increasing {
4291 my ($self) = @_;
4292 return ($self->{'sign'} > 0); # when to the right
4293 }
4294 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Sum_increasing;
4295 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Sum_increasing;
4296 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Radius_increasing;
4297  
4298 sub _NumSeq_Coord_X_non_decreasing {
4299 my ($self) = @_;
4300 return ($self->{'sign'} > 0); # yes when to the right
4301 }
4302 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_non_decreasing; # Min=X
4303 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4304 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4305 *_NumSeq_Coord_BitOr_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4306  
4307 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4308 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4309 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4310 sub _NumSeq_Coord_MinAbs_non_decreasing {
4311 my ($self) = @_;
4312 return ($self->{'sign'} > 0); # yes when to the right
4313 }
4314  
4315 sub _NumSeq_Coord_IntXY_min {
4316 my ($self) = @_;
4317 return ($self->{'align'} eq 'left' ? -1 : 0);
4318 }
4319  
4320 sub _NumSeq_Coord_BitOr_max {
4321 my ($self) = @_;
4322 return ($self->{'align'} eq 'left' ? 1 : undef);
4323 }
4324 use constant _NumSeq_Coord_BitXor_max => 1;
4325  
4326 use constant _NumSeq_Coord_oeis_anum =>
4327 {
4328 'align=left,n_start=1' =>
4329 { Y => 'A076938', # 0,1,1,2,2,3,3,...
4330 # OEIS-Other: A076938 planepath=CellularRule,rule=14 coordinate_type=Y
4331 # OEIS-Other: A076938 planepath=CellularRule,rule=174 coordinate_type=Y
4332 },
4333 'align=right,n_start=1' =>
4334 { Y => 'A076938', # 0,1,1,2,2,3,3,...
4335 # OEIS-Other: A076938 planepath=CellularRule,rule=84 coordinate_type=Y
4336 # OEIS-Other: A076938 planepath=CellularRule,rule=116 coordinate_type=Y
4337 },
4338 };
4339 }
4340 { package Math::PlanePath::CellularRule::Line;
4341 sub _NumSeq_Coord_Radius_integer {
4342 my ($path) = @_;
4343 # centre Radius=Y so integer, otherwise Radius=sqrt(2)*Y not integer
4344 return ($path->{'align'} eq 'centre');
4345 }
4346  
4347 use constant _NumSeq_Coord_Y_increasing => 1; # line upwards
4348 use constant _NumSeq_Coord_Max_increasing => 1; # Max=Y
4349 use constant _NumSeq_Coord_Radius_increasing => 1; # line upwards
4350 use constant _NumSeq_Coord_TRadius_increasing => 1; # line upwards
4351 sub _NumSeq_Coord_TRadius_integer {
4352 my ($path) = @_;
4353 return ($path->{'sign'} != 0); # left or right sloping
4354 }
4355  
4356 sub _NumSeq_Coord_X_increasing {
4357 my ($path) = @_;
4358 return ($path->{'sign'} >= 1); # X=Y diagonal
4359 }
4360 sub _NumSeq_Coord_X_non_decreasing {
4361 my ($path) = @_;
4362 return ($path->{'sign'} >= 0); # X=0 vertical or X=Y diagonal
4363 }
4364 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_non_decreasing; # Min=X
4365 *_NumSeq_Coord_Min_increasing = \&_NumSeq_Coord_X_increasing; # Min=X
4366  
4367 sub _NumSeq_Coord_Sum_increasing {
4368 my ($path) = @_;
4369 return ($path->{'sign'} == -1
4370 ? 0 # X=-Y so X+Y=0
4371 : 1); # X=0 so X+Y=Y, or X=Y so X+Y=2Y
4372 }
4373 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # line upwards
4374 use constant _NumSeq_Coord_SumAbs_increasing => 1; # line upwards
4375  
4376 sub _NumSeq_Coord_Product_increasing {
4377 my ($path) = @_;
4378 return ($path->{'sign'} > 0
4379 ? 1 # X=Y so X*Y=Y^2
4380 : 0); # X=0 so X*Y=0, or X=-Y so X*Y=-(Y^2)
4381 }
4382 sub _NumSeq_Coord_Product_non_decreasing {
4383 my ($path) = @_;
4384 return ($path->{'sign'} >= 0
4385 ? 1 # X=Y so X*Y=Y^2
4386 : 0); # X=0 so X*Y=0, or X=-Y so X*Y=-(Y^2)
4387 }
4388  
4389 # sign=1 X=Y so X-Y=0 always, non-decreasing
4390 # sign=0 X=0 so Y-X=Y, increasing
4391 # sign=-1 X=-Y so Y-X=2*Y, increasing
4392 sub _NumSeq_Coord_DiffXY_non_decreasing {
4393 my ($path) = @_;
4394 return ($path->{'sign'} == 1 ? 1 # X-Y=0 always
4395 : 0);
4396 }
4397 sub _NumSeq_Coord_DiffYX_increasing {
4398 my ($path) = @_;
4399 return ($path->{'sign'} == 1 ? 0 : 1);
4400 }
4401 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_DiffYX_increasing;
4402 use constant _NumSeq_Coord_DiffYX_non_decreasing => 1; # Y-X >= 0 always
4403 use constant _NumSeq_Coord_AbsDiff_non_decreasing => 1; # Y-X >= 0 always
4404 use constant _NumSeq_Coord_GCD_increasing => 1; # GCD==Y
4405  
4406 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4407 sub _NumSeq_Coord_ExperimentalParity_max {
4408 my ($path) = @_;
4409 return ($path->{'align'} eq 'centre' ? 1 : 0);
4410 }
4411  
4412 sub _NumSeq_Coord_ExperimentalNumerator_min {
4413 my ($path) = @_;
4414 return ($path->{'align'} eq 'left'
4415 ? -1
4416 : 0);
4417 }
4418 sub _NumSeq_Coord_ExperimentalNumerator_max {
4419 my ($path) = @_;
4420 return ($path->{'align'} eq 'right'
4421 ? 1 # right X=Y so 1/1 except for 0/0
4422 : 0);
4423 }
4424 sub _NumSeq_Coord_ExperimentalNumerator_non_decreasing {
4425 my ($path) = @_;
4426 return ($path->{'align'} ne 'left');
4427 }
4428  
4429 # ExperimentalDenominator_min => 0; # 0/0 at n_start()
4430 use constant _NumSeq_Coord_ExperimentalDenominator_max => 1;
4431 use constant _NumSeq_Coord_ExperimentalDenominator_non_decreasing => 1;
4432  
4433 # left Y bitand -Y twos-complement gives mask of low 1-bits
4434 sub _NumSeq_Coord_BitAnd_non_decreasing {
4435 my ($path) = @_;
4436 return ($path->{'align'} ne 'left'); # centre BitAnd=0, right BitAnd=Y
4437 }
4438 sub _NumSeq_Coord_BitAnd_increasing {
4439 my ($path) = @_;
4440 return ($path->{'align'} eq 'right'); # right BitAnd=Y
4441 }
4442  
4443 # left Y bitor -Y twos-complement gives all-1s above low 0-bits
4444 sub _NumSeq_Coord_BitOr_increasing {
4445 my ($path) = @_;
4446 return ($path->{'align'} ne 'left'); # centre,right BitOr = Y
4447 }
4448  
4449 sub _NumSeq_Coord_BitXor_min {
4450 my ($path) = @_;
4451 return ($path->{'align'} eq 'left'
4452 ? undef
4453 : 0); # right X=Y so BitXor=0 always, centre X=0 so BitXor=Y
4454 }
4455 sub _NumSeq_Coord_BitXor_max {
4456 my ($path) = @_;
4457 return ($path->{'align'} eq 'centre'
4458 ? undef # centre X=0 BitXor=Y
4459 : 0); # right X=Y so BitXor=0 always, left negative
4460 }
4461 sub _NumSeq_Coord_BitXor_increasing {
4462 my ($path) = @_;
4463 return ($path->{'align'} eq 'centre'); # centre BitXor=Y
4464 }
4465  
4466 # and maximum 0/0=infinity
4467 sub _NumSeq_Coord_IntXY_min {
4468 my ($path) = @_;
4469 return ($path->{'align'} eq 'right'
4470 ? 1 # right X=Y so X/Y=1 always
4471 : $path->{'align'} eq 'left'
4472 ? -1 # left X=-Y so X/Y=-1 always
4473 : 0);
4474 }
4475  
4476 use constant _NumSeq_Coord_FracXY_min => 0; # X=0,+Y,-Y so frac=0
4477 use constant _NumSeq_Coord_FracXY_max => 0;
4478 use constant _NumSeq_Coord_FracXY_integer => 1;
4479 use constant _NumSeq_FracXY_min_is_infimum => 0;
4480 use constant _NumSeq_FracXY_max_is_supremum => 0;
4481  
4482 use constant _NumSeq_Coord_oeis_anum =>
4483 { 'align=left,n_start=0' =>
4484 { X => 'A001489', # integers negative X=0,-1,-2,etc
4485 Min => 'A001489', # Min=X
4486 Y => 'A001477', # integers Y=0,1,2,etc
4487 Max => 'A001477', # Max=Y
4488 Sum => 'A000004', # all zeros
4489 DiffYX => 'A005843', # even 0,2,4,etc
4490 RSquared => 'A001105', # 2*n^2
4491 TRSquared => 'A016742', # 4*n^2
4492 # OEIS-Other: A001489 planepath=CellularRule,rule=2,n_start=0 coordinate_type=X
4493 # OEIS-Other: A001489 planepath=CellularRule,rule=2,n_start=0 coordinate_type=Min
4494 # OEIS-Other: A001477 planepath=CellularRule,rule=2,n_start=0 coordinate_type=Y
4495 # OEIS-Other: A001477 planepath=CellularRule,rule=2,n_start=0 coordinate_type=Max
4496 # OEIS-Other: A000004 planepath=CellularRule,rule=2,n_start=0 coordinate_type=Sum
4497 # OEIS-Other: A005843 planepath=CellularRule,rule=2,n_start=0 coordinate_type=DiffYX
4498 # OEIS-Other: A001105 planepath=CellularRule,rule=2,n_start=0 coordinate_type=RSquared
4499 # OEIS-Other: A016742 planepath=CellularRule,rule=2,n_start=0 coordinate_type=TRSquared
4500 },
4501  
4502 'align=right,n_start=0' =>
4503 { X => 'A001477', # integers Y=0,1,2,etc
4504 Min => 'A001477', # Min=X
4505 Y => 'A001477', # integers Y=0,1,2,etc
4506 Max => 'A001477', # Max=Y
4507 Sum => 'A005843', # even 0,2,4,etc
4508 DiffYX => 'A000004', # all zeros
4509 DiffXY => 'A000004', # all zeros
4510 RSquared => 'A001105', # 2*n^2
4511 TRSquared => 'A016742', # 4*n^2
4512 ExperimentalPairsXY => 'A004526', # 0,0,1,1,2,2,etc cf Math::NumSeq::Runs
4513 # OEIS-Other: A001477 planepath=CellularRule,rule=16,n_start=0 coordinate_type=X
4514 # OEIS-Other: A001477 planepath=CellularRule,rule=16,n_start=0 coordinate_type=Min
4515 # OEIS-Other: A001477 planepath=CellularRule,rule=16,n_start=0 coordinate_type=Y
4516 # OEIS-Other: A001477 planepath=CellularRule,rule=16,n_start=0 coordinate_type=Max
4517 # OEIS-Other: A005843 planepath=CellularRule,rule=16,n_start=0 coordinate_type=Sum
4518 # OEIS-Other: A000004 planepath=CellularRule,rule=16,n_start=0 coordinate_type=DiffYX
4519 # OEIS-Other: A000004 planepath=CellularRule,rule=16,n_start=0 coordinate_type=DiffXY
4520 # OEIS-Other: A001105 planepath=CellularRule,rule=16,n_start=0 coordinate_type=RSquared
4521 # OEIS-Other: A016742 planepath=CellularRule,rule=16,n_start=0 coordinate_type=TRSquared
4522 # OEIS-Other: A004526 planepath=CellularRule,rule=16,n_start=0 coordinate_type=ExperimentalPairsXY
4523 },
4524  
4525 # same as PyramidRows step=0
4526 'align=centre,n_start=0' =>
4527 Math::PlanePath::PyramidRows->_NumSeq_Coord_oeis_anum()->{'step=0,align=centre,n_start=0'},
4528 # OEIS-Other: A000004 planepath=CellularRule,rule=4,n_start=0 coordinate_type=X
4529 # OEIS-Other: A000004 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Min
4530 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Y
4531 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Max
4532 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Sum
4533 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=DiffYX
4534 # OEIS-Other: A001489 planepath=CellularRule,rule=4,n_start=0 coordinate_type=DiffXY
4535 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=AbsDiff
4536 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Radius
4537 # OEIS-Other: A001489 planepath=CellularRule,rule=4,n_start=0 coordinate_type=DiffXY
4538 # OEIS-Other: A000290 planepath=CellularRule,rule=4,n_start=0 coordinate_type=RSquared
4539 # OEIS-Other: A033428 planepath=CellularRule,rule=4,n_start=0 coordinate_type=TRSquared
4540 };
4541  
4542 # CellularRule starts i=1 value=0, but A000027 is OFFSET=1 value=1
4543 # } elsif ($planepath_object->isa('Math::PlanePath::CellularRule::Line')) {
4544 # # for all "rule" parameter values
4545 # if ($coordinate_type eq 'Y'
4546 # || ($planepath_object->{'sign'} == 0
4547 # && ($coordinate_type eq 'Sum'
4548 # || $coordinate_type eq 'DiffYX'
4549 # || $coordinate_type eq 'AbsDiff'
4550 # || $coordinate_type eq 'Radius'))) {
4551 # return 'A000027'; # natural numbers 1,2,3
4552 # # OEIS-Other: A000027 planepath=CellularRule,rule=2 coordinate_type=Y
4553 # # OEIS-Other: A000027 planepath=CellularRule,rule=4 coordinate_type=Sum
4554 # # OEIS-Other: A000027 planepath=CellularRule,rule=4 coordinate_type=DiffYX
4555 # # OEIS-Other: A000027 planepath=CellularRule,rule=4 coordinate_type=AbsDiff
4556 # # OEIS-Other: A000027 planepath=CellularRule,rule=4 coordinate_type=Radius
4557 # }
4558 }
4559 { package Math::PlanePath::CellularRule::OddSolid;
4560 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4561 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4562 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4563 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # always even points
4564 }
4565 { package Math::PlanePath::CellularRule54;
4566 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4567 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4568 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4569 use constant _NumSeq_Coord_IntXY_min => -1;
4570 }
4571 { package Math::PlanePath::CellularRule57;
4572 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4573 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4574 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4575 use constant _NumSeq_Coord_IntXY_min => -1;
4576 }
4577 { package Math::PlanePath::CellularRule190;
4578 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4579 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4580 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4581 use constant _NumSeq_Coord_IntXY_min => -1;
4582 }
4583 { package Math::PlanePath::UlamWarburton;
4584 use constant _NumSeq_Coord_filling_type => 'plane';
4585 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 4;
4586 }
4587 { package Math::PlanePath::UlamWarburtonQuarter;
4588 use constant _NumSeq_Coord_filling_type => 'quadrant';
4589 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 4;
4590 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
4591 }
4592 { package Math::PlanePath::DiagonalRationals;
4593 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # X+Y diagonals
4594 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1; # X+Y diagonals
4595 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=1,Y=2
4596  
4597 use constant _NumSeq_Coord_oeis_anum =>
4598 { 'direction=down,n_start=1' =>
4599 { X => 'A020652', # numerators
4600 Y => 'A020653', # denominators
4601 ExperimentalNumerator => 'A020652', # ExperimentalNumerator=X
4602 ExperimentalDenominator => 'A020653', # ExperimentalDenominator=Y
4603 # OEIS-Catalogue: A020652 planepath=DiagonalRationals coordinate_type=X
4604 # OEIS-Catalogue: A020653 planepath=DiagonalRationals coordinate_type=Y
4605 # OEIS-Other: A020652 planepath=DiagonalRationals coordinate_type=ExperimentalNumerator
4606 # OEIS-Other: A020653 planepath=DiagonalRationals coordinate_type=ExperimentalDenominator
4607  
4608 # Not quite, A038567 has OFFSET=0 to include 0/1
4609 # Sum => 'A038567', # num+den, is den of fractions X/Y <= 1
4610 # SumAbs => 'A038567'
4611 },
4612 'direction=down,n_start=0' =>
4613 { AbsDiff => 'A157806', # abs(num-den), OFFSET=0
4614 # OEIS-Other: A157806 planepath=DiagonalRationals,n_start=0 coordinate_type=AbsDiff
4615 },
4616  
4617 'direction=up,n_start=1' =>
4618 { X => 'A020653', # transposed is denominators
4619 Y => 'A020652', # transposed is numerators
4620 ExperimentalNumerator => 'A020653', # ExperimentalNumerator=X
4621 ExperimentalDenominator => 'A020652', # ExperimentalDenominator=Y
4622 # OEIS-Other: A020652 planepath=DiagonalRationals,direction=up coordinate_type=Y
4623 # OEIS-Other: A020653 planepath=DiagonalRationals,direction=up coordinate_type=X
4624 # OEIS-Other: A020653 planepath=DiagonalRationals,direction=up coordinate_type=ExperimentalNumerator
4625 # OEIS-Other: A020652 planepath=DiagonalRationals,direction=up coordinate_type=ExperimentalDenominator
4626  
4627 # Not quite, A038567 has OFFSET=0 to include 0/1
4628 # Sum => 'A038567', # num+den, is den of fractions X/Y <= 1
4629 },
4630 'direction=up,n_start=0' =>
4631 { AbsDiff => 'A157806', # abs(num-den), OFFSET=0
4632 # OEIS-Other: A157806 planepath=DiagonalRationals,direction=up,n_start=0 coordinate_type=AbsDiff
4633 },
4634 };
4635 }
4636 { package Math::PlanePath::FactorRationals;
4637 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=1,Y=2
4638  
4639 use constant _NumSeq_Coord_oeis_anum =>
4640 { 'factor_coding=even/odd' =>
4641 { X => 'A071974', # numerators
4642 Y => 'A071975', # denominators
4643 Product => 'A019554', # replace squares by their root
4644 # OEIS-Catalogue: A071974 planepath=FactorRationals coordinate_type=X
4645 # OEIS-Catalogue: A071975 planepath=FactorRationals coordinate_type=Y
4646 # OEIS-Catalogue: A019554 planepath=FactorRationals coordinate_type=Product
4647 },
4648 'factor_coding=odd/even' =>
4649 { X => 'A071975', # denominators
4650 Y => 'A071974', # numerators
4651 Product => 'A019554', # replace squares by their root
4652 # OEIS-Other: A071975 planepath=FactorRationals,factor_coding=odd/even coordinate_type=X
4653 # OEIS-Other: A071974 planepath=FactorRationals,factor_coding=odd/even coordinate_type=Y
4654 # OEIS-Other: A019554 planepath=FactorRationals,factor_coding=odd/even coordinate_type=Product
4655 },
4656 };
4657 }
4658 { package Math::PlanePath::GcdRationals;
4659 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=1,Y=2
4660  
4661 use constant _NumSeq_Coord_oeis_anum =>
4662 { 'pairs_order=rows' =>
4663 { X => 'A226314',
4664 Y => 'A054531', # T(n,k) = n/GCD(n,k), being denominators
4665 # OEIS-Catalogue: A226314 planepath=GcdRationals coordinate_type=X
4666 # OEIS-Catalogue: A054531 planepath=GcdRationals coordinate_type=Y
4667 },
4668 'pairs_order=rows_reverse' =>
4669 { Y => 'A054531', # same
4670 # OEIS-Other: A054531 planepath=GcdRationals,pairs_order=rows coordinate_type=Y
4671 },
4672 };
4673 }
4674 { package Math::PlanePath::CoprimeColumns;
4675 use constant _NumSeq_Coord_X_non_decreasing => 1; # columns across
4676 use constant _NumSeq_Coord_ExperimentalNumerator_non_decreasing => 1; # ExperimentalNumerator==X
4677 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max==X
4678 use constant _NumSeq_Coord_IntXY_min => 1; # octant Y<=X so X/Y>=1
4679 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=2,Y=1
4680  
4681 use constant _NumSeq_Coord_oeis_anum =>
4682 { 'direction=up,n_start=0' =>
4683 { X => 'A038567', # fractions denominator
4684 Max => 'A038567', # Max=X since Y <= X
4685 MaxAbs => 'A038567', # MaxAbs=Max
4686 # OEIS-Catalogue: A038567 planepath=CoprimeColumns coordinate_type=X
4687 # OEIS-Other: A038567 planepath=CoprimeColumns coordinate_type=Max
4688 # OEIS-Other: A038567 planepath=CoprimeColumns coordinate_type=MaxAbs
4689 },
4690  
4691 'direction=up,n_start=0,i_start=1' =>
4692 { DiffXY => 'A020653', # diagonals denominators, starting N=1
4693 # OEIS-Other: A020653 planepath=CoprimeColumns coordinate_type=DiffXY i_start=1
4694 },
4695  
4696 'direction=up,n_start=1' =>
4697 { Y => 'A038566', # fractions numerator
4698 Min => 'A038566', # Min=Y since Y <= X
4699 MinAbs => 'A038566', # MinAbs=Min
4700 # OEIS-Catalogue: A038566 planepath=CoprimeColumns,n_start=1 coordinate_type=Y
4701 # OEIS-Other: A038566 planepath=CoprimeColumns,n_start=1 coordinate_type=Min
4702 # OEIS-Other: A038566 planepath=CoprimeColumns,n_start=1 coordinate_type=MinAbs
4703 },
4704 };
4705 }
4706 { package Math::PlanePath::DivisibleColumns;
4707 use constant _NumSeq_Coord_X_non_decreasing => 1; # columns across
4708  
4709 sub _NumSeq_Coord_IntXY_min {
4710 my ($self) = @_;
4711 return ($self->{'proper'} ? 2 : 1);
4712 }
4713 use constant _NumSeq_Coord_FracXY_max => 0; # frac(X/Y)=0 always
4714 use constant _NumSeq_Coord_FracXY_integer => 1;
4715 use constant _NumSeq_FracXY_max_is_supremum => 0;
4716  
4717 sub _NumSeq_Coord_ExperimentalNumerator_min {
4718 my ($self) = @_;
4719 return ($self->{'proper'} ? 2 : 1);
4720 }
4721  
4722 # X/Y = Z/1 since X divisible by Y, ExperimentalDenominator=1 always
4723 use constant _NumSeq_Coord_ExperimentalDenominator_min => 1;
4724 use constant _NumSeq_Coord_ExperimentalDenominator_max => 1;
4725 use constant _NumSeq_Coord_ExperimentalDenominator_non_decreasing => 1;
4726  
4727 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=2,Y=1
4728 sub _NumSeq_Coord_BitXor_min {
4729 my ($self) = @_;
4730 # octant Y<=X so X-Y>=0
4731 return ($self->{'proper'} ? 2 # at X=3,Y=1
4732 : 0); # at X=1,Y=1
4733 }
4734  
4735 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max==X
4736 sub _NumSeq_Coord_MaxAbs_min { return $_[0]->x_minimum } # Max=X
4737  
4738 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
4739  
4740 use constant _NumSeq_Coord_oeis_anum =>
4741 { 'divisor_type=all,n_start=1' =>
4742 { X => 'A061017', # n appears divisors(n) times
4743 Max => 'A061017', # Max=X since Y <= X
4744 MaxAbs => 'A061017', # MaxAbs=Max
4745 Y => 'A027750', # triangle divisors of n
4746 Min => 'A027750', # Min=Y since Y <= X
4747 MinAbs => 'A027750', # MinAbs=Min
4748 GCD => 'A027750', # Y since Y is a divisor of X
4749 IntXY => 'A056538', # divisors in reverse order, X/Y give high to low
4750 ExperimentalNumerator => 'A056538', # same as int(X/Y)
4751 # OEIS-Catalogue: A061017 planepath=DivisibleColumns,n_start=1 coordinate_type=X
4752 # OEIS-Other: A061017 planepath=DivisibleColumns,n_start=1 coordinate_type=Max
4753 # OEIS-Other: A061017 planepath=DivisibleColumns,n_start=1 coordinate_type=MaxAbs
4754 # OEIS-Catalogue: A027750 planepath=DivisibleColumns,n_start=1 coordinate_type=Y
4755 # OEIS-Other: A027750 planepath=DivisibleColumns,n_start=1 coordinate_type=Min
4756 # OEIS-Other: A027750 planepath=DivisibleColumns,n_start=1 coordinate_type=GCD
4757 # OEIS-Catalogue: A056538 planepath=DivisibleColumns,n_start=1 coordinate_type=IntXY
4758 # OEIS-Other: A056538 planepath=DivisibleColumns,n_start=1 coordinate_type=ExperimentalNumerator
4759 },
4760  
4761 'divisor_type=proper,n_start=2' =>
4762 { DiffXY => 'A208460', # X-Y
4763 AbsDiff => 'A208460', # abs(X-Y) same since Y<=X so X-Y>=0
4764 # OEIS-Catalogue: A208460 planepath=DivisibleColumns,divisor_type=proper,n_start=2 coordinate_type=DiffXY
4765 # OEIS-Other: A208460 planepath=DivisibleColumns,divisor_type=proper,n_start=2 coordinate_type=AbsDiff
4766  
4767 # Not quite, A027751 has an extra 1 at the start from reckoning by
4768 # convention 1 as a proper divisor of 1 -- though that's
4769 # inconsistent with A032741 count of proper divisors being 0.
4770 #
4771 # 'divisor_type=proper,n_start=0' =>
4772 # { Y,Min,GCD => 'A027751', # proper divisors by rows
4773 # # OEIS-Catalogue: A027751 planepath=DivisibleColumns,divisor_type=proper coordinate_type=Y
4774 # },
4775 },
4776 };
4777  
4778 }
4779 # { package Math::PlanePath::File;
4780 # # File points from a disk file
4781 # # FIXME: analyze points for min/max maybe
4782 # }
4783 # { package Math::PlanePath::QuintetCurve;
4784 # # inherit from QuintetCentres
4785 # }
4786 { package Math::PlanePath::QuintetCentres;
4787 use constant _NumSeq_Coord_filling_type => 'plane';
4788 }
4789 { package Math::PlanePath::QuintetReplicate;
4790 use constant _NumSeq_Coord_filling_type => 'plane';
4791 }
4792 { package Math::PlanePath::AR2W2Curve;
4793 use constant _NumSeq_Coord_filling_type => 'quadrant';
4794 }
4795 { package Math::PlanePath::BetaOmega;
4796 use constant _NumSeq_Coord_filling_type => 'half';
4797 }
4798 { package Math::PlanePath::KochelCurve;
4799 use constant _NumSeq_Coord_filling_type => 'quadrant';
4800 }
4801 # { package Math::PlanePath::DekkingCurve;
4802 # }
4803 { package Math::PlanePath::DekkingCentres;
4804 use constant _NumSeq_Coord_filling_type => 'quadrant';
4805 }
4806 { package Math::PlanePath::CincoCurve;
4807 use constant _NumSeq_Coord_filling_type => 'quadrant';
4808 }
4809 { package Math::PlanePath::SquareReplicate;
4810 use constant _NumSeq_Coord_filling_type => 'plane';
4811 }
4812 { package Math::PlanePath::CornerReplicate;
4813 use constant _NumSeq_Coord_filling_type => 'quadrant';
4814 use constant _NumSeq_Coord_oeis_anum =>
4815 { '' =>
4816 { Y => 'A059906', # alternate bits second (ZOrderCurve Y)
4817 BitXor => 'A059905', # alternate bits first (ZOrderCurve X)
4818 ExperimentalHammingDist => 'A139351', # count 1-bits at even bit positions
4819 # OEIS-Other: A059906 planepath=CornerReplicate coordinate_type=Y
4820 # OEIS-Other: A059905 planepath=CornerReplicate coordinate_type=BitXor
4821 # OEIS-Catalogue: A139351 planepath=CornerReplicate coordinate_type=ExperimentalHammingDist
4822 },
4823 };
4824 }
4825 { package Math::PlanePath::DigitGroups;
4826 use constant _NumSeq_Coord_filling_type => 'quadrant';
4827 # # Not quite, A073089 is OFFSET=1 not N=0, also A073089 has extra initial 0
4828 # use constant _NumSeq_Coord_oeis_anum =>
4829 # { 'radix=2' =>
4830 # { ExperimentalParity => 'A073089', # DragonMidpoint AbsdY Nodd ^ bit-above-low-0
4831 # # OEIS-Other: A073089 planepath=DigitGroups coordinate_type=ExperimentalParity
4832 # },
4833 # };
4834 }
4835 # { package Math::PlanePath::FibonacciWordFractal;
4836 # }
4837 { package Math::PlanePath::LTiling;
4838 use constant _NumSeq_Coord_filling_type => 'quadrant';
4839 # X=1,Y=1 doesn't occur, only X=1,Y=2 or X=2,Y=1
4840 {
4841 my %_NumSeq_Coord_Max_min = (upper => 1, # X=0,Y=0 not visited by these
4842 left => 1,
4843 ends => 1);
4844 sub _NumSeq_Coord_Max_min {
4845 my ($self) = @_;
4846 return $_NumSeq_Coord_Max_min{$self->{'L_fill'}} || 0;
4847 }
4848 }
4849  
4850 sub _NumSeq_Coord_TRSquared_min {
4851 my ($self) = @_;
4852 return ($self->{'L_fill'} eq 'upper' ? 3 # X=0,Y=1
4853 : ($self->{'L_fill'} eq 'left'
4854 || $self->{'L_fill'} eq 'ends') ? 1 # X=1,Y=0
4855 : 0); # 'middle','all' X=0,Y=0
4856 }
4857 {
4858 my %BitOr_min = (upper => 1, # X=0,Y=0 not visited by these
4859 left => 1,
4860 ends => 1);
4861 sub _NumSeq_Coord_BitOr_min {
4862 my ($self) = @_;
4863 return $BitOr_min{$self->{'L_fill'}} || 0;
4864 }
4865 }
4866 *_NumSeq_Coord_BitXor_min = \&_NumSeq_Coord_BitOr_min;
4867  
4868 {
4869 my %_NumSeq_Coord_ExperimentalHammingDist_min = (upper => 1, # X!=Y for these
4870 left => 1,
4871 ends => 1);
4872 sub _NumSeq_Coord_ExperimentalHammingDist_min {
4873 my ($self) = @_;
4874 return $_NumSeq_Coord_ExperimentalHammingDist_min{$self->{'L_fill'}} || 0;
4875 }
4876 *_NumSeq_Coord_MaxAbs_min = \&_NumSeq_Coord_ExperimentalHammingDist_min;
4877 }
4878  
4879 # Not quite, A112539 OFFSET=1 versus start N=0 here
4880 # use constant _NumSeq_Coord_oeis_anum =>
4881 # { 'L_fill=left' =>
4882 # { ExperimentalParity => 'A112539', # thue-morse count1bits mod 2
4883 # # OEIS-Catalogue: A112539 planepath=LTiling,L_fill=left coordinate_type=ExperimentalParity
4884 # },
4885 # };
4886 }
4887 { package Math::PlanePath::WythoffArray;
4888 use constant _NumSeq_Coord_filling_type => 'quadrant';
4889 # FIXME: if x_start=1 but y_start=0 then want corresponding mixture of
4890 # A-nums. DiffXY is whenever x_start==y_start.
4891 use constant _NumSeq_Coord_oeis_anum =>
4892 { 'x_start=0,y_start=0' =>
4893 { Y => 'A019586', # row containing N
4894 DiffXY => 'A191360', # diagonal containing N
4895 # OEIS-Catalogue: A019586 planepath=WythoffArray coordinate_type=Y
4896 # OEIS-Catalogue: A191360 planepath=WythoffArray coordinate_type=DiffXY
4897  
4898 # Not quite, A035614 has OFFSET start n=0 whereas path starts N=1
4899 # X => 'A035614',
4900 },
4901 'x_start=1,y_start=1' =>
4902 { X => 'A035612', # column number containing N, start column=1
4903 Y => 'A003603', # row number containing N, starting row=1
4904 DiffXY => 'A191360', # diagonal containing N
4905 # OEIS-Catalogue: A035612 planepath=WythoffArray,x_start=1,y_start=1
4906 # OEIS-Catalogue: A003603 planepath=WythoffArray,x_start=1,y_start=1 coordinate_type=Y
4907 # OEIS-Other: A191360 planepath=WythoffArray,x_start=1,y_start=1 coordinate_type=DiffXY
4908 },
4909 };
4910 }
4911 { package Math::PlanePath::PowerArray;
4912 use constant _NumSeq_Coord_filling_type => 'quadrant';
4913 use constant _NumSeq_Coord_oeis_anum =>
4914 { 'radix=2' =>
4915 { X => 'A007814', # base 2 count low 0s, starting n=1
4916 # main generator Math::NumSeq::DigitCountLow
4917 # OEIS-Other: A007814 planepath=PowerArray,radix=2
4918  
4919 # Not quite, A025480 starts OFFSET=0 for the k in n=(2k+1)*2^j-1
4920 # Y => 'A025480',
4921 # # OEIS-Almost: A025480 i_to_n_offset=-1 planepath=PowerArray,radix=2 coordinate_type=Y
4922 },
4923 'radix=3' =>
4924 { X => 'A007949', # k of greatest 3^k dividing n
4925 # OEIS-Other: A007949 planepath=PowerArray,radix=3
4926 # main generator Math::NumSeq::DigitCountLow
4927 },
4928 'radix=5' =>
4929 { X => 'A112765',
4930 # OEIS-Other: A112765 planepath=PowerArray,radix=5
4931 },
4932 'radix=6' =>
4933 { X => 'A122841',
4934 # OEIS-Other: A122841 planepath=PowerArray,radix=6
4935 },
4936 'radix=10' =>
4937 { X => 'A122840',
4938 # OEIS-Other: A112765 planepath=PowerArray,radix=5
4939 },
4940 };
4941 }
4942  
4943 { package Math::PlanePath::ToothpickTree;
4944 sub _NumSeq_Coord_Max_min {
4945 my ($self) = @_;
4946 if ($self->{'parts'} eq '3') { return 0; }
4947 return $self->SUPER::_NumSeq_Coord_Max_min;
4948 }
4949  
4950 {
4951 my %_NumSeq_Coord_IntXY_min = (1 => 0,
4952 octant => 0, # X>=Y-1 so X/Y >= 1-1/Y
4953 wedge => -1, # X>=-Y,Y>=0 so X/Y<=-1
4954 );
4955 sub _NumSeq_Coord_IntXY_min {
4956 my ($self) = @_;
4957 return $_NumSeq_Coord_IntXY_min{$self->{'parts'}};
4958 }
4959 }
4960 {
4961 my %_NumSeq_Coord_IntXY_max = (octant_up => 0,
4962 # except wedge 0/0 = infinity
4963 # wedge => 1, # Y>=X so X/Y<=1
4964 );
4965 sub _NumSeq_Coord_IntXY_max {
4966 my ($self) = @_;
4967 return $_NumSeq_Coord_IntXY_max{$self->{'parts'}};
4968 }
4969 }
4970  
4971 sub _NumSeq_Coord_BitAnd_min {
4972 my ($self) = @_;
4973 return ($self->{'parts'} eq '4'
4974 ? undef # X<0,Y<0
4975 : 0); # otherwise X>0 or Y>0 so BitAnd>=0
4976 }
4977  
4978 {
4979 my %_NumSeq_Coord_TRSquared_min = (2 => 3, # X=0,Y=1
4980 1 => 4, # X=1,Y=1
4981 octant => 4, # X=1,Y=1
4982 octant_up => 13, # X=1,Y=2
4983 );
4984 sub _NumSeq_Coord_TRSquared_min {
4985 my ($self) = @_;
4986 return ($_NumSeq_Coord_TRSquared_min{$self->{'parts'}} || 0);
4987 }
4988 }
4989 {
4990 # usually 7, but in these 8
4991 my %_NumSeq_Coord_ExperimentalLeafDistance_max = (octant => 8,
4992 octant_up => 8,
4993 wedge => 8,
4994 );
4995 sub _NumSeq_Coord_ExperimentalLeafDistance_max {
4996 my ($self) = @_;
4997 return ($_NumSeq_Coord_ExperimentalLeafDistance_max{$self->{'parts'}} || 7);
4998 }
4999 }
5000 }
5001 { package Math::PlanePath::ToothpickReplicate;
5002 *_NumSeq_Coord_BitAnd_min
5003 = \&Math::PlanePath::ToothpickTree::_NumSeq_Coord_BitAnd_min;
5004 *_NumSeq_Coord_TRSquared_min
5005 = \&Math::PlanePath::ToothpickTree::_NumSeq_Coord_TRSquared_min;
5006 }
5007 { package Math::PlanePath::ToothpickUpist;
5008 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
5009 use constant _NumSeq_Coord_Max_non_decreasing => 1; # X<=Y so max=Y
5010 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
5011  
5012 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 9;
5013 }
5014  
5015 { package Math::PlanePath::LCornerTree;
5016 sub _NumSeq_Coord_Max_min {
5017 my ($self) = @_;
5018 return ($self->{'parts'} eq '4' ? undef : 0);
5019 }
5020 {
5021 my %_NumSeq_Coord_IntXY_min
5022 = (1 => 0,
5023 octant => 1, # X>=Y so X/Y>=1, and 0/0
5024 'octant+1' => 0, # X>=Y-1 so int(X/Y)>=0
5025 octant_up => 0, # X>=0 so X/Y>=1, and 0/0
5026 'octant_up+1' => 0, # X>=0 so X/Y>=1, and 0/0
5027 wedge => -2, # X>=-Y-1 so X/Y>=-2
5028 'wedge+1' => -3, # X>=-Y-2 so X/Y>=-3
5029 );
5030 sub _NumSeq_Coord_IntXY_min {
5031 my ($self) = @_;
5032 return $_NumSeq_Coord_IntXY_min{$self->{'parts'}};
5033 }
5034 }
5035  
5036 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 2;
5037 }
5038 { package Math::PlanePath::LCornerReplicate;
5039 use constant _NumSeq_Coord_filling_type => 'quadrant';
5040 }
5041 # { package Math::PlanePath::PeninsulaBridge;
5042 # }
5043  
5044 { package Math::PlanePath::OneOfEight;
5045 sub _NumSeq_Coord_Max_min {
5046 my ($self) = @_;
5047 return ($self->{'parts'} eq '4' ? undef : 0);
5048 }
5049  
5050 sub _NumSeq_Coord_IntXY_min {
5051 my ($self) = @_;
5052 if ($self->{'parts'} eq 'octant') { return 1; }
5053 return $self->SUPER::_NumSeq_Coord_IntXY_min;
5054 }
5055  
5056 {
5057 # usually 2, but in 3side only 1
5058 my %_NumSeq_Coord_ExperimentalLeafDistance_max = ('3side' => 1,
5059 );
5060 sub _NumSeq_Coord_ExperimentalLeafDistance_max {
5061 my ($self) = @_;
5062 return $_NumSeq_Coord_ExperimentalLeafDistance_max{$self->{'parts'}} || 2;
5063 }
5064 }
5065 }
5066  
5067 { package Math::PlanePath::HTree;
5068 use constant _NumSeq_Coord_Depth_non_decreasing => 0;
5069 use constant _NumSeq_Coord_NumSiblings_non_decreasing => 1;
5070 }
5071  
5072 #------------------------------------------------------------------------------
5073 1;
5074 __END__