矩阵上的Scipy LinearOperator

时间:2016-04-05 20:31:48

标签: python scipy linear-algebra

我有一个线性函数A,其输入和输出是(m,n) numpy数组。我想使用CG或GMRES来解决系统A(x) = b。有没有什么方法可以定义scipy LinearOperator而不重塑我的函数A中的输入和输出?

示例:

import numpy as np
import scipy.sparse.linalg as linalg

a = np.array( [ [1,2] , [3,4] ] )
def A(v):
    return a * v

# I want to do this but this fails. Any other
# solution that doesn't involve reshaping?
lin_op = linalg.LinearOperator( ((2,2),(2,2)), matvec=A )

0 个答案:

没有答案