function [hmax] = hh(alpha,algor,hmn0,hmx0,type)
%
%  This function computes the maximal step size for an
%  arbitrary algorithm, and a given alpha value.
%
%  Compute A-matrix first
%
A = aa(alpha);
%
%  Iterate to find hmax
%
maxerr = 1E-6;
err = 100;
hmn = hmn0;
hmx = hmx0;
while err > maxerr,
  h = (hmn + hmx)/2;
  F = ff(A,h,algor);
  lmax = max(abs(eig(F)));
  err = lmax - 1;
  if err*type > 0,
    hmx = h;
   else
    hmn = h;
  end,
  err = abs(err);
  if (hmx0-h)*(h-hmn0) < 1.0E-4,
    h = 0.0;
    err = 0.0;
  end,
end
hmax = h;
%
return
