function A = upshift_matrix ( n )

%*****************************************************************************80
%
%% upshift_matrix() returns the UPSHIFT matrix.
%
%  Formula:
%
%    if ( J-I == 1 mod ( n ) )
%      A(I,J) = 1
%    else
%      A(I,J) = 0
%
%  Example:
%
%    N = 4
%
%    0 1 0 0
%    0 0 1 0
%    0 0 0 1
%    1 0 0 0
%
%  Properties:
%
%    A is integral: int ( A ) = A.
%
%    A is a zero/one matrix.
%
%    A is generally not symmetric: A' /= A.
%
%    A is nonsingular.
%
%    A is a permutation matrix.
%
%    If N is even, det ( A ) = -1.
%    If N is odd,  det ( A ) = +1.
%
%    A is unimodular.
%
%    A is persymmetric: A(I,J) = A(N+1-J,N+1-I).
%
%    A is an N-th root of the identity matrix.
%
%    The inverse of A is the downshift matrix.
%
%    A circulant matrix C, whose first row is (c1, c2, ..., cn), can be
%    written as a polynomial in A:
%      C = c1 * I + c2 * A + c3 * A^2 + ... + cn * A^(n-1).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 March 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of rows and columns of the matrix.
%
%  Output:
%
%    real A(N,N), the matrix.
%
  A = zeros ( n, n );
  for i = 1 : n
    j = i4_wrap ( i + 1, 1, n );
    A(i,j) = 1.0;
  end

  return
end
