Skip to content

Commit

Permalink
Fix issue 4986 -- SparseMatrixCSC reinterpret bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Fox committed Nov 30, 2013
1 parent c7216f3 commit 754fb5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function reinterpret{T,Tv,Ti}(::Type{T}, a::SparseMatrixCSC{Tv,Ti})
mA, nA = size(a)
colptr = copy(a.colptr)
rowval = copy(a.rowval)
nzval = reinterpret(Tv, a.nzval)
nzval = reinterpret(T, a.nzval)
return SparseMatrixCSC{T,Ti}(mA, nA, colptr, rowval, nzval)
end

Expand Down
5 changes: 5 additions & 0 deletions test/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,8 @@ A = sparse(rowval, colval, ones(length(rowval)))
P,post = Base.LinAlg.etree(A, true)
@test P == int32([6,3,8,6,8,7,9,10,10,11,0])
@test post == int32([2,3,5,8,1,4,6,7,9,10,11])

# reinterpret issue 4986
sfe22 = speye(Float64, 2)
mfe22 = eye(Float64, 2)
@test reinterpret(Int64, sfe22) == reinterpret(Int64, mfe22)

0 comments on commit 754fb5e

Please sign in to comment.