function ival = r8mat_is_scalar_diagonal ( m, n, a )

%*****************************************************************************80
%
%% R8MAT_IS_SCALAR_DIAGONAL checks whether an R8MAT is a scalar along diagonals.
%
%  Discussion:
%
%    An R8MAT is a matrix of real values.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    09 April 2017
%
%  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 diagonal scalar.
%    1, the matrix is diagonal scalar.
%
  ival = 1;

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

  return
end
