Skip to content

Commit

Permalink
Add fix for empty matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
laschuet committed Dec 22, 2020
1 parent df6b5d2 commit 40aedf2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ respectively) of `A` or `B`.
"""
function diff(A::AbstractMatrix, B::AbstractMatrix, ia::AbstractVector,
ja::AbstractVector, ib::AbstractVector, jb::AbstractVector)
if size(A) == (0, 0) || size(B) == (0, 0)
T = promote_type(eltype(A), eltype(B))
modvals = sparse([], [], T[])
addvals = view(Vector{T}(undef, 0), :)
remvals = view(Vector{T}(undef, 0), :)
return MatrixDifference(modvals, addvals, remvals)
end

iamap = Dict(zip(ia, 1:length(ia)))
jamap = Dict(zip(ja, 1:length(ja)))
ibmap = Dict(zip(ib, 1:length(ib)))
Expand Down

0 comments on commit 40aedf2

Please sign in to comment.