Forms Hadamard matrices (R.W. Payne).
|Controls printed output (
||Method of construction (
||Number of rows of the matrices|
||Saves the Hadamard matrices|
||Returns 0 if the matrix has been formed successfully and 1 if not|
A Hadamard matrix is a matrix containing values -1 and +1 whose rows are orthogonal: i.e. if
H is a Hadamard matrix
H *+ T(H) = n * IDENTITY(n)
n is the number of rows of
H, which must be 2 or a multiple of 4.
FHADAMARDMATRIX provides several methods for forming the matrices, described in Hedayat, Sloane & Stufken (1999, Chapter 7). These work for all sizes of matrix up to 200, and various other sizes above that. The
METHOD option can be used to specify the method. If this is unset
FHADAMARDMATRIX selects an appropriate method automatically (you may then want to set the
monitoring to record what method has been used). The settings of
METHOD, in the order in which they will be selected, are as follows.
||uses a tensor product construction building on the 2 × 2 matrix to form matrices of size n = 2m for any positive integer m.|
||builds the matrix from four circulant matrices;
||builds the matrix from a circulant and seven retrocirculant matrices; this method is used for the matrix with 188 rows.|
||uses a tensor product between the matrix with two rows, and a Hadamard matrix with n/2 rows.|
||forms matrices with n = 2 × (s + 1), where s is a prime power, using properties of the Galois field of order s.|
||forms matrices with n = s + 1, where s is a prime power, using properties of the Galois field of order s.|
||takes a matrix from a stored repertoire with rows from four to 32.|
The number of rows of the matrix is specified by the
NROWS parameter, the
HADAMARDMATRIX parameter saves the matrix, and the
ERROR parameter can be set to a scalar which returns zero if the matrix has been formed successfully and one if not.
The methods are described in Chapter 7 of Hedayat, Sloane & Stufken (1999).
Hedayat, A.S., Sloane, N.J.A., & Stufken, J. (1999). Orthogonal Arrays, Theory & Applications. Springer-Verlag, New York.
CAPTION 'FHADAMARDMATRIX example'; STYLE=meta SCALAR order; VALUE=8 FHADAMARD order; M PRINT M; FIELD=5; DECIMALS=1 " check matrix Hadamard " DIAGONAL [ROWS=order] I CALCULATE I = 1 MATRIX [ROWS=order; COLUMNS=order] MTM CALCULATE MTM = M*+T(M) & MTM= MTM - I*order & meancheck = MEAN(MTM) & varcheck = VAR(MTM) PRINT meancheck,varcheck