This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / linalg / _special_matrices / hadamard

function

scipy.linalg._special_matrices:hadamard

source: build-install/usr/lib/python3.14/site-packages/scipy/linalg/_special_matrices.py:222

Signature

def hadamard(n, dtype = <class 'int'>)

Summary

Construct a Hadamard matrix.

Extended Summary

Constructs an n-by-n Hadamard matrix, using Sylvester's construction. n must be a power of 2.

Parameters

n : int

The order of the matrix. n must be a power of 2.

dtype : dtype, optional

The data type of the array to be constructed.

Returns

H : (n, n) ndarray

The Hadamard matrix.

Notes

Examples

from scipy.linalg import hadamard
hadamard(2, dtype=complex)
hadamard(4)
✓
array([[ 1,  1,  1,  1],
       [ 1, -1,  1, -1],
       [ 1,  1, -1, -1],
       [ 1, -1, -1,  1]])

Aliases

  • scipy.linalg.hadamard