function ival = r8mat_is_triangular_upper_unit ( m, n, a )

%*****************************************************************************80
%
%% r8mat_is_triangular_upper_unit() determines whether an R8MAT is unit upper triangular.
%
%  Discussion:
%
%    An R8MAT is a matrix of real values.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 April 2017
%
%  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:
%    -1, the matrix is not upper triangular.
%    1, the matrix is unit upper triangular.
%
  ival = 1;

  for i = 1 : m
    for j = 1 : n

      if ( i == j )
        if ( a(i,j) ~= 1.0 )
          ival = -1;
          return
        end
      elseif ( j < i )
        if ( a(i,j) ~= 0.0 )
          ival = -1;
          return
        end
      end

    end
  end

  return
end
