function p = r8poly_value_fast ( d, c, nx, x )

%*****************************************************************************80
%
%% r8poly_value_fast() evaluates a polynomial at many points.
%
%  Discussion:
%
%    The power sum form of a polynomial is:
%
%      p(x) = c(0) + c(1) * x + ... + c(n-1) * x^(n-1) + c(n) * x^(n)
%
%    Because MATLAB doesn't allow 0 indexing, we use an adjusted formula:
%
%      p(x) = c(1) + c(2) * x + ... + c(n) * x^(n-1) + c(n+1) * x^(n)
%
%    This function uses a linear algebra approach that may be faster
%    in MATLAB, although significantly more obscure.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 October 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer D: the degree.
%
%    real C(D+1): the polynomial.  
%
%    integer NX: the number of evaluation points.
%
%    real X(NX,1): the evaluation points.
%
%  Output:
%
%    real P(NX,1): the polynomial values.
%
  x = x(:);
  c = c(:);
%
%  Form a Vandermonde matrix A.
%
  A = ( x(1:nx,1) * ones ( 1, d + 1 ) ) .^ ( ones ( nx, 1 ) * ( 0 : d ) );

  p = A * c;

  return
end
