From fa377a43c17b9b738e2eb9d775984dcaaa33d096 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 17 Aug 2017 16:01:15 +0200 Subject: [PATCH] Fix off-by-one error in iteration count of IDR(s) (#158) * Fix off-by-one error in iteration count * Add test for # of iterations in IDR(s) --- src/idrs.jl | 9 ++++----- test/idrs.jl | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/idrs.jl b/src/idrs.jl index a41dbf93..79dd4d54 100644 --- a/src/idrs.jl +++ b/src/idrs.jl @@ -51,7 +51,7 @@ function idrs_method!(log::ConvergenceHistory, X, op, args, C::T, verbose && @printf("=== idrs ===\n%4s\t%7s\n","iter","resnorm") R = C - op(X, args...)::T normR = vecnorm(R) - iter = 0 + iter = 1 if smoothing X_s = copy(X) @@ -76,7 +76,7 @@ function idrs_method!(log::ConvergenceHistory, X, op, args, C::T, c = zeros(eltype(C),s) om::eltype(C) = 1 - while normR > tol && iter < maxiter + while normR > tol && iter ≤ maxiter for i in 1:s, f[i] = vecdot(P[i], R) end @@ -144,8 +144,7 @@ function idrs_method!(log::ConvergenceHistory, X, op, args, C::T, end push!(log, :resnorm, normR) verbose && @printf("%3d\t%1.2e\n",iter,normR) - iter += 1 - if normR < tol || iter > maxiter + if normR < tol || iter == maxiter shrink!(log) setconv(log, 0<=normR