+ denom = (g' * Q * g);
+
+ % denom is non-negative, since it's a Q-norm. No need to abs() it.
+ if (denom < eps)
+ % Catch divide-by-zeros. If denom is effectively zero, set it to
+ % something tiny instead. This trick is also used in the PCGM.
+ denom = eps;
+ end
+
+ alpha = (g' * g)/denom;