Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make preconditioners part of the solver rather than a random extra #514

Merged
merged 14 commits into from
Aug 8, 2024
Prev Previous commit
Next Next commit
address code review
oscardssmith committed Aug 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit d863dd0aece120643713523d657fdc82a2612069
24 changes: 17 additions & 7 deletions src/common.jl
Original file line number Diff line number Diff line change
@@ -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...)