function A = monomial_to_gegenbauer_matrix ( n, alpha )

%*****************************************************************************80
%
%% monomial_to_gegenbauer_matrix(): convert monomial to Gegenbauer basis.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 April 2024
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Dae San Kim, Taekyun Kim, Soog-Hoon Rim,
%    Some identities involving Gegenbauer polynomials.
%    Advances in Difference Equations,
%    Volume 2012, Number 19, 19 December 2012.
%
%  Input:
%
%    integer N: the order of the matrix.
%
%    real ALPHA: the parameter.
%
%  Output:
%
%    real A(N,N): the matrix.
%
  A = zeros ( n, n );

  if ( n <= 0 )
    return
  end

  for j = 0 : n - 1
    ilo = mod ( j, 2 );
    for i = ilo : 2 : j
      top = ( i + alpha ) * factorial ( j ) * gamma ( alpha );
      bot = 2^j * factorial ( ( j - i ) / 2 ) ...
        * gamma ( ( j + i ) / 2 + alpha + 1.0 );
      A(i+1,j+1) = top / bot;
    end
  end

  return
end
