function a = tribonacci2_matrix ( n )

%*****************************************************************************80
%
%% tribonacci2_matrix() returns the TRIBONACCI2 matrix.
%
%  Example:
%
%    N = 5
%
%    0 1 0 0 0
%    0 0 1 0 0
%    1 1 1 0 0
%    0 1 1 1 0
%    0 0 1 1 1
%
%  Properties:
%
%    A is generally not symmetric: A' /= A.
%
%    A is banded, with bandwidth 4.
%
%    A is integral: int ( A ) = A.
%
%    A is a zero/one matrix.
%
%    If N <= 2 then
%      det ( A ) = 0
%    else
%      det ( A ) = 1
%
%    A is defective, for 4 < N.
%
%    The family of matrices is nested as a function of N.
%
%    A is not diagonally dominant.
%
%    For 3 <= N, A has the eigenvalues:
%
%      1     (N-3) times,
%      A     once, 1/3 * (1+4 cosh(1/3 acosh(2+3/8) ) ) approx 1.83928
%      B+Ci  once, approx -0.4196 + 0.6063i
%      B-Ci  once, approx -0.4196 - 0.6063i
%    where A, B+Ci and B-Ci are the roots of x^3+x^2-x-1=0.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 May 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the order of A.
%
%  Output:
%
%    real A(N,N), the matrix.
%
  a = zeros ( n, n );

  if ( n <= 1 )

  elseif ( n == 2 )

    a(1,2) = 1.0;    

  else

    for i = 1 : n
      if ( i == 1 )
        a(i,2) = 1.0;
      elseif ( i == 2 )
        a(i,3) = 1.0;
      else
        a(i,i-2:i) = 1.0;
      end
    end

  end

  return
end
