A Hadamard matrix is an
matrix
whose entries are either
or
and whose rows are mutually orthogonal. For example, the matrix
defined by

is a Hadamard matrix. An
matrix
whose entries are either
or
is a Hadamard matrix if and only if:
or
, where
is the identity matrix.In general, the tensor product of an
Hadamard matrix and an
Hadamard matrix is an
matrix. In
particular, if there is an
Hadamard matrix then there is a
Hadamard matrix (since one may tensor with
).
This particular case is sometimes called the Sylvester construction.
The Hadamard conjecture (possibly due to Paley) states that a Hadamard
matrix of order
exists if and only if
or
is a multiple
of
.
The module below implements the Paley constructions (see for example [Hora]) and the Sylvester construction. It also allows you to pull a Hadamard matrix from the database at [HadaSloa].
AUTHORS:
REFERENCES:
| [HadaSloa] | N.J.A. Sloane’s Library of Hadamard Matrices, at http://neilsloane.com/hadamard/ |
| [HadaWiki] | Hadamard matrices on Wikipedia, Wikipedia article Hadamard_matrix |
| [Hora] | K. J. Horadam, Hadamard Matrices and Their Applications, Princeton University Press, 2006. |
Returns the i,j-th entry of the Paley matrix, type I case.
EXAMPLES:
sage: sage.combinat.matrices.hadamard_matrix.H1(1,2,3)
-1
Returns the i,j-th entry of the Paley matrix, type II case.
EXAMPLES:
sage: sage.combinat.matrices.hadamard_matrix.H1(1,2,5)
1
Tries to construct a Hadamard matrix using a combination of Paley and Sylvester constructions.
EXAMPLES:
sage: hadamard_matrix(12).det()
2985984
sage: 12^6
2985984
sage: hadamard_matrix(2)
[ 1 1]
[ 1 -1]
sage: hadamard_matrix(8)
[ 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]
sage: hadamard_matrix(8).det() == 8^4
True
Implements the Paley type I construction.
EXAMPLES:
sage: sage.combinat.matrices.hadamard_matrix.hadamard_matrix_paleyI(4)
[ 1 -1 -1 -1]
[ 1 1 1 -1]
[ 1 -1 1 1]
[ 1 1 -1 1]
Implements the Paley type II construction.
EXAMPLES:
sage: sage.combinat.matrices.hadamard_matrix.hadamard_matrix_paleyI(12).det()
2985984
sage: 12^6
2985984
Pulls file from Sloanes database and returns the corresponding Hadamard matrix as a Sage matrix.
You must input a filename of the form “had.n.xxx.txt” as described on the webpage http://neilsloane.com/hadamard/, where “xxx” could be empty or a number of some characters.
If comments=True then the “Automorphism...” line of the had.n.xxx.txt file is printed if it exists. Otherwise nothing is done.
EXAMPLES:
sage: hadamard_matrix_www("had.4.txt") # optional - internet
[ 1 1 1 1]
[ 1 -1 1 -1]
[ 1 1 -1 -1]
[ 1 -1 -1 1]
sage: hadamard_matrix_www("had.16.2.txt",comments=True) # optional - internet
Automorphism group has order = 49152 = 2^14 * 3
[ 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]
[ 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]
[ 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]
[ 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]