function Ab = scale ( i, j )

%*****************************************************************************80
%
%% scale() scales row i so that Ab(i,j) = 1.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 January 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer i, j, the row and column indices of the entry whose value
%    is used to normalize row i.  Ab(i,j) must not be zero.
%    j defaults to i.
%
%  Output:
%
%    real Ab(m,n+k), the augmented matrix has been modified.
%    Row i was divided by Ab(i,j).
%
  global Ab
  global k
  global m
  global n

  if ( nargin == 1 )
    j = i;
  end

  if ( i < 1 || m < i )
    fprintf ( 1, 'scale - Fatal error!\n' );
    fprintf ( 1, '  1 <= I <= %d is required.\n', m );
    error ( 'scale: Fatal error!' );
  end

  if ( j < 1 || n < j )
    fprintf ( 1, 'scale - Fatal error!\n' );
    fprintf ( 1, '  1 <= J <= %d is required.\n', n );
    error ( 'scale: Fatal error!' );
  end

  if ( Ab(i,j) == 0.0 )
    fprintf ( 1, 'scale - Fatal error!\n' );
    fprintf ( 1, '  Ab(%d,%d) = 0.\n', i, j );
    error ( 'scale: Fatal error!' );
  end

  Ab(i,:) = Ab(i,:) / Ab(i,j);

  return
end

