function p = mypolyval(c,z,m)
% function p = mypolyval(c,z,m)
%
% fast and simple polynomial evaluation
%
% p = c(1)*z.^(m-1) + c(2)*z.^(m-2) + ... + c(m-1)*z + c(m)

% Copyright (C) 2008 Matthew T Harrison
%
%    This program is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    any later version.
%
%    This program is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    See <http://www.gnu.org/licenses/> for a copy of the license.

p = c(1);

for j = 2:m
    p = p.*z + c(j);
end