@@ -855,23 +855,17 @@ function SciMLBase.solve!(cache::LinearCache, alg::KLUFactorization; kwargs...)
855855 A = convert (AbstractMatrix, A)
856856 if cache. isfresh
857857 cacheval = @get_cacheval (cache, :KLUFactorization )
858- if cacheval != = nothing && alg. reuse_symbolic
858+ if alg. reuse_symbolic
859859 if alg. check_pattern && ! (SparseArrays. decrement (SparseArrays. getcolptr (A)) ==
860860 cacheval. colptr &&
861- SparseArrays. decrement (SparseArrays. getrowval (A)) == cacheval. rowval)
862- fact = KLU. klu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
863- nonzeros (A)))
864- else
865- # If we have a cacheval already, run umfpack_symbolic to ensure the symbolic factorization exists
866- # This won't recompute if it does.
867- KLU. klu_analyze! (cacheval)
868- copyto! (cacheval. nzval, nonzeros (A))
869- if cacheval. _numeric === C_NULL # We MUST have a numeric factorization for reuse, unlike UMFPACK.
870- KLU. klu_factor! (cacheval)
871- end
872- fact = KLU. klu! (cacheval,
861+ SparseArrays. decrement (SparseArrays. getrowval (A)) ==
862+ cacheval. rowval)
863+ fact = KLU. klu (
873864 SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
874- nonzeros (A)))
865+ nonzeros (A)),
866+ check = false )
867+ else
868+ fact = KLU. klu! (cacheval, nonzeros (A), check = false )
875869 end
876870 else
877871 # New fact each time since the sparsity pattern can change
@@ -882,9 +876,14 @@ function SciMLBase.solve!(cache::LinearCache, alg::KLUFactorization; kwargs...)
882876 cache. cacheval = fact
883877 cache. isfresh = false
884878 end
885-
886- y = ldiv! (cache. u, @get_cacheval (cache, :KLUFactorization ), cache. b)
887- SciMLBase. build_linear_solution (alg, y, nothing , cache)
879+ F = @get_cacheval (cache, :KLUFactorization )
880+ if F. common. status == KLU. KLU_OK
881+ y = ldiv! (cache. u, F, cache. b)
882+ SciMLBase. build_linear_solution (alg, y, nothing , cache)
883+ else
884+ SciMLBase. build_linear_solution (
885+ alg, cache. u, nothing , cache; retcode = ReturnCode. Infeasible)
886+ end
888887end
889888
890889# # CHOLMODFactorization
0 commit comments