scipy.sparse.linalg.
spbandwidth#
- scipy.sparse.linalg.spbandwidth(A)[source]#
返回二维数值数组的下带宽和上带宽。
计算稀疏二维数组
A
的带宽的下限和上限。结果总结为正整数的 2 元组(lo, hi)
。零表示该侧没有子/超对角线条目(三角)。lo``(``hi
) 的最大值比行(列)数少 1。此处仅使用稀疏结构。不检查值是否为零。
- 参数:
- ASciPy 稀疏数组或矩阵
稀疏矩阵最好采用 CSR 或 CSC 格式。
- 返回:
- below, aboveint 的 2 元组
到主对角线下/上方最远非零对角线的距离。
在 1.15.0 版本中添加。
示例
>>> import numpy as np >>> from scipy.sparse.linalg import spbandwidth >>> from scipy.sparse import csc_array, eye_array >>> A = csc_array([[3, 0, 0], [1, -1, 0], [2, 0, 1]], dtype=float) >>> spbandwidth(A) (2, 0) >>> D = eye_array(3, format='csr') >>> spbandwidth(D) (0, 0)