def test_compat_conjgrad(backend, N):
pymr = pytest.importorskip('pymr')
b = backend()
A = indigo.util.randM( N, N, 0.5 )
A = A.H @ A # make positive definite
y = indigo.util.rand64c( N )
x0 = np.zeros( N, dtype=np.complex64 )
A_pmr = pymr.linop.Matrix( A.toarray(), dtype=A.dtype )
x_exp = pymr.alg.cg(A_pmr, A.H * y, x0, maxiter=40)
A_indigo = b.SpMatrix(A)
b.cg(A_indigo, y, x0, maxiter=40)
x_act = x0.copy()
npt.assert_allclose(x_act, x_exp, rtol=1e-6)
评论列表
文章目录