function p = poly_value ( m, c, n, x )

%*****************************************************************************80
%
%% poly_value() evaluates a polynomial.
%
%  Discussion:
%
%    The polynomial 
%
%      p(x) = c1 + c2 * x + c3 * x^2 + ... + cm * x^(m-1)
%
%    can be evaluated at the vector x by the command
%
%      pval = poly_value ( m, c, n, x );
%
%    Unfortunately, the natural MATLAB function to use, polyval(),
%    assumes that the polynomial coefficients are given in the
%    opposite order, so that c1 multiplies x^(m-1).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 July 2012
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the number of polynomial coefficients.
%
%    real C(M), the polynomial coefficients.  C(1) is
%    the constant term.
%
%    integer N, the number of evaluation points.
%
%    real X(N), the evaluation points.
%
%  Output:
%
%    real P(N), the value of the polynomial at the evaluation points.
%
  A = ( x(:) * ones ( 1, m ) ) .^ ( ones ( n, 1 ) * ( 0 : m - 1 ) );

  p = A * c;

  return
end
