1 ## Copyright (C) 2002 André Carezia <acarezia@uol.com.br>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
18 ## Returns the value of the nth-order Chebyshev polynomial calculated at
19 ## the point x. The Chebyshev polynomials are defined by the equations:
21 ## / cos(n acos(x), |x| <= 1
23 ## \ cosh(n acosh(x), |x| > 1
25 ## If x is a vector, the output is a vector of the same size, where each
26 ## element is calculated as y(i) = Tn(x(i)).
28 function T = cheb (n, x)
31 elseif !(isscalar (n) && (n == round(n)) && (n >= 0))
32 error ("cheb: n has to be a positive integer");
35 if (max(size(x)) == 0)
38 # avoid resizing latencies
42 T(ind) = cos(n*acos(x(ind)));
47 T(ind) = cosh(n*acosh(x(ind)));