dpnp.scipy.sparse.linalg.gmres¶
- dpnp.scipy.sparse.linalg.gmres(A, b, x0: dpnp_array | None = None, *, rtol: float = 1e-05, atol: float = 0.0, restart: int | None = None, maxiter: int | None = None, M=None, callback: Callable | None = None, callback_type: str | None = None) tuple[dpnp_array, int][source]¶
Use Generalized Minimal RESidual iteration to solve
Ax = b.For full documentation refer to
scipy.sparse.linalg.gmres.- Parameters:
- A{dpnp.ndarray, usm_ndarray, LinearOperator, csr_matrix}
The real or complex operator of the linear system, shape
(N, N).- b{dpnp.ndarray, usm_ndarray}
Right-hand side of the linear system, shape
(N,)or(N, 1).- x0{None, dpnp.ndarray, usm_ndarray}, optional
Starting guess for the solution. Default:
None(zeros).- rtol, atolfloat, optional
Convergence tolerance:
||r|| <= max(atol, rtol*||b||). Defaults:rtol=1e-5,atol=0.0.- restart{None, int}, optional
Number of iterations between restarts. Larger values increase the per-iteration cost but may aid convergence. Default:
20.- maxiter{None, int}, optional
Maximum number of iterations. Default:
10 * N.- M{None, dpnp.ndarray, usm_ndarray, LinearOperator}, optional
Preconditioner approximating the inverse of A. Default:
None.- callback{None, callable}, optional
Called on every restart as
callback(arg), where arg is selected by callback_type. Default:None.- callback_type{None, 'x', 'pr_norm'}, optional
'x'passes the current solution vector;'pr_norm'passes the relative (preconditioned) residual norm. Default:'pr_norm'when a callback is supplied.
- Returns:
- xdpnp.ndarray
The approximate solution (
M @ xin the right-preconditioned formulation, matching CuPy's return value).- infoint
0if converged; the iteration count if maxiter was reached.