Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a row-indexing bug with sparse matrices that have non-Int indices #18022

Merged
merged 3 commits into from
Aug 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions base/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ function Base.getindex{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, i::Integer, J::Abstract
@inbounds for j = 1:nJ
col = J[j]
rowI = i
ptrA = colptrA[col]
stopA = colptrA[col+1]-1
ptrA = Int(colptrA[col])
stopA = Int(colptrA[col+1]-1)
if ptrA <= stopA
if rowvalA[ptrA] <= rowI
ptrA = searchsortedfirst(rowvalA, rowI, ptrA, stopA, Base.Order.Forward)
Expand Down
6 changes: 1 addition & 5 deletions test/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ all: micro kernel cat shootout blas lapack simd sort spell sparse

micro kernel cat shootout blas lapack simd sort spell sparse:
@$(MAKE) $(QUIET_MAKE) -C $(SRCDIR)/shootout
ifneq ($(OS),WINNT)
@$(call spawn,$(JULIA_EXECUTABLE)) $(SRCDIR)/$@/perf.jl | perl -nle '@_=split/,/; printf "%-18s %8.3f %8.3f %8.3f %8.3f\n", $$_[1], $$_[2], $$_[3], $$_[4], $$_[5]'
else
@$(call spawn,$(JULIA_EXECUTABLE)) $(SRCDIR)/$@/perf.jl 2> /dev/null
endif
@$(call spawn,$(JULIA_EXECUTABLE)) $(call cygpath_w,$(SRCDIR)/$@/perf.jl) | perl -nle '@_=split/,/; printf "%-18s %8.3f %8.3f %8.3f %8.3f\n", $$_[1], $$_[2], $$_[3], $$_[4], $$_[5]'

codespeed:
@$(MAKE) $(QUIET_MAKE) -C $(SRCDIR)/shootout
Expand Down
8 changes: 4 additions & 4 deletions test/perf/shootout/fasta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const IA = 3877.0
const IC = 29573.0

function gen_random()
global rng_state::Float64 = ((rng_state::Float64 * IA + IC) % IM) / IM
global rng_state = ((rng_state::Float64 * IA + IC) % IM) / IM
end
function repeat_fasta(src, n)
k = length(src)
Expand Down Expand Up @@ -55,7 +55,7 @@ end

rng_state = 42.0
function fasta(n=25000000)
repeat_fasta(alu, 2n)
random_fasta(iub1, iub2, 3n)
random_fasta(homosapiens1, homosapiens2, 5n)
repeat_fasta(alu, 2n)
random_fasta(iub1, iub2, 3n)
random_fasta(homosapiens1, homosapiens2, 5n)
end
5 changes: 5 additions & 0 deletions test/sparsedir/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1588,3 +1588,8 @@ end

# Test temporary fix for issue #16548 in PR #16979. Brittle. Expect to remove with `\` revisions.
@test which(\, (SparseMatrixCSC, AbstractVecOrMat)).module == Base.SparseArrays

# Row indexing a SparseMatrixCSC with non-Int integer type
let A = sparse(UInt32[1,2,3], UInt32[1,2,3], [1.0,2.0,3.0])
@test A[1,1:3] == A[1,:] == [1,0,0]
end