Skip to content

Commit d13cb5f

Browse files
pkofodtkelman
authored andcommitted
Fix sparse right multiplication of Symmetric and Hermitian matrices (#21431). (#21432)
(cherry picked from commit 8a3b6c1)
1 parent b428e47 commit d13cb5f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

base/sparse/cholmod.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,4 +1622,11 @@ end
16221622
(*){Ti}(A::Hermitian{Complex{Float64},SparseMatrixCSC{Complex{Float64},Ti}}, B::SparseVecOrMat{Complex{Float64},Ti}) = sparse(Sparse(A)*Sparse(B))
16231623
(*){Ti}(A::Hermitian{Float64,SparseMatrixCSC{Float64,Ti}}, B::SparseVecOrMat{Float64,Ti}) = sparse(Sparse(A)*Sparse(B))
16241624

1625+
(*){Ti}(A::SparseVecOrMat{Float64,Ti},
1626+
B::Symmetric{Float64,SparseMatrixCSC{Float64,Ti}}) = sparse(Sparse(A)*Sparse(B))
1627+
(*){Ti}(A::SparseVecOrMat{Complex{Float64},Ti},
1628+
B::Hermitian{Complex{Float64},SparseMatrixCSC{Complex{Float64},Ti}}) = sparse(Sparse(A)*Sparse(B))
1629+
(*){Ti}(A::SparseVecOrMat{Float64,Ti},
1630+
B::Hermitian{Float64,SparseMatrixCSC{Float64,Ti}}) = sparse(Sparse(A)*Sparse(B))
1631+
16251632
end #module

test/sparsedir/cholmod.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,3 +696,11 @@ for A in (SparseMatrixCSC(2, 2, [1, 2], CHOLMOD.SuiteSparse_long[], Float64[]),
696696
@test_throws ArgumentError CHOLMOD.Sparse(size(A)..., A.colptr - 1, A.rowval - 1, A.nzval)
697697
@test_throws ArgumentError CHOLMOD.Sparse(A)
698698
end
699+
700+
# sparse right multiplication of Symmetric and Hermitian matrices #21431
701+
@test issparse(speye(2)*speye(2)*speye(2))
702+
for T in (Symmetric, Hermitian)
703+
@test issparse(speye(2)*T(speye(2))*speye(2))
704+
@test issparse(speye(2)*(T(speye(2))*speye(2)))
705+
@test issparse((speye(2)*T(speye(2)))*speye(2))
706+
end

0 commit comments

Comments
 (0)