1 function alpha = step_length_positive_definite(g, Q)
3 % Find the minimizer alpha of,
5 % phi(alpha) = f(x + alpha*p)
7 % where ``p`` is a descent direction,
9 % f(x) = (1/2)<Qx,x> - <b,x>
11 % and ``Q`` is positive-definite.
13 % The closed-form solution to this problem is given in Nocedal and
14 % Wright, (3.55). The direction of steepest descent will always be
15 % the negative gradient direction; this simplified form is given in
20 % - ``g`` -- The gradient of f at x.
22 % - ``Q`` -- The positive-definite matrix in the definition of
27 % - ``alpha`` -- The value which decreases ``f`` the most.
31 % All vectors are assumed to be *column* vectors.
35 % denom is non-negative, since it's a Q-norm. No need to abs() it.
37 % Catch divide-by-zeros. If denom is effectively zero, set it to
38 % something tiny instead. This trick is also used in the PCGM.
42 alpha = (g' * g)/denom;