Provides implementations of the Conjugate Orthogonal Conjugate Gradient (COCG) and Conjugate Orthogonal Conjugate Residual (COCR) methods for solving complex symmetric linear systems.
The interface is compatible with scipy.sparse.linalg:
cocg(A, b, x0=None, *, rtol=1e-5, atol=0., maxiter=None, M=None, callback=None)
cocr(A, b, x0=None, *, rtol=1e-5, atol=0., maxiter=None, M=None, callback=None)
pip install git+https://github.com/chillenb/cosolvers
import numpy as np
import scipy
from cosolvers import cocr
A = np.array([
[2.0+0.1j, -0.5j],
[-0.5j, 1.0+0.1j]
])
# diagonal preconditioner, optional
M = scipy.sparse.diags_array(1./np.diag(A))
b = np.array([3.+2.j, 2.])
x, info = cocr(A, b, M=M)
assert np.allclose(A@x, b)
cosolvers
is distributed under the terms of the BSD 3-clause license.