returns an n×n Hadamard matrix.
HadamardMatrix
returns an n×n Hadamard matrix.
Details and Options
- Each entry Hrs of the Hadamard matrix is by default defined as
, where
,
is the 
bit in the binary representation of the integer
, and
. - The size
must be a power of two. - Rows or columns of the HadamardMatrix are basis sequences of the DiscreteHadamardTransform.
- The Hadamard matrix is symmetric and orthogonal and is thus its own inverse. »
- The following options are supported:
-
Method Automatic specify the sequency ordering method WorkingPrecision ∞ precision at which to create entries - The setting of the Method option specifies the sequency ordering (number of zero crossings in the Hadamard basis sequences). Possible settings include:
-
"BitComplement" 
"GrayCode" Gray code reordering of "BitComplement" "Sequency" sequency increases with row and column index (default) - The bit complement ordering is also known as the Sylvester ordering.
- The Gray code ordering is also known as the dyadic ordering or Paley ordering.
- The sequency ordering is also known as the Walsh ordering.
- HadamardMatrix[…,TargetStructure…] specifies the structure of the returned matrix. Possible settings for TargetStructure include:
-
Automatic automatically choose the representation returned "Dense" represent the matrix as a dense matrix "Hermitian" represent the matrix as a Hermitian matrix "Orthogonal" represent the matrix as an orthogonal matrix "Symmetric" represent the matrix as a symmetric matrix "Unitary" represent the matrix as a unitary matrix - HadamardMatrix[…,TargetStructureAutomatic] is equivalent to HadamardMatrix[…,TargetStructure"Dense"].
Examples
open all close allScope (1)
Options (3)
Method (1)
Detect sequency values of rows of a Hadamard matrix:
Total[CrossingDetect[#, CornerNeighbors -> None]]& /@ HadamardMatrix[8, Method -> "BitComplement"]Total[CrossingDetect[#, CornerNeighbors -> None]]& /@ HadamardMatrix[8, Method -> "GrayCode"]Total[CrossingDetect[#, CornerNeighbors -> None]]& /@ HadamardMatrix[8, Method -> "Sequency"]TargetStructure (1)
Return the Hadamard matrix as a dense matrix:
HadamardMatrix[4, TargetStructure -> "Dense"]Return the Hadamard matrix as a symmetric matrix:
HadamardMatrix[4, TargetStructure -> "Symmetric"]Return the Hadamard matrix as an orthogonal matrix:
HadamardMatrix[4, TargetStructure -> "Orthogonal"]Properties & Relations (4)
The discrete Hadamard transform of a vector is equivalent to multiplying the vector by the Hadamard matrix:
data = RandomReal[1, 4];
data . HadamardMatrix[4] == DiscreteHadamardTransform[data]Sylvester's construction of a Hadamard matrix of order 4:
n = 2;
H2 = (1/Sqrt[2])(| | |
| - | -- |
| 1 | 1 |
| 1 | -1 |);
Nest[KroneckerProduct[H2, #]&, (1), n]This corresponds to the bit complement sequency ordering:
% === HadamardMatrix[2^n, Method -> "BitComplement"]The Hadamard matrix is symmetric and orthogonal:
hm = HadamardMatrix[4];
{SymmetricMatrixQ[hm], OrthogonalMatrixQ[hm]}Because of these properties, the Hadamard matrix is its own inverse:
hm.hm == IdentityMatrix[4]Define the n×n "bit reversal" permutation matrix for n a power of 2:
Subscript[𝓅, n_] := PermutationMatrix[IntegerReverse[Range[0, n - 1], 2, BitLength[n] - 1] + 1]Define the n×n Gray code permutation matrix for n a power of 2:
Subscript[ℊ, n_] := PermutationMatrix[BitXor[Range[0, n - 1], Quotient[Range[0, n - 1], 2]] + 1]Generate Hadamard matrices with different sequency orderings:
hs = HadamardMatrix[16, Method -> "Sequency"];
hd = HadamardMatrix[16, Method -> "GrayCode"];
hb = HadamardMatrix[16, Method -> "BitComplement"];The Hadamard matrix with Gray code ordering is equivalent to applying the Gray code permutation to the Hadamard matrix with bit-complement sequency ordering:
Subscript[𝓅, 16].hb == hdThe Hadamard matrix with sequency ordering is equivalent to applying the bit-reversal permutation to the Hadamard matrix with Gray code ordering:
Subscript[ℊ, 16].hd == hsThe Hadamard matrix with sequency ordering is equivalent to successively applying the bit-reversal permutation and Gray code permutation to the Hadamard matrix with bit-complement sequency ordering:
Subscript[ℊ, 16].Subscript[𝓅, 16].hb == hsRelated Guides
History
Introduced in 2012 (9.0) | Updated in 2014 (10.0) ▪ 2023 (13.3) ▪ 2024 (14.0)
Text
Wolfram Research (2012), HadamardMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/HadamardMatrix.html (updated 2024).
CMS
Wolfram Language. 2012. "HadamardMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/HadamardMatrix.html.
APA
Wolfram Language. (2012). HadamardMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HadamardMatrix.html
BibTeX
@misc{reference.wolfram_2026_hadamardmatrix, author="Wolfram Research", title="{HadamardMatrix}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/HadamardMatrix.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_hadamardmatrix, organization={Wolfram Research}, title={HadamardMatrix}, year={2024}, url={https://reference.wolfram.com/language/ref/HadamardMatrix.html}, note=[Accessed: 13-June-2026]}