Skip to content

Commit 212981b

Browse files
authored
Solve with AdjointFactorization of Cholmod and Adjoint rhs (JuliaSparse#595)
Fixes JuliaSparse#594.
1 parent 5f52721 commit 212981b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/solvers/cholmod.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Base: (*), convert, copy, eltype, getindex, getproperty, show, size,
1515
using Base: require_one_based_indexing
1616

1717
using LinearAlgebra
18-
using LinearAlgebra: RealHermSymComplexHerm, AdjOrTrans
18+
using LinearAlgebra: RealHermSymComplexHerm, AdjOrTrans, AdjOrTransAbsMat
1919
import LinearAlgebra: (\), AdjointFactorization,
2020
cholesky, cholesky!, det, diag, ishermitian, isposdef,
2121
issuccess, issymmetric, ldiv!, ldlt, ldlt!, logdet,
@@ -1928,6 +1928,7 @@ function \(adjL::AdjointFactorization{<:VTypes,<:Factor}, B::StridedMatrix)
19281928
L = adjL.parent
19291929
return Matrix(solve(CHOLMOD_A, L, Dense(B)))
19301930
end
1931+
(\)(adjL::AdjointFactorization{<:VTypes,<:Factor}, B::AdjOrTransAbsMat) = adjL \ copy(B)
19311932

19321933
const RealHermSymComplexHermSSL{Ti, Tr} = Union{
19331934
Symmetric{Tr, SparseMatrixCSC{Tr, Ti}},

test/cholmod.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,21 @@ end
10191019
# @test_throws ErrorException cholesky(view(A, :, :), NoPivot())
10201020
end
10211021

1022+
@testset "solve with adjoint factorization and adjoint rhs" begin
1023+
n = 10
1024+
A = sprand(Tv, n, n, 1/n)
1025+
A = A + A' + 10I
1026+
1027+
B = rand(n, 2)
1028+
Bt = Matrix(B')
1029+
Bts = sparse(B')
1030+
1031+
F = cholesky(A)'
1032+
@test F \ B F \ Bt'
1033+
@test F \ B F \ Bts'
1034+
@test issparse(F \ Bts')
1035+
end
1036+
10221037
end # for Tv ∈ (Float32, Float64)
10231038

10241039
end # Base.USE_GPL_LIBS

0 commit comments

Comments
 (0)