hadamard.RdGenerate Hadamard matrix of a certain size.
hadamard(n)An n-by-n Hadamard matrix with n>2 exists only if
rem(n,4)=0. This function handles only the cases where n,
n/12, or n/20 is a power of 2.
Matrix of size n-by-n of orthogonal columns consisting of
1 and -1 only.
Hadamard matrices have applications in combinatorics, signal processing, and numerical analysis.
hadamard(4)
#> [,1] [,2] [,3] [,4]
#> [1,] 1 1 1 1
#> [2,] 1 -1 1 -1
#> [3,] 1 1 -1 -1
#> [4,] 1 -1 -1 1
H <- hadamard(8)
t(H)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,] 1 1 1 1 1 1 1 1
#> [2,] 1 -1 1 -1 1 -1 1 -1
#> [3,] 1 1 -1 -1 1 1 -1 -1
#> [4,] 1 -1 -1 1 1 -1 -1 1
#> [5,] 1 1 1 1 -1 -1 -1 -1
#> [6,] 1 -1 1 -1 -1 1 -1 1
#> [7,] 1 1 -1 -1 -1 -1 1 1
#> [8,] 1 -1 -1 1 -1 1 1 -1