# NAME

Math::NumSeq::GolayRudinShapiro -- parity of adjacent 11 bit pairs

# SYNOPSIS

use Math::NumSeq::GolayRudinShapiro;
my \$seq = Math::NumSeq::GolayRudinShapiro->new;
my (\$i, \$value) = \$seq->next;

# DESCRIPTION

This is the Golay/Rudin/Shapiro sequence of +1 or -1 according as 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 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

Parameter 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, ...

# FUNCTIONS

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

## Random Access

\$value = \$seq->ith(\$i)

Return the \$i'th value from the sequence, being +1 or -1 (or per values_type) according to the number of adjacent 11 bit pairs in \$i.

\$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.

Math::PlanePath::AlternatePaper