版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mifangdebaise/article/details/83245749
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