1 /* Test Octagonal_Shape::affine_dimension().
2 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4
5 This file is part of the Parma Polyhedra Library (PPL).
6
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23
24 #include "ppl_test.hh"
25
26 namespace {
27
28 bool
test01()29 test01() {
30 Variable x(0);
31 Variable y(1);
32
33 TOctagonal_Shape oct(3);
34
35 oct.add_constraint(x <= 2);
36 oct.add_constraint(x - y == 3);
37 oct.add_constraint(y <= 2);
38
39 print_constraints(oct, "*** oct ***");
40
41 dimension_type affine_dim = oct.affine_dimension();
42
43 nout << endl
44 << "The affine dimension of a system of `oct' is:"
45 << endl
46 << affine_dim
47 << endl;
48
49 bool ok = (affine_dim == 2);
50
51 return ok;
52 }
53
54 bool
test02()55 test02() {
56 Variable A(0);
57 Variable B(1);
58 Variable C(2);
59 Variable D(3);
60 Variable E(4);
61
62 TOctagonal_Shape oct(5);
63
64 oct.add_constraint(A <= 5);
65 oct.add_constraint(A - B == 3);
66 oct.add_constraint(C <= 2);
67 oct.add_constraint(E - D == 2);
68
69 print_constraints(oct, "*** oct ***");
70
71 dimension_type affine_dim = oct.affine_dimension();
72
73 nout << endl
74 << "The affine dimension of a system of `oct' is:"
75 << endl
76 << affine_dim
77 << endl;
78
79 bool ok = (affine_dim == 3);
80
81 return ok;
82 }
83
84 bool
test03()85 test03() {
86 Variable A(0);
87 Variable B(1);
88 Variable C(2);
89 Variable D(3);
90 Variable E(4);
91
92 TOctagonal_Shape oct(5);
93
94 oct.add_constraint(A == 5);
95 oct.add_constraint(A - B == 3);
96 oct.add_constraint(C <= 2);
97 oct.add_constraint(E - D == 2);
98
99 print_constraints(oct, "*** oct ***");
100
101 dimension_type affine_dim = oct.affine_dimension();
102
103 nout << endl
104 << "The affine dimension of a system of `oct' is:"
105 << endl
106 << affine_dim
107 << endl;
108
109 bool ok = (affine_dim == 2);
110
111 return ok;
112 }
113
114 bool
test04()115 test04() {
116 Variable A(0);
117 Variable B(1);
118
119 TOctagonal_Shape oct(2);
120 oct.add_constraint(A <= 3);
121 oct.add_constraint(B - A <= -5);
122 oct.add_constraint(-B <= 2);
123
124 print_constraints(oct, "*** oct ***");
125
126 dimension_type affine_dim = oct.affine_dimension();
127
128 nout << endl
129 << "The affine dimension of a system of `oct' is:"
130 << endl
131 << affine_dim
132 << endl;
133
134 bool ok = (affine_dim == 0);
135
136 return ok;
137 }
138
139 bool
test05()140 test05() {
141 TOctagonal_Shape oct(2, EMPTY);
142
143 print_constraints(oct, "*** oct ***");
144
145 dimension_type affine_dim = oct.affine_dimension();
146
147 nout << endl
148 << "The affine dimension of a system of `oct' is:"
149 << endl
150 << affine_dim
151 << endl;
152
153 bool ok = (affine_dim == 0);
154
155 return ok;
156 }
157
158 bool
test06()159 test06() {
160 TOctagonal_Shape oct(2);
161
162 print_constraints(oct, "*** oct ***");
163
164 dimension_type affine_dim = oct.affine_dimension();
165
166 nout << endl
167 << "The affine dimension of a system of `oct' is:"
168 << endl
169 << affine_dim
170 << endl;
171
172 bool ok = (affine_dim == 2);
173
174 return ok;
175 }
176
177 bool
test07()178 test07() {
179 Variable A(0);
180 Variable B(1);
181 Variable D(3);
182
183 TOctagonal_Shape oct(4);
184 oct.add_constraint(A <= 1);
185 oct.add_constraint(A - D == 8);
186 oct.add_constraint(B <= 7);
187
188 print_constraints(oct, "*** oct ***");
189
190 dimension_type affine_dim = oct.affine_dimension();
191
192 nout << endl
193 << "The affine dimension of a system of `oct' is:"
194 << endl
195 << affine_dim
196 << endl;
197
198 bool ok = (affine_dim == 3);
199
200 return ok;
201 }
202
203 bool
test08()204 test08() {
205 Variable A(0);
206 Variable B(1);
207 Variable D(3);
208 Variable E(4);
209
210 TOctagonal_Shape oct(5);
211 oct.add_constraint(A == 1);
212 oct.add_constraint(E == 1);
213 oct.add_constraint(A - D == 8);
214 oct.add_constraint(B <= 7);
215
216 print_constraints(oct, "*** oct ***");
217
218 dimension_type affine_dim = oct.affine_dimension();
219
220 nout << endl
221 << "The affine dimension of a system of `oct' is:"
222 << endl
223 << affine_dim
224 << endl;
225
226 bool ok = (affine_dim == 2);
227
228 return ok;
229 }
230
231 bool
test09()232 test09() {
233 Variable A(0);
234 Variable B(1);
235
236 TOctagonal_Shape oct(2);
237 oct.add_constraint(A == 0);
238 oct.add_constraint(B == 2);
239
240 print_constraints(oct, "*** oct ***");
241
242 dimension_type affine_dim = oct.affine_dimension();
243
244 nout << endl
245 << "The affine dimension of a system of `oct' is:"
246 << endl
247 << affine_dim
248 << endl;
249
250 bool ok = (affine_dim == 0);
251
252 return ok;
253 }
254
255 bool
test10()256 test10() {
257 Variable A(0);
258 Variable B(1);
259
260 TOctagonal_Shape oct(7);
261 oct.add_constraint(A <= 1);
262 oct.add_constraint(B == 2);
263 oct.add_constraint(B - A <= -6);
264
265 print_constraints(oct, "*** oct ***");
266
267 dimension_type affine_dim = oct.affine_dimension();
268
269 nout << endl
270 << "The affine dimension of a system of `oct' is:"
271 << endl
272 << affine_dim
273 << endl;
274
275 bool ok = (affine_dim == 0);
276
277 return ok;
278 }
279
280 bool
test11()281 test11() {
282 TOctagonal_Shape oct(0, UNIVERSE);
283
284 const dimension_type affine_dim = oct.affine_dimension();
285
286 print_constraints(oct, "*** oct ***");
287
288 return affine_dim == 0;
289 }
290
291 } // namespace
292
293 BEGIN_MAIN
294 DO_TEST(test01);
295 DO_TEST(test02);
296 DO_TEST(test03);
297 DO_TEST(test04);
298 DO_TEST(test05);
299 DO_TEST(test06);
300 DO_TEST(test07);
301 DO_TEST(test08);
302 DO_TEST(test09);
303 DO_TEST(test10);
304 DO_TEST(test11);
305 END_MAIN
306
307