scipy.sparse.linalg.aslinearoperator

scipy.sparse.linalg.aslinearoperator(A)[源代码]

作为LinearOperator返回A。

“A”可以是以下任何类型:
  • ndarray

  • 矩阵

  • 稀疏矩阵(例如CSR_MATRATE、LIL_MATRATE等)

  • LinearOperator

  • 具有.form和.matvec属性的对象

有关其他信息,请参阅LinearOperator文档。

注意事项

如果“A”没有.dtype属性,则通过调用 LinearOperator.matvec -设置.dtype属性以防止在创建线性运算符时进行此调用。

示例

>>> 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>