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);
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; ...
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);