Annotation of OpenXM_contrib/PHC/Ada/Math_Lib/Matrices/ts_natvec.adb, Revision 1.1.1.1
1.1 maekawa 1: with text_io,integer_io; use text_io,integer_io;
2: with Standard_Natural_Vectors;
3: with Standard_Natural_Vectors_io;
4: with Standard_Natural_VecVecs;
5: with Standard_Natural_VecVecs_io;
6: with Multprec_Natural_Vectors;
7: with Multprec_Natural_Vectors_io;
8: with Multprec_Natural_VecVecs;
9: with Multprec_Natural_VecVecs_io;
10:
11: procedure ts_natvec is
12:
13: -- DESCRIPTION :
14: -- Tests the vector packages of standard and multi-precision naturals.
15:
16: procedure Test_Standard_Vectors_io is
17:
18: use Standard_Natural_Vectors,Standard_Natural_Vectors_io;
19:
20: n : natural;
21:
22: begin
23: put("Give the dimension : "); get(n);
24: declare
25: nv : Vector(1..n);
26: begin
27: put("Give "); put(n,1); put_line(" natural numbers : "); get(nv);
28: put("Your vector : "); put(nv); new_line;
29: end;
30: end Test_Standard_Vectors_io;
31:
32: procedure Test_Standard_Addition is
33:
34: use Standard_Natural_Vectors,Standard_Natural_Vectors_io;
35:
36: n : natural;
37:
38: begin
39: put("Give the dimension : "); get(n);
40: declare
41: a,b,sum : Vector(1..n);
42: begin
43: put("Give "); put(n,1); put_line(" natural numbers : "); get(a);
44: put("-> vector a : "); put(a); new_line;
45: put("Give "); put(n,1); put_line(" natural numbers : "); get(b);
46: put("-> vector b : "); put(b); new_line;
47: sum := a+b;
48: put(" The sum a+b : "); put(sum); new_line;
49: end;
50: end Test_Standard_Addition;
51:
52: procedure Test_Standard_VecVecs_io is
53:
54: use Standard_Natural_VecVecs,Standard_Natural_VecVecs_io;
55:
56: n : natural;
57:
58: begin
59: put("Give the dimension : "); get(n);
60: declare
61: nv : VecVec(1..n);
62: begin
63: put("Give "); put(n,1); put_line(" natural vectors : "); get(n,nv);
64: put_line("Your vector : "); put(nv); new_line;
65: end;
66: end Test_Standard_VecVecs_io;
67:
68: procedure Test_Multprec_Vectors_io is
69:
70: use Multprec_Natural_Vectors,Multprec_Natural_Vectors_io;
71:
72: n : natural;
73:
74: begin
75: put("Give the dimension : "); get(n);
76: declare
77: nv : Vector(1..n);
78: begin
79: put("Give "); put(n,1); put_line(" natural numbers : "); get(nv);
80: put_line("Your vector : "); put_line(nv);
81: end;
82: end Test_Multprec_Vectors_io;
83:
84: procedure Test_Multprec_VecVecs_io is
85:
86: use Multprec_Natural_VecVecs,Multprec_Natural_VecVecs_io;
87:
88: n : natural;
89:
90: begin
91: put("Give the dimension : "); get(n);
92: declare
93: nv : VecVec(1..n);
94: begin
95: put("Give "); put(n,1); put_line(" natural vectors : "); get(n,nv);
96: put_line("Your vector : "); put_line(nv);
97: end;
98: end Test_Multprec_VecVecs_io;
99:
100: procedure Main is
101:
102: ans : character;
103:
104: begin
105: new_line;
106: put_line("Interactive testing of vectors of natural numbers.");
107: loop
108: new_line;
109: put_line("Choose one of the following : ");
110: put_line(" 0. exit the program.");
111: put_line(" 1. io of vectors of standard natural numbers.");
112: put_line(" 2. addition of vectors of standard natural numbers.");
113: put_line(" 3. io of vectors of vectors of standard natural numbers.");
114: put_line(" 4. io of vectors of multi-precision natural numbers.");
115: put_line(" 5. io of vectors of vectors of multi-precision naturals.");
116: put("Make your choice (0,1,2,3, or 4) : "); get(ans);
117: case ans is
118: when '1' => Test_Standard_Vectors_io;
119: when '2' => Test_Standard_Addition;
120: when '3' => Test_Standard_VecVecs_io;
121: when '4' => Test_Multprec_Vectors_io;
122: when '5' => Test_Multprec_VecVecs_io;
123: when others => null;
124: end case;
125: exit when (ans = '0');
126: end loop;
127: end Main;
128:
129: begin
130: Main;
131: end ts_natvec;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>