Hadamard transform

From Wikipedia, the free encyclopedia
  (Redirected from Walsh transform)
Jump to: navigation, search
Not to be confused with Walsh matrix.
The product of a Boolean function and a Walsh matrix is its Walsh spectrum:[1]
(1,0,1,0,0,1,1,0) * H(8) = (4,2,0,−2,0,2,0,2)
Fast Walsh–Hadamard transform
This is a faster way to calculate the Walsh spectrum of (1,0,1,0,0,1,1,0).
The original function can be expressed by means of its Walsh spectrum as an arithmetical polynomial.

The Hadamard transform (also known as the Walsh–Hadamard transform, Hadamard–Rademacher–Walsh transform, Walsh transform, or Walsh–Fourier transform) is an example of a generalized class of Fourier transforms. It performs an orthogonal, symmetric, involutional, linear operation on 2^m real numbers (or complex numbers, although the Hadamard matrices themselves are purely real).

The Hadamard transform can be regarded as being built out of size-2 discrete Fourier transforms (DFTs), and is in fact equivalent to a multidimensional DFT of size 2\times2\times\cdots\times2\times2.[2] It decomposes an arbitrary input vector into a superposition of Walsh functions.

The transform is named for the French mathematician Jacques Hadamard, the German-American mathematician Hans Rademacher, and the American mathematician Joseph L. Walsh.

Definition[edit]

The Hadamard transform Hm is a 2m × 2m matrix, the Hadamard matrix (scaled by a normalization factor), that transforms 2m real numbers xn into 2m real numbers Xk. The Hadamard transform can be defined in two ways: recursively, or by using the binary (base-2) representation of the indices n and k.

Recursively, we define the 1 × 1 Hadamard transform H0 by the identity H0 = 1, and then define Hm for m > 0 by:

H_m = \frac{1}{\sqrt2} \begin{pmatrix} H_{m-1} & H_{m-1} \\ H_{m-1} & -H_{m-1} \end{pmatrix}

where the 1/√2 is a normalization that is sometimes omitted. Thus, other than this normalization factor, the Hadamard matrices are made up entirely of 1 and −1.

Equivalently, we can define the Hadamard matrix by its (kn)-th entry by writing

k = \sum^{m-1}_{i=0} {k_i 2^i} = k_{m-1} 2^{m-1} + k_{m-2} 2^{m-2} + \cdots + k_1 2 + k_0

and

n = \sum^{m-1}_{i=0} {n_i 2^i} = n_{m-1} 2^{m-1} + n_{m-2} 2^{m-2} + \cdots + n_1 2 + n_0

where the kj and nj are the binary digits (0 or 1) of k and n, respectively. Note that for the element in the top left corner, we define: k = n = 0. In this case, we have:

\left( H_m \right)_{k,n} = \frac{1}{2^\frac{m}{2}} (-1)^{\sum_j k_j n_j}

This is exactly the multidimensional \scriptstyle 2 \,\times\, 2 \,\times\, \cdots \,\times\, 2 \,\times\, 2 DFT, normalized to be unitary, if the inputs and outputs are regarded as multidimensional arrays indexed by the nj and kj, respectively.

Some examples of the Hadamard matrices follow.

\begin{align}
  H_0 = &+1\\
  H_1 = \frac{1}{\sqrt2}
   &\begin{pmatrix}\begin{array}{rr}
    1 & 1\\
    1 & -1
   \end{array}\end{pmatrix}
\end{align}

(This H1 is precisely the size-2 DFT. It can also be regarded as the Fourier transform on the two-element additive group of Z/(2).)

\begin{align}
  H_2 = \frac{1}{2}
   &\begin{pmatrix}\begin{array}{rrrr}
    1 &  1 &  1 &  1\\
    1 & -1 &  1 & -1\\
    1 &  1 & -1 & -1\\
    1 & -1 & -1 &  1
   \end{array}\end{pmatrix}\\
  H_3 = \frac{1}{2^{\frac{3}{2}}}
   &\begin{pmatrix}\begin{array}{rrrrrrrr}
    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{array}\end{pmatrix}\\
  (H_n)_{i,j} = \frac{1}{2^{\frac{n}{2}}} &(-1)^{i \cdot j}
\end{align}

where  i \cdot j is the bitwise dot product of the binary representations of the numbers i and j. For example, if \scriptstyle n \geq 2 , then \scriptstyle ({H_n})_{3,2} \;=\; (-1)^{3 \cdot 2} \;=\; (-1)^{(1,1) \cdot (1,0)} \;=\; (-1)^{1+0} \;=\; (-1)^1 \;=\; -1, agreeing with the above (ignoring the overall constant). Note that the first row, first column of the matrix is denoted by \scriptstyle ({H_n})_{0,0} .

The rows of the Hadamard matrices are the Walsh functions.

Quantum computing applications[edit]

In quantum information processing the Hadamard transformation, more often called Hadamard gate in this context (cf. quantum gate), is a one-qubit rotation, mapping the qubit-basis states |0 \rangle and |1 \rangle to two superposition states with equal weight of the computational basis states |0 \rangle and |1 \rangle . Usually the phases are chosen so that we have

H=\frac{|0\rangle+|1\rangle}{\sqrt{2}}\langle0|+\frac{|0\rangle-|1\rangle}{\sqrt{2}}\langle1|

in Dirac notation. This corresponds to the transformation matrix

H_1=\frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}

in the |0 \rangle , |1 \rangle basis.

Many quantum algorithms use the Hadamard transform as an initial step, since it maps n qubits initialized with |0 \rangle to a superposition of all 2n orthogonal states in the  |0 \rangle , |1 \rangle basis with equal weight.

Hadamard gate operations[edit]

H(|1\rangle) = \frac{1}{\sqrt{2}}|0\rangle-\frac{1}{\sqrt{2}}|1\rangle
H(|0\rangle) = \frac{1}{\sqrt{2}}|0\rangle+\frac{1}{\sqrt{2}}|1\rangle
H\left( \frac{1}{\sqrt{2}}|0\rangle-\frac{1}{\sqrt{2}}|1\rangle \right)= \frac{1}{2}( |0\rangle+|1\rangle) - \frac{1}{2}( |0\rangle - |1\rangle) = |1\rangle
H\left( \frac{1}{\sqrt{2}}|0\rangle+\frac{1}{\sqrt{2}}|1\rangle \right)= \frac{1}{2}( |0\rangle+|1\rangle) + \frac{1}{2}( |0\rangle - |1\rangle) = |0\rangle

One application of the Hadamard gate to either a 0 or 1 qubit will produce a quantum state that, if observed, will be a 0 or 1 with equal probability (as seen in the first two operations). This is exactly like flipping a fair coin in the standard probabilistic model of computation. However, if the Hadamard gate is applied twice in succession (as is effectively being done in the last two operations), then the final state is always the same as the initial state. This would be like taking a fair coin that is showing heads, flipping it twice, and it always landing on heads after the second flip.

Computational complexity[edit]

The Hadamard transform can be computed in n log n operations (n = 2m), using the fast Hadamard transform algorithm.

Other applications[edit]

The Hadamard transform is also used in data encryption, as well as many signal processing and data compression algorithms, such as JPEG XR and MPEG-4 AVC. In video compression applications, it is usually used in the form of the sum of absolute transformed differences. It is also a crucial part of Grover's algorithm and Shor's algorithm in quantum computing. The Hadamard transform is also applied in scientific methods such as NMR, mass spectroscopy and crystallography

See also[edit]

External links[edit]

References[edit]

  1. ^ Compare Figure 1 in Townsend, W. J.; Thornton, M. A. "Walsh Spectrum Computations Using Cayley Graphs". CiteSeerX: 10.1.1.74.8029. 
  2. ^ Kunz, H.O. (1979). "On the Equivalence Between One-Dimensional Discrete Walsh-Hadamard and Multidimensional Discrete Fourier Transforms". IEEE Transactions on Computers 28 (3): 267–8. doi:10.1109/TC.1979.1675334.