當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python SciPy linalg.hadamard用法及代碼示例

本文簡要介紹 python 語言中 scipy.linalg.hadamard 的用法。

用法:

scipy.linalg.hadamard(n, dtype=<class 'int'>)#

構造一個 Hadamard 矩陣。

使用 Sylvester 的構造構造 n-by-n Hadamard 矩陣。 n 必須是 2 的冪。

參數

n int

矩陣的順序。 n 必須是 2 的冪。

dtype dtype,可選

要構造的數組的數據類型。

返回

H (n, n) 數組

哈達瑪矩陣。

注意

例子

>>> from scipy.linalg import hadamard
>>> hadamard(2, dtype=complex)
array([[ 1.+0.j,  1.+0.j],
       [ 1.+0.j, -1.-0.j]])
>>> hadamard(4)
array([[ 1,  1,  1,  1],
       [ 1, -1,  1, -1],
       [ 1,  1, -1, -1],
       [ 1, -1, -1,  1]])

相關用法


注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.linalg.hadamard。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。