本文簡要介紹 python 語言中 scipy.linalg.bandwidth
的用法。
用法:
scipy.linalg.bandwidth(a)#
返回二維數值數組的下限和上限帶寬。
- a: ndarray
大小為 (N, M) 的輸入數組
- lu: 元組
指示較低和較高帶寬的整數的 2 元組。零表示該側(三角形)沒有子或super-diagonal,並且對於N行(N-1)表示該側已滿。相同的示例適用於具有 (M-1) 的上三角形部分。
- TypeError
如果不支持數組的數據類型,特別是NumPy float16、float128 和complex256 數據類型。
參數 ::
返回 ::
拋出 ::
注意:
這個輔助函數隻是簡單地在數組上運行,尋找數組中是否存在帶狀結構的非零條目。因此,性能取決於非零條目的密度以及memory-layout。 Fortran 或 C 連續數組處理得最好,否則會受到額外的隨機內存訪問成本的影響。
策略是隻在上下三角部分分別尋找未測試的帶元素;根據內存布局,我們按行或按列掃描。此外,假設我們正在掃描行,並且在第 6 行中,第 4 個條目是非零的,那麽在隨後的行上,水平搜索僅針對該帶條目進行,因為我們知道該帶已被占用。因此,一個完全密集的矩陣掃描代價是 n 量級的。
例子:
>>> import numpy as np >>> from scipy.linalg import bandwidth >>> A = np.array([[3., 0., 0., 0., 0.], ... [0., 4., 0., 0., 0.], ... [0., 0., 5., 1., 0.], ... [8., 0., 0., 6., 2.], ... [0., 9., 0., 0., 7.]]) >>> bandwidth(A) (3, 1)
相關用法
- Python SciPy linalg.bicgstab用法及代碼示例
- Python SciPy linalg.bicg用法及代碼示例
- Python SciPy linalg.block_diag用法及代碼示例
- Python SciPy linalg.eigvalsh_tridiagonal用法及代碼示例
- Python SciPy linalg.cdf2rdf用法及代碼示例
- Python SciPy linalg.LaplacianNd用法及代碼示例
- Python SciPy linalg.solve_circulant用法及代碼示例
- Python SciPy linalg.polar用法及代碼示例
- Python SciPy linalg.clarkson_woodruff_transform用法及代碼示例
- Python SciPy linalg.rsf2csf用法及代碼示例
- Python SciPy linalg.hessenberg用法及代碼示例
- Python SciPy linalg.tril用法及代碼示例
- Python SciPy linalg.triu用法及代碼示例
- Python SciPy linalg.svd用法及代碼示例
- Python SciPy linalg.ishermitian用法及代碼示例
- Python SciPy linalg.invhilbert用法及代碼示例
- Python SciPy linalg.factorized用法及代碼示例
- Python SciPy linalg.lu_factor用法及代碼示例
- Python SciPy linalg.SuperLU用法及代碼示例
- Python SciPy linalg.lsqr用法及代碼示例
- Python SciPy linalg.cho_factor用法及代碼示例
- Python SciPy linalg.fractional_matrix_power用法及代碼示例
- Python SciPy linalg.eig_banded用法及代碼示例
- Python SciPy linalg.tanhm用法及代碼示例
- Python SciPy linalg.orthogonal_procrustes用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.linalg.bandwidth。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。