我有一个线性函数A
,它的输入和输出是(m,n)
numpy数组。我想用CG或GMRES来解决一个系统A(x) = b
。有没有什么方法可以定义scipyLinearOperator
,而不改变函数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 )
目前没有回答
相关问题 更多 >
编程相关推荐