Skip to content

Commit

Permalink
Add missing specialization for CHOLMOD
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Dec 31, 2022
1 parent 93762b9 commit b02562b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/factorization.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_ldiv!(x, A, b) = ldiv!(x, A, b)

function _ldiv!(x::Vector, A::Factorization, b::Vector)
# workaround https://github.com/JuliaLang/julia/issues/43507
copyto!(x, b)
Expand Down
3 changes: 2 additions & 1 deletion src/factorization_sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Missing ldiv! definitions: https://github.com/JuliaSparse/SparseArrays.jl/issues/242
function _ldiv!(x::Vector,
A::Union{SparseArrays.QR, LinearAlgebra.QRCompactWY,
SuiteSparse.SPQR.QRSparse}, b::Vector)
SuiteSparse.SPQR.QRSparse,
SuiteSparse.CHOLMOD.Factor}, b::Vector)
x .= A \ b
end

Expand Down
17 changes: 17 additions & 0 deletions test/basictests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,23 @@ end
end
end

@testset "CHOLMOD" begin
# Create a posdef symmetric matrix
A = sprand(100,100,0.01); A = A + A' + 100*I;

# rhs
b=rand(100);

# Set the problem
prob = LinearProblem(A,b)
sol = solve(prob)

# Enforce symmetry to use Cholesky, since A is symmetric and posdef
prob2 = LinearProblem(Symmetric(A),b)
sol2 = solve(prob2)
@test abs(norm(A * sol2.u .- b) - norm(A * sol.u .- b)) < 1e-12
end

@testset "Preconditioners" begin
@testset "Vector Diagonal Preconditioner" begin
s = rand(n)
Expand Down

0 comments on commit b02562b

Please sign in to comment.