hadamard.is_Hadamard

hadamard.is_Hadamard(arr, rtol=1e-05, atol=1e-08)

Determine if a matrix is a Hadamard matrix.

Parameters

Name Type Description Default
arr numpy.numpy.ArrayLike A numpy array. required

Raises

Type Description
ValueError If provided array is not a square matrix.
ValueError If number of rows is not a power of 2 or not divisible by 4.
ValueError If values are not +1 or -1.
ValueError If HH.T != nI, where I is the identity matrix of order n.

Returns

Type Description
bool True if given array follows Hadamard properties, otherwise False.

Examples:

import pyLHD
H1 = pyLHD.sylvester(n=8)
H1
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]])
pyLHD.is_Hadamard(H1)
True
H2 = pyLHD.paley(p=7,k=1)
H2
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.]])
pyLHD.is_Hadamard(H2)
True