Skip to content

Commit 22d37ca

Browse files
committed
Fix respectful_similar with SparsityPatternCSC
1 parent 3b9fe4b commit 22d37ca

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/matrices.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ respectful_similar(A::AbstractMatrix) = respectful_similar(A, eltype(A))
4949

5050
respectful_similar(A::AbstractMatrix, ::Type{T}) where {T} = similar(A, T)
5151

52+
# Needed if using `coloring(::SparsityPatternCSC, ...)`
53+
function respectful_similar(A::SparsityPatternCSC, ::Type{T}) where {T}
54+
return SparseArrays.SparseMatrixCSC(
55+
A.m,
56+
A.n,
57+
A.colptr,
58+
A.rowval,
59+
similar(A.rowval, T),
60+
)
61+
end
62+
5263
function respectful_similar(A::Transpose, ::Type{T}) where {T}
5364
return transpose(respectful_similar(parent(A), T))
5465
end

0 commit comments

Comments
 (0)