function ival = r8mat_is_triangular_lower ( m, n, a )

%*****************************************************************************80
%
%% r8mat_is_triangular_lower() determines whether an R8MAT is 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 lower triangular.
%    2, the matrix is unit lower triangular.
%
  ival = 2;

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

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

    end
  end

  return
end
