Skip to content

mapslices for sparse matrices is wrong #21123

@andreasnoack

Description

@andreasnoack

E.g.

julia> mapslices(nnz, speye(3), 1)
1×3 Array{Int64,2}:
 1  2  3

The problem seems to be

_unsafe_getindex!(Aslice, A, idx...)
which doesn't set structural zeros in the slice variable, e.g.

julia> Base._unsafe_getindex!(sparse(ones(3)), speye(3), 1:3, 1)
3-element SparseVector{Float64,Int64} with 3 stored entries:
  [1]  =  1.0
  [2]  =  0.0
  [3]  =  0.0

I don't know the behavior of _unsafe_getindex! should change or if mapslices should use a different function. I'm on

julia> versioninfo()
Julia Version 0.6.0-pre.alpha.180
Commit a365da4c6c* (2017-03-19 13:41 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin16.5.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT NO_AFFINITY HASWELL)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

cc: @mbauman, @timholy

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorsparseSparse arrays

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions