Skip to content

Commit

Permalink
address code review
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith committed Jul 5, 2024
1 parent b2d8a28 commit ebe1555
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,26 +198,36 @@ function SciMLBase.reinit!(cache::LinearCache;
A = nothing,
b = cache.b,
u = cache.u,
p = nothing,)
p = nothing,
reinit_cache = false,)
(; alg, cacheval, isfresh, abstol, reltol, maxiters, verbose, assumptions, sensealg) = cache

precs = hasproperty(alg, :precs) ? alg.precs : DEFAULT_PRECS
Pl, Pr = if isnothing(A) || isnothing(p)
(cache.Pl, cache.Pr)
else
if isnothing(A)
A = cache.A
end
if isnothing(p)
p = cache.p
end
precs(A, p)
else
(cache.Pl, cache.Pr)
end

return LinearCache{typeof(A), typeof(b), typeof(u), typeof(p), typeof(alg), typeof(cacheval),
typeof(Pl), typeof(Pr), typeof(reltol), typeof(assumptions.issq),
typeof(sensealg)}(A, b, u, p, alg, cacheval, isfresh, Pl, Pr, abstol, reltol,
maxiters, verbose, assumptions, sensealg)
if reinit_cache
return LinearCache{typeof(A), typeof(b), typeof(u), typeof(p), typeof(alg), typeof(cacheval),
typeof(Pl), typeof(Pr), typeof(reltol), typeof(assumptions.issq),
typeof(sensealg)}(A, b, u, p, alg, cacheval, isfresh, Pl, Pr, abstol, reltol,
maxiters, verbose, assumptions, sensealg)
else
cache.A = A
cache.b = b
cache.u = u
cache.p = p
cache.Pl = Pl
cache.Pr = Pr
end
end

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

0 comments on commit ebe1555

Please sign in to comment.