|
85 | 85 |
|
86 | 86 | function Base.setproperty!(cache::LinearCache, name::Symbol, x) |
87 | 87 | if name === :A |
88 | | - if hasproperty(cache.alg, :precs) |
| 88 | + if hasproperty(cache.alg, :precs) && !isnothing(cache.alg.precs) |
89 | 89 | Pl, Pr = cache.alg.precs(x, cache.p) |
90 | 90 | setfield!(cache, :Pl, Pl) |
91 | 91 | setfield!(cache, :Pr, Pr) |
92 | 92 | end |
93 | 93 | setfield!(cache, :isfresh, true) |
94 | 94 | elseif name === :p |
95 | | - if hasproperty(cache.alg, :precs) |
| 95 | + if hasproperty(cache.alg, :precs) && !isnothing(cache.alg.precs) |
96 | 96 | Pl, Pr = cache.alg.precs(cache.A, x) |
97 | 97 | setfield!(cache, :Pl, Pl) |
98 | 98 | setfield!(cache, :Pr, Pr) |
@@ -180,7 +180,11 @@ function SciMLBase.init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm, |
180 | 180 | reltol = real(eltype(prob.b))(reltol) |
181 | 181 | abstol = real(eltype(prob.b))(abstol) |
182 | 182 |
|
183 | | - precs = hasproperty(alg, :precs) ? alg.precs : DEFAULT_PRECS |
| 183 | + precs = if hasproperty(alg, :precs) |
| 184 | + isnothing(alg.precs) ? DEFAULT_PRECS : alg.precs |
| 185 | + else |
| 186 | + DEFAULT_PRECS |
| 187 | + end |
184 | 188 | _Pl, _Pr = precs(A, p) |
185 | 189 | if isnothing(Pl) |
186 | 190 | Pl = _Pl |
@@ -215,7 +219,7 @@ function SciMLBase.reinit!(cache::LinearCache; |
215 | 219 | reinit_cache = false,) |
216 | 220 | (; alg, cacheval, abstol, reltol, maxiters, verbose, assumptions, sensealg) = cache |
217 | 221 |
|
218 | | - precs = hasproperty(alg, :precs) ? alg.precs : DEFAULT_PRECS |
| 222 | + precs = (hasproperty(alg, :precs) && !isnothing(alg.precs)) ? alg.precs : DEFAULT_PRECS |
219 | 223 | Pl, Pr = if isnothing(A) || isnothing(p) |
220 | 224 | if isnothing(A) |
221 | 225 | A = cache.A |
|
0 commit comments