X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=tests%2Fpreconditioned_conjugate_gradient_method_tests.m;h=d44ee421570ead5908c49a14a959650c8cb88495;hp=c58eb55edb206042c80477deb3ad41d964133334;hb=84b8fb9002d091f84d0205e923c3989d0138ec9e;hpb=3b53099a4e07530a498d6aa959defa6f01244154 diff --git a/tests/preconditioned_conjugate_gradient_method_tests.m b/tests/preconditioned_conjugate_gradient_method_tests.m index c58eb55..d44ee42 100644 --- a/tests/preconditioned_conjugate_gradient_method_tests.m +++ b/tests/preconditioned_conjugate_gradient_method_tests.m @@ -3,12 +3,9 @@ A = [5,1,2; ... 2,3,7]; M = eye(3); - b = [1;2;3]; - x0 = [1;1;1]; -## Solved over the rationals. cgm = conjugate_gradient_method(A, b, x0, 1e-6, 1000); pcgm = preconditioned_conjugate_gradient_method(A, M, b, x0, 1e-6, 1000); diff = norm(cgm - pcgm); @@ -17,6 +14,12 @@ unit_test_equals("PCGM agrees with CGM when M == I", ... true, ... norm(diff) < 1e-6); +pcgm_simple = simple_preconditioned_cgm(A, M, b, x0, 1e-6, 1000); +diff = norm(pcgm_simple - pcgm); + +unit_test_equals("PCGM agrees with SimplePCGM when M == I", ... + true, ... + norm(diff) < 1e-6); ## Needs to be symmetric! M = [0.97466, 0.24345, 0.54850; ... @@ -29,3 +32,11 @@ diff = norm(cgm - pcgm); unit_test_equals("PCGM agrees with CGM when M != I", ... true, ... norm(diff) < 1e-6); + + +pcgm_simple = simple_preconditioned_cgm(A, M, b, x0, 1e-6, 1000); +diff = norm(pcgm_simple - pcgm); + +unit_test_equals("PCGM agrees with Simple PCGM when M != I", ... + true, ... + norm(diff) < 1e-6);