Skip to content

Commit 0e875bb

Browse files
committed
Add tests, minor fixes
1 parent e20100e commit 0e875bb

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

src/classical.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,15 @@ function rs_direct_interpolation_pass1(S, A, splitting)
177177
m[i] = sum
178178
sum += splitting[i]
179179
end
180-
l = issymmetric(S)? Bp[n]: Bp[n] + 1
181-
for i = 1:l
180+
#@show m
181+
#@show Bj
182+
#l = issymmetric(S)? Bp[n]: Bp[n] + 1
183+
#@show l
184+
#for i = 1:l
182185
#Bj[i] == 0 && continue
183-
Bj[i] = m[Bj[i]]
184-
end
186+
# Bj[i] = m[Bj[i]]
187+
#end
188+
Bj .= m[Bj]
185189

186190
#=Ap = A.colptr
187191
Aj = A.rowval

src/multilevel.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ function Base.show(io::IO, ml::MultiLevel)
3535
str = """
3636
Multilevel Solver
3737
-----------------
38-
Operator Complexity: $op
39-
Grid Complexity: $g
40-
No. of Levels: $(size(ml.levels, 1))
38+
Operator Complexity: $(round(op, 3))
39+
Grid Complexity: $(round(g, 3))
40+
No. of Levels: $(length(ml))
4141
Coarse Solver: $c
4242
Level Unknowns NonZeros
4343
----- -------- --------

test/randlap.jld

42 KB
Binary file not shown.

test/runtests.jl

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

5+
@testset "AMG Tests" begin
6+
57
graph = load("test.jld")["G"]
68
ref_S = load("ref_S_test.jld")["G"]
79
ref_split = readdlm("ref_split_test.txt")
@@ -27,7 +29,6 @@ end
2729
# Ruge-Stuben splitting
2830
S = poisson(7)
2931
@test split_nodes(RS(), S) == [0, 1, 0, 1, 0, 1, 0]
30-
@show "buzz"
3132
srand(0)
3233
S = sprand(10,10,0.1); S = S + S'
3334
@test split_nodes(RS(), S) == [0, 1, 1, 0, 0, 0, 0, 0, 1, 1]
@@ -54,7 +55,9 @@ P, R = AMG.direct_interpolation(A, copy(A), splitting)
5455
0.0 1.0 0.0
5556
0.0 0.5 0.5
5657
0.0 0.0 1.0 ]
57-
58+
A = load("thing.jld")["G"]
59+
ml = ruge_stuben(A)
60+
@test size(ml.levels[2].A, 1) == 19
5861
end
5962

6063
@testset "Coarse Solver" begin
@@ -76,6 +79,22 @@ for i = 1:7
7679
end
7780
@test size(ml.final_A, 1) == 7
7881
@test nnz(ml.final_A) == 19
82+
83+
A = load("randlap.jld")["G"]
84+
ml = ruge_stuben(A)
85+
@test length(ml) == 3
86+
s = [100, 17]
87+
n = [2066, 289]
88+
for i = 1:2
89+
@test size(ml.levels[i].A, 1) == s[i]
90+
@test nnz(ml.levels[i].A) == n[i]
91+
end
92+
@test size(ml.final_A, 1) == 2
93+
@test nnz(ml.final_A) == 4
94+
@test round(AMG.operator_complexity(ml), 3) 1.142
95+
@test round(AMG.grid_complexity(ml), 3) 1.190
96+
97+
7998
end
8099

81100
@testset "Solver" begin
@@ -84,4 +103,12 @@ A = float.(A)
84103
ml = ruge_stuben(A)
85104
x = solve(ml, A * ones(1000))
86105
@test sum(abs2, x - ones(1000)) < 1e-10
106+
107+
A = load("randlap.jld")["G"]
108+
ml = ruge_stuben(A)
109+
x = solve(ml, A * ones(100))
110+
@test sum(abs2, x - zeros(100)) < 1e-10
111+
112+
end
113+
87114
end

0 commit comments

Comments
 (0)