Last change
on this file since 17 was
17,
checked in by zhangj, 10 years ago
|
To have a stable version on the server.
|
-
Property svn:executable set to
*
|
File size:
814 bytes
|
Line | |
---|
1 | function pass = chebpolytest |
---|
2 | |
---|
3 | % Nick Trefethen 29 December 2008 |
---|
4 | |
---|
5 | % Tests of the form chebfun = chebpoly(integer): |
---|
6 | |
---|
7 | tol = chebfunpref('eps'); |
---|
8 | |
---|
9 | T5 = chebpoly(5); |
---|
10 | x = [0 .4 1]; |
---|
11 | exact = [0 .88384 1]; |
---|
12 | pass1 = (norm(T5(x)-exact)<1e-14*(tol/eps)); |
---|
13 | |
---|
14 | T5b = chebpoly(5,[1,9]); |
---|
15 | xb = 4*x + 5; |
---|
16 | pass2 = (norm(T5b(xb)-exact)<1e-14*(tol/eps)); |
---|
17 | |
---|
18 | T100 = chebpoly(100); |
---|
19 | pass3 = (abs(sum(T100)-(-2/9999)) < 1e-15*(tol/eps)); |
---|
20 | |
---|
21 | % Tests of the form vector = chebpoly(chebfun): |
---|
22 | |
---|
23 | a = chebpoly(chebfun('exp(x).*sin(x)')); a = a(end:-1:1); |
---|
24 | exacta = [0.496529947609122 1.228320669845808 0.494795283026613]; |
---|
25 | pass4 = (norm(a(1:3)-exacta)<1e-14*(tol/eps)); |
---|
26 | |
---|
27 | % Combined tests: |
---|
28 | |
---|
29 | f = chebpoly(5) + .25*chebpoly(4); |
---|
30 | exactf = [1 .25 0 0 0 0]; |
---|
31 | pass5 = norm(exactf - chebpoly(f)) < 1e-15*(tol/eps); |
---|
32 | |
---|
33 | pass = pass1 && pass2 && pass3 && pass4 && pass5; |
---|
34 | |
---|
Note: See
TracBrowser
for help on using the repository browser.