Skip to content

Commit fc5c14a

Browse files
Merge pull request #474 from oscardssmith/remove-klu-and-umfpack-from-default
Fix `UMFPACK` to use `check=false`
2 parents e23f5c7 + 86e7191 commit fc5c14a

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/factorization.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -780,21 +780,26 @@ function SciMLBase.solve!(cache::LinearCache, alg::UMFPACKFactorization; kwargs.
780780
SparseArrays.decrement(SparseArrays.getrowval(A)) ==
781781
cacheval.rowval)
782782
fact = lu(SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A),
783-
nonzeros(A)))
783+
nonzeros(A)), check=false)
784784
else
785785
fact = lu!(cacheval,
786786
SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A),
787-
nonzeros(A)))
787+
nonzeros(A)), check=false)
788788
end
789789
else
790-
fact = lu(SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A), nonzeros(A)))
790+
fact = lu(SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A), nonzeros(A)), check=false)
791791
end
792792
cache.cacheval = fact
793793
cache.isfresh = false
794794
end
795795

796-
y = ldiv!(cache.u, @get_cacheval(cache, :UMFPACKFactorization), cache.b)
797-
SciMLBase.build_linear_solution(alg, y, nothing, cache)
796+
F = @get_cacheval(cache, :UMFPACKFactorization)
797+
if F.status == SparseArrays.UMFPACK.UMFPACK_OK
798+
y = ldiv!(cache.u, F, cache.b)
799+
SciMLBase.build_linear_solution(alg, y, nothing, cache)
800+
else
801+
SciMLBase.build_linear_solution(alg, cache.u, nothing, cache; retcode=ReturnCode.Infeasible)
802+
end
798803
end
799804

800805
"""
@@ -840,10 +845,10 @@ function init_cacheval(alg::KLUFactorization, A::AbstractSparseArray, b, u, Pl,
840845
nonzeros(A)))
841846
end
842847

848+
# TODO: guard this against errors
843849
function SciMLBase.solve!(cache::LinearCache, alg::KLUFactorization; kwargs...)
844850
A = cache.A
845851
A = convert(AbstractMatrix, A)
846-
847852
if cache.isfresh
848853
cacheval = @get_cacheval(cache, :KLUFactorization)
849854
if cacheval !== nothing && alg.reuse_symbolic

test/default_algs.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ solve(prob)
3535
LinearSolve.OperatorAssumptions(false)).alg ===
3636
LinearSolve.DefaultAlgorithmChoice.QRFactorization
3737

38+
39+
A = spzeros(2, 2)
40+
# test that solving a singular problem doesn't error
41+
prob = LinearProblem(A, ones(2))
42+
@test solve(prob, UMFPACKFactorization()).retcode == ReturnCode.Infeasible
43+
@test_broken solve(prob, KLUFactorization()).retcode == ReturnCode.Infeasible
44+
45+
3846
@test LinearSolve.defaultalg(sprand(10^4, 10^4, 1e-5) + I, zeros(1000)).alg ===
3947
LinearSolve.DefaultAlgorithmChoice.KLUFactorization
4048
prob = LinearProblem(sprand(1000, 1000, 0.5), zeros(1000))

0 commit comments

Comments
 (0)