Math::N...nShapiro(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

🌸 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 +1 or -1 (or whatever you set in values_type) depending on the number of adjacent 11 bit 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's 0 or 1 instead. no surprises here bestie.

πŸ‘€ SEE ALSO πŸ‘€

  • Math::NumSeq
  • Math::NumSeq::GolayRudinShapiroCumulative
  • Math::NumSeq::BaumSweet
  • Math::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