You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia> m =10# Number rows10
julia> n =10# Number columns10
julia> nz =floor(Int, m *1.5) # Number of non-zero elements15
julia> rowptr =vcat(sort!(rand(0:nz, m)), nz);
julia> colval =rand(0:(n-1), nz);
julia> nzval =randn(nz);
julia> A =SparseMatrixCSR{0}(m, n, rowptr, colval, nzval)
10×10 SparseMatrixCSR{0, Float64, Int64} with 15 stored entries:
[1, 5] =0.48371
[2, 3] =1.72291
[3, 8] =0.707065
[3, 5] =0.622569
[3, 7] =1.57136
[4, 8] =-0.262692
[4, 5] =-0.00643953
[5, 6] =-1.15259
[6, 3] =0.0652688
[6, 2] =1.02735
[7, 2] =0.169683
[9, 6] =-0.648538
[9, 4] =-0.647156
[10, 6] =-1.28313
[10, 7] =0.116641
julia> A[1:3, :]
3×10 Matrix{Float64}:0.00.00.00.00.483710.00.00.00.00.00.00.01.722910.00.00.00.00.00.00.00.00.00.00.00.00.01.571360.00.00.0
This isn't very convenient, especially since this data structure should allow having a compact representation of a slice of rows. The standard SparseMatrixCSC has compact slicing for both rows and columns:
julia> B =sprandn(rng, 10, 10, 0.2)
10×10 SparseMatrixCSC{Float64, Int64} with 19 stored entries:⋅⋅⋅⋅-0.06841670.0414316⋅⋅1.79099⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅0.451416⋅⋅⋅⋅⋅0.245215⋅⋅⋅⋅⋅-0.880614-0.149248⋅⋅⋅⋅⋅⋅⋅⋅⋅-0.673498⋅⋅⋅⋅⋅-0.48382⋅⋅⋅⋅⋅⋅⋅-0.679016-1.93712-0.468799⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅0.04426010.0607505⋅⋅⋅⋅⋅⋅⋅⋅-0.839911⋅⋅⋅⋅⋅⋅⋅0.7159190.151704⋅⋅⋅⋅⋅-1.836680.267189⋅⋅⋅
julia> B[1:3, :]
3×10 SparseMatrixCSC{Float64, Int64} with 5 stored entries:⋅⋅⋅⋅-0.06841670.0414316⋅⋅1.79099⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅0.451416⋅⋅⋅⋅⋅0.245215⋅⋅⋅⋅
julia> B[:, 1:3]
10×3 SparseMatrixCSC{Float64, Int64} with 6 stored entries:⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅-0.880614-0.149248⋅⋅-0.673498⋅⋅⋅⋅⋅⋅0.04426010.0607505⋅-0.839911⋅⋅⋅⋅⋅
The text was updated successfully, but these errors were encountered:
This isn't very convenient, especially since this data structure should allow having a compact representation of a slice of rows. The standard
SparseMatrixCSC
has compact slicing for both rows and columns:The text was updated successfully, but these errors were encountered: