hadamard.sylvester

hadamard.sylvester(n)

Hadamard matrix based on Sylvester’s construction

Parameters

Name Type Description Default
n int The order of the matrix. n must be a power of 2. required

Raises

Type Description
ValueError If n is not a positive integer and not a power of 2.

Returns

Type Description
numpy.numpy.ndarray The Hadamard matrix of order n.

Examples:

import pyLHD
pyLHD.sylvester(n=4)
array([[ 1,  1,  1,  1],
       [ 1, -1,  1, -1],
       [ 1,  1, -1, -1],
       [ 1, -1, -1,  1]])
pyLHD.sylvester(n=8)
array([[ 1,  1,  1,  1,  1,  1,  1,  1],
       [ 1, -1,  1, -1,  1, -1,  1, -1],
       [ 1,  1, -1, -1,  1,  1, -1, -1],
       [ 1, -1, -1,  1,  1, -1, -1,  1],
       [ 1,  1,  1,  1, -1, -1, -1, -1],
       [ 1, -1,  1, -1, -1,  1, -1,  1],
       [ 1,  1, -1, -1, -1, -1,  1,  1],
       [ 1, -1, -1,  1, -1,  1,  1, -1]])