SuiteSparseGraphBLAS.jl
SuiteSparseGraphBLAS.jl copied to clipboard
use SparseArrays machinery for printing
Types here could hookup into SparseArrays show implementation for a nice printing.
julia> using SparseArrays, SuiteSparseGraphBLAS
julia> x = sprand(10, 10, 0.5)
10×10 SparseMatrixCSC{Float64, Int64} with 39 stored entries:
⋅ 0.359801 ⋅ ⋅ ⋅ ⋅ ⋅ 0.579892 0.592154 0.088285
⋅ ⋅ ⋅ 0.522135 ⋅ 0.840658 0.561799 0.158865 ⋅ ⋅
⋅ 0.84019 ⋅ ⋅ 0.189342 ⋅ ⋅ ⋅ 0.889942 0.435336
⋅ ⋅ 0.793216 0.0387143 0.295225 ⋅ ⋅ 0.159388 0.97282 0.630283
0.06779 0.784768 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.71467 ⋅
⋅ 0.452141 0.5673 ⋅ ⋅ 0.497747 0.892377 ⋅ 0.624008 ⋅
⋅ 0.461338 ⋅ ⋅ 0.0744113 ⋅ ⋅ ⋅ 0.817912 ⋅
⋅ 0.685151 ⋅ ⋅ ⋅ 0.4771 ⋅ ⋅ ⋅ 0.110999
⋅ ⋅ 0.671881 ⋅ ⋅ ⋅ 0.848146 0.205909 ⋅ ⋅
⋅ 0.775386 ⋅ ⋅ 0.453898 ⋅ 0.76114 ⋅ ⋅ 0.478859
julia> GBMatrix(x)
10x10 GraphBLAS double matrix, bitmap by col
39 entries, memory: 1.1 KB
(5,1) 0.06779
(1,2) 0.359801
(3,2) 0.84019
(5,2) 0.784768
(6,2) 0.452141
(7,2) 0.461338
(8,2) 0.685151
(10,2) 0.775386
(4,3) 0.793216
(6,3) 0.5673
(9,3) 0.671881
(2,4) 0.522135
(4,4) 0.0387143
(3,5) 0.189342
(4,5) 0.295225
(7,5) 0.0744113
(10,5) 0.453898
(2,6) 0.840658
(6,6) 0.497747
(8,6) 0.4771
(2,7) 0.561799
(6,7) 0.892377
(9,7) 0.848146
(10,7) 0.76114
(1,8) 0.579892
(2,8) 0.158865
(4,8) 0.159388
(9,8) 0.205909
(1,9) 0.592154
...
This is what CUSPARSE types do in CUDA.jl https://github.com/JuliaGPU/CUDA.jl/blob/583b948ef4f1ab739047d19e7f65657a354ec28b/lib/cusparse/array.jl#L503
julia> using SparseArrays, CUDA
julia> x = sprand(3,3,0.5)
3×3 SparseMatrixCSC{Float64, Int64} with 7 stored entries:
⋅ 0.662806 0.34835
0.422577 0.0506328 0.932217
⋅ 0.649229 0.753374
julia> xd = x |> cu
3×3 CUDA.CUSPARSE.CuSparseMatrixCSC{Float32, Int32} with 7 stored entries:
⋅ 0.66280556 0.34835035
0.4225766 0.050632793 0.9322167
⋅ 0.649229 0.7533741
Yep I plan on doing this soon, thanks for the pointer on CuSparseMatrixCSC that will help.