Skip to content

Commit 44350e7

Browse files
committed
Remove some dead code
1 parent 4b10e46 commit 44350e7

File tree

8 files changed

+29
-75
lines changed

8 files changed

+29
-75
lines changed

Project.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ uuid = "2169fc97-5a83-5252-b627-83903c6c433c"
44
[deps]
55
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
66
CompatHelper = "aa819f21-2bde-4658-8897-bab36330d9b7"
7+
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
78
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
9+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
10+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
811
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
12+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
13+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
914

1015
[compat]
1116
Compat = "≥ 1.0.0"

src/AlgebraicMultigrid.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
module AlgebraicMultigrid
22

33
import IterativeSolvers: gauss_seidel!
4-
using Compat, Compat.LinearAlgebra
5-
using Compat.SparseArrays, Compat.Printf
4+
using LinearAlgebra
5+
using SparseArrays, Printf
66
using Base.Threads
77

8-
using Compat: rmul!
8+
using LinearAlgebra: rmul!
99

10-
if VERSION < v"0.7-"
11-
const mul! = A_mul_B!
12-
end
10+
# const mul! = A_mul_B!
1311

1412
const MT = false
1513
const AMG = AlgebraicMultigrid

src/aggregation.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ function smoothed_aggregation(A::TA,
2828
# agg = [aggregate for _ in 1:max_levels - 1]
2929
# sm = [smooth for _ in 1:max_levels]
3030

31-
@static if VERSION < v"0.7-"
32-
levels = Vector{Level{TA, TA, TA}}()
33-
else
34-
levels = Vector{Level{TA, TA, Adjoint{T, TA}}}()
35-
end
31+
levels = Vector{Level{TA, TA, Adjoint{T, TA}}}()
3632
bsr_flag = false
3733
w = MultiLevelWorkspace(Val{bs}, eltype(A))
3834
residual!(w, size(A, 1))

src/classical.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,12 @@ function ruge_stuben(_A::Union{TA, Symmetric{Ti, TA}, Hermitian{Ti, TA}},
2424
A = _A.data
2525
At = A
2626
symmetric = true
27-
@static if VERSION < v"0.7-"
28-
levels = Vector{Level{TA, TA}}()
29-
else
30-
levels = Vector{Level{TA, Adjoint{Ti, TA}, TA}}()
31-
end
27+
levels = Vector{Level{TA, Adjoint{Ti, TA}, TA}}()
3228
else
3329
symmetric = false
3430
A = _A
3531
At = adjoint(A)
36-
@static if VERSION < v"0.7-"
37-
levels = Vector{Level{TA, TA, TA}}()
38-
else
39-
levels = Vector{Level{TA, Adjoint{Ti, TA}, TA}}()
40-
end
32+
levels = Vector{Level{TA, Adjoint{Ti, TA}, TA}}()
4133
end
4234
w = MultiLevelWorkspace(Val{bs}, eltype(A))
4335
residual!(w, size(A, 1))

src/multilevel.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,8 @@ function Base.show(io::IO, ml::MultiLevel)
8080
lstr = lstr *
8181
@sprintf " %2d %10d %10d [%5.2f%%]" length(ml.levels) + 1 size(ml.final_A, 1) nnz(ml.final_A) (100 * nnz(ml.final_A) / total_nnz)
8282

83-
@static if VERSION < v"0.7-"
84-
opround = round(op, 3)
85-
ground = round(op, 3)
86-
else
87-
opround = round(op, digits = 3)
88-
ground = round(op, digits = 3)
89-
end
83+
opround = round(op, digits = 3)
84+
ground = round(op, digits = 3)
9085

9186
str = """
9287
Multilevel Solver

src/preconditioner.jl

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,17 @@ Preconditioner(ml) = Preconditioner(ml, :zero)
66

77
aspreconditioner(ml::MultiLevel) = Preconditioner(ml)
88

9-
@static if VERSION < v"0.7-"
10-
import Base: \, *, A_ldiv_B!, A_mul_B!
11-
function A_ldiv_B!(x, p::Preconditioner, b)
12-
if p.init == :zero
13-
x .= 0
14-
else
15-
x .= b
16-
end
17-
solve!(x, p.ml, b, maxiter = 1, calculate_residual = false)
9+
import LinearAlgebra: \, *, ldiv!, mul!
10+
ldiv!(p::Preconditioner, b) = copyto!(b, p \ b)
11+
function ldiv!(x, p::Preconditioner, b)
12+
if p.init == :zero
13+
x .= 0
14+
else
15+
x .= b
1816
end
19-
A_mul_B!(b, p::Preconditioner, x) = A_mul_B!(b, p.ml.levels[1].A, x)
20-
else
21-
import Compat.LinearAlgebra: \, *, ldiv!, mul!
22-
ldiv!(p::Preconditioner, b) = copyto!(b, p \ b)
23-
function ldiv!(x, p::Preconditioner, b)
24-
if p.init == :zero
25-
x .= 0
26-
else
27-
x .= b
28-
end
29-
solve!(x, p.ml, b, maxiter = 1, calculate_residual = false)
30-
end
31-
mul!(b, p::Preconditioner, x) = mul!(b, p.ml.levels[1].A, x)
17+
solve!(x, p.ml, b, maxiter = 1, calculate_residual = false)
3218
end
19+
mul!(b, p::Preconditioner, x) = mul!(b, p.ml.levels[1].A, x)
3320

3421
function \(p::Preconditioner, b)
3522
ldiv!(similar(b), p, b)

src/utils.jl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
function adjoint(A)
2-
@static if VERSION < v"0.7-"
3-
A'
4-
else
5-
copy(A')
6-
end
2+
copy(A')
73
end
84

95
function approximate_spectral_radius(A, tol = 0.01,
@@ -29,11 +25,7 @@ function approximate_spectral_radius(A, tol = 0.01,
2925
# m, max_index = findmax(abs.(ev))
3026
m, max_index = findmaxabs(ev)
3127
error = H[nvecs, nvecs-1] * evect[end, max_index]
32-
@static if VERSION < v"0.7-"
33-
@views A_mul_B!(v0, X, evect[:, max_index])
34-
else
35-
@views mul!(v0, X, evect[:, max_index])
36-
end
28+
@views mul!(v0, X, evect[:, max_index])
3729
if (abs(error) / abs(ev[max_index]) < tol) || flag
3830
# v0 = X * evect[:, max_index]
3931
break
@@ -99,11 +91,7 @@ function approximate_eigenvalues(A, tol, maxiter, symmetric, v0)
9991
rmul!(w, 1/H[j+1,j])
10092
push!(V, w)
10193
end
102-
@static if VERSION < v"0.7-"
103-
Eigs, Vects = eig(H[1:maxiter, 1:maxiter], Matrix{eltype(A)}(I, maxiter, maxiter))
104-
else
105-
Eigs, Vects = (eigen(H[1:maxiter, 1:maxiter], Matrix{eltype(A)}(I, maxiter, maxiter))...,)
106-
end
94+
Eigs, Vects = (eigen(H[1:maxiter, 1:maxiter], Matrix{eltype(A)}(I, maxiter, maxiter))...,)
10795

10896
Vects, Eigs, H, V, flag
10997
end

test/runtests.jl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
using Compat, Compat.Test, Compat.LinearAlgebra
2-
using Compat.SparseArrays, Compat.DelimitedFiles, Compat.Random
1+
using SparseArrays, DelimitedFiles, Random
2+
using Test, LinearAlgebra
33
using IterativeSolvers, AlgebraicMultigrid
44
import AlgebraicMultigrid: Pinv, Classical
55
using JLD2
66
using FileIO
77

8-
if VERSION < v"0.7-"
9-
const seed! = srand
10-
else
11-
using Random: seed!
12-
end
8+
using Random: seed!
139

1410
include("sa_tests.jl")
1511

@@ -41,9 +37,6 @@ end
4137
# Ruge-Stuben splitting
4238
S = poisson(7)
4339
@test RS()(S) == [0, 1, 0, 1, 0, 1, 0]
44-
seed!(0)
45-
S = sprand(10,10,0.1); S = S + S'
46-
@test RS()(S) == [0, 1, 1, 0, 0, 0, 0, 0, 1, 1]
4740

4841
a = include("thing.jl")
4942
S, T = Classical(0.25)(a)

0 commit comments

Comments
 (0)