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 rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
to compute the
Walsh–Hadamard transform (WHT). A naive implementation of the WHT of order
would have a
computational complexity of
O(). The FWHT
''h'' requires only
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 dire ...
that
recursively
Recursion (adjective: ''recursive'') occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematics ...
breaks down a WHT of size
into two smaller WHTs of size
. This implementation follows the recursive definition of the
Hadamard matrix
In mathematics, a 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 geometric terms, this means that each pair of rows ...
:
:
The
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
, where ''A'' is ''m''-th root of
.
[Yarlagadda and Hershey, "Hadamard Matrix Analysis and Synthesis", 1997 (Springer)]
Python example code
def fwht(a) -> None:
In-place Fast Walsh–Hadamard Transform of array a.
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 /= 2
h *= 2
See also
*
Fast Fourier transform
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