<< makematrix_gallery Makematrix makematrix_hankel >>

Makematrix >> Makematrix > makematrix_hadamard

makematrix_hadamard

Returns the Hadamard matrix

Calling Sequence

A = makematrix_hadamard ( n )

Parameters

n :

a 1-by-1 matrix of doubles, integer value, the size of the matrix to return

A :

a n-by-n matrix of doubles, the Hadamard matrix

Description

Returns the Hadamard matrix of size n. This is a square matrix whose entries are either +1 or -1 and whose rows are mutually orthogonal.

n is expected to be a power of 2.

The Hadamard matrix satisfies A*A' = n*eye(A)

The Hadamard matrix satisfies det(A) = n^(n/2)

This implementation is recursive on n, and generates log2(n) recursive calls.

Examples

A = makematrix_hadamard ( 1 )
A = makematrix_hadamard ( 2 )
A = makematrix_hadamard ( 4 )

// Check orthogonal property
A * A'

for i = 1:10
n = 2^i;
A=  makematrix_hadamard(n);
mprintf("n=%d, det(A)=%e, n^(n/2)=%e\n",..
n,det(A),n^(n/2))
end

Authors

Bibliography

http://en.wikipedia.org/wiki/Hadamard_matrix


Report an issue
<< makematrix_gallery Makematrix makematrix_hankel >>