Skip to content

Commit 6da5e54

Browse files
author
Wimmerer
committed
Correct UMFPACK and test proper variables
1 parent b293926 commit 6da5e54

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/default.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function SciMLBase.solve(cache::LinearCache, alg::Nothing,
3030
alg = GenericFactorization(;fact_alg=ldlt!)
3131
SciMLBase.solve(cache, alg, args...; kwargs...)
3232
elseif A isa SparseMatrixCSC
33-
alg = LUFactorization()
33+
alg = UMFPACKFactorization()
3434
SciMLBase.solve(cache, alg, args...; kwargs...)
3535

3636
# This catches the cases where a factorization overload could exist

src/factorization.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function SciMLBase.solve(cache::LinearCache, alg::AbstractFactorization)
77
ldiv!(cache.u, cache.cacheval, cache.b)
88
end
99

10-
## LUFactorization
10+
## LU Factorizations
1111

1212
struct LUFactorization{P} <: AbstractFactorization
1313
pivot::P
@@ -33,6 +33,21 @@ function init_cacheval(alg::LUFactorization, A, b, u)
3333
return fact
3434
end
3535

36+
# This could be a GenericFactorization perhaps?
37+
struct UMFPACKFactorization <: AbstractFactorization
38+
end
39+
40+
function init_cacheval(alg::UMFPACKFactorization, A, b, u)
41+
if A isa AbstractDiffEqOperator
42+
A = A.A
43+
end
44+
if A isa SparseMatrixCSC
45+
return lu(A)
46+
else
47+
error("Sparse LU is not defined for $(typeof(A))")
48+
end
49+
end
50+
3651
## QRFactorization
3752

3853
struct QRFactorization{P} <: AbstractFactorization

test/runtests.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ end
4242
@test A1 * y b1
4343

4444
_prob = LinearProblem(SymTridiagonal(A1.A), b1; u0=x1)
45-
y = solve(prob1)
45+
y = solve(_prob)
4646
@test A1 * y b1
4747

4848
_prob = LinearProblem(Tridiagonal(A1.A), b1; u0=x1)
49-
y = solve(prob1)
49+
y = solve(_prob)
5050
@test A1 * y b1
5151

5252
_prob = LinearProblem(Symmetric(A1.A), b1; u0=x1)
53-
y = solve(prob1)
53+
y = solve(_prob)
5454
@test A1 * y b1
5555

5656
_prob = LinearProblem(Hermitian(A1.A), b1; u0=x1)
57-
y = solve(prob1)
57+
y = solve(_prob)
5858
@test A1 * y b1
5959

6060
_prob = LinearProblem(sparse(A1.A), b1; u0=x1)
61-
y = solve(prob1)
61+
y = solve(_prob)
6262
@test A1 * y b1
6363
end
6464

0 commit comments

Comments
 (0)