Skip to content

Commit b02562b

Browse files
Add missing specialization for CHOLMOD
1 parent 93762b9 commit b02562b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/factorization.jl

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
_ldiv!(x, A, b) = ldiv!(x, A, b)
2+
23
function _ldiv!(x::Vector, A::Factorization, b::Vector)
34
# workaround https://github.com/JuliaLang/julia/issues/43507
45
copyto!(x, b)

src/factorization_sparse.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Missing ldiv! definitions: https://github.com/JuliaSparse/SparseArrays.jl/issues/242
33
function _ldiv!(x::Vector,
44
A::Union{SparseArrays.QR, LinearAlgebra.QRCompactWY,
5-
SuiteSparse.SPQR.QRSparse}, b::Vector)
5+
SuiteSparse.SPQR.QRSparse,
6+
SuiteSparse.CHOLMOD.Factor}, b::Vector)
67
x .= A \ b
78
end
89

test/basictests.jl

+17
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,23 @@ end
210210
end
211211
end
212212

213+
@testset "CHOLMOD" begin
214+
# Create a posdef symmetric matrix
215+
A = sprand(100,100,0.01); A = A + A' + 100*I;
216+
217+
# rhs
218+
b=rand(100);
219+
220+
# Set the problem
221+
prob = LinearProblem(A,b)
222+
sol = solve(prob)
223+
224+
# Enforce symmetry to use Cholesky, since A is symmetric and posdef
225+
prob2 = LinearProblem(Symmetric(A),b)
226+
sol2 = solve(prob2)
227+
@test abs(norm(A * sol2.u .- b) - norm(A * sol.u .- b)) < 1e-12
228+
end
229+
213230
@testset "Preconditioners" begin
214231
@testset "Vector Diagonal Preconditioner" begin
215232
s = rand(n)

0 commit comments

Comments
 (0)