@@ -30,10 +30,35 @@ cols = [:red, :blue, :green, :magenta, :turqoise] # one color per alg
30
30
allmatrices_md = listnames("*/*")
31
31
32
32
@info "Total number of matrices: $(allmatrices_md.content[1].rows)"
33
+
33
34
times = fill(NaN, length(allmatrices_md.content[1].rows), length(algs))
34
35
percentage_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
35
36
spaced_out_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
36
37
matrix_size = fill(NaN, length(allmatrices_md.content[1].rows))
38
+ bandedness_five = fill(NaN, length(allmatrices_md.content[1].rows))
39
+ bandedness_ten = fill(NaN, length(allmatrices_md.content[1].rows))
40
+ bandedness_twenty = fill(NaN, length(allmatrices_md.content[1].rows))
41
+
42
+ function compute_bandedness(A, bandwidth)
43
+ n = size(A, 1)
44
+ total_band_positions = 0
45
+ non_zero_in_band = 0
46
+ bandwidth = bandwidth
47
+ for r in 1:n
48
+ for c in 1:n
49
+ if abs(r - c) <= bandwidth
50
+ total_band_positions += 1 # This position belongs to the band
51
+ if A[r, c] != 0
52
+ non_zero_in_band += 1 # This element is non-zero in the band
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ percentage_filled = non_zero_in_band / total_band_positions * 100
59
+ return percentage_filled
60
+ end
61
+
37
62
```
38
63
39
64
```julia
@@ -49,18 +74,16 @@ for z in 1:length(allmatrices_md.content[1].rows)
49
74
A = convert(SparseMatrixCSC, A)
50
75
n = size(A, 1)
51
76
52
-
53
77
mtx_copy = copy(A)
54
78
55
79
@info "$n × $n"
56
80
n > 100 && error("Skipping too large matrices")
57
81
58
-
82
+ ## COMPUTING SPACED OUT SPARSITY
59
83
rows, cols = size(mtx_copy)
60
84
new_rows = div(rows, 2)
61
85
new_cols = div(cols, 2)
62
86
condensed = zeros(Int, new_rows, new_cols)
63
-
64
87
while size(mtx_copy, 1) > 32 || size(mtx_copy, 2) > 32
65
88
66
89
rows, cols = size(mtx_copy)
@@ -73,12 +96,11 @@ for z in 1:length(allmatrices_md.content[1].rows)
73
96
block = mtx_copy[r:min(r+1, rows), c:min(c+1, cols)]
74
97
condensed[div(r-1, 2) + 1, div(c-1, 2) + 1] = (length(nonzeros(block)) >= 2) ? 1 : 0
75
98
end
76
- end
77
-
78
- mtx_copy = condensed
79
-
99
+ end
100
+ mtx_copy = condensed
80
101
end
81
102
103
+ ## COMPUTING FACTORIZATION TIME
82
104
b = rand(rng, n)
83
105
u0 = rand(rng, n)
84
106
@@ -90,9 +112,24 @@ for z in 1:length(allmatrices_md.content[1].rows)
90
112
alias_b = true))
91
113
times[z,j] = bt
92
114
end
93
- matrix_size[z] = n
115
+
116
+ bandedness_five[z] = compute_bandedness(A, 5)
117
+ bandedness_ten[z] = compute_bandedness(A, 10)
118
+ bandedness_twenty[z] = compute_bandedness(A, 20)
94
119
percentage_sparsity[z] = length(nonzeros(A)) / n^2
95
120
spaced_out_sparsity[z] = length(nonzeros(mtx_copy)) * percentage_sparsity[z]
121
+ matrix_size[z] = n
122
+
123
+ #=
124
+ p = bar(algnames, times[z, :];
125
+ ylabel = "Time/s",
126
+ yscale = :log10,
127
+ title = "Time on $(currMTX)",
128
+ fmt = :png,
129
+ legend = :outertopright)
130
+ display(p)
131
+ =#
132
+
96
133
println("successfully factorized $(currMTX)")
97
134
catch e
98
135
matrix = allmatrices_md.content[1].rows[z]
108
145
percentage_sparsity = percentage_sparsity[.!isnan.(percentage_sparsity)]
109
146
spaced_out_sparsity = spaced_out_sparsity[.!isnan.(spaced_out_sparsity)]
110
147
spaced_out_sparsity = replace(spaced_out_sparsity, 0 => 1e-10)
148
+ bandedness_five = bandedness_five[.!isnan.(bandedness_five)]
149
+ bandedness_five = replace(bandedness_five, 0 => 1e-10)
150
+ bandedness_ten = bandedness_ten[.!isnan.(bandedness_ten)]
151
+ bandedness_ten = replace(bandedness_ten, 0 => 1e-10)
152
+ bandedness_twenty = bandedness_twenty[.!isnan.(bandedness_twenty)]
153
+ bandedness_twenty = replace(bandedness_twenty, 0 => 1e-10)
111
154
matrix_size = matrix_size[.!isnan.(matrix_size)]
112
155
nanrows = any(isnan, times; dims=2)
113
156
times = times[.!vec(nanrows), :]
@@ -159,6 +202,39 @@ p = scatter(spaced_out_sparsity, times;
159
202
legend = :outertopright)
160
203
```
161
204
205
+ ```julia
206
+ p = scatter(bandedness_five, times;
207
+ ylabel = "Time/s",
208
+ yscale = :log10,
209
+ xlabel = "Bandedness",
210
+ xscale = :log10,
211
+ label = algnames_transpose,
212
+ title = "Factorization Time vs Bandedness, Bandwidth=5",
213
+ fmt = :png,
214
+ legend = :outertopright)
215
+ ```
216
+ ```julia
217
+ p = scatter(bandedness_ten, times;
218
+ ylabel = "Time/s",
219
+ yscale = :log10,
220
+ xlabel = "Bandedness",
221
+ xscale = :log10,
222
+ label = algnames_transpose,
223
+ title = "Factorization Time vs Bandedness, Bandwidth=10",
224
+ fmt = :png,
225
+ legend = :outertopright)
226
+ ```
227
+ ```julia
228
+ p = scatter(bandedness_twenty, times;
229
+ ylabel = "Time/s",
230
+ yscale = :log10,
231
+ xlabel = "Bandedness",
232
+ xscale = :log10,
233
+ label = algnames_transpose,
234
+ title = "Factorization Time vs Bandedness, Bandwidth=20",
235
+ fmt = :png,
236
+ legend = :outertopright)
237
+ ```
162
238
163
239
## Appendix
164
240
0 commit comments