komm.WalshHadamardSequence
Walsh–Hadamard sequence. Consider the following recursive matrix construction: $$ H_1 = \begin{bmatrix} +1 \end{bmatrix}, \qquad H_{2^n} = \begin{bmatrix} H_{2^{n-1}} & H_{2^{n-1}} \\ H_{2^{n-1}} & -H_{2^{n-1}} \end{bmatrix}, $$ for $n = 1, 2, \ldots$. For example, for $n = 3$, $$ H_8 = \begin{bmatrix} +1 & +1 & +1 & +1 & +1 & +1 & +1 & +1 \\ +1 & -1 & +1 & -1 & +1 & -1 & +1 & -1 \\ +1 & +1 & -1 & -1 & +1 & +1 & -1 & -1 \\ +1 & -1 & -1 & +1 & +1 & -1 & -1 & +1 \\ +1 & +1 & +1 & +1 & -1 & -1 & -1 & -1 \\ +1 & -1 & +1 & -1 & -1 & +1 & -1 & +1 \\ +1 & +1 & -1 & -1 & -1 & -1 & +1 & +1 \\ +1 & -1 & -1 & +1 & -1 & +1 & +1 & -1 \\ \end{bmatrix} $$ The above matrix is said to be in natural ordering. If the rows of the matrix are rearranged by first applying the bit-reversal permutation and then the Gray-code permutation, the following matrix is obtained: $$ H_8^{\mathrm{s}} = \begin{bmatrix} +1 & +1 & +1 & +1 & +1 & +1 & +1 & +1 \\ +1 & +1 & +1 & +1 & -1 & -1 & -1 & -1 \\ +1 & +1 & -1 & -1 & -1 & -1 & +1 & +1 \\ +1 & +1 & -1 & -1 & +1 & +1 & -1 & -1 \\ +1 & -1 & -1 & +1 & +1 & -1 & -1 & +1 \\ +1 & -1 & -1 & +1 & -1 & +1 & +1 & -1 \\ +1 & -1 & +1 & -1 & -1 & +1 & -1 & +1 \\ +1 & -1 & +1 & -1 & +1 & -1 & +1 & -1 \\ \end{bmatrix} $$ The above matrix is said to be in sequency ordering. It has the property that row $i$ has exactly $i$ sign changes.
The Walsh–Hadamard sequence of length $L$ and index $i \in [0 : L)$ is a binary sequence whose polar format is the $i$-th row of $H_L$, if assuming natural ordering, or $H_L^{\mathrm{s}}$, if assuming sequency ordering. Fore more details, see Wikipedia: Hadamard matrix and Wikipedia: Walsh matrix.
Parameters:
-
length
(int
) –Length $L$ of the Walsh–Hadamard sequence. Must be a power of two.
-
ordering
(Literal['natural', 'sequency', 'dyadic']
) –Ordering to be assumed. Should be one of
'natural'
,'sequency'
, or'dyadic'
. The default value is'natural'
. -
index
(int
) –Index of the Walsh–Hadamard sequence, with respect to the ordering assumed. Must be in the set $[0 : L)$. The default value is
0
.
Examples:
>>> walsh_hadamard = komm.WalshHadamardSequence(length=8, ordering='natural', index=5)
>>> walsh_hadamard.polar_sequence
array([ 1, -1, 1, -1, -1, 1, -1, 1])
>>> walsh_hadamard = komm.WalshHadamardSequence(length=8, ordering='sequency', index=5)
>>> walsh_hadamard.polar_sequence
array([ 1, -1, -1, 1, -1, 1, 1, -1])
>>> walsh_hadamard = komm.WalshHadamardSequence(length=8, ordering='dyadic', index=5)
Traceback (most recent call last):
...
NotImplementedError