Skip to content

Commit 6edacc3

Browse files
committed
Fix splitting, add a test
1 parent 8df35c9 commit 6edacc3

File tree

5 files changed

+119
-19
lines changed

5 files changed

+119
-19
lines changed

src/splitting.jl

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ function RS_CF_splitting(S::SparseMatrixCSC)
5454
splitting[i] = F_NODE
5555
end
5656
end
57-
@show lambda
58-
@show interval_ptr
59-
@show interval_count
60-
@show node_to_index
61-
@show index_to_node
6257

6358
for top_index = n_nodes:-1:1
6459
i = index_to_node[top_index]
@@ -69,24 +64,19 @@ function RS_CF_splitting(S::SparseMatrixCSC)
6964
else
7065
@assert splitting[i] == U_NODE
7166
splitting[i] = C_NODE
72-
for j in nzrange(T, i)
73-
row = T.rowval[j]
67+
for j in nzrange(S, i)
68+
row = S.rowval[j]
7469
if splitting[row] == U_NODE
7570
splitting[row] = F_NODE
7671

77-
for k in nzrange(S, row)
78-
rowk = S.rowval[k]
79-
@show rowk
80-
if rowk == 83
81-
@show S[:, row]
82-
@show T[:, row]
83-
end
72+
for k in nzrange(T, row)
73+
rowk = T.rowval[k]
74+
8475
if splitting[rowk] == U_NODE
8576
lambda[rowk] >= n_nodes - 1 && continue
8677
lambda_k = lambda[rowk] + 1
8778
old_pos = node_to_index[rowk]
8879
new_pos = interval_ptr[lambda_k] + interval_count[lambda_k]# - 1
89-
@show new_pos
9080

9181
node_to_index[index_to_node[old_pos]] = new_pos
9282
node_to_index[index_to_node[new_pos]] = old_pos
@@ -103,8 +93,9 @@ function RS_CF_splitting(S::SparseMatrixCSC)
10393
end
10494
end
10595
end
106-
for j in nzrange(S, i)
107-
row = S.rowval[j]
96+
97+
for j in nzrange(T, i)
98+
row = T.rowval[j]
10899
if splitting[row] == U_NODE
109100

110101
lambda[row] == 0 && continue

test/ref_S_test.jld

32.5 KB
Binary file not shown.

test/ref_split_test.txt

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
0
2+
0
3+
1
4+
0
5+
0
6+
1
7+
0
8+
0
9+
0
10+
0
11+
0
12+
1
13+
0
14+
0
15+
0
16+
0
17+
0
18+
0
19+
0
20+
0
21+
0
22+
0
23+
0
24+
0
25+
0
26+
0
27+
0
28+
0
29+
0
30+
0
31+
0
32+
0
33+
1
34+
0
35+
1
36+
1
37+
0
38+
1
39+
0
40+
0
41+
1
42+
0
43+
1
44+
0
45+
0
46+
0
47+
0
48+
0
49+
0
50+
0
51+
0
52+
1
53+
0
54+
0
55+
0
56+
0
57+
0
58+
0
59+
0
60+
0
61+
0
62+
1
63+
0
64+
0
65+
1
66+
1
67+
0
68+
0
69+
0
70+
0
71+
0
72+
0
73+
0
74+
0
75+
0
76+
0
77+
0
78+
0
79+
0
80+
0
81+
0
82+
0
83+
0
84+
0
85+
0
86+
0
87+
0
88+
0
89+
0
90+
1
91+
0
92+
1
93+
0
94+
1
95+
0
96+
0
97+
0
98+
0
99+
1
100+
0

test/runtests.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@ using AMG
22
using Base.Test
33
using JLD
44

5+
graph = load("test.jld")["G"]
6+
ref_S = load("ref_S_test.jld")["G"]
7+
ref_split = readdlm("ref_split_test.txt")
8+
59
@testset "Strength of connection" begin
610

711
# classical strength of connection
812
A = poisson(5)
9-
X = strength_of_connection(Classical(0.2), A)
10-
@test full(X) == [ 1.0 0.5 0.0 0.0 0.0
13+
S = strength_of_connection(Classical(0.2), A)
14+
@test full(S) == [ 1.0 0.5 0.0 0.0 0.0
1115
0.5 1.0 0.5 0.0 0.0
1216
0.0 0.5 1.0 0.5 0.0
1317
0.0 0.0 0.5 1.0 0.5
1418
0.0 0.0 0.0 0.5 1.0 ]
19+
S = strength_of_connection(Classical(0.25), graph)
20+
diff = S - ref_S
21+
@test maximum(diff) < 1e-10
1522

1623
end
1724

@@ -31,6 +38,8 @@ S = AMG.strength_of_connection(AMG.Classical(0.25), a)
3138
0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0,
3239
1, 0]
3340

41+
@test split_nodes(RS(), ref_S) == Int.(vec(ref_split))
42+
3443
end
3544

3645
@testset "Interpolation" begin

test/test.jld

40.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)