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

problem of conversion from sparse matrix slice to sparse vector #14013

Closed
ghost opened this issue Nov 16, 2015 · 6 comments
Closed

problem of conversion from sparse matrix slice to sparse vector #14013

ghost opened this issue Nov 16, 2015 · 6 comments
Labels
bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays

Comments

@ghost
Copy link

ghost commented Nov 16, 2015

hello,

the conversion between sparse matrix line and sparse vecteor is not correct

julia> aa = sparse([10. 0 30.])
1x3 sparse matrix with 2 Float64 entries:
[1, 1] = 10.0
[1, 3] = 30.0

julia> full(aa[1,:])
3-element Array{Float64,1}:
10.0
30.0
0.0

the zeros coefficient has been misplaced in the sparse vector.

this happens in the development branch
Version 0.5.0-dev+1265 (2015-11-13 08:40 UTC)
Commit f045831 (0 days old master)
x86_64-linux-gnu

...and just a comment about
#13440

the direction taken by sparse arrays (matrix or vector) library is questionable in my opinion. if a line or column slice of a sparse matrix is transformed into a sparse vector, with a different internal implementation, then you will prevent people from passing slices like a[k,:] to libraries. in my opinion, more generally, the implicit conversion of matrix slices like a[k,:] or a[:,k] into vectors will reduce drastically the main quality of Julia : "it's very easy to plug algorithms between them". we will have to write special case for slices every time.

bests,
M.

@tkelman tkelman added sparse Sparse arrays bug Indicates an unexpected problem or unintended behavior labels Nov 16, 2015
@andreasnoack
Copy link
Member

cc: @mbauman

@mingsystemx Regarding your last point, then notice that you can easily get what you want with e.g. a[k:k,:].

@ghost
Copy link
Author

ghost commented Nov 16, 2015

hello,
I dont like tricks... if some day, a Julia developper says : OMG, a[k;k,:] is not converted to vector, I'll correct this bug... my code is dead.
I prefer to rely on specifications. currently I have done something like this :
git checkout v0.4.1
actually, I found this bug by mistake :) I forgot to checkout the stable release after cloning julia.git !
bests,
M.

@nalimilan
Copy link
Member

@mingsystemx a[k:k,:] is not a trick, that's the documented behavior.

@ViralBShah
Copy link
Member

This is a much discussed point, and the behaviour for sparse is now consistent with the dense behaviour.

@ghost
Copy link
Author

ghost commented Nov 16, 2015

ok, this is the following rule : Trailing dimensions indexed with scalars are dropped
http://docs.julialang.org/en/release-0.4/manual/arrays/

@nalimilan
Copy link
Member

In 0.5, this rule changes: now all dimensions indexed with a scalar are dropped.

mbauman added a commit that referenced this issue Nov 16, 2015
zhmz90 pushed a commit to zhmz90/julia that referenced this issue Nov 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

4 participants