生成稀疏数组
using SparseArrays
A = sparse([1, 1, 2, 3], [1, 3, 2, 3], [0, 1, 2, 0])
3×3 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
0 ⋅ 1
⋅ 2 ⋅
⋅ ⋅ 0
nonzeros(A)
4-element Vector{Int64}:
0
2
1
0
A=sparse([0.0 0.0 1.0;
0.0 2.0 0.0;
0 0 0.0 ])
nonzeros(A)
2-element Vector{Float64}:
2.0
1.0
spzeros(2,3)
2×3 SparseMatrixCSC{Float64, Int64} with 0 stored entries:
⋅ ⋅ ⋅
⋅ ⋅ ⋅
sprand(Bool, 2, 3, 0.5)
2×3 SparseMatrixCSC{Bool, Int64} with 3 stored entries:
1 ⋅ ⋅
1 ⋅ 1
sprand(Float64, 2,3, 0.25)
2×3 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
⋅ 0.114653 ⋅
⋅ 0.584111 ⋅
sprandn(Float64, 2,3, 0.25)
2×3 SparseMatrixCSC{Float64, Int64} with 1 stored entry:
⋅ ⋅ ⋅
⋅ 1.58349 ⋅
spdiagm([1,2,3])
3×3 SparseMatrixCSC{Int64, Int64} with 3 stored entries:
1 ⋅ ⋅
⋅ 2 ⋅
⋅ ⋅ 3
blockdiag(sprand(3,3,0.25), sprand(2,2,0.75))

868

被折叠的 条评论
为什么被折叠?



