Annotation of OpenXM_contrib/PHC/Ada/Schubert/ts_cheby.adb, Revision 1.1.1.1
1.1 maekawa 1: with text_io,integer_io; use text_io,integer_io;
2: with Standard_Floating_Numbers; use Standard_Floating_Numbers;
3: with Standard_Floating_Numbers_io; use Standard_Floating_Numbers_io;
4: with Standard_Floating_Vectors; use Standard_Floating_Vectors;
5: with Standard_Floating_Vectors_io; use Standard_Floating_Vectors_io;
6: with Chebychev_Polynomials; use Chebychev_Polynomials;
7:
8: procedure ts_cheby is
9:
10: procedure Test_Create is
11:
12: k : natural;
13:
14: begin
15: new_line;
16: put_line("Testing the creation of Chebychev polynomials.");
17: new_line;
18: put("Give the degree k : "); get(k);
19: for i in 0..k loop
20: declare
21: pi : constant Vector := Create(i);
22: begin
23: put("The coefficients of the "); put(i,1);
24: put_line("-degree Chebychev polynomial : ");
25: put_line(pi);
26: end;
27: end loop;
28: end Test_Create;
29:
30: procedure Test_Diff is
31:
32: k : natural;
33: ans : character;
34:
35: begin
36: new_line;
37: put_line("Testing the differentiation of Chebychev polynomials.");
38: loop
39: new_line;
40: put("Give the degree k : "); get(k);
41: declare
42: pk : constant Vector := Create(k);
43: dp : constant Vector := Diff(pk);
44: begin
45: put("The coefficients of the "); put(k,1);
46: put_line("-degree Chebychev polynomial : ");
47: put_line(pk);
48: put_line("The coefficients of its derivative : ");
49: put_line(dp);
50: for i in 1..k loop
51: declare
52: dpi : constant Vector := Diff(pk,i);
53: begin
54: put("The coefficients after deriving "); put(i,1);
55: put_line(" times : "); put_line(dpi);
56: end;
57: end loop;
58: end;
59: put("Do you want more tests (y/n) "); get(ans);
60: exit when (ans /= 'y');
61: end loop;
62: end Test_Diff;
63:
64: procedure Test_Int is
65:
66: k : natural;
67: ans : character;
68:
69: begin
70: new_line;
71: put_line("Testing the Antidifferentiation of Chebychev polynomials.");
72: loop
73: new_line;
74: put("Give the degree k : "); get(k);
75: declare
76: pk : constant Vector := Create(k);
77: dp : constant Vector := Int(pk);
78: begin
79: put("The coefficients of the "); put(k,1);
80: put_line("-degree Chebychev polynomial : ");
81: put_line(pk);
82: put_line("The coefficients of its antiderivative : ");
83: put_line(dp);
84: for i in 1..k loop
85: declare
86: dpi : constant Vector := Int(pk,i);
87: begin
88: put("The coefficients after antideriving "); put(i,1);
89: put_line(" times : "); put_line(dpi);
90: end;
91: end loop;
92: end;
93: put("Do you want more tests (y/n) "); get(ans);
94: exit when (ans /= 'y');
95: end loop;
96: end Test_Int;
97:
98: procedure Test_Eval is
99:
100: k : natural;
101: ans : character;
102:
103: begin
104: new_line;
105: put_line("Testing the evaluation of Chebychev polynomials.");
106: loop
107: new_line;
108: put("Give the degree k : "); get(k);
109: declare
110: p : constant Vector := Create(k);
111: x : double_float;
112: begin
113: loop
114: put("Give x : "); get(x);
115: put("p(x) : "); put(Eval(p,x)); new_line;
116: put("COS-ARCCOS-eval : "); put(Eval(k,x)); new_line;
117: put("Do you want more evaluations ? (y/n) "); get(ans);
118: exit when (ans /= 'y');
119: end loop;
120: end;
121: put("Do you want other polynomials to evaluate ? (y/n) "); get(ans);
122: exit when (ans /= 'y');
123: end loop;
124: end Test_Eval;
125:
126: procedure Main is
127:
128: ans : character;
129:
130: begin
131: new_line;
132: put_line("Testing the manipulation of Chebychev polynomials.");
133: loop
134: new_line;
135: put_line("Choose one of the following :");
136: put_line(" 0. Exit this program.");
137: put_line(" 1. Creation of Chebychev polynomials.");
138: put_line(" 2. Differentiation of Chebychev polynomials.");
139: put_line(" 3. Antidifferentiation of Chebychev polynomials.");
140: put_line(" 4. Evaluation of Chebychev polynomials.");
141: put("Type 0,1,2,3 or 4 to make your choice : "); get(ans);
142: exit when (ans = '0');
143: case ans is
144: when '1' => Test_Create;
145: when '2' => Test_Diff;
146: when '3' => Test_Int;
147: when '4' => Test_Eval;
148: when others => null;
149: end case;
150: end loop;
151: end Main;
152:
153: begin
154: Main;
155: end ts_cheby;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>