function [ ival, jval, kval, lval ] = r8mat_is_scalar ( m, n, a )

%*****************************************************************************80
%
%% R8MAT_IS_SCALAR checks whether an R8MAT is a scalar along rows, columns, etc.
%
%  Discussion:
%
%    An R8MAT is a matrix of real values.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    04 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 row scalar.
%    1, the matrix is row scalar.
%
%    Output, integer JVAL:
%    -1, the matrix is not column scalar.
%    1, the matrix is column scalar.
%
%    Output, integer KVAL:
%    -1, the matrix is not diagonal scalar.
%    1, the matrix is diagonal scalar.
%
%    Output, integer LVAL:
%    -1, the matrix is not antidiagonal scalar.
%    1, the matrix is antidiagonal scalar.
%
  ival = 1;

  for i = 1 : m
    s = a(i,1);
    for j = 2 : n
      if ( a(i,j) ~= s )
        ival = -1;
      end
    end
  end

  jval = 1;

  for j = 1 : n
    s = a(1,j);
    for i = 2 : m
      if ( a(i,j) ~= s )
        jval = -1;
      end
    end
  end

  kval = 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 )
        kval = -1;
      end
    end
  end

  lval = 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 )
        lval = -1;
      end
    end
  end

  return
end
