Skip to content

Commit

Permalink
Test zero-residual solution
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsiqueira authored and dpo committed Jan 21, 2017
1 parent e1e245b commit 5428236
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/test_cg_lanczos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,13 @@ shifts = [-4, -3, 2;]
(x, stats) = cg_lanczos_shift_par(full(A), b, [1:6;]);
show(stats);

# Test b == 0
(x, stats) = cg_lanczos(A, zeros(size(A,1)))
@test x == zeros(size(A,1))
@test stats.status == "x = 0 is a zero-residual solution"
(x, stats) = cg_lanczos_shift_par(A, zeros(size(A,1)), [1:6;])
@test x == zeros(size(A,1), 6)
@test stats.status == "x = 0 is a zero-residual solution"
(x, stats) = cg_lanczos_shift_seq(A, zeros(size(A,1)), [1:6;])
@test x == zeros(size(A,1), 6)
@test stats.status == "x = 0 is a zero-residual solution"
4 changes: 4 additions & 0 deletions test/test_cgls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ resid = norm(A' * M * (A * x - b)) / sqrt(dot(b, M * b));
(x, stats) = cgls(sparse(full(A)), b);
show(stats);

# Test b == 0
(x, stats) = cgls(A, zeros(size(A,1)))
@test x == zeros(size(A,1))
@test stats.status == "x = 0 is a zero-residual solution"
4 changes: 4 additions & 0 deletions test/test_cgne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ A = ones(5, 3); b = rand(5); b[1] = -1.0;
(x, stats, resid) = test_cgne(sparse(A), b, λ=1.0e-3);
show(stats);

# Test b == 0
(x, stats) = cgne(A, zeros(size(A,1)), λ=1.0e-3)
@test x == zeros(size(A,2))
@test stats.status == "x = 0 is a zero-residual solution"
6 changes: 6 additions & 0 deletions test/test_craigmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,9 @@ A = ones(5, 3); b = rand(5); b[1] = -1.0;
# Code coverage.
(x, y, stats) = craigmr(sparse(A), b, λ=1.0e-3);
show(stats);

# Test b == 0
(x, y, stats) = craigmr(A, zeros(size(A,1)), λ=1.0e-3)
@test x == zeros(size(A,2))
@test y == zeros(size(A,1))
@test stats.status == "x = 0 is a zero-residual solution"
4 changes: 4 additions & 0 deletions test/test_crls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ resid = norm(A' * M * (A * x - b)) / sqrt(dot(b, M * b));
(x, stats) = crls(sparse(full(A)), b);
show(stats);

# Test b == 0
(x, stats) = crls(A, zeros(size(A,1)))
@test x == zeros(size(A,1))
@test stats.status == "x = 0 is a zero-residual solution"
4 changes: 4 additions & 0 deletions test/test_crmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ A = ones(5, 3); b = rand(5); b[1] = -1.0;
(x, stats, resid) = test_crmr(sparse(A), b, λ=1.0e-3);
show(stats);

# Test b == 0
(x, stats) = crmr(A, zeros(size(A,1)))
@test x == zeros(size(A,2))
@test stats.status == "x = 0 is a zero-residual solution"
5 changes: 5 additions & 0 deletions test/test_lsmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ end
(x, stats) = lsmr(full(A), b);
(x, stats) = lsmr(sparse(full(A)), b);
show(stats);

# Test b == 0
(x, stats) = lsmr(A, zeros(size(A,1)))
@test x == zeros(size(A,1))
@test stats.status == "x = 0 is a zero-residual solution"
5 changes: 5 additions & 0 deletions test/test_lsqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ end
(x, stats) = lsqr(full(A), b);
(x, stats) = lsqr(sparse(full(A)), b);
show(stats);

# Test b == 0
(x, stats) = lsqr(A, zeros(size(A,1)))
@test x == zeros(size(A,1))
@test stats.status == "x = 0 is a zero-residual solution"
4 changes: 4 additions & 0 deletions test/test_minres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ resid = norm(r) / norm(b)
@test(resid <= 100 * minres_tol);
@test(stats.solved);

# Test b == 0
(x, stats) = minres(A, zeros(size(A,1)))
@test x == zeros(size(A,1))
@test stats.status == "x = 0 is a zero-residual solution"

0 comments on commit 5428236

Please sign in to comment.