Skip to content

Commit ebe1555

Browse files
committed
address code review
1 parent b2d8a28 commit ebe1555

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/common.jl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,26 +198,36 @@ function SciMLBase.reinit!(cache::LinearCache;
198198
A = nothing,
199199
b = cache.b,
200200
u = cache.u,
201-
p = nothing,)
201+
p = nothing,
202+
reinit_cache = false,)
202203
(; alg, cacheval, isfresh, abstol, reltol, maxiters, verbose, assumptions, sensealg) = cache
203204

204205
precs = hasproperty(alg, :precs) ? alg.precs : DEFAULT_PRECS
205206
Pl, Pr = if isnothing(A) || isnothing(p)
206-
(cache.Pl, cache.Pr)
207-
else
208207
if isnothing(A)
209208
A = cache.A
210209
end
211210
if isnothing(p)
212211
p = cache.p
213212
end
214213
precs(A, p)
214+
else
215+
(cache.Pl, cache.Pr)
215216
end
216217

217-
return LinearCache{typeof(A), typeof(b), typeof(u), typeof(p), typeof(alg), typeof(cacheval),
218-
typeof(Pl), typeof(Pr), typeof(reltol), typeof(assumptions.issq),
219-
typeof(sensealg)}(A, b, u, p, alg, cacheval, isfresh, Pl, Pr, abstol, reltol,
220-
maxiters, verbose, assumptions, sensealg)
218+
if reinit_cache
219+
return LinearCache{typeof(A), typeof(b), typeof(u), typeof(p), typeof(alg), typeof(cacheval),
220+
typeof(Pl), typeof(Pr), typeof(reltol), typeof(assumptions.issq),
221+
typeof(sensealg)}(A, b, u, p, alg, cacheval, isfresh, Pl, Pr, abstol, reltol,
222+
maxiters, verbose, assumptions, sensealg)
223+
else
224+
cache.A = A
225+
cache.b = b
226+
cache.u = u
227+
cache.p = p
228+
cache.Pl = Pl
229+
cache.Pr = Pr
230+
end
221231
end
222232

223233
function SciMLBase.solve(prob::LinearProblem, args...; kwargs...)

0 commit comments

Comments
 (0)