Skip to content

better printing of sparse matrices? #30587

@stevengj

Description

@stevengj

Compare:

julia> A = Diagonal(rand(1000))
1000×1000 Diagonal{Float64,Array{Float64,1}}:
 0.0341907                                                        
           0.758919                                                
                    0.700876                                       
                             0.453502                              
                                                                  
                                                                 
                                                                       
                                                                  
                                                                 
                                                                  
                                         0.489115                  
                                                  0.791967         
                                                           0.164329

julia> sparse(A)
1000×1000 SparseMatrixCSC{Float64,Int64} with 1000 stored entries:
  [1   ,    1]  =  0.0341907
  [2   ,    2]  =  0.758919
  [3   ,    3]  =  0.700876
  [4   ,    4]  =  0.453502
  [5   ,    5]  =  0.560549
  [6   ,    6]  =  0.832382
  
  [995 ,  995]  =  0.270777
  [996 ,  996]  =  0.0664044
  [997 ,  997]  =  0.689441
  [998 ,  998]  =  0.489115
  [999 ,  999]  =  0.791967
  [1000, 1000]  =  0.164329

Why can't a SparseMatrixCSC be printed in the same way as the structured sparse-matrix types? It would be a heck of a lot more readable.

PS. On an unrelated note, I also notice that the SparseMatrixCSC output isn't setting the :typeinfo property of the IOContext, so it screws up e.g. #30575. Update: This is fixed by #30589.

Metadata

Metadata

Assignees

No one assigned

    Labels

    display and printingAesthetics and correctness of printed representations of objects.sparseSparse arrays

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions