function retval = linstop(xold,xnew)
% usage: doneflag = linstop(xold,xnew)
% description: tests for successful quadratic stopping criterion
% and returns boolean true if successful, false otherwise.
% Input parameters:
% xold: starting point
% xnew: new point

% global variables:
global parms;
global countiter;

countiter = countiter + 1;
maxiter = parms.maxiter;
releps = parms.releps;
abseps = parms.abseps;
ordcoef = parms.ordcoef;
retval = 1;
ordcoef = (1-ordcoef)/ordcoef;
if (countiter == maxiter) % too many iterations?
  disp('Iteration limit reached')
else
  if (norm(xnew-xold)>ordcoef*releps + abseps)
    retval = 0;
  end
end
