Hello,
I think I might be doing something wrong, but it seems that none of the Krylov methods in LinearSolve are using the initial guess I provide. (In the small example below, the initial guess is the true solution.)
import LinearSolve as LS
using SparseArrays
using Random
rng = Random.MersenneTwister(123)
_A = sprand(rng,10,10,0.3)
A = _A * _A'
rhs = rand(rng,10)
# get an "initial guess"
prob1 = LS.LinearProblem(A,rhs)
u0 = LS.solve(prob1,LS.KrylovJL_GMRES())
residual = A * u0 - rhs
# use the initial guess
prob2 = LS.LinearProblem(A,rhs;u0 = u0)
LS.solve(prob2,LS.KrylovJL_GMRES(),verbose = true)
Sounds like a bug. Would you mind filing an issue to make it easy for us to track? (Also @ChrisRackauckas this definitely could explain some of the non-determinism I’ve been running into).
No, this is not a bug. It’s a property of GMRES. We currently zero the values because of the extensive literature on this, see Better initial guesses for reinitialized iterative solvers · Issue #70 · SciML/LinearSolve.jl · GitHub. There are ways to do non-zero guesses, but rand like this is not necessarily convergent so it’s not a good idea to just accept it. We’d have to renormalize it or something, again see the papers linked in the issue.