function ival = r8mat_is_triangular_lower_unit ( m, n, a )

%*****************************************************************************80
%
%% r8mat_is_triangular_lower_unit() determines whether an R8MAT is unit lower 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 lower triangular.
%    1, the matrix is unit lower 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 ( i < j )
        if ( a(i,j) ~= 0.0 )
          ival = -1;
          return
        end
      end

    end
  end

  return
end
