Skip to content

Commit f253065

Browse files
author
Will Kimmerer
authored
specialize init_cacheval (#75)
* specialize init_cacheval * Bump patch for `show` on incomplete KLU. * handle missing numeric factorization
1 parent 372967c commit f253065

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
2424
ArrayInterface = "3"
2525
DocStringExtensions = "0.8"
2626
IterativeSolvers = "0.9.2"
27-
KLU = "0.2.2"
27+
KLU = "0.2.3"
2828
Krylov = "0.7.9"
2929
KrylovKit = "0.5"
3030
RecursiveFactorization = "0.2"

src/factorization.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ Base.@kwdef struct KLUFactorization <: AbstractFactorization
9898
reuse_symbolic::Bool = true
9999
end
100100

101+
function init_cacheval(alg::KLUFactorization, A, b, u, Pl, Pr, maxiters, abstol, reltol, verbose)
102+
return KLU.KLUFactorization(A) # this takes care of the copy internally.
103+
end
104+
101105
function do_factorization(::KLUFactorization, A, b, u)
102106
if A isa AbstractDiffEqOperator
103107
A = A.A
@@ -119,7 +123,10 @@ function SciMLBase.solve(cache::LinearCache, alg::KLUFactorization)
119123
# If we have a cacheval already, run umfpack_symbolic to ensure the symbolic factorization exists
120124
# This won't recompute if it does.
121125
KLU.klu_analyze!(cache.cacheval)
122-
fact = klu!(cache.cacheval, A)
126+
if cache.cacheval._numeric === C_NULL # We MUST have a numeric factorization for reuse, unlike UMFPACK.
127+
KLU.klu_factor!(cache.cacheval)
128+
end
129+
fact = KLU.klu!(cache.cacheval, A)
123130
else
124131
fact = do_factorization(alg, A, cache.b, cache.u)
125132
end

0 commit comments

Comments
 (0)