@@ -137,7 +137,7 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
137137
138138 args = (cache. cacheval, cache. A, cache. b)
139139 kwargs = (atol = atol, rtol = rtol, itmax = itmax, verbose = verbose,
140- alg. kwargs... )
140+ history = true , alg. kwargs... )
141141
142142 if cache. cacheval isa Krylov. CgSolver
143143 N != = I &&
@@ -159,8 +159,10 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
159159 Krylov. solve! (args... ; kwargs... )
160160 end
161161
162- return SciMLBase. build_linear_solution (alg, cache. u, Krylov. Aprod (cache. cacheval),
163- cache)
162+ resid = cache. cacheval. stats. residuals |> last
163+
164+ return SciMLBase. build_linear_solution (alg, cache. u, resid, cache;
165+ iters = cache. cacheval. stats. niter)
164166end
165167
166168# # IterativeSolvers.jl
@@ -247,7 +249,12 @@ function SciMLBase.solve(cache::LinearCache, alg::IterativeSolversJL; kwargs...)
247249 end
248250 cache. verbose && println ()
249251
250- return SciMLBase. build_linear_solution (alg, cache. u, nothing , cache; iters = i)
252+ resid = cache. cacheval. residual
253+ if resid isa IterativeSolvers. Residual
254+ resid = resid. current
255+ end
256+
257+ return SciMLBase. build_linear_solution (alg, cache. u, resid, cache; iters = i)
251258end
252259
253260purge_history! (iter, x, b) = nothing
0 commit comments