If I construct a sparse matrix on the REPL, it can directly display the distribution of non-zero elements of the matrix:
julia> using SparseArrays
julia> sparse(round.(rand(5,5)))
5×5 SparseMatrixCSC{Float64, Int64} with 12 stored entries:
1.0 ⋅ 1.0 ⋅ 1.0
⋅ ⋅ ⋅ 1.0 ⋅
1.0 1.0 1.0 1.0 1.0
⋅ 1.0 ⋅ 1.0 ⋅
⋅ ⋅ ⋅ ⋅ 1.0
Now I want to construct a sparse matrix in a .jl
script and display it when run the script, for example:
using SparseArrays
a = sparse(round.(rand(5,5)))
println("The sparse matrix is:")
# Print the non-zero elements' distribution on the REPL. How to write?
println("Over.")
How to write?