@@ -32,6 +32,7 @@ allmatrices_md = listnames("*/*")
3232@info "Total number of matrices: $(allmatrices_md.content[1].rows)"
3333times = fill(NaN, length(allmatrices_md.content[1].rows), length(algs))
3434percentage_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
35+ spaced_out_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
3536matrix_size = fill(NaN, length(allmatrices_md.content[1].rows))
3637```
3738
@@ -47,12 +48,37 @@ for z in 1:length(allmatrices_md.content[1].rows)
4748 A = mdopen(currMTX).A
4849 A = convert(SparseMatrixCSC, A)
4950 n = size(A, 1)
50- matrix_size[z] = n
51- percentage_sparsity[z] = length(nonzeros(A)) / n^2
52- @info "$n × $n"
51+
5352
54- n > 500 && error("Skipping too large matrices" )
53+ mtx_copy = copy(A )
5554
55+ @info "$n × $n"
56+ n > 100 && error("Skipping too large matrices")
57+
58+
59+ rows, cols = size(mtx_copy)
60+ new_rows = div(rows, 2)
61+ new_cols = div(cols, 2)
62+ condensed = zeros(Int, new_rows, new_cols)
63+
64+ while size(mtx_copy, 1) > 32 || size(mtx_copy, 2) > 32
65+
66+ rows, cols = size(mtx_copy)
67+ new_rows = div(rows, 2)
68+ new_cols = div(cols, 2)
69+ condensed = sparse(zeros(Int, new_rows, new_cols))
70+
71+ for r in 1:2:rows-1
72+ for c in 1:2:cols-1
73+ block = mtx_copy[r:min(r+1, rows), c:min(c+1, cols)]
74+ condensed[div(r-1, 2) + 1, div(c-1, 2) + 1] = (length(nonzeros(block)) >= 2) ? 1 : 0
75+ end
76+ end
77+
78+ mtx_copy = condensed
79+
80+ end
81+
5682 b = rand(rng, n)
5783 u0 = rand(rng, n)
5884
@@ -64,17 +90,9 @@ for z in 1:length(allmatrices_md.content[1].rows)
6490 alias_b = true))
6591 times[z,j] = bt
6692 end
67-
68- #=
69- p = bar(algnames, times[z, :];
70- ylabel = "Time/s",
71- yscale = :log10,
72- title = "Time on $(currMTX)",
73- fmt = :png,
74- legend = :outertopright)
75- display(p)
76- =#
77-
93+ matrix_size[z] = n
94+ percentage_sparsity[z] = length(nonzeros(A)) / n^2
95+ spaced_out_sparsity[z] = length(nonzeros(mtx_copy)) * percentage_sparsity[z]
7896 println("successfully factorized $(currMTX)")
7997 catch e
8098 matrix = allmatrices_md.content[1].rows[z]
@@ -86,6 +104,13 @@ for z in 1:length(allmatrices_md.content[1].rows)
86104 println(e)
87105 end
88106end
107+
108+ percentage_sparsity = percentage_sparsity[.!isnan.(percentage_sparsity)]
109+ spaced_out_sparsity = spaced_out_sparsity[.!isnan.(spaced_out_sparsity)]
110+ spaced_out_sparsity = replace(spaced_out_sparsity, 0 => 1e-10)
111+ matrix_size = matrix_size[.!isnan.(matrix_size)]
112+ nanrows = any(isnan, times; dims=2)
113+ times = times[.!vec(nanrows), :]
89114```
90115
91116```julia
@@ -122,6 +147,18 @@ p = scatter(matrix_size, times;
122147 legend = :outertopright)
123148```
124149
150+ ```julia
151+ p = scatter(spaced_out_sparsity, times;
152+ ylabel = "Time/s",
153+ yscale = :log10,
154+ xlabel = "Spaced Out Sparsity",
155+ xscale = :log10,
156+ label = algnames_transpose,
157+ title = "Factorization Time vs Spaced Out Sparsity",
158+ fmt = :png,
159+ legend = :outertopright)
160+ ```
161+
125162
126163## Appendix
127164
0 commit comments