function ival = r8mat_is_hankel ( m, n, a )

%*****************************************************************************80
%
%% R8MAT_IS_HANKEL checks whether a real rectangular matrix A is Hankel.
%
%  Discussion:
%
%    A Hankel matrix is one which is constant along each anti-diagonal.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    03 November 2007
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer M, N, the row and column dimensions of 
%    the matrix.  M and N must be positive.
%
%    Input, real A(M,N), the matrix.
%
%    Output, integer IVAL:
%    -1, the matrix is not Hankel.
%    1, the matrix is Hankel.
%
  ival = 1;

  for ipj = 2 : n + m
    ilo = max ( 1, ipj - n );
    ihi = min ( m, ipj - 1 );
    s = a(ilo,ipj-ilo);
    for i = ilo + 1 : ihi
      if ( a(i,ipj-i) ~= s )
        ival = -1;
        return
      end
    end
  end

  return
end
