Skip to content

Commit 4991c0e

Browse files
committed
fix idrs! when near solution
1 parent 17ef261 commit 4991c0e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/idrs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ function idrs_method!(log::ConvergenceHistory, X, A, C::T,
8484
T_s = zero(R)
8585
end
8686

87-
if normR <= tol # Initial guess is a good enough solution
88-
return X, ConvergenceHistory(0<= res[end] < tol, tol, length(res), res)
87+
if normR <= tol # Initial guess is a good enough solution
88+
return X
8989
end
9090

9191
Z = zero(C)

test/idrs.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,17 @@ end
4444
@test history.iters == 2
4545
@test length(history[:resnorm]) == 2
4646
end
47+
48+
@testset "Near solution (#222)" begin
49+
x = rand(5)
50+
A = rand(5, 5)
51+
b = rand(5)
52+
53+
x, history = idrs!(x, A, b, log=true)
54+
x_new = copy(x)
55+
x_new, history = idrs!(x_new, A, b, log=true)
56+
57+
@test x_new x
58+
end
59+
4760
end

0 commit comments

Comments
 (0)