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

Sparse matrix edge cases #9917

Closed
karanveerm opened this issue Jan 25, 2015 · 2 comments
Closed

Sparse matrix edge cases #9917

karanveerm opened this issue Jan 25, 2015 · 2 comments
Labels
sparse Sparse arrays
Milestone

Comments

@karanveerm
Copy link

Ref: #9750 (comment)
cc: @ViralBShah

There are a few edge cases where the behavior of sparse matrices is inconsistent with those of regular matrices:

julia> sparse([]) # works fine
0x1 sparse matrix with 0 Any entries:
julia> sparse([]') # should work fine, but doesn't
ERROR: MethodError: `zero` has no method matching zero(::Type{Any})
julia> full(sparse([]))
ERROR: MethodError: `zero` has no method matching zero(::Type{Any})

julia> bVec= []; bSparse = sparse(bVec);
julia> bVec[:1] # this error makes sense
ERROR: BoundsError: attempt to access 0-element Array{Any,1} at index [1]
 in getindex at ./array.jl:260
julia> bSparse[:1] # DivideError makes no sense- we aren't performing divison
ERROR: DivideError: integer division error
 in getindex at sparse/sparsematrix.jl:879

julia> bSparse[2:1] # this should really throw an error
0x1 sparse matrix with 0 Any entries:

julia> e=speye(100);
julia> e[-10:10] # should throw an error
21x1 sparse matrix with 1 Float64 entries:
    [12,  1]  =  1.0
julia> versioninfo()
Julia Version 0.4.0-dev+2892
Commit adc1c83 (2015-01-24 19:45 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3
@tkelman tkelman added the sparse Sparse arrays label Jan 25, 2015
@simonster
Copy link
Member

Looks like linear indexing needs the same treatment I gave 2D indexing in #9864.

@simonster
Copy link
Member

Although bSparse[2:1] shouldn't actually throw an error. That's an empty range and it should be valid to index an empty array by it (and it is, for non-sparse matrices as well).

tanmaykm added a commit to tanmaykm/julia that referenced this issue Feb 9, 2015
tanmaykm added a commit to tanmaykm/julia that referenced this issue Feb 10, 2015
tanmaykm added a commit to tanmaykm/julia that referenced this issue Feb 14, 2015
tanmaykm added a commit that referenced this issue Feb 14, 2015
@ViralBShah ViralBShah added this to the 0.4.0 milestone Mar 25, 2015
simonster added a commit that referenced this issue Jun 4, 2015
(cherry picked from commit 2fedc27)
ref #11408

Conflicts:
	base/sparse/sparsematrix.jl
	test/sparsedir/sparse.jl
mbauman pushed a commit to mbauman/julia that referenced this issue Jun 6, 2015
tkelman pushed a commit to tkelman/julia that referenced this issue Jun 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

4 participants