Skip to content

Commit

Permalink
Merge pull request #7651 from tanmaykm/spmatrix
Browse files Browse the repository at this point in the history
fix #7650 reshape of empty sparse matrices
  • Loading branch information
ViralBShah committed Jul 18, 2014
2 parents 4e24ab4 + fbcf8e4 commit 49ac85f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ function reinterpret{T,Tv,Ti}(::Type{T}, a::SparseMatrixCSC{Tv,Ti})
end

function sparse_compute_reshaped_colptr_and_rowval{Ti}(colptrS::Vector{Ti}, rowvalS::Vector{Ti}, mS::Int, nS::Int, colptrA::Vector{Ti}, rowvalA::Vector{Ti}, mA::Int, nA::Int)
((length(colptrA) == (nA+1)) && (maximum(colptrA) <= (length(rowvalA)+1)) && (maximum(rowvalA) <= mA)) || throw(BoundsError())
lrowvalA = length(rowvalA)
maxrowvalA = (lrowvalA > 0) ? maximum(rowvalA) : zero(Ti)
((length(colptrA) == (nA+1)) && (maximum(colptrA) <= (lrowvalA+1)) && (maxrowvalA <= mA)) || throw(BoundsError())

colptrS[1] = 1
colA = 1
Expand Down
5 changes: 5 additions & 0 deletions test/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,8 @@ end
#Issue 7507
@test (i7507=sparsevec(Dict{Int64, Float64}(), 10))==spzeros(10,1)

#Issue 7650
let S = spzeros(3, 3)
@test size(reshape(S, 9, 1)) == (9,1)
end

0 comments on commit 49ac85f

Please sign in to comment.