Math::N...nShapiro(3)
πΈ Math::NumSeq::GolayRudinShapiro π
okay bestie, welcome to the Golay/Rudin/Shapiro sequence page, straight out of the User Contributed Perl Documentation section of the manual. it's a Math::NumSeq class and it's lowkey obsessed with adjacent 11 bit pairs. let's get into it π
β¨ NAME β¨
Math::NumSeq::GolayRudinShapiro β it's giving parity of adjacent 11 bit pairs, no cap π
π¦ SYNOPSIS π¦
use Math::NumSeq::GolayRudinShapiro;
my $seq = Math::NumSeq::GolayRudinShapiro->new;
my ($i, $value) = $seq->next;
that's it. that's the whole vibe. create the object, pull values, slay π
π DESCRIPTION π
so here's the tea: this is the Golay/Rudin/Shapiro sequence of +1 or -1, depending on whether there's an even or odd number of adjacent 11 bit pairs in i. like, the count of 11 pairs decides everything fr fr.
GRS(i) = (-1) ^ (count 11 bit pairs)
and it starts from i=0, looking like this:
1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, ...
the very first -1 shows up at i=3, because that's binary 11 β one single 11 bit pair, iconic. then i=6 is binary 110, which also has one pair, so -1 again. and later, for example, i=14 is binary 1110 which has two adjacent 11 pairs β and yes, overlapping pairs totally count β so the value is 1 β¨
another way to think about it: 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 every one of those contributes a -1 to the product. meanwhile an odd-length run of 1-bits has an even number of 11 pairs, so it's +1 and it literally has no effect on the result π
and this parity of even-length 1-bit runs β aka the GRS sequence β pops up as the "dX,dY" change for each segment of the alternate paper folding curve. go look at "dX,dY" in Math::PlanePath::AlternatePaper if you wanna see it in the wild π
π« Values Type π«
passing the parameter values_type => '0,1' gives you values 0 and 1 instead β that's just the count of adjacent 11s taken modulo 2. so 0 if it's even, 1 if it's odd. periodt.
values_type => '0,1'
0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, ...
π FUNCTIONS π
check "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all the sequence classes, because that's the shared bestie energy.
"$seq = Math::NumSeq::GolayRudinShapiro->new ()""$seq = Math::NumSeq::GolayRudinShapiro->new (values_type => $str)"
create and return a brand-new sequence object, fresh out the box π
the values_type parameter (it's a string, btw) can be either of these:
"1,-1" 1=even, -1=odd
"0,1" 0=even, 1=odd
π₯ Random Access π₯
"$value = $seq->ith($i)"β return the $i'th value from the sequence, which is+1or-1(or whatever you set invalues_type) depending on the number of adjacent11bit pairs in $i. cute and direct."$bool = $seq->pred($value)"β returns true if $value actually occurs in the sequence, which literally just means"$value == 1"or"$value == -1". or, if you went"values_type=>'0,1'", then it's0or1instead. no surprises here bestie.
π SEE ALSO π
Math::NumSeqMath::NumSeq::GolayRudinShapiroCumulativeMath::NumSeq::BaumSweetMath::NumSeq::Fibbinary
also:
Math::PlanePath::AlternatePaper
π HOME PAGE π
<http://user42.tuxfamily.org/math-numseq/index.html>
π LICENSE π
Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2017, 2019, 2020 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/>.
k bestie that's the whole page, mwah π
this has been Math::N...nShapiro(3), from the perl v5.42.0 manual set, dated 2025-07-25. ily, go count some 11 pairs β¨π
π¦ where this page comes from
- fedora 43: perl-Math-NumSeq 75-11.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms