Skip to content

Commit 2b9e314

Browse files
committed
v0.6 backward compatibility 2
1 parent 52b8322 commit 2b9e314

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
julia 0.6
2-
IterativeSolvers 0.7.0
2+
IterativeSolvers 0.6.0
33
Compat 1.0.0

src/AMG.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ using Compat, Compat.LinearAlgebra
55
using Compat.SparseArrays, Compat.Printf
66
using Base.Threads
77

8+
using Compat: rmul!
9+
810
const MT = false
911

1012
include("utils.jl")

src/preconditioner.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
import LinearAlgebra: \, *, ldiv!, mul!
2-
31
struct Preconditioner
42
ml::MultiLevel
53
end
64

75
aspreconditioner(ml::MultiLevel) = Preconditioner(ml)
86

7+
@static if VERSION < v"0.7-"
8+
import Base: \, *, A_ldiv_B!, A_mul_B!
9+
A_ldiv_B!(x, p::Preconditioner, b) = copyto!(x, p \ b)
10+
A_mul_B!(b, p::Preconditioner, x) = A_mul_B!(b, p.ml.levels[1].A, x)
11+
else
12+
import Compat.LinearAlgebra: \, *, ldiv!, mul!
13+
ldiv!(x, p::Preconditioner, b) = copyto!(x, p \ b)
14+
mul!(b, p::Preconditioner, x) = mul!(b, p.ml.levels[1].A, x)
15+
end
16+
917
\(p::Preconditioner, b) = solve(p.ml, b, maxiter = 1, tol = 1e-12)
1018
*(p::Preconditioner, b) = p.ml.levels[1].A * x
11-
12-
ldiv!(x, p::Preconditioner, b) = copyto!(x, p \ b)
13-
mul!(b, p::Preconditioner, x) = mul!(b, p.ml.levels[1].A, x)

src/utils.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ function approximate_spectral_radius(A, tol = 0.01,
2121
# m, max_index = findmax(abs.(ev))
2222
m, max_index = findmaxabs(ev)
2323
error = H[nvecs, nvecs-1] * evect[end, max_index]
24+
@static if VERSION < v"0.7-"
25+
@views A_mul_B!(v0, X, evect[:, max_index])
26+
else
27+
@views mul!(v0, X, evect[:, max_index])
28+
end
2429
if (abs(error) / abs(ev[max_index]) < tol) || flag
2530
# v0 = X * evect[:, max_index]
26-
mul!(v0, X, evect[:, max_index])
2731
break
28-
else
29-
# v0 = X * evect[:, max_index]
30-
mul!(v0, X, evect[:, max_index])
3132
end
3233
end
33-
3434
ρ = abs(ev[max_index])
35-
3635
end
36+
3737
function findmaxabs(arr)
3838
m = abs(arr[1])
3939
m_i = 1

0 commit comments

Comments
 (0)