Skip to content

Commit 83f5f62

Browse files
committed
make it work for all combinations of precisions
1 parent dc97433 commit 83f5f62

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/classical.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function rs_direct_interpolation_pass1(T, A, splitting)
8282
splitting::Vector{Ti},
8383
Bp::Vector{Ti}) where {Tv,Ti}
8484

85-
85+
8686
Bx = zeros(Tv, Bp[end] - 1)
8787
Bj = zeros(Ti, Bp[end] - 1)
8888

src/multilevel.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ function solve{T}(ml::MultiLevel, b::Vector{T},
6666
tol = 1e-5;
6767
verbose = false,
6868
log = false)
69-
x = zeros(T, size(b))
70-
residuals = Vector{T}()
69+
V = promote_type(eltype(ml.levels[1].A), eltype(b))
70+
x = zeros(V, size(b))
71+
tol = eltype(b)(tol)
72+
residuals = Vector{V}()
7173
A = length(ml) == 1 ? ml.final_A : ml.levels[1].A
7274
normb = norm(b)
7375
if normb != 0
@@ -91,14 +93,14 @@ function solve{T}(ml::MultiLevel, b::Vector{T},
9193
return x
9294
end
9395
end
94-
function __solve{T}(v::V, ml, x::Vector{T}, b::Vector{T}, lvl)
96+
function __solve(v::V, ml, x, b, lvl)
9597

9698
A = ml.levels[lvl].A
9799
presmoother!(ml.presmoother, A, x, b)
98100

99101
res = b - A * x
100102
coarse_b = ml.levels[lvl].R * res
101-
coarse_x = zeros(T, size(coarse_b))
103+
coarse_x = zeros(eltype(coarse_b), size(coarse_b))
102104

103105
if lvl == length(ml.levels)
104106
coarse_x = coarse_solver(ml.coarse_solver, ml.final_A, coarse_b)
@@ -113,5 +115,4 @@ function __solve{T}(v::V, ml, x::Vector{T}, b::Vector{T}, lvl)
113115
x
114116
end
115117

116-
coarse_solver{Tv,Ti}(::Pinv, A::SparseMatrixCSC{Tv,Ti}, b::Vector{Tv}) =
117-
pinv(full(A)) * b
118+
coarse_solver(::Pinv, A, b) = pinv(full(A)) * b

src/smoother.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ smoother!(s::GaussSeidel, ::BackwardSweep, A, x, b) =
3232
gs!(A, b, x, size(A,1), -1, 1)
3333

3434

35-
function gs!{T,Ti}(A::SparseMatrixCSC{T,Ti}, b::Vector{T}, x::Vector{T}, start, step, stop)
35+
function gs!(A, b, x, start, step, stop)
3636
n = size(A, 1)
3737
z = zero(eltype(A))
3838
for i = start:step:stop

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ end
5151
# Direct Interpolation
5252
using AMG
5353
A = poisson(5)
54+
A = Float64.(A)
5455
splitting = [1,0,1,0,1]
5556
P, R = AMG.direct_interpolation(A, copy(A), splitting)
5657
@test P == [ 1.0 0.0 0.0

0 commit comments

Comments
 (0)