Skip to content

Commit

Permalink
specialize init_cacheval (#75)
Browse files Browse the repository at this point in the history
* specialize init_cacheval

* Bump patch for `show` on incomplete KLU.

* handle missing numeric factorization
  • Loading branch information
Will Kimmerer authored Dec 22, 2021
1 parent 372967c commit f253065
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
ArrayInterface = "3"
DocStringExtensions = "0.8"
IterativeSolvers = "0.9.2"
KLU = "0.2.2"
KLU = "0.2.3"
Krylov = "0.7.9"
KrylovKit = "0.5"
RecursiveFactorization = "0.2"
Expand Down
9 changes: 8 additions & 1 deletion src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ Base.@kwdef struct KLUFactorization <: AbstractFactorization
reuse_symbolic::Bool = true
end

function init_cacheval(alg::KLUFactorization, A, b, u, Pl, Pr, maxiters, abstol, reltol, verbose)
return KLU.KLUFactorization(A) # this takes care of the copy internally.
end

function do_factorization(::KLUFactorization, A, b, u)
if A isa AbstractDiffEqOperator
A = A.A
Expand All @@ -119,7 +123,10 @@ function SciMLBase.solve(cache::LinearCache, alg::KLUFactorization)
# If we have a cacheval already, run umfpack_symbolic to ensure the symbolic factorization exists
# This won't recompute if it does.
KLU.klu_analyze!(cache.cacheval)
fact = klu!(cache.cacheval, A)
if cache.cacheval._numeric === C_NULL # We MUST have a numeric factorization for reuse, unlike UMFPACK.
KLU.klu_factor!(cache.cacheval)
end
fact = KLU.klu!(cache.cacheval, A)
else
fact = do_factorization(alg, A, cache.b, cache.u)
end
Expand Down

0 comments on commit f253065

Please sign in to comment.