function v = r8poly_chebyshev_value ( d, x )

%*****************************************************************************80
%
%% r8poly_chebyshev_value() evaluates a Chebyshev polynomials T(D,X).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 October 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer D: the degree.
%
%    real X(M): the evaluation points.
%
%  Output:
%
%    real V(1:M): the Chebyshev polynomial values.
%
  x = x(:);
  m = length ( x );

  if ( d < 0 )
    v = [];
    return
  end

  v = ones ( m, 1 );
  if ( d == 0 )
    return
  end

  vnm1 = v;
  v = x;
 
  for i = 2 : d
    vnm2 = vnm1;
    vnm1 = v;
    v = 2.0 * x .* vnm1 - vnm2;
  end
 
  return
end
