@@ -12,7 +12,7 @@ struct ComposePreconditioner{Ti,To}
12
12
outer:: To
13
13
end
14
14
15
- Base. eltype (A:: ComposePreconditioner ) = Float64 # eltype(A.inner)
15
+ Base. eltype (A:: ComposePreconditioner ) = promote_type ( eltype (A. inner), eltype (A . outer) )
16
16
Base. adjoint (A:: ComposePreconditioner ) = ComposePreconditioner (A. outer' , A. inner' )
17
17
Base. inv (A:: ComposePreconditioner ) = InvComposePreconditioner (A)
18
18
@@ -148,8 +148,16 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
148
148
cache = set_cacheval (cache, solver)
149
149
end
150
150
151
- M = InvComposePreconditioner (alg. Pl, cache. Pl) # left precond
152
- N = InvComposePreconditioner (alg. Pr, cache. Pr) # right
151
+ M = I # left precond
152
+ N = I # right precond
153
+
154
+ if (cache. Pl != I) | (alg. Pl != I)
155
+ M = InvComposePreconditioner (alg. Pl, cache. Pl)
156
+ end
157
+
158
+ if (cache. Pr != I) | (alg. Pr != I)
159
+ N = InvComposePreconditioner (alg. Pr, cache. Pr)
160
+ end
153
161
154
162
atol = cache. abstol
155
163
rtol = cache. reltol
@@ -161,7 +169,7 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
161
169
alg. kwargs... )
162
170
163
171
if cache. cacheval isa Krylov. CgSolver
164
- N != LinearAlgebra . I &&
172
+ N != I &&
165
173
@warn " $(alg. KrylovAlg) doesn't support right preconditioning."
166
174
Krylov. solve! (args... ; M= M,
167
175
kwargs... )
@@ -172,7 +180,7 @@ function SciMLBase.solve(cache::LinearCache, alg::KrylovJL; kwargs...)
172
180
Krylov. solve! (args... ; M= M, N= N,
173
181
kwargs... )
174
182
elseif cache. cacheval isa Krylov. MinresSolver
175
- N != LinearAlgebra . I &&
183
+ N != I &&
176
184
@warn " $(alg. KrylovAlg) doesn't support right preconditioning."
177
185
Krylov. solve! (args... ; M= M,
178
186
kwargs... )
@@ -223,8 +231,16 @@ IterativeSolversJL_MINRES(args...;kwargs...) =
223
231
function init_cacheval (alg:: IterativeSolversJL , cache:: LinearCache )
224
232
@unpack A, b, u = cache
225
233
226
- Pl = ComposePreconditioner (alg. Pl, cache. Pl)
227
- Pr = ComposePreconditioner (alg. Pr, cache. Pr)
234
+ Pl = IterativeSolvers. Identity ()
235
+ Pr = IterativeSolvers. Identity ()
236
+
237
+ if (cache. Pl != I) | (alg. Pl != IterativeSolvers. Identity ())
238
+ Pl = ComposePreconditioner (alg. Pl, cache. Pl)
239
+ end
240
+
241
+ if (cache. Pr != I) | (alg. Pr != IterativeSolvers. Identity ())
242
+ Pr = ComposePreconditioner (alg. Pr, cache. Pr)
243
+ end
228
244
229
245
abstol = cache. abstol
230
246
reltol = cache. reltol
0 commit comments