Julia 稀疏矩阵转稠密矩阵

julia> using LinearAlgebra

julia> @which I
LinearAlgebra

julia> S = spdiagm(-1 => -ones(2), 1 => -ones(2)) + sparse(2I, 2+1, 2+1)
3×3 SparseMatrixCSC{Float64,Int64} with 7 stored entries:
  [1, 1]  =  2.0
  [2, 1]  =  -1.0
  [1, 2]  =  -1.0
  [2, 2]  =  2.0
  [3, 2]  =  -1.0
  [2, 3]  =  -1.0
  [3, 3]  =  2.0

julia> Array(S)
3×3 Array{Float64,2}:
  2.0  -1.0   0.0
 -1.0   2.0  -1.0
  0.0  -1.0   2.0

你可能感兴趣的:(Julia)