@@ -30,10 +30,35 @@ cols = [:red, :blue, :green, :magenta, :turqoise] # one color per alg
3030allmatrices_md = listnames("*/*")
3131
3232@info "Total number of matrices: $(allmatrices_md.content[1].rows)"
33+
3334times = fill(NaN, length(allmatrices_md.content[1].rows), length(algs))
3435percentage_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
3536spaced_out_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
3637matrix_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+
3762```
3863
3964```julia
@@ -49,18 +74,16 @@ for z in 1:length(allmatrices_md.content[1].rows)
4974 A = convert(SparseMatrixCSC, A)
5075 n = size(A, 1)
5176
52-
5377 mtx_copy = copy(A)
5478
5579 @info "$n × $n"
5680 n > 100 && error("Skipping too large matrices")
5781
58-
82+ ## COMPUTING SPACED OUT SPARSITY
5983 rows, cols = size(mtx_copy)
6084 new_rows = div(rows, 2)
6185 new_cols = div(cols, 2)
6286 condensed = zeros(Int, new_rows, new_cols)
63-
6487 while size(mtx_copy, 1) > 32 || size(mtx_copy, 2) > 32
6588
6689 rows, cols = size(mtx_copy)
@@ -73,12 +96,11 @@ for z in 1:length(allmatrices_md.content[1].rows)
7396 block = mtx_copy[r:min(r+1, rows), c:min(c+1, cols)]
7497 condensed[div(r-1, 2) + 1, div(c-1, 2) + 1] = (length(nonzeros(block)) >= 2) ? 1 : 0
7598 end
76- end
77-
78- mtx_copy = condensed
79-
99+ end
100+ mtx_copy = condensed
80101 end
81102
103+ ## COMPUTING FACTORIZATION TIME
82104 b = rand(rng, n)
83105 u0 = rand(rng, n)
84106
@@ -90,9 +112,24 @@ for z in 1:length(allmatrices_md.content[1].rows)
90112 alias_b = true))
91113 times[z,j] = bt
92114 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)
94119 percentage_sparsity[z] = length(nonzeros(A)) / n^2
95120 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+
96133 println("successfully factorized $(currMTX)")
97134 catch e
98135 matrix = allmatrices_md.content[1].rows[z]
108145percentage_sparsity = percentage_sparsity[.!isnan.(percentage_sparsity)]
109146spaced_out_sparsity = spaced_out_sparsity[.!isnan.(spaced_out_sparsity)]
110147spaced_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)
111154matrix_size = matrix_size[.!isnan.(matrix_size)]
112155nanrows = any(isnan, times; dims=2)
113156times = times[.!vec(nanrows), :]
@@ -159,6 +202,39 @@ p = scatter(spaced_out_sparsity, times;
159202 legend = :outertopright)
160203```
161204
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+ ```
162238
163239## Appendix
164240
0 commit comments