Skip to content

Commit 1a611dc

Browse files
committed
Fix tests
1 parent b31b1ef commit 1a611dc

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

src/aggregation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function smoothed_aggregation(A::TA,
1111
max_coarse = 10,
1212
diagonal_dominance = false,
1313
keep = false,
14-
coarse_solver = Pinv) where {T,V,bs,TA<:SparseMatrixCSC{T,V}}
14+
coarse_solver = Pinv, kwargs...) where {T,V,bs,TA<:SparseMatrixCSC{T,V}}
1515

1616
n = size(A, 1)
1717
# B = kron(ones(n, 1), eye(1))

src/classical.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function ruge_stuben(_A::Union{TA, Symmetric{Ti, TA}, Hermitian{Ti, TA}},
1515
postsmoother = GaussSeidel(),
1616
max_levels = 10,
1717
max_coarse = 10,
18-
coarse_solver = Pinv) where {Ti,Tv,bs,TA<:SparseMatrixCSC{Ti,Tv}}
18+
coarse_solver = Pinv, kwargs...) where {Ti,Tv,bs,TA<:SparseMatrixCSC{Ti,Tv}}
1919

2020
s = Solver(strength, CF, presmoother,
2121
postsmoother, max_levels, max_levels)

src/multilevel.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function _solve!(x, ml::MultiLevel, b::AbstractArray{T},
158158
reltol::Real = sqrt(eps(real(eltype(b)))),
159159
verbose::Bool = false,
160160
log::Bool = false,
161-
calculate_residual = true) where {T}
161+
calculate_residual = true, kwargs...) where {T}
162162

163163
A = length(ml) == 1 ? ml.final_A : ml.levels[1].A
164164
V = promote_type(eltype(A), eltype(b))

src/preconditioner.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function ldiv!(x, p::Preconditioner, b)
1515
else
1616
x .= b
1717
end
18-
solve!(x, p.ml, b, p.cycle, maxiter = 1, calculate_residual = false)
18+
_solve!(x, p.ml, b, p.cycle, maxiter = 1, calculate_residual = false)
1919
end
2020
mul!(b, p::Preconditioner, x) = mul!(b, p.ml.levels[1].A, x)
2121

test/runtests.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,24 @@ fsmoother = GaussSeidel(ForwardSweep())
120120
A = poisson(1000)
121121
A = float.(A)
122122
ml = ruge_stuben(A)
123-
x = solve(ml, A * ones(1000))
123+
x = AlgebraicMultigrid._solve(ml, A * ones(1000))
124124
@test sum(abs2, x - ones(1000)) < 1e-8
125125

126126
ml = ruge_stuben(A, presmoother = fsmoother,
127127
postsmoother = fsmoother)
128-
x = solve(ml, A * ones(1000))
128+
x = AlgebraicMultigrid._solve(ml, A * ones(1000))
129129
@test sum(abs2, x - ones(1000)) < 1e-8
130130

131131

132132
A = include("randlap.jl")
133133

134134
ml = ruge_stuben(A, presmoother = fsmoother,
135135
postsmoother = fsmoother)
136-
x = solve(ml, A * ones(100))
136+
x = AlgebraicMultigrid._solve(ml, A * ones(100))
137137
@test sum(abs2, x - zeros(100)) < 1e-8
138138

139139
ml = ruge_stuben(A)
140-
x = solve(ml, A * ones(100))
140+
x = AlgebraicMultigrid._solve(ml, A * ones(100))
141141
@test sum(abs2, x - zeros(100)) < 1e-6
142142

143143

@@ -155,7 +155,7 @@ p = aspreconditioner(ml)
155155
b = zeros(n)
156156
b[1] = 1
157157
b[2] = -1
158-
x = solve(p.ml, A * ones(n), maxiter = 1, abstol = 1e-12)
158+
x = AlgebraicMultigrid._solve(ml, A * ones(n), maxiter = 1, abstol = 1e-12)
159159
diff = x - [ 1.88664780e-16, 2.34982727e-16, 2.33917697e-16,
160160
8.77869044e-17, 7.16783490e-17, 1.43415460e-16,
161161
3.69199021e-17, 9.70950385e-17, 4.77034895e-17,
@@ -173,7 +173,9 @@ diff = x - [ 1.88664780e-16, 2.34982727e-16, 2.33917697e-16,
173173
-6.76965535e-16, -7.00643227e-16, -6.23581397e-16,
174174
-7.03016682e-16]
175175
@test sum(abs2, diff) < 1e-8
176-
x = solve(p.ml, b, maxiter = 1, abstol = 1e-12)
176+
x = solve(A, b, RugeStubenAMG(); presmoother = smoother,
177+
postsmoother = smoother,
178+
maxiter = 1, abstol = 1e-12)
177179
diff = x - [ 0.76347046, -0.5498286 , -0.2705487 , -0.15047352, -0.10248021,
178180
0.60292674, -0.11497073, -0.08460548, -0.06931461, 0.38230708,
179181
-0.055664 , -0.04854558, -0.04577031, 0.09964325, 0.01825624,
@@ -214,7 +216,7 @@ diff = x - [0.823762, -0.537478, -0.306212, -0.19359, -0.147621, 0.685002,
214216
0.0511691, 0.0502043, 0.0498349, 0.0498134]
215217
@test sum(abs2, diff) < 1e-8
216218

217-
x = solve(ml, b, maxiter = 1, reltol = 1e-12)
219+
x = AlgebraicMultigrid._solve(ml, b, maxiter = 1, reltol = 1e-12)
218220
diff = x - [0.775725, -0.571202, -0.290989, -0.157001, -0.106981, 0.622652,
219221
-0.122318, -0.0891874, -0.0709834, 0.392621, -0.055544, -0.0507485,
220222
-0.0466376, 0.107175, 0.0267468, -0.0200843, -0.0282827, -0.0299929,
@@ -240,7 +242,7 @@ for (T,V) in ((Float64, Float64), (Float32,Float32),
240242
ml = smoothed_aggregation(a)
241243
b = V.(b)
242244
c = cg(a, b, maxiter = 10)
243-
@test eltype(solve(ml, b)) == eltype(c)
245+
@test eltype(AlgebraicMultigrid._solve(ml, b)) == eltype(c)
244246
end
245247

246248
end
@@ -316,7 +318,7 @@ for f in (smoothed_aggregation, ruge_stuben)
316318
b = zeros(size(a,1))
317319
b[1] = 1
318320
b[2] = -1
319-
@test sum(abs2, a * solve(ml, b) - b) < 1e-10
321+
@test sum(abs2, a * AlgebraicMultigrid._solve(ml, b) - b) < 1e-10
320322
@test sum(abs2, a * cg(a, b, Pl = p, maxiter = 1000) - b) < 1e-10
321323

322324
end

0 commit comments

Comments
 (0)