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

Indexing into sparse vectors #7170

Closed
karanveerm opened this issue Jun 8, 2014 · 1 comment
Closed

Indexing into sparse vectors #7170

karanveerm opened this issue Jun 8, 2014 · 1 comment

Comments

@karanveerm
Copy link

a=spzeros(4, 1);
a[1:2]
ERROR: no method similar(SparseMatrixCSC{Float64,Int64}, Type{Float64}, (Int64,))
 in getindex at abstractarray.jl:364

a[1:3] = 2
ERROR: no method setindex!(SparseMatrixCSC{Float64,Int64}, Int64, UnitRange{Int64})

Now, of course a[1:2, :] works. However, if I can do a=zeros(4, 1); a[1:2], I'd argue the behavior should be consistent for sparse matrices as well.

I'm on Julia Version 0.3.0-prerelease+3461
Commit c79c2ba* (2014-06-04 06:19 UTC)

@tanmaykm
Copy link
Member

tanmaykm commented Jun 8, 2014

Should be available now with #7047

julia> a=spzeros(4, 1);

julia> a[1:2]
2x1 sparse matrix with 0 Float64 entries:

julia> a[1:3] = 2
2

julia> a
4x1 sparse matrix with 3 Float64 entries:
    [1, 1]  =  2.0
    [2, 1]  =  2.0
    [3, 1]  =  2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants