Skip to content

Commit 0869558

Browse files
committed
use the same initial residual for tests of abstol/reltol
1 parent baa7c5c commit 0869558

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

test/bicgstabl.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ end
4848
n = size(A, 2)
4949
b = ones(T, n)
5050
x0 = A \ b
51-
perturbation = T[(-1)^i for i in 1:n]
51+
perturbation = 10 * sqrt(eps(real(T))) * T[(-1)^i for i in 1:n]
5252

5353
# If the initial residual is small and a small relative tolerance is used,
5454
# many iterations are necessary
55-
x = x0 + sqrt(eps(real(T))) * perturbation
55+
x = x0 + perturbation
5656
initial_residual = norm(A * x - b)
5757
x, ch = bicgstabl!(x, A, b, log=true)
5858
@test 1 niters(ch) n÷2 # BiCGStab(2) makes more than one RHS evaluations per iteration
5959

6060
# If the initial residual is small and a large absolute tolerance is used,
6161
# no iterations are necessary
62-
x = x0 + 10*sqrt(eps(real(T))) * perturbation
62+
x = x0 + perturbation
6363
initial_residual = norm(A * x - b)
6464
x, ch = bicgstabl!(x, A, b, abstol=2*initial_residual, reltol=zero(real(T)), log=true)
6565
@test niters(ch) == 0

test/cg.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,18 @@ end
101101
n = size(A, 2)
102102
b = ones(T, n)
103103
x0 = A \ b
104-
perturbation = T[(-1)^i for i in 1:n]
104+
perturbation = 10 * sqrt(eps(real(T))) * T[(-1)^i for i in 1:n]
105105

106106
# If the initial residual is small and a small relative tolerance is used,
107107
# many iterations are necessary
108-
x = x0 + sqrt(eps(real(T))) * perturbation
108+
x = x0 + perturbation
109109
initial_residual = norm(A * x - b)
110110
x, ch = cg!(x, A, b, log=true)
111111
@test 2 niters(ch) n
112112

113113
# If the initial residual is small and a large absolute tolerance is used,
114114
# no iterations are necessary
115-
x = x0 + 10*sqrt(eps(real(T))) * perturbation
115+
x = x0 + perturbation
116116
initial_residual = norm(A * x - b)
117117
x, ch = cg!(x, A, b, abstol=2*initial_residual, reltol=zero(real(T)), log=true)
118118
@test niters(ch) == 0

test/chebyshev.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ end
7272
n = size(A, 2)
7373
b = ones(T, n)
7474
x0 = A \ b
75-
perturbation = T[(-1)^i for i in 1:n]
75+
perturbation = 10 * sqrt(eps(real(T))) * T[(-1)^i for i in 1:n]
7676
λ_min, λ_max = approx_eigenvalue_bounds(A)
7777

7878
# If the initial residual is small and a small relative tolerance is used,
7979
# many iterations are necessary
80-
x = x0 + sqrt(eps(real(T))) * perturbation
80+
x = x0 + perturbation
8181
initial_residual = norm(A * x - b)
8282
x, ch = chebyshev!(x, A, b, λ_min, λ_max, log=true)
8383
@test 2 niters(ch) n
8484

8585
# If the initial residual is small and a large absolute tolerance is used,
8686
# no iterations are necessary
87-
x = x0 + 10*sqrt(eps(real(T))) * perturbation
87+
x = x0 + perturbation
8888
initial_residual = norm(A * x - b)
8989
x, ch = chebyshev!(x, A, b, λ_min, λ_max, abstol=2*initial_residual, reltol=zero(real(T)), log=true)
9090
@test niters(ch) == 0

test/gmres.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ end
7878
n = size(A, 2)
7979
b = ones(T, n)
8080
x0 = A \ b
81-
perturbation = T[(-1)^i for i in 1:n]
81+
perturbation = 10 * sqrt(eps(real(T))) * T[(-1)^i for i in 1:n]
8282

8383
# If the initial residual is small and a small relative tolerance is used,
8484
# many iterations are necessary
85-
x = x0 + sqrt(eps(real(T))) * perturbation
85+
x = x0 + perturbation
8686
initial_residual = norm(A * x - b)
8787
x, ch = gmres!(x, A, b, log=true)
8888
@test 2 niters(ch) n
8989

9090
# If the initial residual is small and a large absolute tolerance is used,
9191
# no iterations are necessary
92-
x = x0 + 10*sqrt(eps(real(T))) * perturbation
92+
x = x0 + perturbation
9393
initial_residual = norm(A * x - b)
9494
x, ch = gmres!(x, A, b, abstol=2*initial_residual, reltol=zero(real(T)), log=true)
9595
@test niters(ch) == 0

test/idrs.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ end
6666
n = size(A, 2)
6767
b = ones(T, n)
6868
x0 = A \ b
69-
perturbation = T[(-1)^i for i in 1:n]
69+
perturbation = 10 * sqrt(eps(real(T))) * T[(-1)^i for i in 1:n]
7070

7171
# If the initial residual is small and a small relative tolerance is used,
7272
# many iterations are necessary
73-
x = x0 + sqrt(eps(real(T))) * perturbation
73+
x = x0 + perturbation
7474
initial_residual = norm(A * x - b)
7575
x, ch = idrs!(x, A, b, log=true)
7676
@test 2 niters(ch) n
7777

7878
# If the initial residual is small and a large absolute tolerance is used,
7979
# no iterations are necessary
80-
x = x0 + 10*sqrt(eps(real(T))) * perturbation
80+
x = x0 + perturbation
8181
initial_residual = norm(A * x - b)
8282
x, ch = idrs!(x, A, b, abstol=2*initial_residual, reltol=zero(real(T)), log=true)
8383
@test niters(ch) == 0

test/minres.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@ end
7575
n = size(A, 2)
7676
b = ones(T, n)
7777
x0 = A \ b
78-
perturbation = T[(-1)^i for i in 1:n]
78+
perturbation = 10 * sqrt(eps(real(T))) * T[(-1)^i for i in 1:n]
7979

8080
# If the initial residual is small and a small relative tolerance is used,
8181
# many iterations are necessary
82-
x = x0 + sqrt(eps(real(T))) * perturbation
82+
x = x0 + perturbation
8383
initial_residual = norm(A * x - b)
8484
x, ch = minres!(x, A, b, log=true)
8585
@test 2 niters(ch) n
8686

8787
# If the initial residual is small and a large absolute tolerance is used,
8888
# no iterations are necessary
89-
x = x0 + 10*sqrt(eps(real(T))) * perturbation
89+
x = x0 + perturbation
9090
initial_residual = norm(A * x - b)
9191
x, ch = minres!(x, A, b, abstol=2*initial_residual, reltol=zero(real(T)), log=true)
9292
@test niters(ch) == 0

test/qmr.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ end
4545
n = size(A, 2)
4646
b = ones(T, n)
4747
x0 = A \ b
48-
perturbation = T[(-1)^i for i in 1:n]
48+
perturbation = 10 * sqrt(eps(real(T))) * T[(-1)^i for i in 1:n]
4949

5050
# If the initial residual is small and a small relative tolerance is used,
5151
# many iterations are necessary
52-
x = x0 + sqrt(eps(real(T))) * perturbation
52+
x = x0 + perturbation
5353
initial_residual = norm(A * x - b)
5454
x, ch = qmr!(x, A, b, log=true)
5555
@test 2 niters(ch) n
5656

5757
# If the initial residual is small and a large absolute tolerance is used,
5858
# no iterations are necessary
59-
x = x0 + 10*sqrt(eps(real(T))) * perturbation
59+
x = x0 + perturbation
6060
initial_residual = norm(A * x - b)
6161
x, ch = qmr!(x, A, b, abstol=2*initial_residual, reltol=zero(real(T)), log=true)
6262
@test niters(ch) == 0

0 commit comments

Comments
 (0)