Skip to content

Commit

Permalink
fix show matrix (#49)
Browse files Browse the repository at this point in the history
* fix show matrix

* throw
  • Loading branch information
guimarqu authored Sep 28, 2023
1 parent 09a3c60 commit 12a3994
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,16 @@ function Base.show(io::IO, matrix::DynamicSparseMatrix{K,L,T}) where {K,L,T}
pma = matrix.colmajor.pcsc.pma
semaphores = matrix.colmajor.pcsc.semaphores
col_keys = matrix.colmajor.col_keys
tmp = 0
j = nothing
for (index, elmt) in enumerate(pma.array)
if index in semaphores
tmp += 1
print(io, "\n")
else
if !isnothing(elmt)
j = col_keys[tmp]
(i, value) = elmt
println(io, " [$(j), $(i)] = $(value) ")
end
end
end
# TODO: improve performance because a semaphore has a special value so we don't
# need to call findfirst when elmt is not a semaphore.
sem_pos = findfirst(x -> x == index, semaphores)
if !isnothing(sem_pos)
j = col_keys[sem_pos]
elseif !isnothing(elmt)
(i, value) = elmt
println(io, " [$(i), $(j)] = $(value) ")
end
end
end
2 changes: 1 addition & 1 deletion src/pcsr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ end

function deletecolumn!(mpcsc::MappedPackedCSC{K,L,T}, col::L) where {K,L,T}
col_pos, col_key = find(mpcsc.col_keys, col)
col_key != col && throws(ArgumentError("column $(col) does not exist."))
col_key != col && throw(ArgumentError("column $(col) does not exist."))
mpcsc.col_keys[col_pos] = nothing
deletepartition!(mpcsc.pcsc, col_pos)
return true
Expand Down

0 comments on commit 12a3994

Please sign in to comment.