Skip to content

Commit

Permalink
fix col ids in DynamicSparseMartrix show function (#41)
Browse files Browse the repository at this point in the history
* fix matrix display

* mineure
  • Loading branch information
najaverzat authored Apr 21, 2023
1 parent 2b99d1f commit ee779aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ function Base.show(io::IO, matrix::DynamicSparseMatrix{K,L,T}) where {K,L,T}
#col major iteration
pma = matrix.colmajor.pcsc.pma
semaphores = matrix.colmajor.pcsc.semaphores
j = 1
col_keys = matrix.colmajor.col_keys
tmp = 0
for (index, elmt) in enumerate(pma.array)
if index in semaphores
j += 1
tmp += 1
print(io, "\n")
else
if !isnothing(elmt)
j = col_keys[tmp]
(i, value) = elmt
println(io, " [$(j), $(i)] = $(value) ")
end
Expand Down
4 changes: 2 additions & 2 deletions test/unit/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ end


function test_matrix_display()
I = [1, 2, 3, 2, 6, 7, 1, 6, 8] #rows
J = [1, 1, 1, 2, 2, 2, 3, 3, 3] #columns
I = ['a', 'a', 'a', 'b', 'b', 'c', 'd', 'd', 'd'] #rows
J = ['x', 'x', 'x', 'y', 'y', 'y', 'z', 'z', 'z'] #columns
V = [20, 30, 40, 20, 40, 50, 30, 50, 70] #value
matrix = DynamicSparseArrays.dynamicsparse(I, J, V)
@show matrix
Expand Down

0 comments on commit ee779aa

Please sign in to comment.