function ival = r8mat_is_banded_upper ( m, n, a )

%*****************************************************************************80
%
%% r8mat_is_banded_upper() determines whether a matrix is upper banded.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    02 November 2007
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the row and column dimensions of 
%    the matrix.  M and N must be positive.
%
%    real A(M,N), the matrix.
%
%  Output:
%
%    integer IVAL, the upper bandwidth, measured as the
%    number of nonzero diagonals, starting with the main diagonal
%    and proceeding right, with values between 0 and N - 1.
%
  ival = 0;

  for j = 1 : n

    for i = 1 : j - 1

      if ( a(i,j) ~= 0.0 )

        ival = max ( ival, j - i );

      end

    end
  end

  return
end
