我在尝试计算稀疏矩阵的 1 范数时遇到了一个问题。我正在使用该函数scipy.sparse.linalg.onenormest
,但它给了我一个错误,因为运算符只能作用于方阵。
这是一个代码示例:
from scipy import sparse
row = array([0,2,2,0,1,2])
col = array([0,0,1,2,2,2])
data = array([1,2,3,4,5,6])
A = sparse.csc_matrix( (data,(row,col)), shape=(5,3) )
onenormest(A)
这是错误:
Traceback (most recent call last):
File "<ipython console>", line 1, in <module>
File "C:\Python27\lib\site-packages\scipy\sparse\linalg\_onenormest.py", line 76, in onenormest
raise ValueError('expected the operator to act like a square matrix')
ValueError: expected the operator to act like a square matrix
如果我将 A 定义为方阵,则运算符onenormest
可以工作,但这不是我想要的。
任何人都知道如何计算稀疏非方阵的 1 范数?