@@ -22,20 +22,37 @@ srand(1234321)
2222@testset " Matrix{$T }" for T in (Float32, Float64, Complex64, Complex128)
2323 A = randSPD (T, n)
2424 b = rand (T, n)
25- λ_min, λ_max = approx_eigenvalue_bounds (A)
2625 tol = √ (eps (real (T)))
2726
28- x, history = chebyshev (A, b, λ_min, λ_max, tol= tol, maxiter= 10 n, log= true )
29- @test isa (history, ConvergenceHistory)
30- @test history. isconverged
31- @test norm (A * x - b) / norm (b) ≤ tol
27+ # Without a preconditioner
28+ begin
29+ λ_min, λ_max = approx_eigenvalue_bounds (A)
30+ x0 = rand (n)
31+ x, history = chebyshev (A, b, λ_min, λ_max, tol= tol, maxiter= 10 n, log= true )
32+ @test isa (history, ConvergenceHistory)
33+ @test history. isconverged
34+ @test norm (A * x - b) / norm (b) ≤ tol
35+ end
3236
33- # Preconditioned solve
34- B = randSPD (T, n)
35- B_fact = cholfact! (B)
36- λ_min, λ_max = approx_eigenvalue_bounds (B_fact \ A)
37- x, history = chebyshev (A, b, λ_min, λ_max, Pl = B_fact, tol= tol, maxiter= 10 n, log= true )
38- @test history. isconverged
39- @test norm (A * x - b) / norm (b) ≤ tol
37+ # With an initial guess
38+ begin
39+ λ_min, λ_max = approx_eigenvalue_bounds (A)
40+ x0 = rand (T, n)
41+ x, history = chebyshev! (x0, A, b, λ_min, λ_max, tol= tol, maxiter= 10 n, log= true )
42+ @test isa (history, ConvergenceHistory)
43+ @test history. isconverged
44+ @test x == x0
45+ @test norm (A * x - b) / norm (b) ≤ tol
46+ end
47+
48+ # With a preconditioner
49+ begin
50+ B = randSPD (T, n)
51+ B_fact = cholfact! (B)
52+ λ_min, λ_max = approx_eigenvalue_bounds (B_fact \ A)
53+ x, history = chebyshev (A, b, λ_min, λ_max, Pl = B_fact, tol= tol, maxiter= 10 n, log= true )
54+ @test history. isconverged
55+ @test norm (A * x - b) / norm (b) ≤ tol
56+ end
4057end
4158end
0 commit comments