function y = chebpolyval(n,x)
% y = chebpolyval(n,x)
%   Return the values of an n-th order Chebyshev polynomial
%   evaluated at the vector of values x.
%   i.e. y(i) = { cos(N*cos^-1 x)  |x| <= 1
%               { cosh(N*cosh^-1 x) |x| >1
% 2011-11-21 Dan Ellis dpwe@ee.columbia.edu

y = zeros(size(x,1),size(x,2));

cpts = find(abs(x(:))<=1);
hpts = find(abs(x(:))>1);

y(cpts) = cos(n*acos(x(cpts)));
y(hpts) = cosh(n*acosh(x(hpts)));
