- while (k <= max_iterations)
- % Loop until either of our stopping conditions are met. If the
- % loop finishes, we have implicitly met the second stopping
- % condition (number of iterations).
-
- if (norm(gk) < tolerance)
- % This catches the k=0 case, too.
- x = xk;
- return;
- end
+ while (k <= max_iterations && norm(gk, 'inf') > tolerance)
+ % Loop until either of our stopping conditions are met. This
+ % should also work when x0 is a satisfactory point.