@@ -32,6 +32,7 @@ allmatrices_md = listnames("*/*")
32
32
@info "Total number of matrices: $(allmatrices_md.content[1].rows)"
33
33
times = fill(NaN, length(allmatrices_md.content[1].rows), length(algs))
34
34
percentage_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
35
+ spaced_out_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
35
36
matrix_size = fill(NaN, length(allmatrices_md.content[1].rows))
36
37
```
37
38
@@ -47,12 +48,37 @@ for z in 1:length(allmatrices_md.content[1].rows)
47
48
A = mdopen(currMTX).A
48
49
A = convert(SparseMatrixCSC, A)
49
50
n = size(A, 1)
50
- matrix_size[z] = n
51
- percentage_sparsity[z] = length(nonzeros(A)) / n^2
52
- @info "$n × $n"
51
+
53
52
54
- n > 500 && error("Skipping too large matrices" )
53
+ mtx_copy = copy(A )
55
54
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
+
56
82
b = rand(rng, n)
57
83
u0 = rand(rng, n)
58
84
@@ -64,17 +90,9 @@ for z in 1:length(allmatrices_md.content[1].rows)
64
90
alias_b = true))
65
91
times[z,j] = bt
66
92
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]
78
96
println("successfully factorized $(currMTX)")
79
97
catch e
80
98
matrix = allmatrices_md.content[1].rows[z]
@@ -86,6 +104,13 @@ for z in 1:length(allmatrices_md.content[1].rows)
86
104
println(e)
87
105
end
88
106
end
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), :]
89
114
```
90
115
91
116
```julia
@@ -122,6 +147,18 @@ p = scatter(matrix_size, times;
122
147
legend = :outertopright)
123
148
```
124
149
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
+
125
162
126
163
## Appendix
127
164
0 commit comments