From e8d03f4007b828784c68b1d4ff2ba8d644641cef Mon Sep 17 00:00:00 2001
From: Michael Orlitzky
Date: Mon, 25 Mar 2013 14:51:59 -0400
Subject: [PATCH] Simplify (subjectively) the steepest descent loop.
---
optimization/steepest_descent.m | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/optimization/steepest_descent.m b/optimization/steepest_descent.m
index 0a6475e..c0e88dd 100644
--- a/optimization/steepest_descent.m
+++ b/optimization/steepest_descent.m
@@ -58,14 +58,15 @@ function [x, k] = steepest_descent(g, ...
dk = -gk;
alpha_k = step_size(xk);
- xk = xk + (alpha_k * dk);
- gk = g(xk);
+ x_next = xk + (alpha_k * dk);
% We potentially just performed one more iteration than necessary
% in order to simplify the loop. Note that due to the structure of
% our loop, we will have k > max_iterations when we fail to
% converge.
k = k + 1;
+ xk = x_next;
+ gk = g(x_next);
end
x = xk;
--
2.33.1