@@ -137,7 +137,7 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
137
137
138
138
args = (cache. cacheval, cache. A, cache. b)
139
139
kwargs = (atol = atol, rtol = rtol, itmax = itmax, verbose = verbose,
140
- alg. kwargs... )
140
+ history = true , alg. kwargs... )
141
141
142
142
if cache. cacheval isa Krylov. CgSolver
143
143
N != = I &&
@@ -159,8 +159,10 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
159
159
Krylov. solve! (args... ; kwargs... )
160
160
end
161
161
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)
164
166
end
165
167
166
168
# # IterativeSolvers.jl
@@ -247,7 +249,12 @@ function SciMLBase.solve(cache::LinearCache, alg::IterativeSolversJL; kwargs...)
247
249
end
248
250
cache. verbose && println ()
249
251
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)
251
258
end
252
259
253
260
purge_history! (iter, x, b) = nothing
0 commit comments