Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger-luo committed Sep 16, 2021
2 parents 85874b6 + a2cf653 commit 4e48dbc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/SparseMatrixCOO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function allocated_coo(::Type{T}, M::Int, N::Int, nnz::Int) where {T}
SparseMatrixCOO{T}(undef, M, N, nnz)
end

function getindex(coo::SparseMatrixCOO{Tv,Ti}, i::Ti, j::Ti) where {Tv,Ti}
function getindex(coo::SparseMatrixCOO{Tv,Ti}, i::Integer, j::Integer) where {Tv,Ti}
res = zero(Tv)
for k = 1:nnz(coo)
if coo.is[k] == i && coo.js[k] == j
Expand Down Expand Up @@ -110,8 +110,8 @@ isdense(::SparseMatrixCOO) = false
Base.@propagate_inbounds function Base.setindex!(
coo::SparseMatrixCOO{Tv,Ti},
v,
i::Ti,
j::Ti,
i::Integer,
j::Integer,
) where {Tv,Ti}
@boundscheck (1 <= i <= coo.m) && (1 <= j <= coo.n) || throw(BoundsError(coo, (i, j)))

Expand Down
4 changes: 4 additions & 0 deletions test/SparseMatrixCOO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ end
@test coo.is[end] == 1
@test coo.js[end] == 1
@test coo.vs[end] == 0.2

S = SparseMatrixCOO{Float32, Cint}(Cint[], Cint[], Float32[], 5, 5)
S[1, 1] = 3
@test S[1, 1] == 3
end

0 comments on commit 4e48dbc

Please sign in to comment.