Export series as barvinok_enumerate_series and use it in Hadamard_product
[barvinok.git] / testlib.cc
blobb755c239352dd5ef1d40d7f30adcf356fd6e4fec
1 #include <assert.h>
2 #include <sstream>
3 #include <barvinok/barvinok.h>
4 #include <barvinok/set.h>
5 #include <barvinok/options.h>
6 #include <barvinok/evalue.h>
7 #include <barvinok/util.h>
8 #include "conversion.h"
9 #include "evalue_read.h"
10 #include "dpoly.h"
11 #include "lattice_point.h"
12 #include "counter.h"
13 #include "bernoulli.h"
14 #include "hilbert.h"
15 #include "hull.h"
16 #include "ilp.h"
17 #include "matrix_read.h"
18 #include "config.h"
20 using std::cout;
21 using std::cerr;
22 using std::endl;
24 template <typename T>
25 void set_from_string(T& v, const char *s)
27 std::istringstream str(s);
28 str >> v;
31 int test_evalue(struct barvinok_options *options)
33 unsigned nvar, nparam;
34 char **all_vars;
35 evalue *poly1, poly2;
37 poly1 = evalue_read_from_str("(1/4 * n^4 + 1/2 * n^3 + 1/4 * n^2)",
38 NULL, &all_vars, &nvar, &nparam,
39 options->MaxRays);
40 Free_ParamNames(all_vars, nvar+nparam);
42 value_init(poly2.d);
43 evalue_copy(&poly2, poly1);
44 evalue_negate(poly1);
45 eadd(&poly2, poly1);
46 reduce_evalue(poly1);
47 assert(EVALUE_IS_ZERO(*poly1));
48 evalue_free(poly1);
49 free_evalue_refs(&poly2);
52 int test_split_periods(struct barvinok_options *options)
54 unsigned nvar, nparam;
55 char **all_vars;
56 evalue *e;
58 e = evalue_read_from_str("U + 2V + 3 >= 0\n- U -2V >= 0\n- U 10 >= 0\n"
59 "U >= 0\n\n({( 1/3 * U + ( 2/3 * V + 0 ))})",
60 NULL, &all_vars, &nvar, &nparam,
61 options->MaxRays);
62 Free_ParamNames(all_vars, nvar+nparam);
64 evalue_split_periods(e, 2, options->MaxRays);
65 assert(value_zero_p(e->d));
66 assert(e->x.p->type == partition);
67 assert(e->x.p->size == 4);
68 assert(value_zero_p(e->x.p->arr[1].d));
69 assert(e->x.p->arr[1].x.p->type == polynomial);
70 assert(value_zero_p(e->x.p->arr[3].d));
71 assert(e->x.p->arr[3].x.p->type == polynomial);
72 evalue_free(e);
75 int test_specialization(struct barvinok_options *options)
77 Value v;
78 value_init(v);
79 mpq_t count;
80 mpq_init(count);
82 value_set_si(v, 5);
83 dpoly n(2, v);
84 assert(value_cmp_si(n.coeff->p[0], 1) == 0);
85 assert(value_cmp_si(n.coeff->p[1], 5) == 0);
86 assert(value_cmp_si(n.coeff->p[2], 10) == 0);
88 value_set_si(v, 1);
89 dpoly d(2, v, 1);
90 value_set_si(v, 2);
91 dpoly d2(2, v, 1);
92 d *= d2;
93 assert(value_cmp_si(d.coeff->p[0], 2) == 0);
94 assert(value_cmp_si(d.coeff->p[1], 1) == 0);
95 assert(value_cmp_si(d.coeff->p[2], 0) == 0);
97 n.div(d, count, 1);
98 mpq_canonicalize(count);
99 assert(value_cmp_si(mpq_numref(count), 31) == 0);
100 assert(value_cmp_si(mpq_denref(count), 8) == 0);
102 value_set_si(v, -2);
103 dpoly n2(2, v);
104 assert(value_cmp_si(n2.coeff->p[0], 1) == 0);
105 assert(value_cmp_si(n2.coeff->p[1], -2) == 0);
106 assert(value_cmp_si(n2.coeff->p[2], 3) == 0);
108 n2.div(d, count, 1);
109 mpq_canonicalize(count);
110 assert(value_cmp_si(mpq_numref(count), 6) == 0);
111 assert(value_cmp_si(mpq_denref(count), 1) == 0);
113 value_clear(v);
114 mpq_clear(count);
117 int test_lattice_points(struct barvinok_options *options)
119 Param_Vertices V;
120 mat_ZZ tmp;
121 set_from_string(tmp, "[[0 0 0 0 4][0 0 0 0 4][-1 0 1 0 4]]");
122 V.Vertex = zz2matrix(tmp);
123 vec_ZZ lambda;
124 set_from_string(lambda, "[3 5 7]");
125 mat_ZZ rays;
126 set_from_string(rays, "[[0 1 0][4 0 1][0 0 -1]]");
127 term_info num;
128 evalue *point[4];
130 unsigned nvar, nparam;
131 char **all_vars;
132 point[0] = evalue_read_from_str("( -7/4 * a + ( 7/4 * c + "
133 "( 7 * {( 1/4 * a + ( 3/4 * c + 3/4 ) ) } + -21/4 ) ) )",
134 "a,b,c", &all_vars, &nvar, &nparam, options->MaxRays);
135 Free_ParamNames(all_vars, nvar+nparam);
136 point[1] = evalue_read_from_str("( -7/4 * a + ( 7/4 * c + "
137 "( 7 * {( 1/4 * a + ( 3/4 * c + 1/2 ) ) } + -1/2 ) ) )",
138 "a,b,c", &all_vars, &nvar, &nparam, options->MaxRays);
139 Free_ParamNames(all_vars, nvar+nparam);
140 point[2] = evalue_read_from_str("( -7/4 * a + ( 7/4 * c + "
141 "( 7 * {( 1/4 * a + ( 3/4 * c + 1/4 ) ) } + 17/4 ) ) )",
142 "a,b,c", &all_vars, &nvar, &nparam, options->MaxRays);
143 Free_ParamNames(all_vars, nvar+nparam);
144 point[3] = evalue_read_from_str("( -7/4 * a + ( 7/4 * c + "
145 "( 7 * {( 1/4 * a + ( 3/4 * c + 0 ) ) } + 9 ) ) )",
146 "a,b,c", &all_vars, &nvar, &nparam, options->MaxRays);
147 Free_ParamNames(all_vars, nvar+nparam);
149 lattice_point(&V, rays, lambda, &num, 4, options);
150 Matrix_Free(V.Vertex);
152 for (int i = 0; i < 4; ++i) {
153 assert(eequal(num.E[i], point[i]));
154 evalue_free(point[i]);
155 free_evalue_refs(num.E[i]);
156 delete num.E[i];
158 delete [] num.E;
161 static int test_icounter(struct barvinok_options *options)
163 icounter cnt(2);
164 vec_QQ n_coeff;
165 mat_ZZ n_power;
166 mat_ZZ d_power;
167 set_from_string(n_coeff, "[-2/1 1/1]");
168 set_from_string(n_power, "[[2 6][3 6]]");
169 d_power.SetDims(0, 2);
170 cnt.reduce(n_coeff, n_power, d_power);
171 assert(value_cmp_si(mpq_numref(cnt.count), -1) == 0);
172 assert(value_cmp_si(mpq_denref(cnt.count), 1) == 0);
175 static Matrix *matrix_read_from_str(const char *s)
177 std::istringstream str(s);
178 return Matrix_Read(str);
181 static int test_infinite_counter(struct barvinok_options *options)
183 Matrix *M = matrix_read_from_str("1 3\n 1 1 0\n");
184 Polyhedron *ctx = Constraints2Polyhedron(M, options->MaxRays);
185 Matrix_Free(M);
187 /* (1 -1/2 x^5 - 1/2 x^7)/(1-x) */
188 infinite_counter *cnt = new infinite_counter(1, 1);
189 cnt->init(ctx);
190 vec_QQ n_coeff;
191 mat_ZZ n_power;
192 mat_ZZ d_power;
193 set_from_string(n_coeff, "[1/1 -1/2 -1/2]");
194 set_from_string(n_power, "[[0][5][7]]");
195 set_from_string(d_power, "[[1]]");
196 cnt->reduce(n_coeff, n_power, d_power);
197 assert(value_cmp_si(mpq_numref(cnt->count[0]), 6) == 0);
198 assert(value_cmp_si(mpq_denref(cnt->count[0]), 1) == 0);
199 assert(value_cmp_si(mpq_numref(cnt->count[1]), 0) == 0);
200 assert(value_cmp_si(mpq_denref(cnt->count[1]), 1) == 0);
201 delete cnt;
202 Polyhedron_Free(ctx);
204 M = matrix_read_from_str("2 4\n 1 1 0 0\n 1 0 1 0\n");
205 ctx = Constraints2Polyhedron(M, options->MaxRays);
206 Matrix_Free(M);
208 /* (1 - xy)/((1-x)(1-xy)) */
209 cnt = new infinite_counter(2, 3);
210 cnt->init(ctx);
211 set_from_string(n_coeff, "[1/1 -1/1]");
212 set_from_string(n_power, "[[0 0][1 1]]");
213 set_from_string(d_power, "[[1 0][1 1]]");
214 cnt->reduce(n_coeff, n_power, d_power);
215 assert(value_cmp_si(mpq_numref(cnt->count[1]), 0) != 0);
216 assert(value_cmp_si(mpq_numref(cnt->count[2]), 0) == 0);
217 assert(value_cmp_si(mpq_denref(cnt->count[2]), 1) == 0);
218 assert(value_cmp_si(mpq_numref(cnt->count[3]), 0) == 0);
219 assert(value_cmp_si(mpq_denref(cnt->count[3]), 1) == 0);
220 delete cnt;
222 cnt = new infinite_counter(2, 2);
223 cnt->init(ctx);
224 set_from_string(n_coeff, "[-1/2 1/1 -1/3]");
225 set_from_string(n_power, "[[2 6][3 6]]");
226 d_power.SetDims(0, 2);
227 cnt->reduce(n_coeff, n_power, d_power);
228 assert(value_cmp_si(mpq_numref(cnt->count[0]), 1) == 0);
229 assert(value_cmp_si(mpq_denref(cnt->count[0]), 6) == 0);
230 assert(value_cmp_si(mpq_numref(cnt->count[1]), 0) == 0);
231 assert(value_cmp_si(mpq_denref(cnt->count[1]), 1) == 0);
232 assert(value_cmp_si(mpq_numref(cnt->count[2]), 0) == 0);
233 assert(value_cmp_si(mpq_denref(cnt->count[2]), 1) == 0);
234 delete cnt;
236 cnt = new infinite_counter(2, 2);
237 cnt->init(ctx);
238 set_from_string(n_coeff, "[1/1]");
239 set_from_string(n_power, "[[0 11]]");
240 set_from_string(d_power, "[[0 1]]");
241 cnt->reduce(n_coeff, n_power, d_power);
242 assert(value_cmp_si(mpq_numref(cnt->count[1]), 0) != 0);
243 assert(value_cmp_si(mpq_numref(cnt->count[2]), 0) == 0);
244 assert(value_cmp_si(mpq_denref(cnt->count[2]), 1) == 0);
245 delete cnt;
247 Polyhedron_Free(ctx);
249 return 0;
252 static int test_series(struct barvinok_options *options)
254 Matrix *M = matrix_read_from_str(
255 "12 11\n"
256 " 0 1 0 0 0 0 0 1 0 0 3 \n"
257 " 0 0 1 0 0 0 0 -1 1 0 -5 \n"
258 " 0 0 0 1 0 0 0 0 -2 -1 6 \n"
259 " 0 0 0 0 1 0 0 1 1 0 5 \n"
260 " 0 0 0 0 0 1 0 0 -1 0 0 \n"
261 " 0 0 0 0 0 0 1 -2 0 -1 -3 \n"
262 " 1 0 0 0 0 0 0 2 0 1 3 \n"
263 " 1 0 0 0 0 0 0 1 -1 0 5 \n"
264 " 1 0 0 0 0 0 0 -1 -1 0 -5 \n"
265 " 1 0 0 0 0 0 0 -1 0 0 -3 \n"
266 " 1 0 0 0 0 0 0 0 2 1 -6 \n"
267 " 1 0 0 0 0 0 0 0 1 0 0 \n");
268 Polyhedron *P = Constraints2Polyhedron(M, options->MaxRays);
269 Matrix_Free(M);
270 Polyhedron *C = Universe_Polyhedron(3);
271 gen_fun *gf = barvinok_series_with_options(P, C, options);
272 Polyhedron_Free(P);
273 Polyhedron_Free(C);
274 delete gf;
276 M = matrix_read_from_str(
277 "7 8\n"
278 " 0 1 1 0 0 1 0 2 \n"
279 " 0 0 0 1 0 -2 0 6 \n"
280 " 0 0 0 0 1 -1 0 -1 \n"
281 " 0 0 0 0 0 0 1 0 \n"
282 " 1 0 1 0 0 0 0 0 \n"
283 " 1 0 -1 0 0 -1 0 -2 \n"
284 " 1 0 0 0 0 1 0 -3 \n");
285 P = Constraints2Polyhedron(M, options->MaxRays);
286 Matrix_Free(M);
287 C = Universe_Polyhedron(2);
288 gf = barvinok_series_with_options(P, C, options);
289 Polyhedron_Free(P);
290 Polyhedron_Free(C);
291 delete gf;
293 M = matrix_read_from_str(
294 "2 3\n"
295 "1 1 0\n"
296 "1 -1 10\n");
297 P = Constraints2Polyhedron(M, options->MaxRays);
298 Matrix_Free(M);
299 C = Universe_Polyhedron(1);
300 gf = barvinok_series_with_options(P, C, options);
301 Polyhedron_Free(P);
302 Polyhedron_Free(C);
303 gen_fun *sum = gf->summate(1, options);
304 delete gf;
305 delete sum;
307 return 0;
310 int test_todd(struct barvinok_options *options)
312 tcounter t(2, options->max_index);
313 assert(value_cmp_si(t.todd.coeff->p[0], 1) == 0);
314 assert(value_cmp_si(t.todd.coeff->p[1], -3) == 0);
315 assert(value_cmp_si(t.todd.coeff->p[2], 3) == 0);
316 assert(value_cmp_si(t.todd_denom->p[0], 1) == 0);
317 assert(value_cmp_si(t.todd_denom->p[1], 6) == 0);
318 assert(value_cmp_si(t.todd_denom->p[2], 36) == 0);
320 vec_ZZ lambda;
321 set_from_string(lambda, "[1 -1]");
322 zz2values(lambda, t.lambda->p);
324 mat_ZZ rays;
325 set_from_string(rays, "[[-1 0][-1 1]]");
327 QQ one(1, 1);
329 vec_ZZ v;
330 set_from_string(v, "[2 0 1]");
331 Vector *vertex = Vector_Alloc(3);
332 zz2values(v, vertex->p);
334 t.handle(rays, vertex->p, one, 1, options);
335 assert(value_cmp_si(mpq_numref(t.count), 71) == 0);
336 assert(value_cmp_si(mpq_denref(t.count), 24) == 0);
338 set_from_string(rays, "[[0 -1][1 -1]]");
339 set_from_string(v, "[0 2 1]");
340 zz2values(v, vertex->p);
342 t.handle(rays, vertex->p, one, 1, options);
343 assert(value_cmp_si(mpq_numref(t.count), 71) == 0);
344 assert(value_cmp_si(mpq_denref(t.count), 12) == 0);
346 set_from_string(rays, "[[1 0][0 1]]");
347 set_from_string(v, "[0 0 1]");
348 zz2values(v, vertex->p);
350 t.handle(rays, vertex->p, one, 1, options);
351 assert(value_cmp_si(mpq_numref(t.count), 6) == 0);
352 assert(value_cmp_si(mpq_denref(t.count), 1) == 0);
354 Vector_Free(vertex);
357 int test_bernoulli(struct barvinok_options *options)
359 struct bernoulli_coef *bernoulli_coef;
360 struct poly_list *faulhaber, *bernoulli;
361 bernoulli_coef = bernoulli_coef_compute(2);
362 faulhaber = faulhaber_compute(4);
363 bernoulli_coef = bernoulli_coef_compute(8);
364 assert(value_cmp_si(bernoulli_coef->num->p[6], 1) == 0);
365 assert(value_cmp_si(bernoulli_coef->den->p[6], 42) == 0);
366 assert(value_cmp_si(faulhaber->poly[3]->p[0], 0) == 0);
367 assert(value_cmp_si(faulhaber->poly[3]->p[1], 0) == 0);
368 assert(value_cmp_si(faulhaber->poly[3]->p[2], 1) == 0);
369 assert(value_cmp_si(faulhaber->poly[3]->p[3], -2) == 0);
370 assert(value_cmp_si(faulhaber->poly[3]->p[4], 1) == 0);
371 assert(value_cmp_si(faulhaber->poly[3]->p[5], 4) == 0);
373 bernoulli = bernoulli_compute(6);
374 assert(value_cmp_si(bernoulli->poly[6]->p[0], 1) == 0);
375 assert(value_cmp_si(bernoulli->poly[6]->p[1], 0) == 0);
376 assert(value_cmp_si(bernoulli->poly[6]->p[2], -21) == 0);
377 assert(value_cmp_si(bernoulli->poly[6]->p[3], 0) == 0);
378 assert(value_cmp_si(bernoulli->poly[6]->p[4], 105) == 0);
379 assert(value_cmp_si(bernoulli->poly[6]->p[5], -126) == 0);
380 assert(value_cmp_si(bernoulli->poly[6]->p[6], 42) == 0);
381 assert(value_cmp_si(bernoulli->poly[6]->p[7], 42) == 0);
383 unsigned nvar, nparam;
384 char **all_vars;
385 evalue *base, *sum1, *sum2;
386 base = evalue_read_from_str("(1 * n + 1)", NULL, &all_vars, &nvar, &nparam,
387 options->MaxRays);
389 sum1 = evalue_polynomial(faulhaber->poly[3], base);
390 Free_ParamNames(all_vars, nvar+nparam);
392 sum2 = evalue_read_from_str("(1/4 * n^4 + 1/2 * n^3 + 1/4 * n^2)",
393 NULL, &all_vars, &nvar, &nparam,
394 options->MaxRays);
395 Free_ParamNames(all_vars, nvar+nparam);
396 assert(eequal(sum1, sum2));
397 evalue_free(base);
398 evalue_free(sum1);
399 evalue_free(sum2);
402 int test_bernoulli_sum(struct barvinok_options *options)
404 unsigned nvar, nparam;
405 char **all_vars;
406 evalue *e, *sum1, *sum2;
407 e = evalue_read_from_str("i + -1 >= 0\n -i + n >= 0\n\n 1 + (-1 *i) + i^2",
408 "i", &all_vars, &nvar, &nparam,
409 options->MaxRays);
410 Free_ParamNames(all_vars, nvar+nparam);
412 sum1 = Bernoulli_sum_evalue(e, 1, options);
413 sum2 = evalue_read_from_str("n -1 >= 0\n\n (1/3 * n^3 + 2/3 * n)",
414 NULL, &all_vars, &nvar, &nparam,
415 options->MaxRays);
416 Free_ParamNames(all_vars, nvar+nparam);
417 evalue_negate(sum1);
418 eadd(sum2, sum1);
419 reduce_evalue(sum1);
420 assert(EVALUE_IS_ZERO(*sum1));
421 evalue_free(e);
422 evalue_free(sum1);
424 e = evalue_read_from_str("-i + -1 >= 0\n i + n >= 0\n\n 1 + i + i^2",
425 "i", &all_vars, &nvar, &nparam,
426 options->MaxRays);
427 Free_ParamNames(all_vars, nvar+nparam);
428 sum1 = Bernoulli_sum_evalue(e, 1, options);
429 evalue_negate(sum1);
430 eadd(sum2, sum1);
431 reduce_evalue(sum1);
432 assert(EVALUE_IS_ZERO(*sum1));
433 evalue_free(e);
434 evalue_free(sum1);
436 evalue_free(sum2);
438 e = evalue_read_from_str("i + 4 >= 0\n -i + n >= 0\n\n i",
439 "i", &all_vars, &nvar, &nparam,
440 options->MaxRays);
441 Free_ParamNames(all_vars, nvar+nparam);
442 sum1 = Bernoulli_sum_evalue(e, 1, options);
443 sum2 = evalue_read_from_str("n + 0 >= 0\n\n (1/2 * n^2 + 1/2 * n + (-10))\n"
444 "n + 4 >= 0\n -n -1 >= 0\n\n (1/2 * n^2 + 1/2 * n + (-10))",
445 NULL, &all_vars, &nvar, &nparam,
446 options->MaxRays);
447 Free_ParamNames(all_vars, nvar+nparam);
448 evalue_negate(sum1);
449 eadd(sum2, sum1);
450 reduce_evalue(sum1);
451 assert(EVALUE_IS_ZERO(*sum1));
452 evalue_free(e);
453 evalue_free(sum1);
454 evalue_free(sum2);
456 e = evalue_read_from_str("i -5 >= 0\n -i + n >= 0\n j -1 >= 0\n i -j >= 0\n"
457 "k -1 >= 0\n j -k >= 0\n\n1",
458 "i,j,k", &all_vars, &nvar, &nparam,
459 options->MaxRays);
460 Free_ParamNames(all_vars, nvar+nparam);
461 sum1 = Bernoulli_sum_evalue(e, 3, options);
462 sum2 = evalue_read_from_str("n -5 >= 0\n\n"
463 "1/6 * n^3 + 1/2 * n^2 + 1/3 * n + -20",
464 NULL, &all_vars, &nvar, &nparam,
465 options->MaxRays);
466 Free_ParamNames(all_vars, nvar+nparam);
467 evalue_negate(sum1);
468 eadd(sum2, sum1);
469 reduce_evalue(sum1);
470 assert(EVALUE_IS_ZERO(*sum1));
471 evalue_free(e);
472 evalue_free(sum1);
473 evalue_free(sum2);
476 int test_hilbert(struct barvinok_options *options)
478 #ifdef USE_ZSOLVE
479 Matrix *M = matrix_read_from_str(
480 "2 4\n"
481 " 1 4 -3 0 \n"
482 " 1 3 2 0 \n");
483 Polyhedron *P = Constraints2Polyhedron(M, options->MaxRays);
484 Matrix_Free(M);
486 M = Cone_Hilbert_Basis(P, options->MaxRays);
487 assert(M->NbRows = 5);
488 assert(M->NbColumns = 3);
489 Matrix_Free(M);
491 M = Cone_Integer_Hull(P, NULL, 0, options);
492 assert(M->NbRows = 4);
493 assert(M->NbColumns = 3);
494 Matrix_Free(M);
496 Polyhedron_Free(P);
497 #endif
500 int test_ilp(struct barvinok_options *options)
502 Matrix *M = matrix_read_from_str(
503 "2 4\n"
504 " 1 4 -3 0 \n"
505 " 1 3 2 0 \n");
506 Polyhedron *P = Constraints2Polyhedron(M, options->MaxRays);
507 Matrix_Free(M);
508 Vector *obj = Vector_Alloc(2);
509 value_set_si(obj->p[0], 7);
510 value_set_si(obj->p[1], -1);
511 Value min, max;
512 value_init(min);
513 value_init(max);
515 value_set_si(min, 1);
516 value_set_si(max, 17);
517 Vector *opt = Polyhedron_Integer_Minimum(P, obj->p, min, max,
518 NULL, 0, options);
519 assert(opt);
520 assert(value_cmp_si(opt->p[0], 1) == 0);
521 assert(value_cmp_si(opt->p[1], 1) == 0);
522 assert(value_cmp_si(opt->p[2], 1) == 0);
523 Vector_Free(opt);
525 value_clear(min);
526 value_clear(max);
527 Vector_Free(obj);
528 Polyhedron_Free(P);
531 int test_hull(struct barvinok_options *options)
533 Matrix *M = matrix_read_from_str(
534 "4 4\n"
535 "1 32 -20 7\n"
536 "1 8 -44 187\n"
537 "1 -48 -4 285\n"
538 "1 8 68 -199\n");
539 Polyhedron *P = Constraints2Polyhedron(M, options->MaxRays);
540 Matrix_Free(M);
542 Matrix *hull = Polyhedron_Integer_Hull(P, options);
543 Polyhedron_Free(P);
544 assert(hull->NbRows == 4);
545 M = Matrix_Alloc(hull->NbRows, 1+hull->NbColumns);
546 for (int i = 0; i < hull->NbRows; ++i) {
547 value_set_si(M->p[i][0], 1);
548 Vector_Copy(hull->p[i], M->p[i]+1, hull->NbColumns);
550 Matrix_Free(hull);
551 Polyhedron *H = Constraints2Polyhedron(M, options->MaxRays);
552 Matrix_Free(M);
554 M = matrix_read_from_str(
555 "4 4\n"
556 "1 2 3 1 \n"
557 "1 3 4 1 \n"
558 "1 5 3 1 \n"
559 "1 5 5 1 \n");
560 P = Constraints2Polyhedron(M, options->MaxRays);
561 Matrix_Free(M);
562 assert(PolyhedronIncludes(P, H) && PolyhedronIncludes(H, P));
563 Polyhedron_Free(P);
564 Polyhedron_Free(H);
566 M = matrix_read_from_str(
567 "3 4\n"
568 "1 2 6 -3 \n"
569 "1 2 -6 3 \n"
570 "1 -2 0 3 \n");
571 P = Constraints2Polyhedron(M, options->MaxRays);
572 Matrix_Free(M);
573 assert(!emptyQ(P));
574 hull = Polyhedron_Integer_Hull(P, options);
575 Polyhedron_Free(P);
576 assert(hull->NbRows == 0);
577 Matrix_Free(hull);
580 int main(int argc, char **argv)
582 struct barvinok_options *options = barvinok_options_new_with_defaults();
583 test_evalue(options);
584 test_split_periods(options);
585 test_specialization(options);
586 test_lattice_points(options);
587 test_icounter(options);
588 test_infinite_counter(options);
589 test_series(options);
590 test_todd(options);
591 test_bernoulli(options);
592 test_bernoulli_sum(options);
593 test_hilbert(options);
594 test_ilp(options);
595 test_hull(options);
596 barvinok_options_free(options);