Skip to content

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.

References
  1. https://en.wikipedia.org/wiki/Hadamard_matrix
  2. https://en.wikipedia.org/wiki/Walsh_matrix

__init__

Constructor for the class.

Parameters:

  • length (int)

    Length $L$ of the Walsh–Hadamard sequence. Must be a power of two.

  • ordering (Optional[str])

    Ordering to be assumed. Should be one of 'natural', 'sequency', or 'dyadic'. The default value is 'natural'.

  • index (Optional[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=64, ordering='sequency', index=60)
>>> walsh_hadamard.polar_sequence[:16]
array([ 1, -1,  1, -1,  1, -1,  1, -1,  1, -1,  1, -1,  1, -1,  1, -1])
>>> walsh_hadamard = komm.WalshHadamardSequence(length=128, ordering='natural', index=60)
>>> walsh_hadamard.polar_sequence[:16]
array([ 1,  1,  1,  1, -1, -1, -1, -1, -1, -1, -1, -1,  1,  1,  1,  1])

index property

The index of the Walsh–Hadamard sequence, with respect to the ordering assumed.

ordering property

The ordering assumed.