scipy.sparse.linalg.
aslinearoperator#
- scipy.sparse.linalg.aslinearoperator(A)[source]#
将 A 作为 LinearOperator 返回。
- “A”可以是以下任何类型
ndarray
matrix
稀疏数组(例如 csr_array、lil_array 等)
LinearOperator
具有 .shape 和 .matvec 属性的对象
有关更多信息,请参阅 LinearOperator 文档。
注释
如果“A”没有 .dtype 属性,则通过调用
LinearOperator.matvec
确定数据类型 - 设置 .dtype 属性以防止在线性算子创建时调用此函数。示例
>>> import numpy as np >>> from scipy.sparse.linalg import aslinearoperator >>> M = np.array([[1,2,3],[4,5,6]], dtype=np.int32) >>> aslinearoperator(M) <2x3 MatrixLinearOperator with dtype=int32>