From fe28d4fa7b80f3150681c4d8bfb88ef02bf3b1ae Mon Sep 17 00:00:00 2001
From: Michael Orlitzky
Date: Mon, 25 Mar 2013 20:28:10 -0400
Subject: [PATCH] Try again to make the steepest descent tests work.
---
tests/steepest_descent_tests.m | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tests/steepest_descent_tests.m b/tests/steepest_descent_tests.m
index 035c82d..93b2782 100644
--- a/tests/steepest_descent_tests.m
+++ b/tests/steepest_descent_tests.m
@@ -6,7 +6,7 @@
## stopping condition, so we should too.
##
max_iterations = 100000;
-tolerance = 1e-10;
+tolerance = 1e-8;
## First a simple example.
Q = [5,1,2; ...
@@ -57,10 +57,13 @@ for n = [ 5, 10, 25, 50, 100 ]
max_iterations, ...
C, ...
C');
- x_sd = steepest_descent(g, x0, step_size, tolerance, max_iterations);
+ [x_sd, k] = steepest_descent(g, x0, step_size, tolerance, max_iterations);
- ## Note: pcg() uses the 2-norm.
- diff = abs(norm(g(x_pcg)) - norm(g(x_sd), 'inf'));
+ diff = norm(x_pcg - x_sd, 'inf');
msg = sprintf("Our steepest descent agrees with Octave's pcg, n=%d.", n);
- unit_test_equals(msg, true, diff <= tolerance);
+
+ ## There's no good way to choose the tolerance here, since each
+ ## individual algorithm terminates based on the (2,infinity)-norm of
+ ## the gradient.
+ unit_test_equals(msg, true, diff <= sqrt(tolerance));
end
--
2.33.1