From 74c1271e17394da0bf0e544c9a9f469c37ccf139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Moral=20S=C3=A1nchez?= <88042165+e-moral-sanchez@users.noreply.github.com> Date: Wed, 22 Jan 2025 14:18:14 +0100 Subject: [PATCH] fix bug gmres (#452) Solves issue https://github.com/pyccel/psydac/issues/451. --- psydac/linalg/solvers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/psydac/linalg/solvers.py b/psydac/linalg/solvers.py index 862868ea2..0a72d226f 100644 --- a/psydac/linalg/solvers.py +++ b/psydac/linalg/solvers.py @@ -1007,7 +1007,7 @@ def solve(self, b, out=None): pp += rp # new residual norm - res_sqr = r.dot(r) + res_sqr = r.dot(r).real niter += 1 @@ -1804,6 +1804,10 @@ def solve(self, b, out=None): r -= b am = sqrt(r.dot(r).real) + if am < tol: + self._info = {'niter': 1, 'success': am < tol, 'res_norm': am } + return x + beta.append(am) r *= - 1 / am