function ival = r8mat_is_cyclic_tridiagonal ( m, n, a )

%*****************************************************************************80
%
%% R8MAT_IS_CYCLIC_TRIDIAGONAL determines whether a matrix is cyclic tridiagonal.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    13 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, the report:
%    -1, the matrix is not square.
%    -2, the matrix has illegal nonzero values.
%    1, the matrix is cyclic tridiagonal.
%
  if ( ~ r8mat_is_square ( m, n, a ) )
    ival = -1;
    return
  end

  for i = 1 : n

    j = i + 1;

    for k = 1 : n - 3

      j = j + 1;

      if ( n < j )
        j = j - n;
      end

      if ( a(i,j) ~= 0.0 )
        ival = -2;
        return
      end

    end

  end

  ival = 1;

  return
end
