Construct a Hadamard matrix.
hadamard(n) constructs an n-by-n Hadamard matrix, using Sylvester’s construction. n must be a power of 2.
Parameters : | n : int
dtype : numpy dtype
|
---|---|
Returns : | H : ndarray with shape (n, n)
|
Notes
New in version 0.8.0.
Examples
>>> hadamard(2, dtype=complex)
array([[ 1.+0.j, 1.+0.j],
[ 1.+0.j, -1.-0.j]])
>>> hadamard(4)
array([[ 1, 1, 1, 1],
[ 1, -1, 1, -1],
[ 1, 1, -1, -1],
[ 1, -1, -1, 1]])