Hey, I have 2 questions regarding displaying SparseArrays.
(1) When using SparseArrays
the code
n=15; x=sprand(Float16,n,n,0.3); x.nzval .=1; display(x)
produces
15×15 SparseMatrixCSC{Float16, Int64} with 67 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 ⋅
1.0 ⋅ ⋅ ⋅ ⋅ 1.0 ⋅ ⋅ 1.0 ⋅ ⋅ ⋅ 1.0 ⋅ ⋅
⋅ 1.0 ⋅ 1.0 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0 ⋅ ⋅ 1.0
⋅ ⋅ 1.0 ⋅ 1.0 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0 1.0 1.0 ⋅
1.0 ⋅ 1.0 1.0 ⋅ ⋅ ⋅ ⋅ 1.0 1.0 ⋅ 1.0 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 1.0 ⋅ ⋅ ⋅ ⋅ 1.0 1.0 1.0 1.0 1.0 1.0 ⋅
⋅ 1.0 1.0 1.0 ⋅ ⋅ ⋅ 1.0 1.0 ⋅ ⋅ 1.0 ⋅ ⋅ ⋅
⋅ 1.0 ⋅ ⋅ 1.0 1.0 ⋅ ⋅ ⋅ ⋅ 1.0 ⋅ ⋅ ⋅ 1.0
⋅ ⋅ ⋅ ⋅ 1.0 ⋅ 1.0 ⋅ 1.0 1.0 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 1.0 ⋅ ⋅ ⋅ 1.0 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
1.0 ⋅ 1.0 ⋅ ⋅ ⋅ 1.0 ⋅ ⋅ ⋅ ⋅ ⋅ 1.0 ⋅ 1.0
⋅ ⋅ ⋅ ⋅ 1.0 1.0 ⋅ ⋅ 1.0 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0 ⋅ 1.0 1.0 1.0 ⋅ ⋅
However, changing to n=16
gives
16×16 SparseMatrixCSC{Float16, Int64} with 82 stored entries:
⎡⢹⠤⢀⠥⠉⠎⠈⣱⎤
⎢⡘⠅⠍⠂⠀⠑⠣⠠⎥
⎢⡤⠊⡦⣀⢘⠴⣠⠖⎥
⎣⣐⠹⠈⠐⡏⡅⢀⠛⎦
When working on a bigger 4K screen, this is unsatisfactory. How can I customize the display, so that I set the max number of rows/columns to either some specific numbers, or to screen/terminal height/width?
I do not wish to convert to a dense matrix, since the .
are useful to immediately see the zeros. With dense matrices, the width and height of the screen/terminal is correctly detected, and truncation is done only after that width/height is crossed.
(2) How could I display sparse arrays larger than the threshold? In Mathematica, this is doable (though it is viewed as a dense matrix):
At the bottom, you can see the slider, and you can use it to inspect the whole matrix.