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