Skip to content

Commit f3294de

Browse files
bug fixing
1 parent d94b888 commit f3294de

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

benchmarks/LinearSolve/MatrixDepot.jmd

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,24 @@ for z in 1:length(allmatrices_md.content[1].rows)
5151
matrix_size[z] = n
5252

5353
mtx_copy = copy(A)
54-
54+
55+
@info "$n × $n"
56+
n > 500 && error("Skipping too large matrices")
57+
58+
rows, cols = size(mtx_copy)
59+
new_rows = div(rows, 2)
60+
new_cols = div(cols, 2)
61+
condensed = zeros(Int, new_rows, new_cols)
62+
5563
while size(condensed, 1) > 32 || size(condensed, 2) > 32
5664
rows, cols = size(mtx_copy)
5765
new_rows = div(rows, 2)
5866
new_cols = div(cols, 2)
59-
condensed = zeros(Int, new_rows, new_cols)
67+
condensed = sparse(zeros(Int, new_rows, new_cols))
6068

6169
for r in 1:2:rows-1
6270
for c in 1:2:cols-1
63-
block = mtx_copy[r:r+1, c:c+1]
71+
block = sparse(mtx_copy[r:r+1, c:c+1])
6472
condensed[div(r-1, 2) + 1, div(c-1, 2) + 1] = (length(nonzeros(block)) >= 3) ? 1 : 0
6573
end
6674
end
@@ -70,11 +78,10 @@ for z in 1:length(allmatrices_md.content[1].rows)
7078

7179

7280
percentage_sparsity[z] = length(nonzeros(A)) / n^2
73-
@info "$n × $n"
74-
81+
7582
spaced_out_sparsity[z] = length(nonzeros(mtx_copy)) * percentage_sparsity[z]
7683

77-
n > 500 && error("Skipping too large matrices")
84+
7885

7986
b = rand(rng, n)
8087
u0 = rand(rng, n)
@@ -99,6 +106,8 @@ for z in 1:length(allmatrices_md.content[1].rows)
99106
println(e)
100107
end
101108
end
109+
110+
print(percentage_sparsity)
102111
```
103112

104113
```julia

0 commit comments

Comments
 (0)