komm.WalshHadamardSequence
Walsh–Hadamard sequence. 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$, $H_L^{\mathrm{d}}$, or $H_L^{\mathrm{s}}$, for natural, dyadic, or sequency ordering, respectively. These are $L \times L$ matrices with the same rows, in different orders.
In natural ordering (also known as Hadamard ordering), the matrix $H_L$ is defined recursively by $$ 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$. In dyadic ordering (also known as Paley ordering), the matrix $H_L^{\mathrm{d}}$ is obtained by applying the bit-reversal permutation to the rows of $H_L$. In sequency ordering (also known as Walsh ordering), the matrix $H_L^{\mathrm{s}}$ is obtained by applying the Gray-code permutation to the rows of $H_L^{\mathrm{d}}$; its row $i$ has exactly $i$ sign changes. For example, for $L = 8$, $$ 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} $$ $$ H_8^{\mathrm{d}} = \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} $$ $$ 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} $$
For 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(8, ordering='natural', index=6)
>>> walsh_hadamard.polar_sequence
array([ 1, 1, -1, -1, -1, -1, 1, 1])
>>> walsh_hadamard = komm.WalshHadamardSequence(8, ordering='sequency', index=6)
>>> walsh_hadamard.polar_sequence
array([ 1, -1, 1, -1, -1, 1, -1, 1])
>>> walsh_hadamard = komm.WalshHadamardSequence(8, ordering='dyadic', index=6)
>>> walsh_hadamard.polar_sequence
array([ 1, -1, -1, 1, 1, -1, -1, 1])