Math::NumSeq::GolayRudinShapiro -- parity of adjacent 11 bit pairs
use Math::NumSeq::GolayRudinShapiro; my $seq = Math::NumSeq::GolayRudinShapiro->new; my ($i, $value) = $seq->next;
This is the Golay/Rudin/Shapiro sequence of +1 or -1 according to there being an even or odd number of adjacent 11 bit pairs in i.
GRS(i) = (-1) ^ (count 11 bit pairs) starting from i=0 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, ...
The first -1 is at i=3 which is binary 11 with a single 11 bit pair, then i=6 binary 110 likewise -1. Later for example i=14 is binary 1110 which has two adjacent 11 pairs (overlapping pairs count), so value=1.
The value is also the parity of the number of even-length runs of 1-bits in i. An even length run has an odd number of 11 pairs, so each of them is a -1 in the product. An odd-length run of 1-bits is an even number of 11 pairs and so is +1 and has no effect on the result.
Such a parity of even-length 1-bit runs and hence the GRS sequence arises as the "dX,dY" change for each segment of the alternate paper folding curve. See "dX,dY" in Math::PlanePath::AlternatePaper.
values_type => '0,1' gives values 0 and 1, being the count of adjacent 11s taken modulo 2, so 0 if even, 1 if odd.
values_type => '0,1' 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, ...
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$seq = Math::NumSeq::GolayRudinShapiro->new ()
$seq = Math::NumSeq::GolayRudinShapiro->new (values_type => $str)
Create and return a new sequence object. The
values_type parameter (a string) can be
"1,-1" 1=even, -1=odd "0,1" 0=even, 1=odd
$value = $seq->ith($i)
$i'th value from the sequence, being +1 or -1 (or per
values_type) according to the number of adjacent 11 bit pairs in
$bool = $seq->pred($value)
Return true if
$value occurs in the sequence, which simply means
$value == 1 or
$value == -1. Or if
values_type=>'0,1' then 0 or 1.
Copyright 2010, 2011, 2012, 2013 Kevin Ryde
Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.