changeset 11676:623e142cbebb octave-forge

added test to chebyshevpoly
author nir-krakauer
date Wed, 01 May 2013 18:49:16 +0000
parents f1b4cc830302
children 48857707ecb1
files main/miscellaneous/inst/chebyshevpoly.m
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/main/miscellaneous/inst/chebyshevpoly.m	Wed May 01 02:55:33 2013 +0000
+++ b/main/miscellaneous/inst/chebyshevpoly.m	Wed May 01 18:49:16 2013 +0000
@@ -18,11 +18,11 @@
 ## 
 ## Compute the coefficients of the Chebyshev polynomial, given the 
 ## @var{order}. We calculate the Chebyshev polynomial using the recurrence
-## relations, Tn+1(x) = (2*x*Tn(x) - Tn-1(x)). The @var{kind} can set to
-## compute the first or second kind chebyshev polynomial.
+## relations Tn+1(x) = (2*x*Tn(x) - Tn-1(x)). The @var{kind} can be set to
+## compute the first or second kind Chebyshev polynomial.
 ##
-## If the value @var{x} is specified, the polynomial is also evaluated,
-## otherwise just the return the coefficients of the polynomial are returned.
+## If the value @var{x} is specified, the polynomial is evaluated at @var{x},
+## otherwise just the coefficients of the polynomial are returned.
 ## 
 ## This is NOT the generalized Chebyshev polynomial.
 ##
@@ -64,3 +64,12 @@
   endif
 
 endfunction
+
+%!test
+%!  x = logspace(-2, 2, 30);
+%!  maxdeg = 10;
+%!  for n = 1:maxdeg
+%!    assert( chebyshevpoly(1,n,cos(x)), cos(n*x), 1E3*eps )
+%!    assert( chebyshevpoly(2,n,cos(x)) .* sin(x), sin((n+1)*x), 1E3*eps )
+%!  endfor 
+