Fast Walsh–Hadamard transform
In computational mathematics, the Hadamard ordered fast Walsh–Hadamard transform (FWHTh) is an efficient algorithm to compute the Walsh–Hadamard transform (WHT). A naive implementation of the WHT of order {\displaystyle n=2^{m}} would have a computational complexity of O({\displaystyle n^{2}}). The FWHTh requires only {\displaystyle n\log n} additions or subtractions.
The FWHTh is a divide-and-conquer algorithm that recursively breaks down a WHT of size {\displaystyle n} into two smaller WHTs of size {\displaystyle n/2}. [1] This implementation follows the recursive definition of the {\displaystyle 2^{m}\times 2^{m}} Hadamard matrix {\displaystyle H_{m}}:
- {\displaystyle H_{m}={\frac {1}{\sqrt {2}}}{\begin{pmatrix}H_{m-1}&H_{m-1}\\H_{m-1}&-H_{m-1}\end{pmatrix}}.}
The {\displaystyle 1/{\sqrt {2}}} normalization factors for each stage may be grouped together or even omitted.
The sequency-ordered, also known as Walsh-ordered, fast Walsh–Hadamard transform, FWHTw, is obtained by computing the FWHTh as above, and then rearranging the outputs.
A simple fast nonrecursive implementation of the Walsh–Hadamard transform follows from decomposition of the Hadamard transform matrix as {\displaystyle H_{m}=A^{m}}, where A is m-th root of {\displaystyle H_{m}}. [2]
Python example code
[edit ]importmath deffwht(a) -> None: """In-place Fast Walsh–Hadamard Transform of array a.""" assert math.log2(len(a)).is_integer(), "length of a is a power of 2" h = 1 while h < len(a): # perform FWHT for i in range(0, len(a), h * 2): for j in range(i, i + h): x = a[j] y = a[j + h] a[j] = x + y a[j + h] = x - y # normalize and increment a /= math.sqrt(2) h *= 2
See also
[edit ]References
[edit ]External links
[edit ]- Charles Constantine Gumas, A century old, the fast Hadamard transform proves useful in digital communications
This signal processing-related article is a stub. You can help Wikipedia by expanding it.
This algorithms or data structures-related article is a stub. You can help Wikipedia by expanding it.