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

make sparsevec preserve zeros #15584

Merged
merged 1 commit into from
Apr 17, 2016
Merged

Conversation

KristofferC
Copy link
Sponsor Member

After #15242 there is a mismatch between the constructors of sparse matrices / sparse vectors whether they preserve values in the sparse structure that happened to accumulate to zero.

Currently, matrices keeps them while vectors remove them:

julia> sparsevec([1,2,3], [0.0, 1.0, 2.0])
Sparse vector of length 3, with 2 Float64 nonzero entries:
  [2]  =  1.0
  [3]  =  2.0


julia> sparse([1, 2, 3], [1, 1, 1], [0.0, 1.0, 2.0])
3x1 sparse matrix with 3 Float64 entries:
    [1, 1]  =  0.0
    [2, 1]  =  1.0
    [3, 1]  =  2.0

This makes sparse vectors behave the same as matrices:

julia> sparsevec([1,2,3], [0.0, 1.0, 2.0])
Sparse vector of length 3, with 3 Float64 nonzero entries:
  [1]  =  0.0
  [2]  =  1.0
  [3]  =  2.0

@ViralBShah ViralBShah added the sparse Sparse arrays label Mar 22, 2016
@KristofferC
Copy link
Sponsor Member Author

Bump.

@KristofferC
Copy link
Sponsor Member Author

bump

@tkelman tkelman merged commit 54625f5 into JuliaLang:master Apr 17, 2016
@KristofferC KristofferC deleted the sparse_vec_zeros branch April 17, 2016 17:11
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

Successfully merging this pull request may close these issues.

3 participants