NumSeq/PlanePathCoord.pm untested

filter: Statementstmt 0.0% 0 / 2765 Branchbran 0.0% 0 / 552 Conditioncond 0.0% 0 / 443 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 692 Podpod 0.0% 0 / 304 totaltotal 0.0% 0 / 4756 CC 274 SCAR 28.6
CC
274
Cov
0%
_kronecker_symbol
306.0
oeis_anum
240.0
_coordinate_func_GCD
90.0
CRAP 17.4
1 # Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin Ryde
2  
3 # This file is part of Math-PlanePath.
4 #
5 # Math-PlanePath is free software; you can redistribute it and/or modify
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 = 128;
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 RSquared => 'A336336', # norm
2151 # OEIS-Catalogue: A174344 planepath=SquareSpiral coordinate_type=X
2152 # OEIS-Catalogue: A214526 planepath=SquareSpiral coordinate_type=SumAbs
2153 # OEIS-Catalogue: A336336 planepath=SquareSpiral coordinate_type=RSquared
2154 },
2155 'wider=0,n_start=0' =>
2156 { Sum => 'A180714', # X+Y of square spiral
2157 AbsDiff => 'A053615', # n..0..n, distance to pronic
2158 # OEIS-Catalogue: A180714 planepath=SquareSpiral,n_start=0 coordinate_type=Sum
2159 # OEIS-Other: A053615 planepath=SquareSpiral,n_start=0 coordinate_type=AbsDiff
2160 },
2161 };
2162 }
2163 { package Math::PlanePath::GreekKeySpiral;
2164 use constant _NumSeq_Coord_filling_type => 'plane';
2165 sub _NumSeq_Coord_MaxAbs_non_decreasing {
2166 my ($self) = @_;
2167 return ($self->{'turns'} == 0); # when same as SquareSpiral
2168 }
2169 }
2170 { package Math::PlanePath::PyramidSpiral;
2171 use constant _NumSeq_Coord_filling_type => 'plane';
2172 use constant _NumSeq_Coord_oeis_anum =>
2173 { 'n_start=0' =>
2174 { X => 'A329116',
2175 Y => 'A329972',
2176 # OEIS-Catalogue: A329116 planepath=PyramidSpiral,n_start=0 coordinate_type=X
2177 # OEIS-Catalogue: A329972 planepath=PyramidSpiral,n_start=0 coordinate_type=Y
2178 ExperimentalAbsX => 'A053615', # runs n..0..n, OFFSET=0
2179 # OEIS-Catalogue: A053615 planepath=PyramidSpiral,n_start=0 coordinate_type=ExperimentalAbsX
2180 },
2181 };
2182 }
2183 { package Math::PlanePath::TriangleSpiral;
2184 use constant _NumSeq_Coord_filling_type => 'triangular';
2185 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
2186 }
2187 { package Math::PlanePath::TriangleSpiralSkewed;
2188 use constant _NumSeq_Coord_filling_type => 'plane';
2189 }
2190 { package Math::PlanePath::DiamondSpiral;
2191 use constant _NumSeq_Coord_filling_type => 'plane';
2192 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1; # diagonals pos,neg
2193 use constant _NumSeq_Coord_oeis_anum =>
2194 { 'n_start=0' =>
2195 { X => 'A010751', # up 1, down 2, up 3, down 4, etc
2196 Y => 'A305258',
2197 ExperimentalAbsY => 'A053616',
2198 # OEIS-Catalogue: A010751 planepath=DiamondSpiral,n_start=0
2199 # OEIS-Catalogue: A305258 planepath=DiamondSpiral,n_start=0 coordinate_type=Y
2200 # OEIS-Other: A053616 planepath=DiamondSpiral,n_start=0 coordinate_type=ExperimentalAbsY
2201 },
2202 };
2203 }
2204 { package Math::PlanePath::AztecDiamondRings;
2205 use constant _NumSeq_Coord_filling_type => 'plane';
2206 }
2207 { package Math::PlanePath::PentSpiralSkewed;
2208 use constant _NumSeq_Coord_filling_type => 'plane';
2209 }
2210 { package Math::PlanePath::HexSpiral;
2211 use constant _NumSeq_Coord_filling_type => 'triangular';
2212 # origin 0,0 if wider even, otherwise only X=1,Y=0 if wider odd
2213 sub _NumSeq_Coord_TRSquared_min { $_[0]->rsquared_minimum }
2214  
2215 # always odd/even according to wider odd/even
2216 sub _NumSeq_Coord_ExperimentalParity_min {
2217 my ($self) = @_;
2218 return $self->{'wider'} & 1;
2219 }
2220 *_NumSeq_Coord_ExperimentalParity_max = \&_NumSeq_Coord_ExperimentalParity_min;
2221  
2222 # X!=Y when wider odd
2223 *_NumSeq_Coord_ExperimentalHammingDist_min = \&_NumSeq_Coord_ExperimentalParity_min;
2224 *_NumSeq_Coord_MaxAbs_min = \&_NumSeq_Coord_ExperimentalParity_min;
2225  
2226 use constant _NumSeq_Coord_oeis_anum =>
2227 {
2228 'wider=0,n_start=0' =>
2229 {X => 'A328818',
2230 Y => 'A307012',
2231 # OEIS-Catalogue: A328818 planepath=HexSpiral,n_start=0 coordinate_type=X
2232 # OEIS-Catalogue: A307012 planepath=HexSpiral,n_start=0 coordinate_type=Y
2233 },
2234 };
2235 }
2236 { package Math::PlanePath::HexSpiralSkewed;
2237 use constant _NumSeq_Coord_filling_type => 'plane';
2238 }
2239 { package Math::PlanePath::HexArms;
2240 use constant _NumSeq_Coord_filling_type => 'triangular';
2241 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
2242 }
2243 { package Math::PlanePath::HeptSpiralSkewed;
2244 use constant _NumSeq_Coord_filling_type => 'plane';
2245 }
2246 { package Math::PlanePath::AnvilSpiral;
2247 use constant _NumSeq_Coord_filling_type => 'plane';
2248 }
2249 { package Math::PlanePath::OctagramSpiral;
2250 use constant _NumSeq_Coord_filling_type => 'plane';
2251 }
2252 { package Math::PlanePath::KnightSpiral;
2253 use constant _NumSeq_Coord_filling_type => 'plane';
2254 }
2255 { package Math::PlanePath::CretanLabyrinth;
2256 use constant _NumSeq_Coord_filling_type => 'plane';
2257 }
2258 { package Math::PlanePath::SquareArms;
2259 use constant _NumSeq_Coord_filling_type => 'plane';
2260 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # successive squares
2261 }
2262 { package Math::PlanePath::DiamondArms;
2263 use constant _NumSeq_Coord_filling_type => 'plane';
2264 }
2265 { package Math::PlanePath::SacksSpiral;
2266 use constant _NumSeq_Coord_X_integer => 0;
2267 use constant _NumSeq_Coord_Y_integer => 0;
2268 use constant _NumSeq_Coord_Radius_increasing => 1; # Radius==sqrt($i)
2269 use constant _NumSeq_Coord_RSquared_smaller => 0; # RSquared==$i
2270 use constant _NumSeq_Coord_RSquared_integer => 1;
2271  
2272 use constant _NumSeq_Coord_oeis_anum =>
2273 { '' =>
2274 { RSquared => 'A001477', # integers 0,1,2,3,etc
2275 # OEIS-Other: A001477 planepath=SacksSpiral coordinate_type=RSquared
2276 },
2277 };
2278 }
2279 { package Math::PlanePath::VogelFloret;
2280 use constant _NumSeq_Coord_X_integer => 0;
2281 use constant _NumSeq_Coord_Y_integer => 0;
2282 use constant _NumSeq_AbsDiff_min_is_infimum => 1;
2283 use constant _NumSeq_MinAbs_min_is_infimum => 1;
2284 use constant _NumSeq_MaxAbs_min_is_infimum => 1;
2285  
2286 sub _NumSeq_Coord_Radius_min {
2287 my ($self) = @_;
2288 # starting N=1 at R=radius_factor*sqrt(1), theta=something
2289 return $self->{'radius_factor'};
2290 }
2291 sub _NumSeq_Coord_TRSquared_min {
2292 my ($self) = @_;
2293 # starting N=1 at R=radius_factor*sqrt(1), theta=something
2294 my ($x,$y) = $self->n_to_xy($self->n_start);
2295 return $x*$x + 3*$y*$y;
2296 }
2297 sub _NumSeq_Coord_Radius_func {
2298 my ($seq, $i) = @_;
2299 ### VogelFloret Radius: $i, $seq->{'planepath_object'}
2300 # R=radius_factor*sqrt($n)
2301 # avoid sin/cos in the main n_to_xy()
2302  
2303 my $path = $seq->{'planepath_object'};
2304 my $rf = $path->{'radius_factor'};
2305  
2306 # promote BigInt $i -> BigFloat so that sqrt() doesn't round, and in
2307 # case radius_factor is not an integer
2308 if (ref $i && $i->isa('Math::BigInt') && $rf != int($rf)) {
2309 require Math::BigFloat;
2310 $i = Math::BigFloat->new($i);
2311 }
2312  
2313 return sqrt($i) * $rf;
2314 }
2315 use constant _NumSeq_Coord_Radius_increasing => 1; # Radius==sqrt($i)
2316 use constant _NumSeq_Coord_RSquared_smaller => 0; # RSquared==$i
2317 }
2318 { package Math::PlanePath::TheodorusSpiral;
2319 use constant _NumSeq_Coord_X_integer => 0;
2320 use constant _NumSeq_Coord_Y_integer => 0;
2321 use constant _NumSeq_Coord_Radius_increasing => 1; # Radius==sqrt($i)
2322 use constant _NumSeq_Coord_RSquared_smaller => 0; # RSquared==$i
2323 use constant _NumSeq_Coord_RSquared_integer => 1;
2324  
2325 use constant _NumSeq_Coord_oeis_anum =>
2326 { '' =>
2327 { RSquared => 'A001477', # integers 0,1,2,3,etc
2328 # OEIS-Other: A001477 planepath=TheodorusSpiral coordinate_type=RSquared
2329 },
2330 };
2331 }
2332 { package Math::PlanePath::ArchimedeanChords;
2333 use constant _NumSeq_Coord_X_integer => 0;
2334 use constant _NumSeq_Coord_Y_integer => 0;
2335 use constant _NumSeq_Coord_Radius_increasing => 1; # spiralling outwards
2336 }
2337 { package Math::PlanePath::MultipleRings;
2338  
2339 #---------
2340 # X
2341 sub _NumSeq_Coord_X_increasing {
2342 my ($self) = @_;
2343 # step==0 trivial on X axis
2344 return ($self->{'step'} == 0 ? 1 : 0);
2345 }
2346 sub _NumSeq_Coord_X_integer {
2347 my ($self) = @_;
2348 return ($self->{'step'} == 0); # step==0 trivial on X axis
2349 }
2350  
2351 #---------
2352 # Y
2353 *_NumSeq_Coord_Y_integer = \&_NumSeq_Coord_X_increasing;
2354 *_NumSeq_Coord_Y_non_decreasing = \&_NumSeq_Coord_X_increasing;
2355  
2356 *_NumSeq_Coord_Sum_increasing = \&_NumSeq_Coord_X_increasing;
2357 *_NumSeq_Coord_DiffXY_increasing = \&_NumSeq_Coord_X_increasing;
2358 *_NumSeq_Coord_DiffXYdiv2_increasing = \&_NumSeq_Coord_X_increasing;
2359 *_NumSeq_Coord_TRSquared_integer = \&_NumSeq_Coord_X_increasing;
2360 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_X_increasing;
2361 *_NumSeq_Coord_Product_integer = \&_NumSeq_Coord_X_increasing;
2362 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_X_increasing;
2363 *_NumSeq_Coord_BitOr_increasing = \&_NumSeq_Coord_X_increasing;
2364 *_NumSeq_Coord_BitXor_increasing = \&_NumSeq_Coord_X_increasing;
2365 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_increasing;
2366 *_NumSeq_Coord_Max_increasing = \&_NumSeq_Coord_X_increasing;
2367  
2368 #---------
2369 # SumAbs
2370 sub _NumSeq_Coord_SumAbs_non_decreasing {
2371 my ($self) = @_;
2372 # step==0 trivial on X axis
2373 # polygon step=4 same x+y in ring, others vary
2374 return ($self->{'step'} == 0
2375 || ($self->{'ring_shape'} eq 'polygon' && $self->{'step'} == 4)
2376 ? 1
2377 : 0);
2378 }
2379 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_X_increasing;
2380  
2381 #---------
2382 # Product
2383 sub _NumSeq_Coord_Product_max {
2384 my ($self) = @_;
2385 # step==0 trivial on X axis
2386 # polygon step=4 same x+y in ring, others vary
2387 return ($self->{'step'} == 0 ? 0 # step=0 always Y=0 so X*Y=0
2388 : undef);
2389 }
2390 *_NumSeq_Coord_BitAnd_max = \&_NumSeq_Coord_Product_max;
2391  
2392 #---------
2393 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_X_increasing;
2394 sub _NumSeq_AbsDiff_min_is_infimum {
2395 my ($self) = @_;
2396 # step multiple of 4 always falls on X=Y, otherwise approaches 0 only
2397 return ($self->{'ring_shape'} eq 'polygon'
2398 && $self->{'step'} % 4);
2399 }
2400  
2401 #---------
2402 # RSquared
2403 sub _NumSeq_Coord_RSquared_smaller {
2404 my ($self) = @_;
2405 # step==0 on X axis RSquared is i^2, bigger than i.
2406 # 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,
2407 # bigger than i from i=5 onwards
2408 return ($self->{'step'} <= 1 ? 0 : 1);
2409 }
2410 *_NumSeq_Coord_RSquared_integer = \&_NumSeq_Coord_Radius_integer;
2411 *_NumSeq_Coord_RSquared_non_decreasing = \&_NumSeq_Coord_Radius_non_decreasing;
2412  
2413 #---------
2414 # Radius
2415 sub _NumSeq_Coord_Radius_integer {
2416 my ($self) = @_;
2417 # step==0 on X axis R=N
2418 # step==1 start X=0,Y=0, spaced 1 apart on X axis, same radius for others
2419 # step==6 start X=1,Y=0, spaced 1 apart
2420 return ($self->{'step'} <= 1 || $self->{'step'} == 6);
2421 }
2422 sub _NumSeq_Coord_Radius_non_decreasing {
2423 my ($self) = @_;
2424 # circle is non-decreasing, polygon varies
2425 return ! ($self->{'ring_shape'} eq 'polygon' && $self->{'step'} >= 3);
2426 }
2427 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_X_increasing;
2428  
2429 #---------
2430 # TRadius
2431 sub _NumSeq_Coord_TRadius_min {
2432 my ($self) = @_;
2433 return $self->_NumSeq_Coord_Radius_min;
2434 }
2435 sub _NumSeq_Coord_TRSquared_min {
2436 my ($self) = @_;
2437 return $self->rsquared_minimum;
2438 }
2439 sub _NumSeq_Coord_TRadius_non_decreasing {
2440 my ($self) = @_;
2441 # step==0 trivial on X axis
2442 return ($self->{'step'} == 0 ? 1 : 0);
2443 }
2444 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_X_increasing;
2445 *_NumSeq_Coord_TRadius_integer = \&_NumSeq_Coord_X_increasing;
2446  
2447 #---------
2448 # GCD
2449 *_NumSeq_Coord_GCD_integer = \&_NumSeq_Coord_X_increasing;
2450 *_NumSeq_Coord_GCD_increasing = \&_NumSeq_Coord_X_increasing;
2451  
2452 #---------
2453 # IntXY
2454 # step=0 X/0 so IntXY=X
2455 *_NumSeq_Coord_IntXY_increasing = \&_NumSeq_Coord_X_increasing;
2456  
2457 #---------
2458 # FracXY
2459 sub _NumSeq_Coord_FracXY_max {
2460 my ($self) = @_;
2461 return ($self->{'step'} == 0 ? 0 : 1);
2462 }
2463 sub _NumSeq_FracXY_max_is_supremum {
2464 my ($self) = @_;
2465 return ($self->{'step'} == 0 ? 0 : 1);
2466 }
2467 *_NumSeq_Coord_FracXY_non_decreasing = \&_NumSeq_Coord_X_increasing;
2468 *_NumSeq_Coord_FracXY_integer = \&_NumSeq_Coord_X_increasing;
2469  
2470 sub _NumSeq_ExperimentalParity_min_is_infimum {
2471 my ($self) = @_;
2472 return $self->{'ring_shape'} eq 'polygon';
2473 }
2474  
2475 use constant _NumSeq_Coord_oeis_anum =>
2476 {
2477 # MultipleRings step=0 is trivial X=N,Y=0
2478 'step=0,ring_shape=circle' =>
2479 { Y => 'A000004', # all-zeros
2480 Product => 'A000004', # all-zeros
2481 # OEIS-Other: A000004 planepath=MultipleRings,step=0 coordinate_type=Y
2482 # OEIS-Other: A000004 planepath=MultipleRings,step=0 coordinate_type=Product
2483  
2484 # OFFSET
2485 # X => 'A001477', # integers 0 upwards
2486 # Sum => 'A001477', # integers 0 upwards
2487 # AbsDiff => 'A001477', # integers 0 upwards
2488 # Radius => 'A001477', # integers 0 upwards
2489 # DiffXY => 'A001477', # integers 0 upwards
2490 # DiffYX => 'A001489', # negative integers 0 downwards
2491 # RSquared => 'A000290', # squares 0 upwards
2492 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=X
2493 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=Sum
2494 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=AbsDiff
2495 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=Radius
2496 # # OEIS-Other: A001477 planepath=MultipleRings,step=0 coordinate_type=DiffXY
2497 # # OEIS-Other: A001489 planepath=MultipleRings,step=0 coordinate_type=DiffYX
2498 # # OEIS-Other: A000290 planepath=MultipleRings,step=0 coordinate_type=RSquared
2499 },
2500 };
2501 }
2502 # { package Math::PlanePath::PixelRings;
2503 # }
2504 { package Math::PlanePath::FilledRings;
2505 use constant _NumSeq_Coord_filling_type => 'plane';
2506 }
2507 { package Math::PlanePath::Hypot;
2508 use constant _NumSeq_Coord_filling_type => 'plane';
2509 sub _NumSeq_Coord_TRSquared_min { $_[0]->rsquared_minimum }
2510  
2511 # in order of radius so monotonic, but always have 4x duplicates or more
2512 use constant _NumSeq_Coord_Radius_non_decreasing => 1;
2513  
2514 sub _NumSeq_Coord_ExperimentalHammingDist_min {
2515 my ($self) = @_;
2516 return ($self->{'points'} eq 'odd' ? 1 : 0);
2517 }
2518 *_NumSeq_Coord_ExperimentalParity_min = \&_NumSeq_Coord_ExperimentalHammingDist_min;
2519 *_NumSeq_Coord_MaxAbs_min = \&_NumSeq_Coord_ExperimentalHammingDist_min;
2520  
2521 sub _NumSeq_Coord_ExperimentalParity_max {
2522 my ($self) = @_;
2523 return ($self->{'points'} eq 'even' ? 0 : 1);
2524 }
2525 }
2526 { package Math::PlanePath::HypotOctant;
2527 use constant _NumSeq_Coord_IntXY_min => 1; # triangular X>=Y so X/Y >= 1
2528  
2529 sub _NumSeq_Coord_TRSquared_min { $_[0]->rsquared_minimum }
2530 sub _NumSeq_Coord_BitXor_min {
2531 my ($self) = @_;
2532 # "odd" always has X!=Ymod2 so differ in low bit
2533 return ($self->{'points'} eq 'odd' ? 1 : 0);
2534 }
2535  
2536 # in order of radius so monotonic, but can have duplicates
2537 use constant _NumSeq_Coord_Radius_non_decreasing => 1;
2538  
2539 sub _NumSeq_Coord_ExperimentalHammingDist_min {
2540 my ($self) = @_;
2541 return ($self->{'points'} eq 'odd' ? 1 : 0);
2542 }
2543  
2544 sub _NumSeq_Coord_ExperimentalParity_min {
2545 my ($self) = @_;
2546 return ($self->{'points'} eq 'odd' ? 1 : 0);
2547 }
2548 sub _NumSeq_Coord_ExperimentalParity_max {
2549 my ($self) = @_;
2550 return ($self->{'points'} eq 'even' ? 0 : 1);
2551 }
2552 }
2553 { package Math::PlanePath::TriangularHypot;
2554 use constant _NumSeq_Coord_filling_type => 'triangular';
2555 sub _NumSeq_Coord_TRSquared_min {
2556 my ($self) = @_;
2557 return ($self->{'points'} eq 'odd'
2558 ? 1 # odd at X=1,Y=0
2559 : $self->{'points'} eq 'hex_centred'
2560 ? 4 # hex_centred at X=2,Y=0 or X=1,Y=1
2561 : 0); # even,all at X=0,Y=0
2562 }
2563  
2564 # in order of triangular radius so monotonic, but can have duplicates so
2565 # non-decreasing
2566 use constant _NumSeq_Coord_TRadius_non_decreasing => 1;
2567  
2568 sub _NumSeq_Coord_ExperimentalHammingDist_min {
2569 my ($self) = @_;
2570 return ($self->{'points'} eq 'odd' ? 1 : 0); # X!=Y when odd
2571 }
2572 *_NumSeq_Coord_ExperimentalParity_min = \&_NumSeq_Coord_ExperimentalHammingDist_min;
2573 sub _NumSeq_Coord_MaxAbs_min {
2574 my ($self) = @_;
2575 return ($self->{'points'} eq 'odd' || $self->{'points'} eq 'hex_centred'
2576 ? 1 : 0);
2577 }
2578  
2579 sub _NumSeq_Coord_ExperimentalParity_max {
2580 my ($self) = @_;
2581 return ($self->{'points'} eq 'odd' || $self->{'points'} eq 'all' ? 1 : 0);
2582 }
2583 }
2584 { package Math::PlanePath::PythagoreanTree;
2585 use constant _NumSeq_Coord_SubHeight_min => undef;
2586 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => undef;
2587  
2588 {
2589 my %_NumSeq_Coord_IntXY_min = (AB => 0, # A>=1,B>=1 so int(A/B)>=0
2590 AC => 0, # A<C so int(A/C)==0 always
2591 BC => 0, # B<C so int(A/C)==0 always
2592 PQ => 1, # octant X>=Y+1 so X/Y>1
2593 SM => 0, # A>=1,B>=1 so int(A/B)>=0
2594 SC => 0,
2595 MC => 0,
2596 );
2597 sub _NumSeq_Coord_IntXY_min {
2598 my ($self) = @_;
2599 return $_NumSeq_Coord_IntXY_min{$self->{'coordinates'}};
2600 }
2601 }
2602 {
2603 my %_NumSeq_Coord_IntXY_max = (AC => 0, # A<C so int(A/C)==0 always
2604 BC => 0, # B<C so int(A/C)==0 always
2605 SM => 0, # X<Y so int(X/Y)<1
2606 SC => 0, # X<Y so int(X/Y)<1
2607 MC => 0, # X<Y so int(X/Y)<1
2608 );
2609 sub _NumSeq_Coord_IntXY_max {
2610 my ($self) = @_;
2611 return $_NumSeq_Coord_IntXY_max{$self->{'coordinates'}};
2612 }
2613 }
2614  
2615 # P=2,Q=1 frac=0
2616 # otherwise A,B,C have no common factor and >1 so frac!=0
2617 sub _NumSeq_FracXY_min_is_infimum {
2618 my ($self) = @_;
2619 return $self->{'coordinates'} ne 'PQ';
2620 }
2621  
2622 {
2623 my %_NumSeq_Coord_ExperimentalDenominator_min = (AB => 4, # at A=3,B=4 no common factor
2624 AC => 5, # at A=3,B=5
2625 BC => 5, # at B=4,B=5
2626 PQ => 1, # at P=2,Q=1
2627 );
2628 sub _NumSeq_Coord_ExperimentalDenominator_min {
2629 my ($self) = @_;
2630 return $_NumSeq_Coord_ExperimentalDenominator_min{$self->{'coordinates'}};
2631 }
2632 }
2633  
2634 {
2635 my %_NumSeq_Coord_BitAnd_min = (AB => 0, # at X=3,Y=4
2636 AC => 1, # at X=3,Y=5
2637 BC => 0, # at X=8,Y=17
2638 PQ => 0, # at X=2,Y=1
2639 SM => 0, # at X=3,Y=4
2640 SC => 0, # at X=3,Y=5
2641 MC => 0, # at X=4,Y=5
2642 );
2643 sub _NumSeq_Coord_BitAnd_min {
2644 my ($self) = @_;
2645 return $_NumSeq_Coord_BitAnd_min{$self->{'coordinates'}};
2646 }
2647 }
2648 {
2649 my %_NumSeq_Coord_BitOr_min = (AB => 7, # at A=3,B=4
2650 AC => 7, # at A=3,C=5
2651 BC => 5, # at B=4,C=5
2652 PQ => 3, # at P=2,Q=1
2653 SM => 7, # at X=3,Y=4
2654 SC => 7, # at X=3,Y=5
2655 MC => 5, # at X=4,Y=5
2656 );
2657 sub _NumSeq_Coord_BitOr_min {
2658 my ($self) = @_;
2659 return $_NumSeq_Coord_BitOr_min{$self->{'coordinates'}};
2660 }
2661 }
2662 {
2663 my %_NumSeq_Coord_BitXor_min = (AB => 1, # at X=21,Y=20
2664 AC => 6, # at X=3,Y=5
2665 BC => 1, # at X=4,Y=5
2666 PQ => 1, # at X=3,Y=2
2667 SM => 1, # at X=3,Y=4
2668 SC => 6, # at X=3,Y=5
2669 MC => 1, # at X=4,Y=5
2670 );
2671 sub _NumSeq_Coord_BitXor_min {
2672 my ($self) = @_;
2673 return $_NumSeq_Coord_BitXor_min{$self->{'coordinates'}};
2674 }
2675 }
2676  
2677 sub _NumSeq_Coord_Radius_integer {
2678 my ($self) = @_;
2679 return ($self->{'coordinates'} eq 'AB' # hypot
2680 || $self->{'coordinates'} eq 'SM'); # hypot
2681 }
2682  
2683 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
2684  
2685 {
2686 my %_NumSeq_Coord_ExperimentalParity_min = (PQ => 1, # one odd one even, so odd always
2687 AB => 1, # odd,even so odd always
2688 BA => 1,
2689 BC => 1, # even,odd so odd always
2690 );
2691 sub _NumSeq_Coord_ExperimentalParity_min {
2692 my ($self) = @_;
2693 return $_NumSeq_Coord_ExperimentalParity_min{$self->{'coordinates'}} || 0;
2694 }
2695 }
2696 sub _NumSeq_Coord_ExperimentalParity_max {
2697 my ($self) = @_;
2698 return ($self->{'coordinates'} eq 'AC'
2699 ? 0 # odd,odd so even always
2700 : 1);
2701 }
2702  
2703 # Not quite right.
2704 # sub _NumSeq_Coord_pred_Radius {
2705 # my ($path, $value) = @_;
2706 # return ($value >= 0
2707 # && ($path->{'coordinate_type'} ne 'AB'
2708 # || $value == int($value)));
2709 # }
2710  
2711 use constant _NumSeq_Coord_oeis_anum =>
2712 { 'tree_type=UAD,coordinates=AB,digit_order=HtoL' =>
2713 { X => 'A321768',
2714 Y => 'A321769',
2715 Radius => 'A321770', # hypotenuse
2716 # OEIS-Catalogue: A321768 planepath=PythagoreanTree coordinate_type=X
2717 # OEIS-Catalogue: A321769 planepath=PythagoreanTree coordinate_type=Y
2718 # OEIS-Other: A321770 planepath=PythagoreanTree coordinate_type=Radius
2719 },
2720 'tree_type=UAD,coordinates=AC,digit_order=HtoL' =>
2721 { X => 'A321768',
2722 Y => 'A321770',
2723 Min => 'A321768', # min = A
2724 MinAbs => 'A321768',
2725 Max => 'A321770', # min = C
2726 MaxAbs => 'A321770',
2727 # OEIS-Other: A321768 planepath=PythagoreanTree,coordinates=AC coordinate_type=X
2728 # OEIS-Catalogue: A321770 planepath=PythagoreanTree,coordinates=AC coordinate_type=Y
2729 # OEIS-Other: A321768 planepath=PythagoreanTree,coordinates=AC coordinate_type=Min
2730 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=AC coordinate_type=Max
2731 # OEIS-Other: A321768 planepath=PythagoreanTree,coordinates=AC coordinate_type=MinAbs
2732 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=AC coordinate_type=MaxAbs
2733 },
2734 'tree_type=UAD,coordinates=BC,digit_order=HtoL' =>
2735 { X => 'A321769',
2736 Y => 'A321770',
2737 Min => 'A321769', # min = B
2738 MinAbs => 'A321769',
2739 Max => 'A321770', # max = C
2740 MaxAbs => 'A321770',
2741 # OEIS-Other: A321769 planepath=PythagoreanTree,coordinates=BC coordinate_type=X
2742 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=BC coordinate_type=Y
2743 # OEIS-Other: A321769 planepath=PythagoreanTree,coordinates=BC coordinate_type=Min
2744 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=BC coordinate_type=Max
2745 # OEIS-Other: A321769 planepath=PythagoreanTree,coordinates=BC coordinate_type=MinAbs
2746 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=BC coordinate_type=MaxAbs
2747 },
2748 'tree_type=UAD,coordinates=SM,digit_order=HtoL' =>
2749 { Radius => 'A321770', # hypotenuse
2750 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=SM coordinate_type=Radius
2751 },
2752 'tree_type=UAD,coordinates=SC,digit_order=HtoL' =>
2753 { Y => 'A321770',
2754 Max => 'A321770', # max = C
2755 MaxAbs => 'A321770',
2756 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=SC coordinate_type=Y
2757 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=SC coordinate_type=Max
2758 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=SC coordinate_type=MaxAbs
2759 },
2760 'tree_type=UAD,coordinates=MC,digit_order=HtoL' =>
2761 { Y => 'A321770',
2762 Max => 'A321770', # max = C
2763 MaxAbs => 'A321770',
2764 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=MC coordinate_type=Y
2765 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=MC coordinate_type=Max
2766 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=MC coordinate_type=MaxAbs
2767 },
2768  
2769 'tree_type=UAD,coordinates=PQ,digit_order=HtoL' =>
2770 { X => 'A321782',
2771 Y => 'A321783',
2772 Min => 'A321783', # min = Y
2773 MinAbs => 'A321783',
2774 Max => 'A321782', # min = X
2775 MaxAbs => 'A321782',
2776 Sum => 'A321784',
2777 SumAbs => 'A321784',
2778 DiffXY => 'A321785',
2779 AbsDiff => 'A321785',
2780 RSquared => 'A321770', # p^2 + q^2 = C
2781 # OEIS-Catalogue: A321782 planepath=PythagoreanTree,coordinates=PQ coordinate_type=X
2782 # OEIS-Catalogue: A321783 planepath=PythagoreanTree,coordinates=PQ coordinate_type=Y
2783 # OEIS-Other: A321783 planepath=PythagoreanTree,coordinates=PQ coordinate_type=Min
2784 # OEIS-Other: A321783 planepath=PythagoreanTree,coordinates=PQ coordinate_type=MinAbs
2785 # OEIS-Other: A321782 planepath=PythagoreanTree,coordinates=PQ coordinate_type=Max
2786 # OEIS-Other: A321782 planepath=PythagoreanTree,coordinates=PQ coordinate_type=MaxAbs
2787 # OEIS-Catalogue: A321784 planepath=PythagoreanTree,coordinates=PQ coordinate_type=Sum
2788 # OEIS-Other: A321784 planepath=PythagoreanTree,coordinates=PQ coordinate_type=SumAbs
2789 # OEIS-Catalogue: A321785 planepath=PythagoreanTree,coordinates=PQ coordinate_type=DiffXY
2790 # OEIS-Other: A321785 planepath=PythagoreanTree,coordinates=PQ coordinate_type=AbsDiff
2791 # OEIS-Other: A321770 planepath=PythagoreanTree,coordinates=PQ coordinate_type=RSquared
2792  
2793 # No, 2*p*q = B, not just p*q
2794 # Product => 'A321769', # 2*p*q = B
2795 # # OEIS-Other: A321769 planepath=PythagoreanTree,coordinates=PQ coordinate_type=Product
2796 },
2797  
2798 'tree_type=UAD,coordinates=PQ,digit_order=LtoH' =>
2799 { X => 'A321782', # P is same in HtoL and LtoH
2800 Max => 'A321782', # min = X
2801 MaxAbs => 'A321782',
2802 # OEIS-Other: A321782 planepath=PythagoreanTree,coordinates=PQ,digit_order=LtoH coordinate_type=X
2803 # OEIS-Other: A321782 planepath=PythagoreanTree,coordinates=PQ,digit_order=LtoH coordinate_type=Max
2804 # OEIS-Other: A321782 planepath=PythagoreanTree,coordinates=PQ,digit_order=LtoH coordinate_type=MaxAbs
2805 },
2806 };
2807 }
2808 { package Math::PlanePath::RationalsTree;
2809 use constant _NumSeq_Coord_BitAnd_min => 0; # X=1,Y=2
2810 use constant _NumSeq_Coord_BitXor_min => 0; # X=1,Y=1
2811 use constant _NumSeq_Coord_SubHeight_min => undef;
2812 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => undef;
2813  
2814 use constant _NumSeq_Coord_oeis_anum =>
2815 { 'tree_type=SB' =>
2816 { IntXY => 'A153036',
2817 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2818 # OEIS-Catalogue: A153036 planepath=RationalsTree coordinate_type=IntXY
2819 # OEIS-Catalogue: A000523 planepath=RationalsTree coordinate_type=Depth
2820  
2821 # Not quite, OFFSET n=0 cf N=1 here
2822 # Y => 'A047679', # SB denominator
2823 # # OEIS-Catalogue: A047679 planepath=RationalsTree coordinate_type=Y
2824 #
2825 # X => 'A007305', # SB numerators but starting extra 0,1
2826 # Sum => 'A007306', # Farey/SB denominators, but starting extra 1,1
2827 # Product => 'A119272', # num*den, but starting extra 1,1
2828 # cf A054424 permutation
2829 },
2830 'tree_type=CW' =>
2831 {
2832 # A070871 Stern adjacent S(n)*S(n+1), or Conway's alimentary function,
2833 # cf A070872 where S(n)*S(n+1) = n
2834 # A070873 where S(n)*S(n+1) > n
2835 # A070874 where S(n)*S(n+1) < n
2836 Product => 'A070871',
2837 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2838 # OEIS-Catalogue: A070871 planepath=RationalsTree,tree_type=CW coordinate_type=Product
2839 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=CW coordinate_type=Depth
2840  
2841 # Not quite, A007814 has extra initial 0, OFFSET=0 "0,1,0,2,0"
2842 # whereas path CW IntXY starts N=1 "1,0,2,0,1"
2843 # IntXY => 'A007814', # countlow1bits(N)
2844 # # OEIS-Other: A007814 planepath=RationalsTree,tree_type=CW coordinate_type=IntXY
2845  
2846 # Not quite, CW X and Y is Stern diatomic A002487, but RationalsTree
2847 # starts N=0 X=1,1,2 or Y=1,2 rather than from 0
2848  
2849 # Not quite, CW DiffYX is A070990 stern diatomic first diffs, but
2850 # path starts N=1 diff="0,1,-1,2,-1,1,-2", whereas A070990 starts n=0
2851 # "1,-1,2,-1,1,-2" one less term and would be n_start=-1
2852 },
2853 'tree_type=AYT' =>
2854 { X => 'A020650', # AYT numerator
2855 Y => 'A020651', # AYT denominator
2856 Sum => 'A086592', # Kepler's tree denominators
2857 SumAbs => 'A086592', # Kepler's tree denominators
2858 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2859 IntXY => 'A135523',
2860 # OEIS-Catalogue: A020650 planepath=RationalsTree,tree_type=AYT coordinate_type=X
2861 # OEIS-Catalogue: A020651 planepath=RationalsTree,tree_type=AYT coordinate_type=Y
2862 # OEIS-Other: A086592 planepath=RationalsTree,tree_type=AYT coordinate_type=Sum
2863 # OEIS-Other: A086592 planepath=RationalsTree,tree_type=AYT coordinate_type=SumAbs
2864 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=AYT coordinate_type=Depth
2865 # OEIS-Catalogue: A135523 planepath=RationalsTree,tree_type=AYT coordinate_type=IntXY
2866  
2867 # Not quite, DiffYX almost A070990 Stern diatomic first differences,
2868 # but we have an extra 0 at the start, and we start i=1 rather than
2869 # n=0 too
2870 },
2871 'tree_type=HCS' =>
2872 {
2873 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2874 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=HCS coordinate_type=Depth
2875  
2876 # # Not quite, OFFSET=0 value=1/1 corresponding to N=0 X=0/Y=1 here
2877 # Sum => 'A071585', # rats>=1 is HCS num+den
2878 # Y => 'A071766', # rats>=1 HCS denominator
2879 # # OEIS-Catalogue: A071585 planepath=RationalsTree,tree_type=HCS coordinate_type=X
2880 # # OEIS-Catalogue: A071766 planepath=RationalsTree,tree_type=HCS coordinate_type=Y
2881 },
2882 'tree_type=Bird' =>
2883 { X => 'A162909', # Bird tree numerators
2884 Y => 'A162910', # Bird tree denominators
2885 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2886 # OEIS-Catalogue: A162909 planepath=RationalsTree,tree_type=Bird coordinate_type=X
2887 # OEIS-Catalogue: A162910 planepath=RationalsTree,tree_type=Bird coordinate_type=Y
2888 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=Bird coordinate_type=Depth
2889 },
2890 'tree_type=Drib' =>
2891 { X => 'A162911', # Drib tree numerators
2892 Y => 'A162912', # Drib tree denominators
2893 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2894 # OEIS-Catalogue: A162911 planepath=RationalsTree,tree_type=Drib coordinate_type=X
2895 # OEIS-Catalogue: A162912 planepath=RationalsTree,tree_type=Drib coordinate_type=Y
2896 # OEIS-Other: A000523 planepath=RationalsTree,tree_type=Drib coordinate_type=Depth
2897 },
2898 'tree_type=L' =>
2899 {
2900 X => 'A174981', # numerator
2901 # OEIS-Catalogue: A174981 planepath=RationalsTree,tree_type=L coordinate_type=X
2902  
2903 # # Not quite, A002487 extra initial, so n=2 is denominator at N=0
2904 # Y => 'A002487', # denominator, stern diatomic
2905 # # OEIS-Catalogue: A071585 planepath=RationalsTree,tree_type=HCS coordinate_type=Y
2906  
2907 # Not quite, A000523 is OFFSET=1 path starts N=0
2908 # Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2909 },
2910 };
2911 }
2912 { package Math::PlanePath::FractionsTree;
2913 use constant _NumSeq_Coord_IntXY_max => 0; # X/Y<1 always
2914 use constant _NumSeq_Coord_IntXY_non_decreasing => 1;
2915 use constant _NumSeq_FracXY_min_is_infimum => 1; # no common factor
2916 use constant _NumSeq_Coord_BitXor_min => 1; # X=2,Y=3
2917 use constant _NumSeq_Coord_SubHeight_min => undef;
2918 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => undef;
2919 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
2920  
2921 use constant _NumSeq_Coord_oeis_anum =>
2922 { 'tree_type=Kepler' =>
2923 { X => 'A020651', # numerators, same as AYT denominators
2924 Y => 'A086592', # Kepler half-tree denominators
2925 DiffYX => 'A020650', # AYT numerators
2926 AbsDiff => 'A020650', # AYT numerators
2927 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
2928 # OEIS-Other: A020651 planepath=FractionsTree coordinate_type=X
2929 # OEIS-Catalogue: A086592 planepath=FractionsTree coordinate_type=Y
2930 # OEIS-Other: A020650 planepath=FractionsTree coordinate_type=DiffYX
2931 # OEIS-Other: A020650 planepath=FractionsTree coordinate_type=AbsDiff
2932 # OEIS-Other: A000523 planepath=FractionsTree coordinate_type=Depth
2933  
2934 # Not quite, Sum is from 1/2 value=3 skipping the initial value=2 in
2935 # A086593 which would be 1/1. Also is every second denominator, but
2936 # again no initial value=2.
2937 # Sum => 'A086593',
2938 # Y_odd => 'A086593', # at N=1,3,5,etc
2939 },
2940 };
2941 }
2942 { package Math::PlanePath::CfracDigits;
2943 use constant _NumSeq_Coord_IntXY_max => 0; # upper octant 0 < X/Y < 1
2944 use constant _NumSeq_Coord_IntXY_non_decreasing => 1;
2945 use constant _NumSeq_FracXY_min_is_infimum => 1; # X,Y no common factor
2946  
2947 # X=Y doesn't occur so X,Y always differ by at least 1 bit. The smallest
2948 # two differing by 1 bit are X=1,Y=2.
2949 use constant _NumSeq_Coord_BitOr_min => 3; # X=1,Y=2
2950  
2951 use constant _NumSeq_Coord_BitXor_min => 1; # X=2,Y=3
2952 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
2953  
2954 # use constant _NumSeq_Coord_oeis_anum =>
2955 # { 'radix=2' =>
2956 # {
2957 # },
2958 # };
2959 }
2960 { package Math::PlanePath::ChanTree;
2961  
2962 sub _NumSeq_Coord_Max_min {
2963 my ($self) = @_;
2964 # except in k=2 Calkin-Wilf, point X=1,Y=1 doesn't occur, only X=1,Y=2
2965 # or X=2,Y=1
2966 return ($self->{'k'} == 2 ? 1 : 2);
2967 }
2968 *_NumSeq_Coord_MaxAbs_min = \&_NumSeq_Coord_Max_min;
2969  
2970 use constant _NumSeq_Coord_SubHeight_min => undef;
2971 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => undef;
2972  
2973 sub _NumSeq_Coord_Product_min {
2974 my ($self) = @_;
2975 return ($self->{'reduced'} || $self->{'k'} == 2
2976 ? 1 # X=1,Y=1 reduced or k=2 X=1,Y=1
2977 : 2); # X=1,Y=2
2978 }
2979 sub _NumSeq_Coord_TRSquared_min {
2980 my ($self) = @_;
2981 return ($self->{'k'} == 2
2982 || ($self->{'reduced'} && ($self->{'k'} & 1) == 0)
2983 ? 4 # X=1,Y=1 reduced k even, or k=2 top 1/1
2984 : 7); # X=2,Y=1
2985 }
2986  
2987 use constant _NumSeq_Coord_BitAnd_min => 0; # X=1,Y=2
2988 sub _NumSeq_Coord_BitOr_min {
2989 my ($self) = @_;
2990 return ($self->{'k'} == 2 || $self->{'reduced'} ? 1 # X=1,Y=1
2991 : $self->{'k'} & 1 ? 3 # k odd X=1,Y=2
2992 : 2); # k even X=2,Y=2
2993 }
2994 sub _NumSeq_Coord_BitXor_min {
2995 my ($self) = @_;
2996 return ($self->{'k'} == 2 || $self->{'reduced'} ? 0 # X=1,Y=1
2997 : $self->{'k'} & 1 ? 1 # k odd X=2,Y=3
2998 : 0); # k even X=2,Y=2
2999 }
3000  
3001 sub _NumSeq_Coord_ExperimentalParity_min {
3002 my ($self) = @_;
3003 return ($self->{'k'} % 2
3004 ? 1 # k odd has one odd, one even, so odd
3005 : 0);
3006 }
3007 # X!=Y when k odd
3008 *_NumSeq_Coord_ExperimentalHammingDist_min = \&_NumSeq_Coord_ExperimentalParity_min;
3009  
3010 use constant _NumSeq_Coord_oeis_anum =>
3011 {
3012 do { # k=2 same as CW
3013 my $cw = { Product => 'A070871',
3014 Depth => 'A000523', # floor(log2(n)) starting OFFSET=1
3015 # OEIS-Other: A070871 planepath=ChanTree,k=2,n_start=1 coordinate_type=Product
3016 # OEIS-Other: A000523 planepath=ChanTree,k=2,n_start=1 coordinate_type=Depth
3017 };
3018 (
3019 'k=2,n_start=1' => $cw,
3020  
3021 # 'k=2,reduced=0,points=even,n_start=1' => $cw,
3022 # 'k=2,reduced=1,points=even,n_start=1' => $cw,
3023 # 'k=2,reduced=0,points=all,n_start=1' => $cw,
3024 # 'k=2,reduced=1,points=all,n_start=1' => $cw,
3025 ),
3026 },
3027 # 'k=3,reduced=0,points=even,n_start=0' =>
3028 'k=3,n_start=0' =>
3029 { X => 'A191379',
3030 # OEIS-Catalogue: A191379 planepath=ChanTree
3031 },
3032 };
3033 }
3034  
3035 { package Math::PlanePath::PeanoCurve;
3036 use constant _NumSeq_Coord_filling_type => 'quadrant';
3037 use constant _NumSeq_Coord_oeis_anum =>
3038 {
3039 # Same in GrayCode and WunderlichSerpentine
3040 'radix=3' =>
3041 { X => 'A163528',
3042 Y => 'A163529',
3043 Sum => 'A163530',
3044 SumAbs => 'A163530',
3045 RSquared => 'A163531',
3046 # OEIS-Catalogue: A163528 planepath=PeanoCurve coordinate_type=X
3047 # OEIS-Catalogue: A163529 planepath=PeanoCurve coordinate_type=Y
3048 # OEIS-Catalogue: A163530 planepath=PeanoCurve coordinate_type=Sum
3049 # OEIS-Other: A163530 planepath=PeanoCurve coordinate_type=SumAbs
3050 # OEIS-Catalogue: A163531 planepath=PeanoCurve coordinate_type=RSquared
3051 },
3052 };
3053 }
3054 { package Math::PlanePath::PeanoDiagonals;
3055 use constant _NumSeq_Coord_filling_type => 'quadrant';
3056 }
3057 { package Math::PlanePath::WunderlichSerpentine;
3058 use constant _NumSeq_Coord_filling_type => 'quadrant';
3059 use constant _NumSeq_Coord_oeis_anum =>
3060 {
3061 do {
3062 my $peano = { X => 'A163528',
3063 Y => 'A163529',
3064 Sum => 'A163530',
3065 SumAbs => 'A163530',
3066 RSquared => 'A163531',
3067 };
3068 # OEIS-Other: A163528 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=X
3069 # OEIS-Other: A163529 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=Y
3070 # OEIS-Other: A163530 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=Sum
3071 # OEIS-Other: A163530 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=SumAbs
3072 # OEIS-Other: A163531 planepath=WunderlichSerpentine,serpentine_type=Peano,radix=3 coordinate_type=RSquared
3073  
3074 # ENHANCE-ME: with serpentine_type by bits too
3075 ('serpentine_type=Peano,radix=3' => $peano,
3076 )
3077 },
3078 };
3079 }
3080 { package Math::PlanePath::HilbertCurve;
3081 use constant _NumSeq_Coord_filling_type => 'quadrant';
3082 use constant _NumSeq_Coord_oeis_anum =>
3083 { '' =>
3084 { X => 'A059253',
3085 Y => 'A059252',
3086 Sum => 'A059261',
3087 SumAbs => 'A059261',
3088 DiffXY => 'A059285',
3089 RSquared => 'A163547',
3090 BitXor => 'A059905', # alternate bits first (ZOrderCurve X)
3091 ExperimentalHammingDist => 'A139351', # count 1-bits at even bit positions
3092 # OEIS-Catalogue: A059253 planepath=HilbertCurve coordinate_type=X
3093 # OEIS-Catalogue: A059252 planepath=HilbertCurve coordinate_type=Y
3094 # OEIS-Catalogue: A059261 planepath=HilbertCurve coordinate_type=Sum
3095 # OEIS-Other: A059261 planepath=HilbertCurve coordinate_type=SumAbs
3096 # OEIS-Catalogue: A059285 planepath=HilbertCurve coordinate_type=DiffXY
3097 # OEIS-Catalogue: A163547 planepath=HilbertCurve coordinate_type=RSquared
3098 # OEIS-Other: A059905 planepath=HilbertCurve coordinate_type=BitXor
3099 # OEIS-Other: A139351 planepath=HilbertCurve coordinate_type=ExperimentalHammingDist
3100 },
3101 };
3102 }
3103 { package Math::PlanePath::HilbertSides;
3104 use constant _NumSeq_Coord_filling_type => 'quadrant';
3105 use constant _NumSeq_Coord_oeis_anum =>
3106 { '' =>
3107 {
3108 # 1 -1
3109 # / /
3110 # 0 3 0 X-Y = 0,1,0,-1
3111 # / | /
3112 # 3---2 -1 2 1
3113 # | / | /
3114 # 0---1 0---1
3115 DiffXY => 'A059285',
3116 # OEIS-Other: A059285 planepath=HilbertSides coordinate_type=DiffXY
3117 },
3118 };
3119 }
3120 { package Math::PlanePath::HilbertSpiral;
3121 use constant _NumSeq_Coord_filling_type => 'plane';
3122 use constant _NumSeq_Coord_oeis_anum =>
3123 { '' =>
3124 {
3125 # HilbertSpiral going negative is mirror on X=-Y line, which is
3126 # (-Y,-X), so DiffXY = -Y-(-X) = X-Y same diff as plain HilbertCurve.
3127 DiffXY => 'A059285',
3128 # OEIS-Other: A059285 planepath=HilbertSpiral coordinate_type=DiffXY
3129 },
3130 };
3131 }
3132 { package Math::PlanePath::ZOrderCurve;
3133 use constant _NumSeq_Coord_filling_type => 'quadrant';
3134 use constant _NumSeq_Coord_oeis_anum =>
3135 { 'radix=2' =>
3136 { X => 'A059905', # alternate bits first
3137 Y => 'A059906', # alternate bits second
3138 BitAnd => 'A292373',
3139 BitXor => 'A309952',
3140 # OEIS-Catalogue: A059905 planepath=ZOrderCurve coordinate_type=X
3141 # OEIS-Catalogue: A059906 planepath=ZOrderCurve coordinate_type=Y
3142 # OEIS-Catalogue: A292373 planepath=ZOrderCurve coordinate_type=BitAnd
3143 # OEIS-Catalogue: A309952 planepath=ZOrderCurve coordinate_type=BitXor
3144 },
3145 'radix=3' =>
3146 { X => 'A163325', # alternate ternary digits first
3147 Y => 'A163326', # alternate ternary digits second
3148 # OEIS-Catalogue: A163325 planepath=ZOrderCurve,radix=3 coordinate_type=X
3149 # OEIS-Catalogue: A163326 planepath=ZOrderCurve,radix=3 coordinate_type=Y
3150 },
3151 'radix=10' =>
3152 {
3153 Sum => 'A080463',
3154 SumAbs => 'A080463',
3155 # OEIS-Catalogue: A080463 planepath=ZOrderCurve,radix=10 coordinate_type=Sum
3156 # OEIS-Other: A080463 planepath=ZOrderCurve,radix=10 coordinate_type=SumAbs
3157 },
3158 'radix=10,i_start=10' =>
3159 {
3160 # i_start=10 per A080464 OFFSET=10, it skips all but one initial zeros
3161 AbsDiff => 'A080465',
3162 Product => 'A080464',
3163 # OEIS-Catalogue: A080464 planepath=ZOrderCurve,radix=10 coordinate_type=Product i_start=10
3164 # OEIS-Catalogue: A080465 planepath=ZOrderCurve,radix=10 coordinate_type=AbsDiff i_start=10
3165 },
3166 };
3167 }
3168 { package Math::PlanePath::GrayCode;
3169 use constant _NumSeq_Coord_filling_type => 'quadrant';
3170 use constant _NumSeq_Coord_oeis_anum =>
3171 {
3172 do {
3173 my $peano = { X => 'A163528',
3174 Y => 'A163529',
3175 Sum => 'A163530',
3176 SumAbs => 'A163530',
3177 RSquared => 'A163531',
3178 };
3179 my $z = { BitXor => 'A059905',
3180 };
3181 my $fst = { X => 'A309952', # ZOrder too
3182 };
3183 ('apply_type=TsF,gray_type=reflected,radix=3' => $peano,
3184 'apply_type=FsT,gray_type=reflected,radix=3' => $peano,
3185 # OEIS-Other: A163528 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=X
3186 # OEIS-Other: A163529 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=Y
3187 # OEIS-Other: A163530 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=Sum
3188 # OEIS-Other: A163530 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=SumAbs
3189 # OEIS-Other: A163531 planepath=GrayCode,apply_type=TsF,radix=3 coordinate_type=RSquared
3190  
3191 # OEIS-Other: A163528 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=X
3192 # OEIS-Other: A163529 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=Y
3193 # OEIS-Other: A163530 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=Sum
3194 # OEIS-Other: A163530 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=SumAbs
3195 # OEIS-Other: A163531 planepath=GrayCode,apply_type=FsT,radix=3 coordinate_type=RSquared
3196  
3197 # TsF = Fs when radix=2
3198 'apply_type=TsF,gray_type=reflected,radix=2' => $z,
3199 'apply_type=TsF,gray_type=modular,radix=2' => $z,
3200 'apply_type=Fs,gray_type=reflected,radix=2' => $z,
3201 'apply_type=Fs,gray_type=modular,radix=2' => $z,
3202 # OEIS-Other: A059905 planepath=GrayCode,apply_type=TsF coordinate_type=BitXor
3203 # OEIS-Other: A059905 planepath=GrayCode,apply_type=TsF,gray_type=modular coordinate_type=BitXor
3204 # OEIS-Other: A059905 planepath=GrayCode,apply_type=Fs coordinate_type=BitXor
3205 # OEIS-Other: A059905 planepath=GrayCode,apply_type=Fs,gray_type=modular coordinate_type=BitXor
3206  
3207 # FsT = Ts when radix=2
3208 'apply_type=FsT,gray_type=reflected,radix=2' => $fst,
3209 'apply_type=FsT,gray_type=modular,radix=2' => $fst,
3210 'apply_type=Ts,gray_type=reflected,radix=2' => $fst,
3211 'apply_type=Ts,gray_type=modular,radix=2' => $fst,
3212 # OEIS-Other: A309952 planepath=GrayCode,apply_type=Ts coordinate_type=X
3213 # OEIS-Other: A309952 planepath=GrayCode,apply_type=Ts,gray_type=modular coordinate_type=X
3214 # OEIS-Other: A309952 planepath=GrayCode,apply_type=Ts coordinate_type=X
3215 # OEIS-Other: A309952 planepath=GrayCode,apply_type=Ts,gray_type=modular coordinate_type=X
3216 ),
3217  
3218 },
3219 };
3220 }
3221 { package Math::PlanePath::ImaginaryBase;
3222 use constant _NumSeq_Coord_filling_type => 'plane';
3223 }
3224 { package Math::PlanePath::ImaginaryHalf;
3225 use constant _NumSeq_Coord_filling_type => 'half';
3226 }
3227 { package Math::PlanePath::CubicBase;
3228 use constant _NumSeq_Coord_filling_type => 'triangular';
3229 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3230 }
3231 { package Math::PlanePath::Flowsnake;
3232 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3233  
3234 use constant _NumSeq_Coord_oeis_anum =>
3235 { 'arms=1' =>
3236 {Y => 'A334486',
3237 # OEIS-Catalogue: A334486 planepath=Flowsnake coordinate_type=Y
3238 },
3239 };
3240 }
3241 { package Math::PlanePath::FlowsnakeCentres;
3242 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3243 }
3244 { package Math::PlanePath::GosperIslands;
3245 use constant _NumSeq_Coord_TRSquared_min => 4; # minimum X=1,Y=1
3246 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3247 }
3248 { package Math::PlanePath::GosperReplicate;
3249 use constant _NumSeq_Coord_filling_type => 'triangular';
3250 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3251 }
3252 { package Math::PlanePath::GosperSide;
3253 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3254 }
3255 { package Math::PlanePath::KochCurve;
3256 use constant _NumSeq_Coord_IntXY_min => 3; # at X=3,Y=1 among the Y>0 points
3257 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3258 }
3259 { package Math::PlanePath::KochPeaks;
3260 use constant _NumSeq_Coord_MaxAbs_min => 1; # odd always
3261 use constant _NumSeq_Coord_TRSquared_min => 1; # minimum X=1,Y=0
3262 use constant _NumSeq_Coord_ExperimentalParity_min => 1; # odd always
3263 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
3264 }
3265 { package Math::PlanePath::KochSnowflakes;
3266 use constant _NumSeq_Coord_Y_integer => 0;
3267 use constant _NumSeq_Coord_BitAnd_integer => 1; # only Y non-integer
3268 use constant _NumSeq_Coord_TRSquared_min => 3*4/9; # minimum X=0,Y=2/3
3269 use constant _NumSeq_Coord_MaxAbs_min => 2/3; # at N=3
3270 use constant _NumSeq_Coord_TRadius_min => sqrt(_NumSeq_Coord_TRSquared_min);
3271 use constant _NumSeq_Coord_GCD_integer => 0;
3272 }
3273 { package Math::PlanePath::KochSquareflakes;
3274 use constant _NumSeq_Coord_X_integer => 0;
3275 use constant _NumSeq_Coord_Y_integer => 0;
3276 use constant _NumSeq_Coord_MaxAbs_min => 1/2; # at N=1
3277 use constant _NumSeq_Coord_Sum_integer => 1;
3278 use constant _NumSeq_Coord_SumAbs_integer => 1;
3279 use constant _NumSeq_Coord_DiffXY_integer => 1;
3280 use constant _NumSeq_Coord_DiffYX_integer => 1;
3281 use constant _NumSeq_Coord_AbsDiff_integer => 1;
3282 use constant _NumSeq_Coord_BitXor_integer => 1; # 0.5 xor 0.5 cancels out
3283 use constant _NumSeq_Coord_TRSquared_min => 1; # X=1/2, Y=1/2
3284 use constant _NumSeq_Coord_TRSquared_integer => 1;
3285 use constant _NumSeq_Coord_GCD_integer => 0; # GCD(1/2,1/2)=1/2
3286 }
3287 { package Math::PlanePath::QuadricCurve;
3288 use constant _NumSeq_Coord_IntXY_min => undef; # negatives
3289 use constant _NumSeq_Coord_oeis_anum =>
3290 { '' =>
3291 {X => 'A332246',
3292 Y => 'A332247',
3293 # OEIS-Catalogue: A332246 planepath=QuadricCurve coordinate_type=X
3294 # OEIS-Catalogue: A332247 planepath=QuadricCurve coordinate_type=Y
3295 },
3296 };
3297 }
3298 { package Math::PlanePath::QuadricIslands;
3299 use constant _NumSeq_Coord_X_integer => 0;
3300 use constant _NumSeq_Coord_Y_integer => 0;
3301 use constant _NumSeq_Coord_Sum_integer => 1; # 0.5 + 0.5 = integer
3302 use constant _NumSeq_Coord_SumAbs_integer => 1;
3303 use constant _NumSeq_Coord_DiffXY_integer => 1;
3304 use constant _NumSeq_Coord_DiffYX_integer => 1;
3305 use constant _NumSeq_Coord_AbsDiff_integer => 1;
3306 use constant _NumSeq_Coord_GCD_integer => 0; # GCD(1/2,1/2)=1/2
3307  
3308 # BitXor X=1/2=0.1 Y=-1/2=-0.1=...1111.0 BitXor=0
3309 use constant _NumSeq_Coord_BitXor_integer => 1;
3310  
3311 # TRSquared on X=1/2,Y=1/2 is TR^2 = (1/2)^2+3*(1/2)^2 = 1
3312 use constant _NumSeq_Coord_TRSquared_integer => 1;
3313 use constant _NumSeq_Coord_TRSquared_min => 1; # X=1/2,Y=1/2
3314 }
3315 { package Math::PlanePath::SierpinskiTriangle;
3316 sub _NumSeq_Coord_Y_non_decreasing {
3317 my ($self) = @_;
3318 return ($self->{'align'} ne 'diagonal'); # rows upwards, except diagonal
3319 }
3320 # Max==Y for align!=diagonal
3321 *_NumSeq_Coord_Max_non_decreasing = \&_NumSeq_Coord_Y_non_decreasing;
3322 *_NumSeq_Coord_MaxAbs_non_decreasing = \&_NumSeq_Coord_Y_non_decreasing;
3323  
3324 sub _NumSeq_Coord_Sum_non_decreasing {
3325 my ($self) = @_;
3326 return ($self->{'align'} eq 'diagonal'); # anti-diagonals
3327 }
3328 *_NumSeq_Coord_SumAbs_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3329  
3330 use constant _NumSeq_Coord_IntXY_min => -1; # wedge
3331  
3332 # align=diagonal has X,Y no 1-bits in common, so BitAnd==0
3333 sub _NumSeq_Coord_BitAnd_max {
3334 my ($self) = @_;
3335 return ($self->{'align'} eq 'diagonal' ? 0
3336 : undef);
3337 }
3338 sub _NumSeq_Coord_BitAnd_non_decreasing {
3339 my ($self) = @_;
3340 return ($self->{'align'} eq 'diagonal');
3341 }
3342  
3343 # align=right,diagonal has X,Y BitOr 1-bits accumulating ...
3344 sub _NumSeq_Coord_BitOr_non_decreasing {
3345 my ($self) = @_;
3346 return ($self->{'align'} eq 'right'
3347 || $self->{'align'} eq 'diagonal');
3348 }
3349  
3350 # align=diagonal has X,Y no bits in common so is same as BitOr 1-bits
3351 # accumulating ...
3352 sub _NumSeq_Coord_BitXor_non_decreasing {
3353 my ($self) = @_;
3354 return ($self->{'align'} eq 'diagonal');
3355 }
3356  
3357 sub _NumSeq_Coord_ExperimentalParity_max {
3358 my ($self) = @_;
3359 return ($self->{'align'} eq 'triangular'
3360 ? 0 # triangular always even points
3361 : 1);
3362 }
3363  
3364 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 4;
3365 }
3366 { package Math::PlanePath::SierpinskiArrowhead;
3367 use constant _NumSeq_Coord_IntXY_min => -1; # wedge
3368 *_NumSeq_Coord_ExperimentalParity_max
3369 = \&Math::PlanePath::SierpinskiTriangle::_NumSeq_Coord_ExperimentalParity_max;
3370  
3371 use constant _NumSeq_Coord_oeis_anum =>
3372 { 'align=diagonal' =>
3373 { X => 'A334483',
3374 Y => 'A334484',
3375 # OEIS-Catalogue: A334483 planepath=SierpinskiArrowhead,align=diagonal coordinate_type=X
3376 # OEIS-Catalogue: A334484 planepath=SierpinskiArrowhead,align=diagonal coordinate_type=Y
3377 },
3378 'align=left' =>
3379 { Sum => 'A334483',
3380 MinAbs => 'A334484',
3381 # OEIS-Other: A334483 planepath=SierpinskiArrowhead,align=left coordinate_type=Sum
3382 # OEIS-Other: A334484 planepath=SierpinskiArrowhead,align=left coordinate_type=MinAbs
3383 },
3384 'align=right' =>
3385 { X => 'A334483',
3386 Min => 'A334483',
3387 MinAbs => 'A334483',
3388 DiffYX => 'A334484',
3389 AbsDiff => 'A334484',
3390 # OEIS-Other: A334483 planepath=SierpinskiArrowhead,align=right coordinate_type=X
3391 # OEIS-Other: A334483 planepath=SierpinskiArrowhead,align=right coordinate_type=Min
3392 # OEIS-Other: A334483 planepath=SierpinskiArrowhead,align=right coordinate_type=MinAbs
3393 # OEIS-Other: A334484 planepath=SierpinskiArrowhead,align=right coordinate_type=DiffYX
3394 # OEIS-Other: A334484 planepath=SierpinskiArrowhead,align=right coordinate_type=AbsDiff
3395 },
3396 };
3397 }
3398 { package Math::PlanePath::SierpinskiArrowheadCentres;
3399 use constant _NumSeq_Coord_IntXY_min => -1; # wedge
3400 *_NumSeq_Coord_BitAnd_max
3401 = \&Math::PlanePath::SierpinskiTriangle::_NumSeq_Coord_BitAnd_max;
3402 *_NumSeq_Coord_BitAnd_non_decreasing
3403 = \&Math::PlanePath::SierpinskiTriangle::_NumSeq_Coord_BitAnd_non_decreasing;
3404 *_NumSeq_Coord_ExperimentalParity_max
3405 = \&Math::PlanePath::SierpinskiTriangle::_NumSeq_Coord_ExperimentalParity_max;
3406 }
3407 { package Math::PlanePath::SierpinskiCurve;
3408 {
3409 my @Max_min = (undef,
3410 1, # 1 arm, octant X>Y and X>=1
3411 1, # 2 arms, quadrant X>=1 or Y>=1
3412 1, # 3 arms
3413 0, # 4 arms
3414 # more than 3 arm, Max goes negative unbounded
3415 );
3416 sub _NumSeq_Coord_Max_min {
3417 my ($self) = @_;
3418 return $Max_min[$self->arms_count];
3419 }
3420 }
3421 {
3422 my @IntXY_min = (undef,
3423 1, # octant X>Y so X/Y>1
3424 0, # quadrant X>=0 so X/Y>=0
3425 -1, # 3-oct X>=-Y so X/Y>=-1
3426 ); # arms>=4 has X unbounded negative
3427 sub _NumSeq_Coord_IntXY_min {
3428 my ($self) = @_;
3429 return $IntXY_min[$self->arms_count];
3430 }
3431 }
3432  
3433 use constant _NumSeq_Coord_TRSquared_min => 1; # minimum X=1,Y=0
3434 sub _NumSeq_Coord_BitOr_min {
3435 my ($self) = @_;
3436 return ($self->arms_count <= 2
3437 ? 1 # X=0,Y=0 not visited BitOr(X,Y)>=1
3438 : undef); # going X negative
3439 }
3440 sub _NumSeq_Coord_BitXor_min {
3441 my ($self) = @_;
3442 return ($self->arms_count <= 2
3443 ? 1 # X!=Y so BitXor(X,Y)>=1
3444 : undef); # going X negative
3445 }
3446 }
3447 { package Math::PlanePath::SierpinskiCurveStair;
3448 use constant _NumSeq_Coord_Max_min => 1;
3449 *_NumSeq_Coord_IntXY_min = \&Math::PlanePath::SierpinskiCurve::_NumSeq_Coord_IntXY_min;
3450 *_NumSeq_Coord_BitOr_min = \&Math::PlanePath::SierpinskiCurve::_NumSeq_Coord_BitOr_min;
3451 *_NumSeq_Coord_BitXor_min = \&Math::PlanePath::SierpinskiCurve::_NumSeq_Coord_BitXor_min;
3452 use constant _NumSeq_Coord_TRSquared_min => 1; # minimum X=1,Y=0
3453 }
3454 { package Math::PlanePath::HIndexing;
3455 use constant _NumSeq_Coord_filling_type => 'quadrant';
3456 # # except 0/0=inf
3457 # # use constant _NumSeq_Coord_IntXY_max => 1; # upper octant X<=Y so X/Y<=1
3458  
3459 use constant _NumSeq_Coord_oeis_anum =>
3460 { '' =>
3461 { X => 'A334235',
3462 Y => 'A334236',
3463 # OEIS-Catalogue: A334235 planepath=HIndexing coordinate_type=X
3464 # OEIS-Catalogue: A334236 planepath=HIndexing coordinate_type=Y
3465 },
3466 };
3467 }
3468 { package Math::PlanePath::DragonCurve;
3469 use constant _NumSeq_Coord_n_list_max => 2;
3470  
3471 use constant _NumSeq_Coord_oeis_anum =>
3472 { 'arms=1' =>
3473 {X => 'A332383',
3474 Y => 'A332384',
3475 # OEIS-Catalogue: A332383 planepath=DragonCurve coordinate_type=X
3476 # OEIS-Catalogue: A332384 planepath=DragonCurve coordinate_type=Y
3477 },
3478 };
3479  
3480 # 4-arm plane filling if full grid
3481 sub _NumSeq_Coord_ExperimentalNeighbours4_min {
3482 my ($self) = @_;
3483 return $self->arms_count == 4 ? 4 : 2;
3484 }
3485 # use constant _NumSeq_Coord_ExperimentalNeighbours6_min => 0; # ???
3486 sub _NumSeq_Coord_ExperimentalNeighbours8_min {
3487 my ($self) = @_;
3488 return $self->arms_count == 4 ? 8 : 3;
3489 }
3490 }
3491 { package Math::PlanePath::DragonRounded;
3492 use constant _NumSeq_Coord_TRSquared_min => 1; # minimum X=1,Y=0
3493 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
3494 use constant _NumSeq_Coord_MaxAbs_min => 1; # X!=Y
3495 }
3496 # { package Math::PlanePath::DragonMidpoint;
3497 # }
3498 { package Math::PlanePath::AlternatePaper;
3499 use constant _NumSeq_Coord_n_list_max => 2;
3500 {
3501 my @_NumSeq_Coord_IntXY_min = (undef,
3502 1, # 1 arm, octant X+Y>=0
3503 0, # 2 arms, X>=0
3504 0, # 3 arms, X>-Y so X/Y>-1
3505 ); # more than 3 arm, X neg axis so undef
3506 sub _NumSeq_Coord_IntXY_min {
3507 my ($self) = @_;
3508 return $_NumSeq_Coord_IntXY_min[$self->arms_count];
3509 }
3510 }
3511  
3512 # 8-arm plane filling if full grid
3513 {
3514 # arms 1 2 3 4 5 6 7 8
3515 my @_NumSeq_Coord_ExperimentalNeighbours3_min = (undef, 1,1,2,2,3,3,3,3);
3516 sub _NumSeq_Coord_ExperimentalNeighbours3_min {
3517 my ($self) = @_;
3518 return $_NumSeq_Coord_ExperimentalNeighbours3_min[$self->arms_count];
3519 }
3520 }
3521 {
3522 # arms 1 2 3 4 5 6 7 8
3523 my @_NumSeq_Coord_ExperimentalNeighbours4_min = (undef, 1,2,2,3,3,3,3,4);
3524 sub _NumSeq_Coord_ExperimentalNeighbours4_min {
3525 my ($self) = @_;
3526 return $_NumSeq_Coord_ExperimentalNeighbours4_min[$self->arms_count];
3527 }
3528 }
3529 # use constant _NumSeq_Coord_ExperimentalNeighbours6_min => 0; # ???
3530 {
3531 # arms 1 2 3 4 5 6 7 8
3532 my @_NumSeq_Coord_ExperimentalNeighbours8_min = (undef, 2,3,4,5,6,7,7,8);
3533 sub _NumSeq_Coord_ExperimentalNeighbours8_min {
3534 my ($self) = @_;
3535 return $_NumSeq_Coord_ExperimentalNeighbours8_min[$self->arms_count];
3536 }
3537 }
3538  
3539 use constant _NumSeq_Coord_oeis_anum =>
3540 { 'i_start=1' =>
3541 { DiffXY => 'A020990', # GRS*(-1)^n cumulative
3542 AbsDiff => 'A020990',
3543  
3544 # Not quite Sum, OFFSET=0 value=1 corresponds to N=1 Sum=1, so
3545 # A020986 doesn't have N=0 Sum=0.
3546 # Sum => 'A020986', # GRS cumulative
3547 # # OEIS-Catalogue: A020986 planepath=AlternatePaper coordinate_type=Sum i_start=1
3548  
3549 # X_undoubled => 'A020986', # GRS cumulative
3550 # Y_undoubled => 'A020990', # GRS*(-1)^n cumulative
3551 },
3552 };
3553 }
3554 { package Math::PlanePath::AlternatePaperMidpoint;
3555 {
3556 my @_NumSeq_Coord_IntXY_min = (undef,
3557 1, # 1 arm, octant X+Y>=0
3558 0, # 2 arms, X>=0
3559 0, # 3 arms, X>-Y so X/Y>-1
3560 ); # more than 3 arm, X neg axis so undef
3561 sub _NumSeq_Coord_IntXY_min {
3562 my ($self) = @_;
3563 return $_NumSeq_Coord_IntXY_min[$self->arms_count];
3564 }
3565 }
3566 use constant _NumSeq_Coord_oeis_anum =>
3567 { 'arms=1' =>
3568 {X => 'A334576',
3569 Y => 'A334577',
3570 # OEIS-Catalogue: A334576 planepath=AlternatePaperMidpoint coordinate_type=X
3571 # OEIS-Catalogue: A334577 planepath=AlternatePaperMidpoint coordinate_type=Y
3572 },
3573 };
3574 }
3575 { package Math::PlanePath::TerdragonCurve;
3576 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3577 use constant _NumSeq_Coord_n_list_max => 3;
3578 }
3579 { package Math::PlanePath::TerdragonRounded;
3580 use constant _NumSeq_Coord_TRSquared_min => 4; # either X=2,Y=0 or X=1,Y=1
3581 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3582 }
3583 { package Math::PlanePath::TerdragonMidpoint;
3584 use constant _NumSeq_Coord_TRSquared_min => 4; # either X=2,Y=0 or X=1,Y=1
3585 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3586 }
3587 { package Math::PlanePath::AlternateTerdragon;
3588 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
3589 use constant _NumSeq_Coord_n_list_max => 3;
3590 }
3591 { package Math::PlanePath::R5DragonCurve;
3592 use constant _NumSeq_Coord_n_list_max => 2;
3593 }
3594 # { package Math::PlanePath::R5DragonMidpoint;
3595 # }
3596 { package Math::PlanePath::CCurve;
3597 use constant _NumSeq_Coord_n_list_max => 4;
3598 use constant _NumSeq_Coord_oeis_anum =>
3599 { '' =>
3600 {X => 'A332251',
3601 Y => 'A332252',
3602 # OEIS-Catalogue: A332251 planepath=CCurve coordinate_type=X
3603 # OEIS-Catalogue: A332252 planepath=CCurve coordinate_type=Y
3604 },
3605 };
3606 }
3607 # { package Math::PlanePath::ComplexPlus;
3608 # Sum X+Y < 0 at N=16
3609 # use constant _NumSeq_Coord_oeis_anum =>
3610 # { 'realpart=1,arms=1' =>
3611 # {
3612 # # not quite, OFFSET=1 but start N=0 here
3613 # # NegX => 'A290885',
3614 # # Y => 'A290884',
3615 # # RSquared => 'A290886',
3616 # # OEIS-Catalogue: A290884 planepath=ComplexPlus coordinate_type=Y
3617 # # OEIS-Catalogue: A290886 planepath=ComplexPlus coordinate_type=RSquared
3618 # },
3619 # };
3620 # }
3621 { package Math::PlanePath::ComplexMinus;
3622 use constant _NumSeq_Coord_filling_type => 'plane';
3623 use constant _NumSeq_Coord_oeis_anum =>
3624 { 'realpart=1' =>
3625 {X => 'A318438',
3626 Y => 'A318439',
3627 RSquared => 'A318479',
3628 # OEIS-Catalogue: A318438 planepath=ComplexMinus coordinate_type=X
3629 # OEIS-Catalogue: A318439 planepath=ComplexMinus coordinate_type=Y
3630 # OEIS-Catalogue: A318479 planepath=ComplexMinus coordinate_type=RSquared
3631 },
3632 };
3633 }
3634 { package Math::PlanePath::ComplexRevolving;
3635 use constant _NumSeq_Coord_filling_type => 'plane';
3636 }
3637 { package Math::PlanePath::Rows;
3638 use constant _NumSeq_extra_parameter_info_list =>
3639 { name => 'width',
3640 type => 'integer',
3641 };
3642  
3643 *_NumSeq_Coord_X_non_decreasing = \&_NumSeq_Coord_Y_increasing;
3644  
3645 sub _NumSeq_Coord_Y_increasing {
3646 my ($self) = @_;
3647 return ($self->{'width'} == 1
3648 ? 1 # X=N,Y=0 only
3649 : 0);
3650 }
3651  
3652 sub _NumSeq_Coord_Min_max { $_[0]->x_maximum }
3653 *_NumSeq_Coord_Max_increasing=\&_NumSeq_Coord_Y_increasing; # height=1 Max=Y
3654 sub _NumSeq_Coord_Max_non_decreasing {
3655 my ($self) = @_;
3656 return ($self->{'width'} <= 2);
3657 }
3658  
3659 sub _NumSeq_Coord_Sum_non_decreasing {
3660 my ($self) = @_;
3661 return ($self->{'width'} <= 2
3662 ? 1 # width=1 is X=0,Y=N only, or width=2 is X=0,1,Y=N/2
3663 : 0);
3664 }
3665 *_NumSeq_Coord_Sum_increasing = \&_NumSeq_Coord_Y_increasing;
3666  
3667 *_NumSeq_Coord_SumAbs_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3668 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Y_increasing;
3669  
3670 *_NumSeq_Coord_DiffYX_increasing = \&_NumSeq_Coord_Y_increasing;
3671  
3672 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_Y_increasing;
3673  
3674 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_Y_increasing;
3675  
3676 sub _NumSeq_Coord_BitAnd_max {
3677 my ($self) = @_;
3678 return $self->{'width'}-1; # at X=Y=width-1
3679 }
3680 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_Y_increasing;
3681  
3682 *_NumSeq_Coord_BitOr_increasing = \&_NumSeq_Coord_Y_increasing;
3683 *_NumSeq_Coord_BitXor_increasing = \&_NumSeq_Coord_Y_increasing;
3684  
3685 *_NumSeq_Coord_Radius_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3686 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Y_increasing;
3687 *_NumSeq_Coord_Radius_integer = \&_NumSeq_Coord_Y_increasing;
3688  
3689 *_NumSeq_Coord_GCD_increasing = \&_NumSeq_Coord_Y_increasing;
3690  
3691 # width <= 2 one or two columns is increasing
3692 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Sum_non_decreasing;
3693  
3694 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
3695  
3696 use constant _NumSeq_Coord_oeis_anum =>
3697 { 'n_start=1,width=1' =>
3698 { Product => 'A000004', # all zeros
3699 # OEIS-Other: A000004 planepath=Rows,width=1 coordinate_type=Product
3700  
3701 # OFFSET
3702 # Y => 'A001477', # integers 0 upwards
3703 # Sum => 'A001477', # integers 0 upwards
3704 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=Y
3705 # DiffXY => 'A001489', # negative integers 0 downwards
3706 # DiffYX => 'A001477', # integers 0 upwards
3707 # AbsDiff => 'A001477', # integers 0 upwards
3708 # Radius => 'A001477', # integers 0 upwards
3709 # RSquared => 'A000290', # squares 0 upwards
3710 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=Sum
3711 # # OEIS-Other: A001489 planepath=Rows,width=1 coordinate_type=DiffXY
3712 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=DiffYX
3713 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=AbsDiff
3714 # # OEIS-Other: A001477 planepath=Rows,width=1 coordinate_type=Radius
3715 # # OEIS-Other: A000290 planepath=Rows,width=1 coordinate_type=RSquared
3716 },
3717  
3718 'n_start=0,width=2' =>
3719 { X => 'A000035', # 0,1 repeating OFFSET=0
3720 Y => 'A004526', # 0,0,1,1,2,2,etc cf Math::NumSeq::Runs
3721 # OEIS-Other: A000035 planepath=Rows,width=2,n_start=0 coordinate_type=X
3722 # OEIS-Other: A004526 planepath=Rows,width=2,n_start=0 coordinate_type=Y
3723  
3724 # # Not quite, A142150 OFFSET=0 starting 0,0,1,0,2 interleave integers
3725 # # and 0 but Product here extra 0 start 0,0,0,1,0,2,0
3726 # # Product => 'A142150'
3727 #
3728 # # Not quite, GCD=>'A057979' but A057979 extra initial 1
3729 },
3730 };
3731 }
3732 { package Math::PlanePath::Columns;
3733 use constant _NumSeq_extra_parameter_info_list =>
3734 { name => 'height',
3735 type => 'integer',
3736 };
3737  
3738 sub _NumSeq_Coord_X_increasing {
3739 my ($self) = @_;
3740 return ($self->{'height'} == 1
3741 ? 1 # X=N,Y=0 only
3742 : 0);
3743 }
3744 use constant _NumSeq_Coord_X_non_decreasing => 1; # columns across
3745  
3746 *_NumSeq_Coord_Y_non_decreasing = \&_NumSeq_Coord_X_increasing;
3747  
3748 sub _NumSeq_Coord_Min_max { $_[0]->y_maximum }
3749 *_NumSeq_Coord_Max_increasing=\&_NumSeq_Coord_X_increasing; # height=1 Max=X
3750 sub _NumSeq_Coord_Max_non_decreasing {
3751 my ($self) = @_;
3752 return ($self->{'height'} <= 2);
3753 }
3754  
3755 *_NumSeq_Coord_Sum_increasing = \&_NumSeq_Coord_X_increasing;
3756 sub _NumSeq_Coord_Sum_non_decreasing {
3757 my ($self) = @_;
3758 return ($self->{'height'} <= 2
3759 ? 1 # height=1 is X=N,Y=0 only, or height=2 is X=N/2,Y=0,1
3760 : 0);
3761 }
3762  
3763 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_X_increasing;
3764 *_NumSeq_Coord_SumAbs_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3765  
3766 *_NumSeq_Coord_DiffXY_increasing = \&_NumSeq_Coord_X_increasing;
3767 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_X_increasing;
3768  
3769 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_X_increasing;
3770 *_NumSeq_Coord_Radius_integer = \&_NumSeq_Coord_X_increasing;
3771 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_X_increasing;
3772 *_NumSeq_Coord_TRadius_integer = \&_NumSeq_Coord_X_increasing;
3773  
3774 sub _NumSeq_Coord_BitAnd_max {
3775 my ($self) = @_;
3776 return $self->{'height'}-1; # at X=Y=height-1
3777 }
3778 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_X_increasing;
3779  
3780 *_NumSeq_Coord_BitOr_increasing = \&_NumSeq_Coord_X_increasing;
3781 *_NumSeq_Coord_BitXor_increasing = \&_NumSeq_Coord_X_increasing;
3782 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_X_increasing;
3783 *_NumSeq_Coord_GCD_increasing = \&_NumSeq_Coord_X_increasing;
3784  
3785 *_NumSeq_Coord_Radius_non_decreasing = \&_NumSeq_Coord_Sum_non_decreasing;
3786  
3787 use constant _NumSeq_Coord_oeis_anum =>
3788 { 'n_start=1,height=1' =>
3789 { Product => 'A000004', # all zeros
3790 # OEIS-Other: A000004 planepath=Columns,height=1 coordinate_type=Product
3791  
3792 # OFFSET
3793 # X => 'A001477', # integers 0 upwards
3794 # Sum => 'A001477', # integers 0 upwards
3795 # DiffXY => 'A001477', # integers 0 upwards
3796 # DiffYX => 'A001489', # negative integers 0 downwards
3797 # AbsDiff => 'A001477', # integers 0 upwards
3798 # Radius => 'A001477', # integers 0 upwards
3799 # RSquared => 'A000290', # squares 0 upwards
3800 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=X
3801 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=Sum
3802 # # OEIS-Other: A001489 planepath=Columns,height=1 coordinate_type=DiffYX
3803 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=DiffXY
3804 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=AbsDiff
3805 # # OEIS-Other: A001477 planepath=Columns,height=1 coordinate_type=Radius
3806 # # OEIS-Other: A000290 planepath=Columns,height=1 coordinate_type=RSquared
3807 },
3808  
3809 'n_start=0,height=2' =>
3810 { X => 'A004526', # 0,0,1,1,2,2,etc, as per Math::NumSeq::Runs 2rep
3811 Y => 'A000035', # 0,1 repeating OFFSET=0
3812 # OEIS-Other: A004526 planepath=Columns,height=2,n_start=0 coordinate_type=X
3813 # OEIS-Other: A000035 planepath=Columns,height=2,n_start=0 coordinate_type=Y
3814 },
3815 };
3816 }
3817 { package Math::PlanePath::Diagonals;
3818 use constant _NumSeq_Coord_filling_type => 'quadrant';
3819 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # X+Y diagonals
3820  
3821 sub _NumSeq_Coord_SumAbs_non_decreasing {
3822 my ($self) = @_;
3823 return ($self->{'x_start'} >= 0 && $self->{'y_start'} >= 0);
3824 }
3825  
3826 # these irrespective where x_start,y_start make x_minimum(),y_minimum()
3827 use constant _NumSeq_Coord_BitAnd_min => 0; # when all diff bits
3828 use constant _NumSeq_Coord_BitXor_min => 0; # when X=Y
3829  
3830 use constant _NumSeq_Coord_oeis_anum =>
3831 {
3832 'direction=down,n_start=1,x_start=0,y_start=0' =>
3833 { ExperimentalPairsXY => 'A057554', # starting OFFSET=1 so the default n_start=1 here
3834 # OEIS-Catalogue: A057554 planepath=Diagonals coordinate_type=ExperimentalPairsXY
3835 },
3836 'direction=up,n_start=1,x_start=0,y_start=0' =>
3837 { ExperimentalPairsYX => 'A057554', # starting OFFSET=1 so the default n_start=1 here
3838 # OEIS-Other: A057554 planepath=Diagonals,direction=up coordinate_type=ExperimentalPairsYX
3839 },
3840  
3841 'direction=down,n_start=1,x_start=1,y_start=0' =>
3842 { ExperimentalNumerator => 'A164306', # T(n,k) = k/GCD(n,k) n,k>=1 offset=1
3843 ExperimentalDenominator => 'A167192', # T(n,k) = (n-k)/GCD(n,k) n,k>=1 offset=1
3844 # OEIS-Catalogue: A164306 planepath=Diagonals,x_start=1,y_start=0 coordinate_type=ExperimentalNumerator
3845 # OEIS-Catalogue: A167192 planepath=Diagonals,x_start=1,y_start=0 coordinate_type=ExperimentalDenominator
3846 },
3847  
3848 'direction=down,n_start=1,x_start=1,y_start=1' =>
3849 { Product => 'A003991', # X*Y starting (1,1) n=1
3850 GCD => 'A003989', # GCD by diagonals starting (1,1) n=1
3851 Min => 'A003983', # X,Y>=1
3852 MinAbs => 'A003983', # MinAbs=Min
3853 Max => 'A051125', # X,Y>=1
3854 MaxAbs => 'A051125', # MaxAbs=Max
3855 IntXY => 'A004199', # X>=0,Y>=0, X/Y round towards zero
3856 ExperimentalPairsXY => 'A057555', # starting OFFSET=1 so n_start=1 here
3857 # OEIS-Catalogue: A003991 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=Product
3858 # OEIS-Catalogue: A003989 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=GCD
3859 # OEIS-Catalogue: A003983 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=Min
3860 # OEIS-Other: A003983 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=MinAbs
3861 # OEIS-Catalogue: A051125 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=Max
3862 # OEIS-Other: A051125 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=MaxAbs
3863 # OEIS-Catalogue: A004199 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=IntXY
3864 # OEIS-Catalogue: A057555 planepath=Diagonals,x_start=1,y_start=1 coordinate_type=ExperimentalPairsXY
3865  
3866 # cf A003990 LCM starting (1,1) n=1
3867 # A003992 X^Y power starting (1,1) n=1
3868 },
3869  
3870 'direction=up,n_start=1,x_start=1,y_start=1' =>
3871 { Product => 'A003991', # X*Y starting (1,1) n=1
3872 GCD => 'A003989', # GCD by diagonals starting (1,1) n=1
3873 IntXY => 'A003988', # Int(X/Y) starting (1,1) n=1
3874 ExperimentalPairsYX => 'A057555', # starting OFFSET=1 so n_start=1 here
3875 # OEIS-Other: A003991 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=Product
3876 # OEIS-Other: A003989 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=GCD
3877 # OEIS-Catalogue: A003988 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=IntXY
3878 # OEIS-Other: A057555 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=ExperimentalPairsYX
3879  
3880 # num,den of reduction of A004736/A002260 which is run1toK/runKto1.
3881 ExperimentalNumerator => 'A112543', # 1,2,1,3,1,1,4,3,2,1,5,2,1,1,1,6,
3882 ExperimentalDenominator => 'A112544', # 1,1,2,1,1,3,1,2,3,4,1,1,1,2,5,1,
3883 # OEIS-Catalogue: A112543 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=ExperimentalNumerator
3884 # OEIS-Catalogue: A112544 planepath=Diagonals,direction=up,x_start=1,y_start=1 coordinate_type=ExperimentalDenominator
3885 },
3886  
3887 #------------------
3888 # n_start=0 instead
3889  
3890 'direction=down,n_start=0,x_start=0,y_start=0' =>
3891 { X => 'A002262', # runs 0toN 0, 0,1, 0,1,2, etc
3892 Y => 'A025581', # runs Nto0 0, 1,0, 2,1,0, 3,2,1,0 descend
3893 Sum => 'A003056', # 0, 1,1, 2,2,2, 3,3,3,3
3894 SumAbs => 'A003056', # same
3895 Product => 'A004247', # 0, 0,0,0, 1, 0,0, 2,2, 0,0, 3,4,5, 0,0
3896 DiffYX => 'A114327', # Y-X by anti-diagonals
3897 AbsDiff => 'A049581', # abs(Y-X) by anti-diagonals
3898 RSquared => 'A048147', # x^2+y^2 by diagonals
3899 BitAnd => 'A004198', # X bitand Y
3900 BitOr => 'A003986', # X bitor Y, cf A006583 diagonal totals
3901 BitXor => 'A003987', # cf A006582 X xor Y diagonal totals
3902 GCD => 'A109004', # GCD(x,y) by diagonals, (0,0) at n=0
3903 Min => 'A004197', # X,Y>=0, runs 0toNto0,0toNNto0
3904 MinAbs => 'A004197', # MinAbs=Min
3905 Max => 'A003984',
3906 MaxAbs => 'A003984', # MaxAbs=Max
3907 ExperimentalHammingDist => 'A101080',
3908 # OEIS-Other: A002262 planepath=Diagonals,n_start=0 coordinate_type=X
3909 # OEIS-Other: A025581 planepath=Diagonals,n_start=0 coordinate_type=Y
3910 # OEIS-Other: A003056 planepath=Diagonals,n_start=0 coordinate_type=Sum
3911 # OEIS-Other: A003056 planepath=Diagonals,n_start=0 coordinate_type=SumAbs
3912 # OEIS-Catalogue: A004247 planepath=Diagonals,n_start=0 coordinate_type=Product
3913 # OEIS-Catalogue: A114327 planepath=Diagonals,n_start=0 coordinate_type=DiffYX
3914 # OEIS-Catalogue: A049581 planepath=Diagonals,n_start=0 coordinate_type=AbsDiff
3915 # OEIS-Catalogue: A048147 planepath=Diagonals,n_start=0 coordinate_type=RSquared
3916 # OEIS-Catalogue: A004198 planepath=Diagonals,n_start=0 coordinate_type=BitAnd
3917 # OEIS-Catalogue: A003986 planepath=Diagonals,n_start=0 coordinate_type=BitOr
3918 # OEIS-Catalogue: A003987 planepath=Diagonals,n_start=0 coordinate_type=BitXor
3919 # OEIS-Catalogue: A109004 planepath=Diagonals,n_start=0 coordinate_type=GCD
3920 # OEIS-Catalogue: A004197 planepath=Diagonals,n_start=0 coordinate_type=Min
3921 # OEIS-Other: A004197 planepath=Diagonals,n_start=0 coordinate_type=MinAbs
3922 # OEIS-Catalogue: A003984 planepath=Diagonals,n_start=0 coordinate_type=Max
3923 # OEIS-Other: A003984 planepath=Diagonals,n_start=0 coordinate_type=MaxAbs
3924 # OEIS-Catalogue: A101080 planepath=Diagonals,n_start=0 coordinate_type=ExperimentalHammingDist
3925 },
3926 'direction=up,n_start=0,x_start=0,y_start=0' =>
3927 { X => 'A025581', # \ opposite of direction="down"
3928 Y => 'A002262', # /
3929 Sum => 'A003056', # \
3930 SumAbs => 'A003056', # | same as direction="down'
3931 Product => 'A004247', # |
3932 AbsDiff => 'A049581', # |
3933 RSquared => 'A048147', # /
3934 DiffXY => 'A114327', # transposed from direction="down"
3935 BitAnd => 'A004198', # X bitand Y
3936 BitOr => 'A003986', # X bitor Y, cf A006583 diagonal totals
3937 BitXor => 'A003987', # cf A006582 X xor Y diagonal totals
3938 GCD => 'A109004', # GCD(x,y) by diagonals, (0,0) at n=0
3939 ExperimentalHammingDist => 'A101080',
3940 # OEIS-Other: A025581 planepath=Diagonals,direction=up,n_start=0 coordinate_type=X
3941 # OEIS-Other: A002262 planepath=Diagonals,direction=up,n_start=0 coordinate_type=Y
3942 # OEIS-Other: A003056 planepath=Diagonals,direction=up,n_start=0 coordinate_type=Sum
3943 # OEIS-Other: A003056 planepath=Diagonals,direction=up,n_start=0 coordinate_type=SumAbs
3944 # OEIS-Other: A004247 planepath=Diagonals,direction=up,n_start=0 coordinate_type=Product
3945 # OEIS-Other: A114327 planepath=Diagonals,direction=up,n_start=0 coordinate_type=DiffXY
3946 # OEIS-Other: A049581 planepath=Diagonals,direction=up,n_start=0 coordinate_type=AbsDiff
3947 # OEIS-Other: A048147 planepath=Diagonals,direction=up,n_start=0 coordinate_type=RSquared
3948 # OEIS-Other: A004198 planepath=Diagonals,direction=up,n_start=0 coordinate_type=BitAnd
3949 # OEIS-Other: A003986 planepath=Diagonals,direction=up,n_start=0 coordinate_type=BitOr
3950 # OEIS-Other: A003987 planepath=Diagonals,direction=up,n_start=0 coordinate_type=BitXor
3951 # OEIS-Other: A109004 planepath=Diagonals,direction=up,n_start=0 coordinate_type=GCD
3952 # OEIS-Other: A101080 planepath=Diagonals,direction=up,n_start=0 coordinate_type=ExperimentalHammingDist
3953 },
3954  
3955 };
3956 }
3957 { package Math::PlanePath::DiagonalsAlternating;
3958 use constant _NumSeq_Coord_filling_type => 'quadrant';
3959 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # X+Y diagonals
3960 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1; # X+Y diagonals
3961  
3962 use constant _NumSeq_Coord_oeis_anum =>
3963 { 'n_start=0' =>
3964 { X => 'A319572',
3965 Y => 'A319573',
3966 Sum => 'A003056', # 0, 1,1, 2,2,2, 3,3,3,3
3967 SumAbs => 'A003056', # same
3968 Product => 'A004247', # 0, 0,0,0, 1, 0,0, 2,2, 0,0, 3,4,5, 0,0
3969 AbsDiff => 'A049581', # abs(Y-X) by anti-diagonals
3970 RSquared => 'A048147', # x^2+y^2 by diagonals
3971 BitAnd => 'A004198', # X bitand Y
3972 BitOr => 'A003986', # X bitor Y, cf A006583 diagonal totals
3973 BitXor => 'A003987', # cf A006582 X xor Y diagonal totals
3974 Min => 'A004197', # runs 0toNto0,0toNNto0
3975 MinAbs => 'A004197', # MinAbs=Min
3976 Max => 'A003984',
3977 MaxAbs => 'A003984', # MaxAbs=Max
3978 ExperimentalHammingDist => 'A101080',
3979 # OEIS-Catalogue: A319572 planepath=DiagonalsAlternating,n_start=0 coordinate_type=X
3980 # OEIS-Catalogue: A319573 planepath=DiagonalsAlternating,n_start=0 coordinate_type=Y
3981 # OEIS-Other: A003056 planepath=DiagonalsAlternating,n_start=0 coordinate_type=Sum
3982 # OEIS-Other: A003056 planepath=DiagonalsAlternating,n_start=0 coordinate_type=SumAbs
3983 # OEIS-Other: A004247 planepath=DiagonalsAlternating,n_start=0 coordinate_type=Product
3984 # OEIS-Other: A049581 planepath=DiagonalsAlternating,n_start=0 coordinate_type=AbsDiff
3985 # OEIS-Other: A048147 planepath=DiagonalsAlternating,n_start=0 coordinate_type=RSquared
3986 # OEIS-Other: A004198 planepath=DiagonalsAlternating,n_start=0 coordinate_type=BitAnd
3987 # OEIS-Other: A003986 planepath=DiagonalsAlternating,n_start=0 coordinate_type=BitOr
3988 # OEIS-Other: A003987 planepath=DiagonalsAlternating,n_start=0 coordinate_type=BitXor
3989 # OEIS-Other: A004197 planepath=DiagonalsAlternating,n_start=0 coordinate_type=Min
3990 # OEIS-Other: A004197 planepath=DiagonalsAlternating,n_start=0 coordinate_type=MinAbs
3991 # OEIS-Other: A003984 planepath=DiagonalsAlternating,n_start=0 coordinate_type=Max
3992 # OEIS-Other: A003984 planepath=DiagonalsAlternating,n_start=0 coordinate_type=MaxAbs
3993 # OEIS-Other: A101080 planepath=DiagonalsAlternating,n_start=0 coordinate_type=ExperimentalHammingDist
3994 },
3995 };
3996 }
3997 { package Math::PlanePath::DiagonalsOctant;
3998 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # X+Y diagonals
3999 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1; # X+Y diagonals
4000  
4001 use constant _NumSeq_Coord_oeis_anum =>
4002 { 'direction=down,n_start=0' =>
4003 { X => 'A055087', # 0, 0,1, 0,1, 0,1,2, 0,1,2, etc
4004 Min => 'A055087', # X<=Y so Min=X
4005 MinAbs => 'A055087', # MinAbs=Min
4006 Sum => 'A055086', # reps floor(n/2)+1
4007 SumAbs => 'A055086', # same
4008 DiffYX => 'A082375', # step=2 k to 0
4009 # OEIS-Catalogue: A055087 planepath=DiagonalsOctant,n_start=0 coordinate_type=X
4010 # OEIS-Other: A055087 planepath=DiagonalsOctant,n_start=0 coordinate_type=Min
4011 # OEIS-Other: A055087 planepath=DiagonalsOctant,n_start=0 coordinate_type=MinAbs
4012 # OEIS-Catalogue: A055086 planepath=DiagonalsOctant,n_start=0 coordinate_type=Sum
4013 # OEIS-Other: A055086 planepath=DiagonalsOctant,n_start=0 coordinate_type=SumAbs
4014 # OEIS-Catalogue: A082375 planepath=DiagonalsOctant,n_start=0 coordinate_type=DiffYX
4015 },
4016 'direction=up,n_start=0' =>
4017 { Sum => 'A055086', # reps floor(n/2)+1
4018 SumAbs => 'A055086', # same
4019 # OEIS-Other: A055086 planepath=DiagonalsOctant,direction=up,n_start=0 coordinate_type=Sum
4020 # OEIS-Other: A055086 planepath=DiagonalsOctant,direction=up,n_start=0 coordinate_type=SumAbs
4021 },
4022 };
4023 }
4024 { package Math::PlanePath::MPeaks;
4025 use constant _NumSeq_Coord_filling_type => 'half';
4026 }
4027 { package Math::PlanePath::Staircase;
4028 use constant _NumSeq_Coord_filling_type => 'quadrant';
4029 }
4030 # { package Math::PlanePath::StaircaseAlternating;
4031 # }
4032 { package Math::PlanePath::Corner;
4033 use constant _NumSeq_Coord_filling_type => 'quadrant';
4034 sub _NumSeq_Coord_Max_non_decreasing {
4035 my ($self) = @_;
4036 # non-decreasing when wider=0 or 1
4037 return ($self->{'wider'} <= 1);
4038 }
4039 use constant _NumSeq_Coord_oeis_anum =>
4040 { 'wider=0,n_start=1' =>
4041 { Sum => 'A213088', # Manhattan X+Y
4042 SumAbs => 'A213088',
4043 # OEIS-Catalogue: A213088 planepath=Corner coordinate_type=Sum
4044 # OEIS-Other: A213088 planepath=Corner coordinate_type=SumAbs
4045 },
4046 'wider=0,n_start=0' =>
4047 { DiffXY => 'A196199', # runs -n to n
4048 AbsDiff => 'A053615', # runs n..0..n
4049 Max => 'A000196', # n repeated 2n+1 times, floor(sqrt(N))
4050 MaxAbs => 'A000196', # MaxAbs=Max
4051 # OEIS-Other: A196199 planepath=Corner,n_start=0 coordinate_type=DiffXY
4052 # OEIS-Other: A053615 planepath=Corner,n_start=0 coordinate_type=AbsDiff
4053 # OEIS-Other: A000196 planepath=Corner,n_start=0 coordinate_type=Max
4054 # OEIS-Other: A000196 planepath=Corner,n_start=0 coordinate_type=MaxAbs
4055  
4056 # Not quite, A053188 has extra initial 0
4057 # AbsDiff => 'A053188', # distance to nearest square
4058 },
4059 };
4060 }
4061 { package Math::PlanePath::PyramidRows;
4062  
4063 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_Y_increasing;
4064  
4065 # Max==Y and Y is non-decreasing when
4066 # step=0 align=any
4067 # step=1 align=any
4068 # step=2 align=left or centre
4069 # step>2 align=left
4070 sub _NumSeq_Coord_Max_non_decreasing {
4071 my ($self) = @_;
4072 return ($self->{'step'} <= 1
4073 || ($self->{'step'} == 2 && $self->{'align'} eq 'centre')
4074 || $self->{'align'} eq 'left');
4075 }
4076  
4077 sub _NumSeq_Coord_MaxAbs_non_decreasing {
4078 my ($self) = @_;
4079 return ($self->{'step'} <= 1
4080 || ($self->{'step'} == 2 && $self->{'align'} eq 'centre'));
4081 }
4082  
4083 *_NumSeq_Coord_Sum_increasing = \&_NumSeq_Coord_Y_increasing;
4084 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Y_increasing;
4085  
4086 sub _NumSeq_Coord_IntXY_min {
4087 my ($self) = @_;
4088 return ($self->{'align'} eq 'left' ? - $self->{'step'}
4089 : $self->{'align'} eq 'centre' ? - int($self->{'step'}/2)
4090 : 0); # right
4091 }
4092  
4093 sub _NumSeq_Coord_FracXY_max {
4094 my ($self) = @_;
4095 return ($self->{'step'} == 0 ? 0 : 1); # step=0 X=0 frac=0 always
4096 }
4097 *_NumSeq_FracXY_max_is_supremum = \&_NumSeq_Coord_FracXY_max;
4098 sub _NumSeq_Coord_FracXY_integer {
4099 my ($self) = @_;
4100 return ($self->{'step'} == 0 ? 1 : 0); # step=0 X=0 frac=0 always
4101 }
4102  
4103 sub _NumSeq_Coord_Radius_integer {
4104 my ($self) = @_;
4105 return ($self->{'step'} == 0);
4106 }
4107  
4108 sub _NumSeq_Coord_Y_increasing {
4109 my ($self) = @_;
4110 return ($self->{'step'} == 0
4111 ? 1 # column X=0,Y=N
4112 : 0);
4113 }
4114 *_NumSeq_Coord_DiffYX_increasing = \&_NumSeq_Coord_Y_increasing;
4115 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_Y_increasing;
4116 *_NumSeq_Coord_Max_increasing = \&_NumSeq_Coord_Y_increasing;
4117 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Y_increasing;
4118 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Y_increasing;
4119 *_NumSeq_Coord_BitOr_increasing = \&_NumSeq_Coord_Y_increasing;
4120 *_NumSeq_Coord_BitXor_increasing = \&_NumSeq_Coord_Y_increasing;
4121 *_NumSeq_Coord_GCD_increasing = \&_NumSeq_Coord_Y_increasing;
4122  
4123 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4124 *_NumSeq_Coord_X_non_decreasing = \&_NumSeq_Coord_Y_increasing; # X=0 always
4125 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_Y_increasing; # N*0=0
4126  
4127 # step=0 constant ExperimentalNumerator=0
4128 sub _NumSeq_Coord_ExperimentalNumerator_max {
4129 my ($self) = @_;
4130 return ($self->{'step'} == 0 ? 0 : undef);
4131 }
4132  
4133 # step=0 has Y=0 so BitAnd=0 always
4134 *_NumSeq_Coord_BitAnd_max = \&_NumSeq_Coord_ExperimentalNumerator_max;
4135 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_Y_increasing;
4136  
4137 # cf A050873 GCD(X+1,Y+1) by rows n>=1 k=1..n, x_start=1,y_start=1
4138 # A051173 LCM(X+1,Y+1) by rows n>=1 k=1..n, x_start=1,y_start=1
4139 #
4140 # Maybe with x_start,y_start to go by rows starting from 1.
4141 # ExperimentalDenominator => 'A164306', # T(n,k) = k/GCD(n,k) n,k>=1 offset=1
4142 # # OEIS-Catalogue: A164306 planepath=PyramidRows,step=1,x_start=1,y_start=1 coordinate_type=ExperimentalDenominator
4143 # ExperimentalDenominator => 'A167192', # T(n,k) = (n-k)/GCD(n,k) n,k>=1 offset=1
4144 # # OEIS-Catalogue: A167192 planepath=PyramidRows,step=1,x_start=1,y_start=1,align=left coordinate_type=ExperimentalNumerator
4145 #
4146 use constant _NumSeq_Coord_oeis_anum =>
4147 {
4148 # PyramidRows step=0 is trivial X=0,Y=N
4149 do {
4150 my $href = { X => 'A000004', # all-zeros
4151 Product => 'A000004', # all-zeros
4152 # OEIS-Other: A000004 planepath=PyramidRows,step=0 coordinate_type=X
4153 # OEIS-Other: A000004 planepath=PyramidRows,step=0 coordinate_type=Product
4154 };
4155 ('step=0,align=centre' => $href,
4156 'step=0,align=right' => $href,
4157 'step=0,align=left' => $href,
4158 );
4159 },
4160 do {
4161 my $href = { X => 'A000004', # all zeros
4162 Min => 'A000004', # Min=X
4163 Y => 'A001477', # integers Y=0,1,2,etc
4164 Max => 'A001477', # Max=Y
4165 MaxAbs => 'A001477', # MaxAbs=Max
4166 Sum => 'A001477', # Sum=Y
4167 DiffYX => 'A001477', # DiffYX=Y
4168 DiffXY => 'A001489', # negatives 0,-1,-2,etc
4169 AbsDiff => 'A001477', # AbsDiff=Y
4170 Product => 'A000004', # Product=0
4171 Radius => 'A001477', # Radius=Y
4172 GCD => 'A001477', # GCD=Y
4173 RSquared => 'A000290', # n^2
4174 TRSquared => 'A033428', # 3*n^2
4175 BitAnd => 'A000004', # BitAnd=0
4176 BitOr => 'A001477', # BitOr=Y
4177 BitXor => 'A001477', # BitXor=Y
4178 # OEIS-Other: A000004 planepath=PyramidRows,step=0,n_start=0 coordinate_type=X
4179 # OEIS-Other: A000004 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Min
4180 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Y
4181 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Max
4182 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=MaxAbs
4183 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Sum
4184 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=DiffYX
4185 # OEIS-Other: A001489 planepath=PyramidRows,step=0,n_start=0 coordinate_type=DiffXY
4186 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=AbsDiff
4187 # OEIS-Other: A000004 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Product
4188 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=Radius
4189 # OEIS-Other: A001489 planepath=PyramidRows,step=0,n_start=0 coordinate_type=DiffXY
4190 # OEIS-Other: A000290 planepath=PyramidRows,step=0,n_start=0 coordinate_type=RSquared
4191 # OEIS-Other: A033428 planepath=PyramidRows,step=0,n_start=0 coordinate_type=TRSquared
4192 # OEIS-Other: A000004 planepath=PyramidRows,step=0,n_start=0 coordinate_type=BitAnd
4193 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=BitOr
4194 # OEIS-Other: A001477 planepath=PyramidRows,step=0,n_start=0 coordinate_type=BitXor
4195 };
4196 ('step=0,align=centre,n_start=0' => $href,
4197 'step=0,align=right,n_start=0' => $href,
4198 'step=0,align=left,n_start=0' => $href,
4199 );
4200 },
4201  
4202 # PyramidRows step=1
4203 # cf A050873 GCD triangle starting (1,1) n=1
4204 # A051173 LCM triangle starting (1,1) n=1
4205 # A003991 X*Y product starting (1,1) n=1
4206 # A001316 count of occurrences of n as BitOr
4207 do {
4208 my $href =
4209 { X => 'A002262', # 0, 0,1, 0,1,2, etc (Diagonals)
4210 Min => 'A002262', # X<=Y always
4211 Y => 'A003056', # 0, 1,1, 2,2,2, 3,3,3,3 (Diagonals)
4212 Max => 'A003056', # Max=Y as Y>=X always
4213 MaxAbs => 'A003056', # MaxAbs=Max as Y>=0 always
4214 DiffYX => 'A025581', # descending N to 0 (Diagonals)
4215 AbsDiff => 'A025581', # absdiff same
4216 Sum => 'A051162', # triangle X+Y for X=0 to Y inclusive
4217 SumAbs => 'A051162', # sumabs same
4218 Product => 'A079904',
4219 RSquared => 'A069011', # triangle X^2+Y^2 for X=0 to Y inclusive
4220 GCD => 'A109004', # same as by diagonals
4221 BitAnd => 'A080099',
4222 BitOr => 'A080098',
4223 BitXor => 'A051933',
4224 };
4225 ('step=1,align=centre,n_start=0' => $href,
4226 'step=1,align=right,n_start=0' => $href,
4227 );
4228 # OEIS-Other: A002262 planepath=PyramidRows,step=1,n_start=0 coordinate_type=X
4229 # OEIS-Other: A002262 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Min
4230 # OEIS-Other: A003056 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Y
4231 # OEIS-Other: A003056 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Max
4232 # OEIS-Other: A003056 planepath=PyramidRows,step=1,n_start=0 coordinate_type=MaxAbs
4233 # OEIS-Other: A025581 planepath=PyramidRows,step=1,n_start=0 coordinate_type=DiffYX
4234 # OEIS-Other: A025581 planepath=PyramidRows,step=1,n_start=0 coordinate_type=AbsDiff
4235 # OEIS-Other: A051162 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Sum
4236 # OEIS-Other: A051162 planepath=PyramidRows,step=1,n_start=0 coordinate_type=SumAbs
4237 # OEIS-Catalogue: A079904 planepath=PyramidRows,step=1,n_start=0 coordinate_type=Product
4238 # OEIS-Catalogue: A069011 planepath=PyramidRows,step=1,n_start=0 coordinate_type=RSquared
4239 # OEIS-Other: A109004 planepath=PyramidRows,step=1,n_start=0 coordinate_type=GCD
4240 # OEIS-Catalogue: A080099 planepath=PyramidRows,step=1,n_start=0 coordinate_type=BitAnd
4241 # OEIS-Catalogue: A080098 planepath=PyramidRows,step=1,n_start=0 coordinate_type=BitOr
4242 # OEIS-Catalogue: A051933 planepath=PyramidRows,step=1,n_start=0 coordinate_type=BitXor
4243  
4244 # OEIS-Other: A002262 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=X
4245 # OEIS-Other: A003056 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=Y
4246 # OEIS-Other: A025581 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=DiffYX
4247 # OEIS-Other: A025581 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=AbsDiff
4248 # OEIS-Other: A051162 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=Sum
4249 # OEIS-Other: A051162 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=SumAbs
4250 # OEIS-Other: A079904 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=Product
4251 # OEIS-Other: A069011 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=RSquared
4252 # OEIS-Other: A080099 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=BitAnd
4253 # OEIS-Other: A080098 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=BitOr
4254 # OEIS-Other: A051933 planepath=PyramidRows,step=1,align=right,n_start=0 coordinate_type=BitXor
4255 },
4256  
4257 # 'step=1,align=left,n_start=0' =>
4258 # { ExperimentalAbsX => 'A025581', # descending runs n to 0
4259 # },
4260  
4261 # PyramidRows step=2
4262 'step=2,align=centre,n_start=0' =>
4263 { X => 'A196199', # runs -n to n
4264 Min => 'A196199', # X since X<Y
4265 Y => 'A000196', # n appears 2n+1 times, starting 0
4266 Max => 'A000196', # Y since X<Y
4267 Sum => 'A053186', # runs 0 to 2n
4268 ExperimentalAbsX => 'A053615', # runs n to 0 to n
4269 # OEIS-Catalogue: A196199 planepath=PyramidRows,n_start=0 coordinate_type=X
4270 # OEIS-Other: A196199 planepath=PyramidRows,n_start=0 coordinate_type=Min
4271 # OEIS-Catalogue: A000196 planepath=PyramidRows,n_start=0 coordinate_type=Y
4272 # OEIS-Other: A000196 planepath=PyramidRows,n_start=0 coordinate_type=Max
4273 # OEIS-Other: A053186 planepath=PyramidRows,n_start=0 coordinate_type=Sum
4274 # OEIS-Other: A053615 planepath=PyramidRows,n_start=0 coordinate_type=ExperimentalAbsX
4275  
4276 # # Not quite, extra initial 0
4277 # DiffYX => 'A068527', # dist to next square
4278 # AbsDiff => 'A068527', # same since Y-X>0
4279 },
4280 'step=2,align=right,n_start=0' =>
4281 { X => 'A053186', # runs 0 to 2n
4282 Y => 'A000196', # n appears 2n+1 times, starting 0
4283 DiffXY => 'A196199', # runs -n to n
4284 AbsDiff => 'A053615', # n..0..n, distance to pronic
4285 # OEIS-Other: A053186 planepath=PyramidRows,align=right,n_start=0 coordinate_type=X
4286 # OEIS-Other: A000196 planepath=PyramidRows,align=right,n_start=0 coordinate_type=Y
4287 # OEIS-Other: A196199 planepath=PyramidRows,align=right,n_start=0 coordinate_type=DiffXY
4288 # OEIS-Other: A053615 planepath=PyramidRows,align=right,n_start=0 coordinate_type=AbsDiff
4289 },
4290 'step=2,align=left,n_start=0' =>
4291 { X => '', # runs -2n+1 to 0
4292 Y => 'A000196', # n appears 2n+1 times, starting 0
4293 Sum => 'A196199', # -n to n
4294 # OEIS-Other: A000196 planepath=PyramidRows,align=left,n_start=0 coordinate_type=Y
4295 # OEIS-Other: A196199 planepath=PyramidRows,align=left,n_start=0 coordinate_type=Sum
4296  
4297 # Not quite, A068527 doesn't have two initial 0s
4298 # ExperimentalAbsX => 'A068527', # dist to next square
4299 # # OEIS-Other: A068527 planepath=PyramidRows,align=left,n_start=0 coordinate_type=ExperimentalAbsX
4300 },
4301  
4302 # PyramidRows step=3
4303 do {
4304 my $href =
4305 { Y => 'A180447', # n appears 3n+1 times, starting 0
4306 };
4307 ('step=3,align=centre,n_start=0' => $href,
4308 'step=3,align=right,n_start=0' => $href,
4309 );
4310 # OEIS-Catalogue: A180447 planepath=PyramidRows,step=3,n_start=0 coordinate_type=Y
4311 # OEIS-Other: A180447 planepath=PyramidRows,step=3,align=right,n_start=0 coordinate_type=Y
4312 },
4313 'step=3,align=left,n_start=0' =>
4314 { Y => 'A180447', # n appears 3n+1 times, starting 0
4315 Max => 'A180447', # Y since X<Y
4316 },
4317 # OEIS-Other: A180447 planepath=PyramidRows,step=3,align=left,n_start=0 coordinate_type=Y
4318 # OEIS-Other: A180447 planepath=PyramidRows,step=3,align=left,n_start=0 coordinate_type=Max
4319  
4320 # PyramidRows step=4
4321 'step=4,align=right,n_start=0' =>
4322 { X => 'A060511', # amount exceeding hexagonal number
4323 },
4324 # OEIS-Catalogue: A060511 planepath=PyramidRows,step=4,align=right,n_start=0 coordinate_type=X
4325 };
4326 }
4327 { package Math::PlanePath::PyramidSides;
4328 use constant _NumSeq_Coord_filling_type => 'half';
4329 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1;
4330  
4331 use constant _NumSeq_Coord_oeis_anum =>
4332 { 'n_start=0' =>
4333 { X => 'A196199', # runs -n to n
4334 SumAbs => 'A000196', # n appears 2n+1 times, starting 0
4335 # OEIS-Other: A196199 planepath=PyramidSides,n_start=0 coordinate_type=X
4336 # OEIS-Other: A000196 planepath=PyramidSides,n_start=0 coordinate_type=SumAbs
4337  
4338 ExperimentalAbsX => 'A053615', # runs n to 0 to n
4339 # OEIS-Other: A053615 planepath=PyramidSides,n_start=0 coordinate_type=ExperimentalAbsX
4340 },
4341 };
4342 }
4343 { package Math::PlanePath::CellularRule;
4344  
4345 # single cell
4346 # 111 -> any
4347 # 110 -> any
4348 # 101 -> any
4349 # 100 -> 0 initial
4350 # 011 -> any
4351 # 010 -> 0 initial
4352 # 001 -> 0 initial
4353 # 000 -> 0
4354 # so (rule & 0x17) == 0
4355 #
4356 # right 2 cell line 0x54,74,D4,F4
4357 # 111 -> any
4358 # 110 -> 1
4359 # 101 -> any
4360 # 100 -> 1
4361 # 011 -> 0
4362 # 010 -> 1
4363 # 001 -> 0
4364 # 000 -> 0
4365 # so (rule & 0x5F) == 0x54
4366 #
4367 sub _NumSeq_Coord_X_increasing {
4368 my ($self) = @_;
4369 ### CellularRule _NumSeq_Coord_X_increasing() rule: $self->{'rule'}
4370 return (($self->{'rule'} & 0x17) == 0 # single cell only
4371 ? 1
4372 : 0);
4373 }
4374 sub _NumSeq_Coord_Sum_increasing {
4375 my ($self) = @_;
4376 return (($self->{'rule'} & 0x17) == 0 # single cell only
4377 || ($self->{'rule'} & 0x5F) == 0x54 # right line 2
4378 ? 1
4379 : 0);
4380 }
4381 *_NumSeq_Coord_Min_increasing = \&_NumSeq_Coord_Sum_increasing; # Min=X
4382 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Sum_increasing;
4383 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Sum_increasing;
4384 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Radius_increasing;
4385  
4386 *_NumSeq_Coord_Y_increasing = \&_NumSeq_Coord_X_increasing;
4387 *_NumSeq_Coord_Max_increasing = \&_NumSeq_Coord_X_increasing; # Max==Y
4388 *_NumSeq_Coord_Product_increasing = \&_NumSeq_Coord_X_increasing;
4389 *_NumSeq_Coord_DiffXY_increasing = \&_NumSeq_Coord_X_increasing;
4390 *_NumSeq_Coord_DiffYX_increasing = \&_NumSeq_Coord_X_increasing;
4391 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_X_increasing;
4392 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4393  
4394 sub _NumSeq_Coord_X_non_decreasing {
4395 my ($self) = @_;
4396 return (($self->{'rule'} & 0x17) == 0 # single cell only
4397 || ($self->{'rule'} & 0x5F) == 0x54 # right line 2
4398 ? 1
4399 : 0);
4400 }
4401 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_non_decreasing; # Min=X
4402 sub _NumSeq_Coord_Product_non_decreasing {
4403 my ($self) = @_;
4404 return (($self->{'rule'} & 0x17) == 0 # single cell only
4405 || ($self->{'rule'} & 0x5F) == 0x54 # right line 2
4406 ? 1
4407 : 0);
4408 }
4409  
4410 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4411 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max==Y
4412  
4413 sub _NumSeq_Coord_BitAnd_max {
4414 my ($self) = @_;
4415 return (($self->{'rule'} & 0x17) == 0 # single cell only
4416 || ($self->{'rule'} & 0x5F) == 0x54 # right line 2
4417 ? 0
4418 : undef);
4419 }
4420  
4421 sub _NumSeq_Coord_ExperimentalParity_max {
4422 my ($self) = @_;
4423 return (($self->{'rule'} & 0x17) == 0 # single cell only
4424 ? 0 # X=0,Y=0 even
4425  
4426 : 1);
4427 }
4428 }
4429 { package Math::PlanePath::CellularRule::OneTwo;
4430 sub _NumSeq_Coord_Sum_increasing {
4431 my ($self) = @_;
4432 return ($self->{'sign'} > 0); # when to the right
4433 }
4434 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Sum_increasing;
4435 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Sum_increasing;
4436 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Radius_increasing;
4437  
4438 sub _NumSeq_Coord_X_non_decreasing {
4439 my ($self) = @_;
4440 return ($self->{'sign'} > 0); # yes when to the right
4441 }
4442 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_non_decreasing; # Min=X
4443 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4444 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4445 *_NumSeq_Coord_BitOr_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4446  
4447 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4448 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4449 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4450 sub _NumSeq_Coord_MinAbs_non_decreasing {
4451 my ($self) = @_;
4452 return ($self->{'sign'} > 0); # yes when to the right
4453 }
4454  
4455 sub _NumSeq_Coord_IntXY_min {
4456 my ($self) = @_;
4457 return ($self->{'align'} eq 'left' ? -1 : 0);
4458 }
4459  
4460 sub _NumSeq_Coord_BitOr_max {
4461 my ($self) = @_;
4462 return ($self->{'align'} eq 'left' ? 1 : undef);
4463 }
4464 use constant _NumSeq_Coord_BitXor_max => 1;
4465  
4466 use constant _NumSeq_Coord_oeis_anum =>
4467 { 'align=left,n_start=0' =>
4468 { Y => 'A004396', # one even two odd
4469 Max => 'A004396', # Max=Y
4470 SumAbs => 'A131452', # a(3n)=4n, a(3n+1)=4n+2, a(3n+2)=4n+1.
4471 DiffYX => 'A131452', # X<0 so Y-X=abs(Y)+abs(X)
4472 # OEIS-Catalogue: A004396 planepath=CellularRule,rule=6,n_start=0 coordinate_type=Y
4473 # OEIS-Other: A004396 planepath=CellularRule,rule=166,n_start=0 coordinate_type=Max
4474 # OEIS-Catalogue: A131452 planepath=CellularRule,rule=6,n_start=0 coordinate_type=SumAbs
4475 # OEIS-Other: A131452 planepath=CellularRule,rule=166,n_start=0 coordinate_type=SumAbs
4476  
4477 # Maybe, but OFFSET in fractions?
4478 # Sum => 'A022003', # 1/999 decimal 0,0,1,0,0,1
4479 # # OEIS-Other: A022003 planepath=CellularRule,rule=166,n_start=0 coordinate_type=Sum
4480 },
4481  
4482 'align=right,n_start=0' =>
4483 { X => 'A004523', # 0,0,1,2,2,3 two even, one odd
4484 Min => 'A004523', # Min=X
4485 BitAnd => 'A004523', # BitAnd=X
4486 Y => 'A004396', # one even two odd
4487 Max => 'A004396', # Max=Y
4488 BitOr => 'A004396', # BitOr=Y
4489 SumAbs => 'A004773', # 0,1,2 mod 4
4490 ExperimentalPairsXY => 'A002264', # triples 0,0,0, 1,1,1, etc
4491  
4492 # OEIS-Catalogue: A004523 planepath=CellularRule,rule=20,n_start=0 coordinate_type=X
4493 # OEIS-Other: A004523 planepath=CellularRule,rule=20,n_start=0 coordinate_type=Min
4494 # OEIS-Other: A004523 planepath=CellularRule,rule=20,n_start=0 coordinate_type=BitAnd
4495 # OEIS-Other: A004396 planepath=CellularRule,rule=20,n_start=0 coordinate_type=Y
4496 # OEIS-Other: A004396 planepath=CellularRule,rule=180,n_start=0 coordinate_type=Max
4497 # OEIS-Other: A004396 planepath=CellularRule,rule=180,n_start=0 coordinate_type=BitOr
4498 # OEIS-Catalogue: A004773 planepath=CellularRule,rule=20,n_start=0 coordinate_type=SumAbs
4499 # OEIS-Other: A004773 planepath=CellularRule,rule=180,n_start=0 coordinate_type=SumAbs
4500 # OEIS-Other: A002264 planepath=CellularRule,rule=20,n_start=0 coordinate_type=ExperimentalPairsXY
4501 },
4502 };
4503 }
4504 { package Math::PlanePath::CellularRule::Two;
4505 sub _NumSeq_Coord_Sum_increasing {
4506 my ($self) = @_;
4507 return ($self->{'sign'} > 0); # when to the right
4508 }
4509 *_NumSeq_Coord_SumAbs_increasing = \&_NumSeq_Coord_Sum_increasing;
4510 *_NumSeq_Coord_Radius_increasing = \&_NumSeq_Coord_Sum_increasing;
4511 *_NumSeq_Coord_TRadius_increasing = \&_NumSeq_Coord_Radius_increasing;
4512  
4513 sub _NumSeq_Coord_X_non_decreasing {
4514 my ($self) = @_;
4515 return ($self->{'sign'} > 0); # yes when to the right
4516 }
4517 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_non_decreasing; # Min=X
4518 *_NumSeq_Coord_Product_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4519 *_NumSeq_Coord_BitAnd_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4520 *_NumSeq_Coord_BitOr_non_decreasing = \&_NumSeq_Coord_X_non_decreasing;
4521  
4522 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4523 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4524 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4525 sub _NumSeq_Coord_MinAbs_non_decreasing {
4526 my ($self) = @_;
4527 return ($self->{'sign'} > 0); # yes when to the right
4528 }
4529  
4530 sub _NumSeq_Coord_IntXY_min {
4531 my ($self) = @_;
4532 return ($self->{'align'} eq 'left' ? -1 : 0);
4533 }
4534  
4535 sub _NumSeq_Coord_BitOr_max {
4536 my ($self) = @_;
4537 return ($self->{'align'} eq 'left' ? 1 : undef);
4538 }
4539 use constant _NumSeq_Coord_BitXor_max => 1;
4540  
4541 use constant _NumSeq_Coord_oeis_anum =>
4542 {
4543 'align=left,n_start=1' =>
4544 { Y => 'A076938', # 0,1,1,2,2,3,3,...
4545 # OEIS-Other: A076938 planepath=CellularRule,rule=14 coordinate_type=Y
4546 # OEIS-Other: A076938 planepath=CellularRule,rule=174 coordinate_type=Y
4547 },
4548 'align=right,n_start=1' =>
4549 { Y => 'A076938', # 0,1,1,2,2,3,3,...
4550 # OEIS-Other: A076938 planepath=CellularRule,rule=84 coordinate_type=Y
4551 # OEIS-Other: A076938 planepath=CellularRule,rule=116 coordinate_type=Y
4552 },
4553 };
4554 }
4555 { package Math::PlanePath::CellularRule::Line;
4556 sub _NumSeq_Coord_Radius_integer {
4557 my ($path) = @_;
4558 # centre Radius=Y so integer, otherwise Radius=sqrt(2)*Y not integer
4559 return ($path->{'align'} eq 'centre');
4560 }
4561  
4562 use constant _NumSeq_Coord_Y_increasing => 1; # line upwards
4563 use constant _NumSeq_Coord_Max_increasing => 1; # Max=Y
4564 use constant _NumSeq_Coord_Radius_increasing => 1; # line upwards
4565 use constant _NumSeq_Coord_TRadius_increasing => 1; # line upwards
4566 sub _NumSeq_Coord_TRadius_integer {
4567 my ($path) = @_;
4568 return ($path->{'sign'} != 0); # left or right sloping
4569 }
4570  
4571 sub _NumSeq_Coord_X_increasing {
4572 my ($path) = @_;
4573 return ($path->{'sign'} >= 1); # X=Y diagonal
4574 }
4575 sub _NumSeq_Coord_X_non_decreasing {
4576 my ($path) = @_;
4577 return ($path->{'sign'} >= 0); # X=0 vertical or X=Y diagonal
4578 }
4579 *_NumSeq_Coord_Min_non_decreasing = \&_NumSeq_Coord_X_non_decreasing; # Min=X
4580 *_NumSeq_Coord_Min_increasing = \&_NumSeq_Coord_X_increasing; # Min=X
4581  
4582 sub _NumSeq_Coord_Sum_increasing {
4583 my ($path) = @_;
4584 return ($path->{'sign'} == -1
4585 ? 0 # X=-Y so X+Y=0
4586 : 1); # X=0 so X+Y=Y, or X=Y so X+Y=2Y
4587 }
4588 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # line upwards
4589 use constant _NumSeq_Coord_SumAbs_increasing => 1; # line upwards
4590  
4591 sub _NumSeq_Coord_Product_increasing {
4592 my ($path) = @_;
4593 return ($path->{'sign'} > 0
4594 ? 1 # X=Y so X*Y=Y^2
4595 : 0); # X=0 so X*Y=0, or X=-Y so X*Y=-(Y^2)
4596 }
4597 sub _NumSeq_Coord_Product_non_decreasing {
4598 my ($path) = @_;
4599 return ($path->{'sign'} >= 0
4600 ? 1 # X=Y so X*Y=Y^2
4601 : 0); # X=0 so X*Y=0, or X=-Y so X*Y=-(Y^2)
4602 }
4603  
4604 # sign=1 X=Y so X-Y=0 always, non-decreasing
4605 # sign=0 X=0 so Y-X=Y, increasing
4606 # sign=-1 X=-Y so Y-X=2*Y, increasing
4607 sub _NumSeq_Coord_DiffXY_non_decreasing {
4608 my ($path) = @_;
4609 return ($path->{'sign'} == 1 ? 1 # X-Y=0 always
4610 : 0);
4611 }
4612 sub _NumSeq_Coord_DiffYX_increasing {
4613 my ($path) = @_;
4614 return ($path->{'sign'} == 1 ? 0 : 1);
4615 }
4616 *_NumSeq_Coord_AbsDiff_increasing = \&_NumSeq_Coord_DiffYX_increasing;
4617 use constant _NumSeq_Coord_DiffYX_non_decreasing => 1; # Y-X >= 0 always
4618 use constant _NumSeq_Coord_AbsDiff_non_decreasing => 1; # Y-X >= 0 always
4619 use constant _NumSeq_Coord_GCD_increasing => 1; # GCD==Y
4620  
4621 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4622 sub _NumSeq_Coord_ExperimentalParity_max {
4623 my ($path) = @_;
4624 return ($path->{'align'} eq 'centre' ? 1 : 0);
4625 }
4626  
4627 sub _NumSeq_Coord_ExperimentalNumerator_min {
4628 my ($path) = @_;
4629 return ($path->{'align'} eq 'left'
4630 ? -1
4631 : 0);
4632 }
4633 sub _NumSeq_Coord_ExperimentalNumerator_max {
4634 my ($path) = @_;
4635 return ($path->{'align'} eq 'right'
4636 ? 1 # right X=Y so 1/1 except for 0/0
4637 : 0);
4638 }
4639 sub _NumSeq_Coord_ExperimentalNumerator_non_decreasing {
4640 my ($path) = @_;
4641 return ($path->{'align'} ne 'left');
4642 }
4643  
4644 # ExperimentalDenominator_min => 0; # 0/0 at n_start()
4645 use constant _NumSeq_Coord_ExperimentalDenominator_max => 1;
4646 use constant _NumSeq_Coord_ExperimentalDenominator_non_decreasing => 1;
4647  
4648 # left Y bitand -Y twos-complement gives mask of low 1-bits
4649 sub _NumSeq_Coord_BitAnd_non_decreasing {
4650 my ($path) = @_;
4651 return ($path->{'align'} ne 'left'); # centre BitAnd=0, right BitAnd=Y
4652 }
4653 sub _NumSeq_Coord_BitAnd_increasing {
4654 my ($path) = @_;
4655 return ($path->{'align'} eq 'right'); # right BitAnd=Y
4656 }
4657  
4658 # left Y bitor -Y twos-complement gives all-1s above low 0-bits
4659 sub _NumSeq_Coord_BitOr_increasing {
4660 my ($path) = @_;
4661 return ($path->{'align'} ne 'left'); # centre,right BitOr = Y
4662 }
4663  
4664 sub _NumSeq_Coord_BitXor_min {
4665 my ($path) = @_;
4666 return ($path->{'align'} eq 'left'
4667 ? undef
4668 : 0); # right X=Y so BitXor=0 always, centre X=0 so BitXor=Y
4669 }
4670 sub _NumSeq_Coord_BitXor_max {
4671 my ($path) = @_;
4672 return ($path->{'align'} eq 'centre'
4673 ? undef # centre X=0 BitXor=Y
4674 : 0); # right X=Y so BitXor=0 always, left negative
4675 }
4676 sub _NumSeq_Coord_BitXor_increasing {
4677 my ($path) = @_;
4678 return ($path->{'align'} eq 'centre'); # centre BitXor=Y
4679 }
4680  
4681 # and maximum 0/0=infinity
4682 sub _NumSeq_Coord_IntXY_min {
4683 my ($path) = @_;
4684 return ($path->{'align'} eq 'right'
4685 ? 1 # right X=Y so X/Y=1 always
4686 : $path->{'align'} eq 'left'
4687 ? -1 # left X=-Y so X/Y=-1 always
4688 : 0);
4689 }
4690  
4691 use constant _NumSeq_Coord_FracXY_min => 0; # X=0,+Y,-Y so frac=0
4692 use constant _NumSeq_Coord_FracXY_max => 0;
4693 use constant _NumSeq_Coord_FracXY_integer => 1;
4694 use constant _NumSeq_FracXY_min_is_infimum => 0;
4695 use constant _NumSeq_FracXY_max_is_supremum => 0;
4696  
4697 use constant _NumSeq_Coord_oeis_anum =>
4698 { 'align=left,n_start=0' =>
4699 { X => 'A001489', # integers negative X=0,-1,-2,etc
4700 Min => 'A001489', # Min=X
4701 Y => 'A001477', # integers Y=0,1,2,etc
4702 Max => 'A001477', # Max=Y
4703 Sum => 'A000004', # all zeros
4704 DiffYX => 'A005843', # even 0,2,4,etc
4705 RSquared => 'A001105', # 2*n^2
4706 TRSquared => 'A016742', # 4*n^2
4707 # OEIS-Other: A001489 planepath=CellularRule,rule=2,n_start=0 coordinate_type=X
4708 # OEIS-Other: A001489 planepath=CellularRule,rule=2,n_start=0 coordinate_type=Min
4709 # OEIS-Other: A001477 planepath=CellularRule,rule=2,n_start=0 coordinate_type=Y
4710 # OEIS-Other: A001477 planepath=CellularRule,rule=2,n_start=0 coordinate_type=Max
4711 # OEIS-Other: A000004 planepath=CellularRule,rule=2,n_start=0 coordinate_type=Sum
4712 # OEIS-Other: A005843 planepath=CellularRule,rule=2,n_start=0 coordinate_type=DiffYX
4713 # OEIS-Other: A001105 planepath=CellularRule,rule=2,n_start=0 coordinate_type=RSquared
4714 # OEIS-Other: A016742 planepath=CellularRule,rule=2,n_start=0 coordinate_type=TRSquared
4715 },
4716  
4717 'align=right,n_start=0' =>
4718 { X => 'A001477', # integers Y=0,1,2,etc
4719 Min => 'A001477', # Min=X
4720 Y => 'A001477', # integers Y=0,1,2,etc
4721 Max => 'A001477', # Max=Y
4722 Sum => 'A005843', # even 0,2,4,etc
4723 DiffYX => 'A000004', # all zeros
4724 DiffXY => 'A000004', # all zeros
4725 RSquared => 'A001105', # 2*n^2
4726 TRSquared => 'A016742', # 4*n^2
4727 ExperimentalPairsXY => 'A004526', # 0,0,1,1,2,2,etc cf Math::NumSeq::Runs
4728 # OEIS-Other: A001477 planepath=CellularRule,rule=16,n_start=0 coordinate_type=X
4729 # OEIS-Other: A001477 planepath=CellularRule,rule=16,n_start=0 coordinate_type=Min
4730 # OEIS-Other: A001477 planepath=CellularRule,rule=16,n_start=0 coordinate_type=Y
4731 # OEIS-Other: A001477 planepath=CellularRule,rule=16,n_start=0 coordinate_type=Max
4732 # OEIS-Other: A005843 planepath=CellularRule,rule=16,n_start=0 coordinate_type=Sum
4733 # OEIS-Other: A000004 planepath=CellularRule,rule=16,n_start=0 coordinate_type=DiffYX
4734 # OEIS-Other: A000004 planepath=CellularRule,rule=16,n_start=0 coordinate_type=DiffXY
4735 # OEIS-Other: A001105 planepath=CellularRule,rule=16,n_start=0 coordinate_type=RSquared
4736 # OEIS-Other: A016742 planepath=CellularRule,rule=16,n_start=0 coordinate_type=TRSquared
4737 # OEIS-Other: A004526 planepath=CellularRule,rule=16,n_start=0 coordinate_type=ExperimentalPairsXY
4738 },
4739  
4740 # same as PyramidRows step=0
4741 'align=centre,n_start=0' =>
4742 Math::PlanePath::PyramidRows->_NumSeq_Coord_oeis_anum()->{'step=0,align=centre,n_start=0'},
4743 # OEIS-Other: A000004 planepath=CellularRule,rule=4,n_start=0 coordinate_type=X
4744 # OEIS-Other: A000004 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Min
4745 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Y
4746 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Max
4747 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Sum
4748 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=DiffYX
4749 # OEIS-Other: A001489 planepath=CellularRule,rule=4,n_start=0 coordinate_type=DiffXY
4750 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=AbsDiff
4751 # OEIS-Other: A001477 planepath=CellularRule,rule=4,n_start=0 coordinate_type=Radius
4752 # OEIS-Other: A001489 planepath=CellularRule,rule=4,n_start=0 coordinate_type=DiffXY
4753 # OEIS-Other: A000290 planepath=CellularRule,rule=4,n_start=0 coordinate_type=RSquared
4754 # OEIS-Other: A033428 planepath=CellularRule,rule=4,n_start=0 coordinate_type=TRSquared
4755 };
4756  
4757 # CellularRule starts i=1 value=0, but A000027 is OFFSET=1 value=1
4758 # } elsif ($planepath_object->isa('Math::PlanePath::CellularRule::Line')) {
4759 # # for all "rule" parameter values
4760 # if ($coordinate_type eq 'Y'
4761 # || ($planepath_object->{'sign'} == 0
4762 # && ($coordinate_type eq 'Sum'
4763 # || $coordinate_type eq 'DiffYX'
4764 # || $coordinate_type eq 'AbsDiff'
4765 # || $coordinate_type eq 'Radius'))) {
4766 # return 'A000027'; # natural numbers 1,2,3
4767 # # OEIS-Other: A000027 planepath=CellularRule,rule=2 coordinate_type=Y
4768 # # OEIS-Other: A000027 planepath=CellularRule,rule=4 coordinate_type=Sum
4769 # # OEIS-Other: A000027 planepath=CellularRule,rule=4 coordinate_type=DiffYX
4770 # # OEIS-Other: A000027 planepath=CellularRule,rule=4 coordinate_type=AbsDiff
4771 # # OEIS-Other: A000027 planepath=CellularRule,rule=4 coordinate_type=Radius
4772 # }
4773 }
4774 { package Math::PlanePath::CellularRule::OddSolid;
4775 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4776 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4777 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4778 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # always even points
4779 }
4780 { package Math::PlanePath::CellularRule54;
4781 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4782 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4783 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4784 use constant _NumSeq_Coord_IntXY_min => -1;
4785 }
4786 { package Math::PlanePath::CellularRule57;
4787 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4788 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4789 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4790 use constant _NumSeq_Coord_IntXY_min => -1;
4791 }
4792 { package Math::PlanePath::CellularRule190;
4793 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
4794 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max=Y
4795 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
4796 use constant _NumSeq_Coord_IntXY_min => -1;
4797 }
4798 { package Math::PlanePath::UlamWarburton;
4799 use constant _NumSeq_Coord_filling_type => 'plane';
4800 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 4;
4801 }
4802 { package Math::PlanePath::UlamWarburtonQuarter;
4803 use constant _NumSeq_Coord_filling_type => 'quadrant';
4804 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 4;
4805 use constant _NumSeq_Coord_ExperimentalParity_max => 0; # even always
4806 }
4807 { package Math::PlanePath::DiagonalRationals;
4808 use constant _NumSeq_Coord_Sum_non_decreasing => 1; # X+Y diagonals
4809 use constant _NumSeq_Coord_SumAbs_non_decreasing => 1; # X+Y diagonals
4810 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=1,Y=2
4811  
4812 use constant _NumSeq_Coord_oeis_anum =>
4813 { 'direction=down,n_start=1' =>
4814 { X => 'A020652', # numerators
4815 Y => 'A020653', # denominators
4816 ExperimentalNumerator => 'A020652', # ExperimentalNumerator=X
4817 ExperimentalDenominator => 'A020653', # ExperimentalDenominator=Y
4818 # OEIS-Catalogue: A020652 planepath=DiagonalRationals coordinate_type=X
4819 # OEIS-Catalogue: A020653 planepath=DiagonalRationals coordinate_type=Y
4820 # OEIS-Other: A020652 planepath=DiagonalRationals coordinate_type=ExperimentalNumerator
4821 # OEIS-Other: A020653 planepath=DiagonalRationals coordinate_type=ExperimentalDenominator
4822  
4823 # Not quite, A038567 has OFFSET=0 to include 0/1
4824 # Sum => 'A038567', # num+den, is den of fractions X/Y <= 1
4825 # SumAbs => 'A038567'
4826 },
4827 'direction=down,n_start=0' =>
4828 { AbsDiff => 'A157806', # abs(num-den), OFFSET=0
4829 # OEIS-Other: A157806 planepath=DiagonalRationals,n_start=0 coordinate_type=AbsDiff
4830 },
4831  
4832 'direction=up,n_start=1' =>
4833 { X => 'A020653', # transposed is denominators
4834 Y => 'A020652', # transposed is numerators
4835 ExperimentalNumerator => 'A020653', # ExperimentalNumerator=X
4836 ExperimentalDenominator => 'A020652', # ExperimentalDenominator=Y
4837 # OEIS-Other: A020652 planepath=DiagonalRationals,direction=up coordinate_type=Y
4838 # OEIS-Other: A020653 planepath=DiagonalRationals,direction=up coordinate_type=X
4839 # OEIS-Other: A020653 planepath=DiagonalRationals,direction=up coordinate_type=ExperimentalNumerator
4840 # OEIS-Other: A020652 planepath=DiagonalRationals,direction=up coordinate_type=ExperimentalDenominator
4841  
4842 # Not quite, A038567 has OFFSET=0 to include 0/1
4843 # Sum => 'A038567', # num+den, is den of fractions X/Y <= 1
4844 },
4845 'direction=up,n_start=0' =>
4846 { AbsDiff => 'A157806', # abs(num-den), OFFSET=0
4847 # OEIS-Other: A157806 planepath=DiagonalRationals,direction=up,n_start=0 coordinate_type=AbsDiff
4848 },
4849 };
4850 }
4851 { package Math::PlanePath::FactorRationals;
4852 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=1,Y=2
4853  
4854 use constant _NumSeq_Coord_oeis_anum =>
4855 { 'factor_coding=even/odd' =>
4856 { X => 'A071974', # numerators
4857 Y => 'A071975', # denominators
4858 Product => 'A019554', # replace squares by their root
4859 # OEIS-Catalogue: A071974 planepath=FactorRationals coordinate_type=X
4860 # OEIS-Catalogue: A071975 planepath=FactorRationals coordinate_type=Y
4861 # OEIS-Catalogue: A019554 planepath=FactorRationals coordinate_type=Product
4862 },
4863 'factor_coding=odd/even' =>
4864 { X => 'A071975', # denominators
4865 Y => 'A071974', # numerators
4866 Product => 'A019554', # replace squares by their root
4867 # OEIS-Other: A071975 planepath=FactorRationals,factor_coding=odd/even coordinate_type=X
4868 # OEIS-Other: A071974 planepath=FactorRationals,factor_coding=odd/even coordinate_type=Y
4869 # OEIS-Other: A019554 planepath=FactorRationals,factor_coding=odd/even coordinate_type=Product
4870 },
4871 };
4872 }
4873 { package Math::PlanePath::GcdRationals;
4874 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=1,Y=2
4875  
4876 use constant _NumSeq_Coord_oeis_anum =>
4877 { 'pairs_order=rows' =>
4878 { X => 'A226314',
4879 Y => 'A054531', # T(n,k) = n/GCD(n,k), being denominators
4880 # OEIS-Catalogue: A226314 planepath=GcdRationals coordinate_type=X
4881 # OEIS-Catalogue: A054531 planepath=GcdRationals coordinate_type=Y
4882 },
4883 'pairs_order=rows_reverse' =>
4884 { Y => 'A054531', # same
4885 # OEIS-Other: A054531 planepath=GcdRationals,pairs_order=rows coordinate_type=Y
4886 },
4887 };
4888 }
4889 { package Math::PlanePath::CoprimeColumns;
4890 use constant _NumSeq_Coord_X_non_decreasing => 1; # columns across
4891 use constant _NumSeq_Coord_ExperimentalNumerator_non_decreasing => 1; # ExperimentalNumerator==X
4892 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max==X
4893 use constant _NumSeq_Coord_IntXY_min => 1; # octant Y<=X so X/Y>=1
4894 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=2,Y=1
4895  
4896 use constant _NumSeq_Coord_oeis_anum =>
4897 { 'direction=up,n_start=0' =>
4898 { X => 'A038567', # fractions denominator
4899 Max => 'A038567', # Max=X since Y <= X
4900 MaxAbs => 'A038567', # MaxAbs=Max
4901 # OEIS-Catalogue: A038567 planepath=CoprimeColumns coordinate_type=X
4902 # OEIS-Other: A038567 planepath=CoprimeColumns coordinate_type=Max
4903 # OEIS-Other: A038567 planepath=CoprimeColumns coordinate_type=MaxAbs
4904 },
4905  
4906 'direction=up,n_start=0,i_start=1' =>
4907 { DiffXY => 'A020653', # diagonals denominators, starting N=1
4908 # OEIS-Other: A020653 planepath=CoprimeColumns coordinate_type=DiffXY i_start=1
4909 },
4910  
4911 'direction=up,n_start=1' =>
4912 { Y => 'A038566', # fractions numerator
4913 Min => 'A038566', # Min=Y since Y <= X
4914 MinAbs => 'A038566', # MinAbs=Min
4915 # OEIS-Catalogue: A038566 planepath=CoprimeColumns,n_start=1 coordinate_type=Y
4916 # OEIS-Other: A038566 planepath=CoprimeColumns,n_start=1 coordinate_type=Min
4917 # OEIS-Other: A038566 planepath=CoprimeColumns,n_start=1 coordinate_type=MinAbs
4918 },
4919 };
4920 }
4921 { package Math::PlanePath::DivisibleColumns;
4922 use constant _NumSeq_Coord_X_non_decreasing => 1; # columns across
4923  
4924 sub _NumSeq_Coord_IntXY_min {
4925 my ($self) = @_;
4926 return ($self->{'proper'} ? 2 : 1);
4927 }
4928 use constant _NumSeq_Coord_FracXY_max => 0; # frac(X/Y)=0 always
4929 use constant _NumSeq_Coord_FracXY_integer => 1;
4930 use constant _NumSeq_FracXY_max_is_supremum => 0;
4931  
4932 sub _NumSeq_Coord_ExperimentalNumerator_min {
4933 my ($self) = @_;
4934 return ($self->{'proper'} ? 2 : 1);
4935 }
4936  
4937 # X/Y = Z/1 since X divisible by Y, ExperimentalDenominator=1 always
4938 use constant _NumSeq_Coord_ExperimentalDenominator_min => 1;
4939 use constant _NumSeq_Coord_ExperimentalDenominator_max => 1;
4940 use constant _NumSeq_Coord_ExperimentalDenominator_non_decreasing => 1;
4941  
4942 use constant _NumSeq_Coord_BitAnd_min => 0; # at X=2,Y=1
4943 sub _NumSeq_Coord_BitXor_min {
4944 my ($self) = @_;
4945 # octant Y<=X so X-Y>=0
4946 return ($self->{'proper'} ? 2 # at X=3,Y=1
4947 : 0); # at X=1,Y=1
4948 }
4949  
4950 use constant _NumSeq_Coord_Max_non_decreasing => 1; # Max==X
4951 sub _NumSeq_Coord_MaxAbs_min { return $_[0]->x_minimum } # Max=X
4952  
4953 use constant _NumSeq_Coord_ExperimentalHammingDist_min => 1; # X!=Y
4954  
4955 use constant _NumSeq_Coord_oeis_anum =>
4956 { 'divisor_type=all,n_start=1' =>
4957 { X => 'A061017', # n appears divisors(n) times
4958 Max => 'A061017', # Max=X since Y <= X
4959 MaxAbs => 'A061017', # MaxAbs=Max
4960 Y => 'A027750', # triangle divisors of n
4961 Min => 'A027750', # Min=Y since Y <= X
4962 MinAbs => 'A027750', # MinAbs=Min
4963 GCD => 'A027750', # Y since Y is a divisor of X
4964 IntXY => 'A056538', # divisors in reverse order, X/Y give high to low
4965 ExperimentalNumerator => 'A056538', # same as int(X/Y)
4966 # OEIS-Catalogue: A061017 planepath=DivisibleColumns,n_start=1 coordinate_type=X
4967 # OEIS-Other: A061017 planepath=DivisibleColumns,n_start=1 coordinate_type=Max
4968 # OEIS-Other: A061017 planepath=DivisibleColumns,n_start=1 coordinate_type=MaxAbs
4969 # OEIS-Catalogue: A027750 planepath=DivisibleColumns,n_start=1 coordinate_type=Y
4970 # OEIS-Other: A027750 planepath=DivisibleColumns,n_start=1 coordinate_type=Min
4971 # OEIS-Other: A027750 planepath=DivisibleColumns,n_start=1 coordinate_type=GCD
4972 # OEIS-Catalogue: A056538 planepath=DivisibleColumns,n_start=1 coordinate_type=IntXY
4973 # OEIS-Other: A056538 planepath=DivisibleColumns,n_start=1 coordinate_type=ExperimentalNumerator
4974 },
4975  
4976 'divisor_type=proper,n_start=2' =>
4977 { DiffXY => 'A208460', # X-Y
4978 AbsDiff => 'A208460', # abs(X-Y) same since Y<=X so X-Y>=0
4979 # OEIS-Catalogue: A208460 planepath=DivisibleColumns,divisor_type=proper,n_start=2 coordinate_type=DiffXY
4980 # OEIS-Other: A208460 planepath=DivisibleColumns,divisor_type=proper,n_start=2 coordinate_type=AbsDiff
4981  
4982 # Not quite, A027751 has an extra 1 at the start from reckoning by
4983 # convention 1 as a proper divisor of 1 -- though that's
4984 # inconsistent with A032741 count of proper divisors being 0.
4985 #
4986 # 'divisor_type=proper,n_start=0' =>
4987 # { Y,Min,GCD => 'A027751', # proper divisors by rows
4988 # # OEIS-Catalogue: A027751 planepath=DivisibleColumns,divisor_type=proper coordinate_type=Y
4989 # },
4990 },
4991 };
4992  
4993 }
4994 # { package Math::PlanePath::File;
4995 # # File points from a disk file
4996 # # FIXME: analyze points for min/max maybe
4997 # }
4998 # { package Math::PlanePath::QuintetCurve;
4999 # # inherit from QuintetCentres
5000 # }
5001 { package Math::PlanePath::QuintetCentres;
5002 use constant _NumSeq_Coord_filling_type => 'plane';
5003 }
5004 { package Math::PlanePath::QuintetReplicate;
5005 use constant _NumSeq_Coord_filling_type => 'plane';
5006 use constant _NumSeq_Coord_oeis_anum =>
5007 { 'numbering_type=fixed' =>
5008 {X => 'A316657',
5009 Y => 'A316658',
5010 RSquared => 'A316707',
5011 # OEIS-Catalogue: A316657 planepath=QuintetReplicate coordinate_type=X
5012 # OEIS-Catalogue: A316658 planepath=QuintetReplicate coordinate_type=Y
5013 # OEIS-Catalogue: A316707 planepath=QuintetReplicate coordinate_type=RSquared
5014 },
5015 };
5016 }
5017 { package Math::PlanePath::AR2W2Curve;
5018 use constant _NumSeq_Coord_filling_type => 'quadrant';
5019 }
5020 { package Math::PlanePath::BetaOmega;
5021 use constant _NumSeq_Coord_filling_type => 'half';
5022 }
5023 { package Math::PlanePath::KochelCurve;
5024 use constant _NumSeq_Coord_filling_type => 'quadrant';
5025 }
5026 # { package Math::PlanePath::DekkingCurve;
5027 # }
5028 { package Math::PlanePath::DekkingCentres;
5029 use constant _NumSeq_Coord_filling_type => 'quadrant';
5030 }
5031 { package Math::PlanePath::CincoCurve;
5032 use constant _NumSeq_Coord_filling_type => 'quadrant';
5033 }
5034 { package Math::PlanePath::SquareReplicate;
5035 use constant _NumSeq_Coord_filling_type => 'plane';
5036 }
5037 { package Math::PlanePath::CornerReplicate;
5038 use constant _NumSeq_Coord_filling_type => 'quadrant';
5039 use constant _NumSeq_Coord_oeis_anum =>
5040 { '' =>
5041 { Y => 'A059906', # alternate bits second (ZOrderCurve Y)
5042 BitXor => 'A059905', # alternate bits first (ZOrderCurve X)
5043 ExperimentalHammingDist => 'A139351', # count 1-bits at even bit positions
5044 # OEIS-Other: A059906 planepath=CornerReplicate coordinate_type=Y
5045 # OEIS-Other: A059905 planepath=CornerReplicate coordinate_type=BitXor
5046 # OEIS-Catalogue: A139351 planepath=CornerReplicate coordinate_type=ExperimentalHammingDist
5047 },
5048 };
5049 }
5050 { package Math::PlanePath::DigitGroups;
5051 use constant _NumSeq_Coord_filling_type => 'quadrant';
5052 # # Not quite, A073089 is OFFSET=1 not N=0, also A073089 has extra initial 0
5053 # use constant _NumSeq_Coord_oeis_anum =>
5054 # { 'radix=2' =>
5055 # { ExperimentalParity => 'A073089', # DragonMidpoint AbsdY Nodd ^ bit-above-low-0
5056 # # OEIS-Other: A073089 planepath=DigitGroups coordinate_type=ExperimentalParity
5057 # },
5058 # };
5059 }
5060 # { package Math::PlanePath::FibonacciWordFractal;
5061 # }
5062 { package Math::PlanePath::LTiling;
5063 use constant _NumSeq_Coord_filling_type => 'quadrant';
5064 # X=1,Y=1 doesn't occur, only X=1,Y=2 or X=2,Y=1
5065 {
5066 my %_NumSeq_Coord_Max_min = (upper => 1, # X=0,Y=0 not visited by these
5067 left => 1,
5068 ends => 1);
5069 sub _NumSeq_Coord_Max_min {
5070 my ($self) = @_;
5071 return $_NumSeq_Coord_Max_min{$self->{'L_fill'}} || 0;
5072 }
5073 }
5074  
5075 sub _NumSeq_Coord_TRSquared_min {
5076 my ($self) = @_;
5077 return ($self->{'L_fill'} eq 'upper' ? 3 # X=0,Y=1
5078 : ($self->{'L_fill'} eq 'left'
5079 || $self->{'L_fill'} eq 'ends') ? 1 # X=1,Y=0
5080 : 0); # 'middle','all' X=0,Y=0
5081 }
5082 {
5083 my %BitOr_min = (upper => 1, # X=0,Y=0 not visited by these
5084 left => 1,
5085 ends => 1);
5086 sub _NumSeq_Coord_BitOr_min {
5087 my ($self) = @_;
5088 return $BitOr_min{$self->{'L_fill'}} || 0;
5089 }
5090 }
5091 *_NumSeq_Coord_BitXor_min = \&_NumSeq_Coord_BitOr_min;
5092  
5093 {
5094 my %_NumSeq_Coord_ExperimentalHammingDist_min = (upper => 1, # X!=Y for these
5095 left => 1,
5096 ends => 1);
5097 sub _NumSeq_Coord_ExperimentalHammingDist_min {
5098 my ($self) = @_;
5099 return $_NumSeq_Coord_ExperimentalHammingDist_min{$self->{'L_fill'}} || 0;
5100 }
5101 *_NumSeq_Coord_MaxAbs_min = \&_NumSeq_Coord_ExperimentalHammingDist_min;
5102 }
5103  
5104 # Not quite, A112539 OFFSET=1 versus start N=0 here
5105 # use constant _NumSeq_Coord_oeis_anum =>
5106 # { 'L_fill=left' =>
5107 # { ExperimentalParity => 'A112539', # thue-morse count1bits mod 2
5108 # # OEIS-Catalogue: A112539 planepath=LTiling,L_fill=left coordinate_type=ExperimentalParity
5109 # },
5110 # };
5111 }
5112 { package Math::PlanePath::WythoffArray;
5113 use constant _NumSeq_Coord_filling_type => 'quadrant';
5114 # FIXME: if x_start=1 but y_start=0 then want corresponding mixture of
5115 # A-nums. DiffXY is whenever x_start==y_start.
5116 use constant _NumSeq_Coord_oeis_anum =>
5117 { 'x_start=0,y_start=0' =>
5118 { Y => 'A019586', # row containing N
5119 DiffXY => 'A191360', # diagonal containing N
5120 # OEIS-Catalogue: A019586 planepath=WythoffArray coordinate_type=Y
5121 # OEIS-Catalogue: A191360 planepath=WythoffArray coordinate_type=DiffXY
5122  
5123 # Not quite, A035614 has OFFSET start n=0 whereas path starts N=1
5124 # X => 'A035614',
5125 },
5126 'x_start=1,y_start=1' =>
5127 { X => 'A035612', # column number containing N, start column=1
5128 Y => 'A003603', # row number containing N, starting row=1
5129 DiffXY => 'A191360', # diagonal containing N
5130 # OEIS-Catalogue: A035612 planepath=WythoffArray,x_start=1,y_start=1
5131 # OEIS-Catalogue: A003603 planepath=WythoffArray,x_start=1,y_start=1 coordinate_type=Y
5132 # OEIS-Other: A191360 planepath=WythoffArray,x_start=1,y_start=1 coordinate_type=DiffXY
5133 },
5134 };
5135 }
5136 { package Math::PlanePath::PowerArray;
5137 use constant _NumSeq_Coord_filling_type => 'quadrant';
5138 use constant _NumSeq_Coord_oeis_anum =>
5139 { 'radix=2' =>
5140 { X => 'A007814', # base 2 count low 0s, starting n=1
5141 # main generator Math::NumSeq::DigitCountLow
5142 # OEIS-Other: A007814 planepath=PowerArray,radix=2
5143  
5144 # Not quite, A025480 starts OFFSET=0 for the k in n=(2k+1)*2^j-1
5145 # Y => 'A025480',
5146 # # OEIS-Almost: A025480 i_to_n_offset=-1 planepath=PowerArray,radix=2 coordinate_type=Y
5147 },
5148 'radix=3' =>
5149 { X => 'A007949', # k of greatest 3^k dividing n
5150 # OEIS-Other: A007949 planepath=PowerArray,radix=3
5151 # main generator Math::NumSeq::DigitCountLow
5152 },
5153 'radix=5' =>
5154 { X => 'A112765',
5155 # OEIS-Other: A112765 planepath=PowerArray,radix=5
5156 },
5157 'radix=6' =>
5158 { X => 'A122841',
5159 # OEIS-Other: A122841 planepath=PowerArray,radix=6
5160 },
5161 'radix=10' =>
5162 { X => 'A122840',
5163 # OEIS-Other: A112765 planepath=PowerArray,radix=5
5164 },
5165 };
5166 }
5167  
5168 { package Math::PlanePath::ToothpickTree;
5169 sub _NumSeq_Coord_Max_min {
5170 my ($self) = @_;
5171 if ($self->{'parts'} eq '3') { return 0; }
5172 return $self->SUPER::_NumSeq_Coord_Max_min;
5173 }
5174  
5175 {
5176 my %_NumSeq_Coord_IntXY_min = (1 => 0,
5177 octant => 0, # X>=Y-1 so X/Y >= 1-1/Y
5178 wedge => -1, # X>=-Y,Y>=0 so X/Y<=-1
5179 );
5180 sub _NumSeq_Coord_IntXY_min {
5181 my ($self) = @_;
5182 return $_NumSeq_Coord_IntXY_min{$self->{'parts'}};
5183 }
5184 }
5185 {
5186 my %_NumSeq_Coord_IntXY_max = (octant_up => 0,
5187 # except wedge 0/0 = infinity
5188 # wedge => 1, # Y>=X so X/Y<=1
5189 );
5190 sub _NumSeq_Coord_IntXY_max {
5191 my ($self) = @_;
5192 return $_NumSeq_Coord_IntXY_max{$self->{'parts'}};
5193 }
5194 }
5195  
5196 sub _NumSeq_Coord_BitAnd_min {
5197 my ($self) = @_;
5198 return ($self->{'parts'} eq '4'
5199 ? undef # X<0,Y<0
5200 : 0); # otherwise X>0 or Y>0 so BitAnd>=0
5201 }
5202  
5203 {
5204 my %_NumSeq_Coord_TRSquared_min = (2 => 3, # X=0,Y=1
5205 1 => 4, # X=1,Y=1
5206 octant => 4, # X=1,Y=1
5207 octant_up => 13, # X=1,Y=2
5208 );
5209 sub _NumSeq_Coord_TRSquared_min {
5210 my ($self) = @_;
5211 return ($_NumSeq_Coord_TRSquared_min{$self->{'parts'}} || 0);
5212 }
5213 }
5214 {
5215 # usually 7, but in these 8
5216 my %_NumSeq_Coord_ExperimentalLeafDistance_max = (octant => 8,
5217 octant_up => 8,
5218 wedge => 8,
5219 );
5220 sub _NumSeq_Coord_ExperimentalLeafDistance_max {
5221 my ($self) = @_;
5222 return ($_NumSeq_Coord_ExperimentalLeafDistance_max{$self->{'parts'}} || 7);
5223 }
5224 }
5225 }
5226 { package Math::PlanePath::ToothpickReplicate;
5227 *_NumSeq_Coord_BitAnd_min
5228 = \&Math::PlanePath::ToothpickTree::_NumSeq_Coord_BitAnd_min;
5229 *_NumSeq_Coord_TRSquared_min
5230 = \&Math::PlanePath::ToothpickTree::_NumSeq_Coord_TRSquared_min;
5231 }
5232 { package Math::PlanePath::ToothpickUpist;
5233 use constant _NumSeq_Coord_Y_non_decreasing => 1; # rows upwards
5234 use constant _NumSeq_Coord_Max_non_decreasing => 1; # X<=Y so max=Y
5235 use constant _NumSeq_Coord_MaxAbs_non_decreasing => 1; # -Y<=X<=Y so MaxAbs=Y
5236  
5237 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 9;
5238 }
5239  
5240 { package Math::PlanePath::LCornerTree;
5241 sub _NumSeq_Coord_Max_min {
5242 my ($self) = @_;
5243 return ($self->{'parts'} eq '4' ? undef : 0);
5244 }
5245 {
5246 my %_NumSeq_Coord_IntXY_min
5247 = (1 => 0,
5248 octant => 1, # X>=Y so X/Y>=1, and 0/0
5249 'octant+1' => 0, # X>=Y-1 so int(X/Y)>=0
5250 octant_up => 0, # X>=0 so X/Y>=1, and 0/0
5251 'octant_up+1' => 0, # X>=0 so X/Y>=1, and 0/0
5252 wedge => -2, # X>=-Y-1 so X/Y>=-2
5253 'wedge+1' => -3, # X>=-Y-2 so X/Y>=-3
5254 );
5255 sub _NumSeq_Coord_IntXY_min {
5256 my ($self) = @_;
5257 return $_NumSeq_Coord_IntXY_min{$self->{'parts'}};
5258 }
5259 }
5260  
5261 use constant _NumSeq_Coord_ExperimentalLeafDistance_max => 2;
5262 }
5263 { package Math::PlanePath::LCornerReplicate;
5264 use constant _NumSeq_Coord_filling_type => 'quadrant';
5265 }
5266 # { package Math::PlanePath::PeninsulaBridge;
5267 # }
5268  
5269 { package Math::PlanePath::OneOfEight;
5270 sub _NumSeq_Coord_Max_min {
5271 my ($self) = @_;
5272 return ($self->{'parts'} eq '4' ? undef : 0);
5273 }
5274  
5275 sub _NumSeq_Coord_IntXY_min {
5276 my ($self) = @_;
5277 if ($self->{'parts'} eq 'octant') { return 1; }
5278 return $self->SUPER::_NumSeq_Coord_IntXY_min;
5279 }
5280  
5281 {
5282 # usually 2, but in 3side only 1
5283 my %_NumSeq_Coord_ExperimentalLeafDistance_max = ('3side' => 1,
5284 );
5285 sub _NumSeq_Coord_ExperimentalLeafDistance_max {
5286 my ($self) = @_;
5287 return $_NumSeq_Coord_ExperimentalLeafDistance_max{$self->{'parts'}} || 2;
5288 }
5289 }
5290 }
5291  
5292 { package Math::PlanePath::HTree;
5293 use constant _NumSeq_Coord_Depth_non_decreasing => 0;
5294 use constant _NumSeq_Coord_NumSiblings_non_decreasing => 1;
5295 }
5296  
5297 #------------------------------------------------------------------------------
5298 1;
5299 __END__