4848show (io:: IO , S:: SparseMatrixCSR ) = show (convert (IOContext, io), S:: SparseMatrixCSR )
4949# show(io::IOContext, S::SparseMatrixCSR) = dump(S)
5050
51- function Base . show (io:: IOContext , S:: SparseMatrixCSR )
51+ function show (io:: IOContext , S:: SparseMatrixCSR{Bi} ) where {Bi}
5252 nnz (S) == 0 && return show (io, MIME (" text/plain" ), S)
5353
5454 ioc = IOContext (io, :compact => true )
5555 function _format_line (r, col, padr, padc)
56- print (ioc, " \n [" , rpad (S . colval[r] , padr), " , " , lpad (col , padc), " ] = " )
56+ print (ioc, " \n [" , rpad (col , padr), " , " , lpad (S . colval[r] , padc), " ] = " )
5757 if isassigned (S. nzval, Int (r))
5858 show (ioc, S. nzval[r])
5959 else
@@ -75,17 +75,17 @@ function Base.show(io::IOContext, S::SparseMatrixCSR)
7575
7676 rows = displaysize (io)[1 ] - 4 # -4 from [Prompt, header, newline after elements, new prompt]
7777 if ! get (io, :limit , false ) || rows >= nnz (S) # Will the whole matrix fit when printed?
78- cols = _get_cols (1 , nnz (S))
78+ cols = _get_cols (Bi , nnz (S)+ S . offset )
7979 padr, padc = ndigits .((maximum (S. colval[1 : nnz (S)]), cols[end ]))
80- _format_line .(1 : nnz (S), cols, padr, padc)
80+ _format_line .(1 : nnz (S), cols.+ S . offset , padr, padc)
8181 else
8282 if rows <= 2
8383 print (io, " \n \u 22ee" )
8484 return
8585 end
8686 s1, e1 = 1 , div (rows - 1 , 2 ) # -1 accounts for \vdots
8787 s2, e2 = nnz (S) - (rows - 1 - e1) + 1 , nnz (S)
88- cols1, cols2 = _get_cols (s1, e1), _get_cols (s2, e2)
88+ cols1, cols2 = _get_cols (s1+ S . offset , e1+ S . offset ), _get_cols (s2+ S . offset , e2+ S . offset )
8989 padr = ndigits (max (maximum (S. colval[s1: e1]), maximum (S. colval[s2: e2])))
9090 padc = ndigits (cols2[end ])
9191 _format_line .(s1: e1, cols1, padr, padc)
0 commit comments