function A = chebyshev_to_monomial_matrix ( n )

%*****************************************************************************80
%
%% chebyshev_to_monomial_matrix() returns the CHEBY_T matrix.
%
%  Example:
%
%    N = 11
%
%    1  .  -1    .    1    .   -1    .     1    .    -1
%    .  1   .   -3    .    5    .   -7     .    9     .
%    .  .   2    .   -8    .   18    .   -32    .    50
%    .  .   .    4    .  -20    .   56     . -120     .
%    .  .   .    .    8    .  -48    .   160    .  -400
%    .  .   .    .    .   16    . -112     .  432     .
%    .  .   .    .    .    .   32    .  -256    .  1120
%    .  .   .    .    .    .    .   64     . -576     .
%    .  .   .    .    .    .    .    .   128    . -1280
%    .  .   .    .    .    .    .    .     .  256     .
%    .  .   .    .    .    .    .    .     .    .   512
%
%  Properties:
%
%    A is generally not symmetric: A' /= A.
%
%    A is integral: int ( A ) = A.
%
%    A is reducible.
%
%    A is lower triangular.
%
%    Each row of A sums to 1.
%
%    det ( A ) = 2^( (N-1) * (N-2) / 2 )
%
%    A is not normal: A' * A /= A * A'.
%
%    For I = 1:
%      LAMBDA(1) = 1
%    For 1 < I
%      LAMBDA(I) = 2^(I-2)
%
%    The family of matrices is nested as a function of N.
%
%    A is not diagonally dominant.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 April 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N: the order of A.
%
%  Output:
%
%    real A(N,N): the matrix.
%
  A = zeros ( n, n );

  if ( n <= 0 )
    return
  end

  A(1,1) = 1.0;

  if ( n == 1 )
    return
  end

  A(2,2) = 1.0;

  for j = 3 : n

    for i = 1 : n
      A(i,j) = - A(i,j-2);
    end

    for i = 2 : n
      A(i,j) = A(i,j) + 2.0 * A(i-1,j-1);
    end

  end

  return
end
