Skip to content

Commit

Permalink
Solve with AdjointFactorization of Cholmod and Adjoint rhs (#595)
Browse files Browse the repository at this point in the history
Fixes #594.
  • Loading branch information
dkarrasch authored Jan 16, 2025
1 parent 5f52721 commit 212981b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/solvers/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Base: (*), convert, copy, eltype, getindex, getproperty, show, size,
using Base: require_one_based_indexing

using LinearAlgebra
using LinearAlgebra: RealHermSymComplexHerm, AdjOrTrans
using LinearAlgebra: RealHermSymComplexHerm, AdjOrTrans, AdjOrTransAbsMat
import LinearAlgebra: (\), AdjointFactorization,
cholesky, cholesky!, det, diag, ishermitian, isposdef,
issuccess, issymmetric, ldiv!, ldlt, ldlt!, logdet,
Expand Down Expand Up @@ -1928,6 +1928,7 @@ function \(adjL::AdjointFactorization{<:VTypes,<:Factor}, B::StridedMatrix)
L = adjL.parent
return Matrix(solve(CHOLMOD_A, L, Dense(B)))
end
(\)(adjL::AdjointFactorization{<:VTypes,<:Factor}, B::AdjOrTransAbsMat) = adjL \ copy(B)

const RealHermSymComplexHermSSL{Ti, Tr} = Union{
Symmetric{Tr, SparseMatrixCSC{Tr, Ti}},
Expand Down
15 changes: 15 additions & 0 deletions test/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,21 @@ end
# @test_throws ErrorException cholesky(view(A, :, :), NoPivot())
end

@testset "solve with adjoint factorization and adjoint rhs" begin
n = 10
A = sprand(Tv, n, n, 1/n)
A = A + A' + 10I

B = rand(n, 2)
Bt = Matrix(B')
Bts = sparse(B')

F = cholesky(A)'
@test F \ B F \ Bt'
@test F \ B F \ Bts'
@test issparse(F \ Bts')
end

end # for Tv ∈ (Float32, Float64)

end # Base.USE_GPL_LIBS
Expand Down

0 comments on commit 212981b

Please sign in to comment.