function Ab = swap ( i1, i2 )

%*****************************************************************************80
%
%% swap() swaps rows i1 and i2.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 January 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer i1, i2, the rows to be swapped.
%
%  Output:
%
%    real Ab(m,n+k), the augmented matrix has been modified.
%
  global Ab
  global k
  global m
  global n

  if ( i1 < 1 || m < i1 )
    fprintf ( 1, 'swap: Fatal error!\n' );
    fprintf ( 1, '  1 <= I1 <= %d is required.\n', m );
    error ( 'swap: Fatal error!' );
  end

  if ( i2 < 1 || m < i2 )
    fprintf ( 1, 'swap: Fatal error!\n' );
    fprintf ( 1, '  1 <= I2 <= %d is required.\n', m );
    error ( 'swap: Fatal error!' );
  end

  t        = Ab(i1,:);
  Ab(i1,:) = Ab(i2,:);
  Ab(i2,:) = t;

  return
end

