cupyx.scipy.sparse.linalg.cgs(A, b, x0=None, tol=1e-05, maxiter=None, M=None, callback=None, atol=None)[source]

Use Conjugate Gradient Squared iteration to solve Ax = b.

  • A (ndarray, spmatrix or LinearOperator) – The real or complex matrix of the linear system with shape (n, n).

  • b (cupy.ndarray) – Right hand side of the linear system with shape (n,) or (n, 1).

  • x0 (cupy.ndarray) – Starting guess for the solution.

  • tol (float) – Tolerance for convergence.

  • maxiter (int) – Maximum number of iterations.

  • M (ndarray, spmatrix or LinearOperator) – Preconditioner for A. The preconditioner should approximate the inverse of A. M must be cupy.ndarray, cupyx.scipy.sparse.spmatrix or cupyx.scipy.sparse.linalg.LinearOperator.

  • callback (function) – User-specified function to call after each iteration. It is called as callback(xk), where xk is the current solution vector.

  • atol (float) – Tolerance for convergence.


It returns x (cupy.ndarray) and info (int) where x is the converged solution and info provides convergence information.

Return type