Skip to content

Commit 92d7a71

Browse files
Auto-reset GMRES u to zero
#70 shows that setting the initial condition in GMRES is a minefield. Currently it's pretty much impossible for any user to guess correctly so pretty much any case would do better with resetting to zero. The papers suggest doing that even if the rescaling is done in many cases, and the tests require it. So for the sanity of everyone, I think it's best to reset to zero, and if the rescaling is implemented this can be removed, but until then keeping it hardcoded is a good idea.
1 parent 0b47fe1 commit 92d7a71

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

src/iterative_wrappers.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ purge_history!(iter, x, b) = nothing
221221
function purge_history!(iter::IterativeSolvers.GMRESIterable, x, b)
222222
iter.k = 1
223223
iter.x = x
224+
fill!(x,false)
224225
iter.b = b
225226

226227
iter.residual.current = IterativeSolvers.init!(iter.arnoldi, iter.x, iter.b, iter.Pl, iter.Ax, initially_zero = true)

test/runtests.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,18 @@ function test_interface(alg, prob1, prob2)
1616
A1 = prob1.A; b1 = prob1.b; x1 = prob1.u0
1717
A2 = prob2.A; b2 = prob2.b; x2 = prob2.u0
1818

19-
x1 .= false
2019
y = solve(prob1, alg; cache_kwargs...)
2120
@test A1 * y b1
2221

2322
cache = SciMLBase.init(prob1,alg; cache_kwargs...) # initialize cache
24-
cache.u .= false
2523
y = solve(cache)
2624
@test A1 * y b1
2725

2826
cache = LinearSolve.set_A(cache,copy(A2))
29-
cache.u .= false
3027
y = solve(cache)
3128
@test A2 * y b1
3229

3330
cache = LinearSolve.set_b(cache,b2)
34-
cache.u .= false
3531
y = solve(cache)
3632
@test A2 * y b2
3733

0 commit comments

Comments
 (0)