function value = r8poly_values_horner ( d, c, nx, x )

%*****************************************************************************80
%
%% r8poly_values_horner() evaluates a polynomial using Horner's method.
%
%  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)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 December 2013
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer D: the degree.
%
%    real C(D+1): the polynomial coefficients.  
%
%    integer NX: the number of evaluation points.
%
%    real X(NX): the evaluation points.
%
%  Output:
%
%    real VALUE(NX): the polynomial values.
%
  x = x(:);
  c = c(:);

  value = zeros ( nx, 1 );

  value(1:d) = c(d+1);
  for i = d - 1 : -1 : 0
    value(1:nx) = value(1:nx) .* x(1:nx) + c(i+1);
  end

  return
end
