Fast Walsh–Hadamard Transform
   HOME

TheInfoList



OR:

In computational mathematics, the Hadamard ordered fast Walsh–Hadamard transform (FWHT''h'') is an efficient
algorithm In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
to compute the Walsh–Hadamard transform (WHT). A naive implementation of the WHT of order n = 2^m would have a
computational complexity In computer science, the computational complexity or simply complexity of an algorithm is the amount of resources required to run it. Particular focus is given to computation time (generally measured by the number of needed elementary operations ...
of O(n^2). The FWHT''h'' requires only n \log n additions or subtractions. The FWHT''h'' is a
divide-and-conquer algorithm In computer science, divide and conquer is an algorithm design paradigm. A divide-and-conquer algorithm recursively breaks down a problem into two or more sub-problems of the same or related type, until these become simple enough to be solved dir ...
that
recursively Recursion occurs when the definition of a concept or process depends on a simpler or previous version of itself. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in m ...
breaks down a WHT of size n into two smaller WHTs of size n/2. This implementation follows the recursive definition of the 2^m \times 2^m
Hadamard matrix In mathematics, an Hadamard matrix, named after the French mathematician Jacques Hadamard, is a square matrix whose entries are either +1 or −1 and whose rows are mutually orthogonal. In geometry, geometric terms, this means that each pair of r ...
H_m: :H_m = \frac \begin H_ & H_ \\ H_ & -H_ \end. The 1/\sqrt2 normalization factors for each stage may be grouped together or even omitted. The sequency-ordered, also known as Walsh-ordered, fast Walsh–Hadamard transform, FWHT''w'', is obtained by computing the FWHT''h'' 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 H_m = A^m, where ''A'' is ''m''-th root of H_m. Yarlagadda and Hershey, "Hadamard Matrix Analysis and Synthesis", 1997 (Springer)


Python example code

import math def fwht(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 y = a + h a = x + y a + h= x - y # normalize and increment a /= math.sqrt(2) h *= 2


See also

*
Fast Fourier transform A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT). A Fourier transform converts a signal from its original domain (often time or space) to a representation in ...


References


External links

* Charles Constantine Gumas
A century old, the fast Hadamard transform proves useful in digital communications
Digital signal processing Articles with example Python (programming language) code {{algorithm-stub