@@ -231,3 +231,40 @@ function purge_history!(iter::IterativeSolvers.GMRESIterable, x, b)
231
231
iter. β = iter. residual. current
232
232
nothing
233
233
end
234
+
235
+ # # KrylovKit.jl
236
+
237
+ struct KrylovKitJL{F,I,K} <: AbstractKrylovSubspaceMethod
238
+ KrylovAlg:: F
239
+ gmres_restart:: I
240
+ kwargs:: K
241
+ end
242
+
243
+ function KrylovKitJL (KrylovAlg = KrylovKit. GMRES, gmres_restart= 0 , kwargs... )
244
+ return KrylovJL (KrylovAlg, gmres_restart, kwargs)
245
+ end
246
+
247
+ KrylovKitJL_GMRES (kwargs... ) = KrylovKitJL ()
248
+ KrylovKitJL_CG (kwargs... ) = KrylovKitJL (KrylovKitAlg= KrylovKit. CG, kwargs... )
249
+
250
+ function SciMLBase. solve (cache:: LinearCache , alg:: KrylovKitJL , kwargs... )
251
+
252
+ atol = float (cache. abstol)
253
+ rtol = float (cache. reltol)
254
+ maxiter = cache. maxiters
255
+ verbosity = cache. verbose ? 1 : 0
256
+ krylovdim = alg. gmres_restart
257
+
258
+ kwargs = (atol= atol, rtol= rtol, maxiter= maxiter, verbosity= verbosity,
259
+ krylovdim = krylovdim, alg. kwargs... )
260
+
261
+ x, info = KrylovKit. linsolve (cache. A, cache. b, cache. u, alg. KrylovAlg,
262
+ [a₀:: Number = 0 , a₁:: Number = 1 ])
263
+ copy! (cache. u, x)
264
+ resid = info. normres
265
+ retcode = info. converged == 1 ? :Default : :DidNotConverge
266
+ iters = info. numiter
267
+
268
+ return SciMLBase. build_linear_solution (alg,cache. u, resid,cache;
269
+ retcode = retcode, iters = iters)
270
+ end
0 commit comments