JuliaLinearAlgebra / IterativeSolvers.jl

Iterative algorithms for solving linear systems, eigensystems, and singular value problems
MIT License
399 stars 105 forks source link

stopping with preconditioners #249

Closed lkapelevich closed 3 years ago

lkapelevich commented 5 years ago

I'm trying to use gmres, and I'm wondering why the method can sometimes terminate with a preconditioner when the residuals are still quite large?

using IterativeSolvers, AlgebraicMultigrid, Random
Random.seed!(1)
A = sprandn(50, 50, 0.1)
x = randn(50)
b = A * x
ml = ruge_stuben(A)
p = aspreconditioner(ml)
(y, log) = gmres(A, b, log = true, restart = size(A, 2), verbose = true, Pl = p, tol = 1e-9)
# julia> log
# Converged after 13 iterations.
# julia> log[:resnorm][end]
# 0.5156281490822161
(y, log) = gmres(A, b, log = true, restart = size(A, 2), verbose = true, tol = 1e-9)
# julia> log
# Converged after 50 iterations.
# julia> log[:resnorm][end]
# 3.184916424132057e-15
ranocha commented 3 years ago

The residuals used/estimated internally are changed by a left preconditioner (as in your case). That's why it's often better to use a right preconditioner, see

Ghai, A., Lu, C. and Jiao, X., 2019. A comparison of preconditioned Krylov subspace methods for large‐scale nonsymmetric linear systems. Numerical Linear Algebra with Applications, 26(1), p.e2215. https://arxiv.org/abs/1607.00351

lkapelevich commented 3 years ago

Thanks!