diff --git a/src/factorization.jl b/src/factorization.jl index b1dd74570..bcbd276b0 100644 --- a/src/factorization.jl +++ b/src/factorization.jl @@ -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) diff --git a/src/factorization_sparse.jl b/src/factorization_sparse.jl index e56b80f17..aea1b8862 100644 --- a/src/factorization_sparse.jl +++ b/src/factorization_sparse.jl @@ -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 diff --git a/test/basictests.jl b/test/basictests.jl index ca053e46d..de7e081e0 100644 --- a/test/basictests.jl +++ b/test/basictests.jl @@ -210,6 +210,24 @@ 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)