function i = wrap ( i, ilo, ihi )
%
%% WRAP uses wrap-around counting.
%
%  I, on input, the number to be wrapped.
%  I can be a vector.
%
%  ILO, IHI, the range for I.
%
%  I, on output, a value between ILO and IHI.
%
  n = ihi + 1 - ilo;
  i = ilo + mod ( i - ilo, n );

  return
end
