% COMPDIR Computes a search direction in a subspace defined by Z.
% Helper function for NLCONST.
% Returns Newton direction if possible.
% Returns random direction if gradient is small.
% Otherwise, returns steepest descent direction.
% If the steepest descent direction is small it computes ...