@@ -34,11 +34,11 @@ Random.seed!(1234321)
34
34
@test ch. isconverged
35
35
36
36
# If you start from the exact solution, you should converge immediately
37
- x,ch = cg! (A \ b, A, b; reltol = 10 * reltol, log= true )
37
+ x,ch = cg! (A \ b, A, b; abstol = 2 n * eps ( real (T)), reltol= zero ( real (T)) , log= true )
38
38
@test niters (ch) ≤ 1
39
39
@test nprods (ch) ≤ 2
40
40
41
- # Test with cholfact should converge immediately
41
+ # Test with cholfact as preconditioner should converge immediately
42
42
F = cholesky (A, Val (false ))
43
43
x,ch = cg (A, b; Pl= F, log= true )
44
44
@test niters (ch) ≤ 2
56
56
57
57
rhs = randn (size (A, 2 ))
58
58
rmul! (rhs, inv (norm (rhs)))
59
+ abstol = 1e-5
59
60
reltol = 1e-5
60
61
61
62
@testset " SparseMatrixCSC{$T , $Ti }" for T in (Float64, Float32), Ti in (Int64, Int32)
75
76
76
77
@testset " Function with specified starting guess" begin
77
78
x0 = randn (size (rhs))
78
- xCG, hCG = cg! (copy (x0), Af, rhs; reltol = reltol, maxiter= 100 , log= true )
79
- xJAC, hJAC = cg! (copy (x0), Af, rhs; Pl= P, reltol = reltol, maxiter= 100 , log= true )
79
+ xCG, hCG = cg! (copy (x0), Af, rhs; abstol = abstol, reltol= 0.0 , maxiter= 100 , log= true )
80
+ xJAC, hJAC = cg! (copy (x0), Af, rhs; Pl= P, abstol = abstol, reltol= 0.0 , maxiter= 100 , log= true )
80
81
@test norm (A * xCG - rhs) ≤ reltol
81
82
@test norm (A * xJAC - rhs) ≤ reltol
82
83
@test niters (hJAC) == niters (hCG)
107
108
x = x0 + sqrt (eps (real (T))) * perturbation
108
109
initial_residual = norm (A * x - b)
109
110
x, ch = cg! (x, A, b, log= true )
110
- @test_broken 2 ≤ niters (ch) ≤ n
111
- # This test is currently broken since `norm(b)` is used in `cg_iterator!`
112
- # instead of the initial `residual` as described in the documentation.
111
+ @test 2 ≤ niters (ch) ≤ n
113
112
114
113
# If the initial residual is small and a large absolute tolerance is used,
115
114
# no iterations are necessary
0 commit comments