Skip to content

Commit 0bbacb4

Browse files
committed
Do early length comparison in sparsity pattern check
1 parent 49d76ed commit 0bbacb4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/LinearSolveSparseArraysExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function SciMLBase.solve!(
200200
cacheval = LinearSolve.@get_cacheval(cache, :UMFPACKFactorization)
201201
if alg.reuse_symbolic
202202
# Caches the symbolic factorization: https://github.com/JuliaLang/julia/pull/33738
203-
if alg.check_pattern && pattern_changed(cacheval, A)
203+
if length(cacheval.nzval) != length(A.nzval) || alg.check_pattern && pattern_changed(cacheval, A)
204204
fact = lu(
205205
SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A),
206206
nonzeros(A)),
@@ -280,7 +280,7 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::KLUFactorization;
280280
if cache.isfresh
281281
cacheval = LinearSolve.@get_cacheval(cache, :KLUFactorization)
282282
if alg.reuse_symbolic
283-
if alg.check_pattern && pattern_changed(cacheval, A)
283+
if length(cacheval.nzval) != length(A.nzval) || alg.check_pattern && pattern_changed(cacheval, A)
284284
fact = KLU.klu(
285285
SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A),
286286
nonzeros(A)),

0 commit comments

Comments
 (0)