4 #include <NTL/vec_ZZ.h>
5 #include <NTL/mat_ZZ.h>
6 #include <barvinok/NTL_QQ.h>
7 #include <barvinok/polylib.h>
8 #include <barvinok/barvinok.h>
9 #include <barvinok/set.h>
10 #include <barvinok/options.h>
11 #include <barvinok/basis_reduction.h>
12 #include <barvinok/evalue.h>
13 #include <barvinok/util.h>
14 #include "conversion.h"
15 #include "evalue_read.h"
17 #include "lattice_point.h"
19 #include "bernoulli.h"
24 #include "matrix_read.h"
25 #include "remove_equalities.h"
33 void set_from_string(T
& v
, const char *s
)
35 std::istringstream
str(s
);
39 static Matrix
*matrix_read_from_str(const char *s
)
41 std::istringstream
str(s
);
42 return Matrix_Read(str
);
45 static int test_equalities(struct barvinok_options
*options
)
47 Matrix
*M
= matrix_read_from_str(
49 " 0 23 0 0 -10 0 0 0 7 -44 -8 \n"
50 " 0 0 23 0 5 0 0 0 -15 114 27 \n"
51 " 0 0 0 1 0 0 0 0 0 -1 2 \n"
52 " 0 0 0 0 0 1 0 0 -1 8 0 \n"
53 " 0 0 0 0 0 0 1 0 0 -1 2 \n"
54 " 0 0 0 0 0 0 0 1 0 -1 -1 \n"
55 " 1 0 0 0 10 0 0 0 -7 44 8 \n"
56 " 1 0 0 0 -5 0 0 0 15 -114 -27 \n"
57 " 1 0 0 0 1 0 0 0 0 0 0 \n"
58 " 1 0 0 0 0 0 0 0 1 -8 0 \n"
59 " 1 0 0 0 0 0 0 0 0 1 -2 \n");
60 Polyhedron
*P
= Constraints2Polyhedron(M
, options
->MaxRays
);
63 remove_all_equalities(&P
, NULL
, NULL
, NULL
, 2, options
->MaxRays
);
71 int test_evalue_read(struct barvinok_options
*options
)
73 unsigned nvar
, nparam
;
74 const char **all_vars
;
77 e1
= evalue_read_from_str("(1 * aa + 2 * a)",
78 NULL
, &all_vars
, &nvar
, &nparam
, options
->MaxRays
);
79 Free_ParamNames(all_vars
, nvar
+nparam
);
80 e2
= evalue_read_from_str("(3 * aa)",
81 NULL
, &all_vars
, &nvar
, &nparam
, options
->MaxRays
);
82 Free_ParamNames(all_vars
, nvar
+nparam
);
83 assert(!eequal(e1
, e2
));
89 static void evalue_check_disjoint(evalue
*e
)
95 if (EVALUE_IS_ZERO(*e
))
97 for (i
= 0; i
< e
->x
.p
->size
/2; ++i
) {
98 Polyhedron
*A
= EVALUE_DOMAIN(e
->x
.p
->arr
[2*i
]);
99 for (j
= i
+1; j
< e
->x
.p
->size
/2; ++j
) {
100 Polyhedron
*B
= EVALUE_DOMAIN(e
->x
.p
->arr
[2*j
]);
101 Polyhedron
*I
= DomainIntersection(A
, B
, 0);
108 static int test_eadd(struct barvinok_options
*options
)
110 unsigned nvar
, nparam
;
111 const char **all_vars
;
114 e1
= evalue_read_from_str(" d -1 = 0\n"
119 "d,h", &all_vars
, &nvar
, &nparam
,
121 Free_ParamNames(all_vars
, nvar
+nparam
);
122 e2
= evalue_read_from_str(
134 "d,h", &all_vars
, &nvar
, &nparam
,
136 Free_ParamNames(all_vars
, nvar
+nparam
);
138 evalue_check_disjoint(e1
);
144 int test_evalue(struct barvinok_options
*options
)
146 unsigned nvar
, nparam
;
147 const char **all_vars
;
148 evalue
*poly1
, poly2
;
150 poly1
= evalue_read_from_str("(1/4 * n^4 + 1/2 * n^3 + 1/4 * n^2)",
151 NULL
, &all_vars
, &nvar
, &nparam
,
153 Free_ParamNames(all_vars
, nvar
+nparam
);
156 evalue_copy(&poly2
, poly1
);
157 evalue_negate(poly1
);
159 reduce_evalue(poly1
);
160 assert(EVALUE_IS_ZERO(*poly1
));
162 free_evalue_refs(&poly2
);
166 int test_substitute(struct barvinok_options
*options
)
168 unsigned nvar
, nparam
;
169 const char **all_vars
;
170 const char *vars
= "a,b";
174 e1
= evalue_read_from_str("[ { 1/3 * a } = 0 ] * \n"
175 " ([ { 1/5 * b + 2/5 } = 0 ] * 5) + \n"
176 "[ { 1/3 * a } != 0 ] * 42",
177 vars
, &all_vars
, &nvar
, &nparam
,
179 Free_ParamNames(all_vars
, nvar
+nparam
);
181 subs
[0] = evalue_read_from_str("(2 * b + 5)",
182 vars
, &all_vars
, &nvar
, &nparam
,
184 Free_ParamNames(all_vars
, nvar
+nparam
);
185 subs
[1] = evalue_read_from_str("(a + 1)",
186 vars
, &all_vars
, &nvar
, &nparam
,
188 Free_ParamNames(all_vars
, nvar
+nparam
);
190 evalue_substitute(e1
, subs
);
191 evalue_free(subs
[0]);
192 evalue_free(subs
[1]);
195 e2
= evalue_read_from_str("[ { 2/3 * b + 2/3 } = 0 ] * \n"
196 " ([ { 1/5 * a + 3/5 } = 0 ] * 5) + \n"
197 "[ { 2/3 * b + 2/3 } != 0 ] * 42",
198 vars
, &all_vars
, &nvar
, &nparam
,
200 Free_ParamNames(all_vars
, nvar
+nparam
);
203 assert(eequal(e1
, e2
));
210 int test_specialization(struct barvinok_options
*options
)
219 assert(value_cmp_si(n
.coeff
->p
[0], 1) == 0);
220 assert(value_cmp_si(n
.coeff
->p
[1], 5) == 0);
221 assert(value_cmp_si(n
.coeff
->p
[2], 10) == 0);
228 assert(value_cmp_si(d
.coeff
->p
[0], 2) == 0);
229 assert(value_cmp_si(d
.coeff
->p
[1], 1) == 0);
230 assert(value_cmp_si(d
.coeff
->p
[2], 0) == 0);
233 mpq_canonicalize(count
);
234 assert(value_cmp_si(mpq_numref(count
), 31) == 0);
235 assert(value_cmp_si(mpq_denref(count
), 8) == 0);
239 assert(value_cmp_si(n2
.coeff
->p
[0], 1) == 0);
240 assert(value_cmp_si(n2
.coeff
->p
[1], -2) == 0);
241 assert(value_cmp_si(n2
.coeff
->p
[2], 3) == 0);
244 mpq_canonicalize(count
);
245 assert(value_cmp_si(mpq_numref(count
), 6) == 0);
246 assert(value_cmp_si(mpq_denref(count
), 1) == 0);
253 int test_lattice_points(struct barvinok_options
*options
)
257 set_from_string(tmp
, "[[0 0 0 0 4][0 0 0 0 4][-1 0 1 0 4]]");
258 V
.Vertex
= zz2matrix(tmp
);
260 set_from_string(lambda
, "[3 5 7]");
262 set_from_string(rays
, "[[0 1 0][4 0 1][0 0 -1]]");
266 unsigned nvar
, nparam
;
267 const char **all_vars
;
268 point
[0] = evalue_read_from_str("( -7/4 * a + ( 7/4 * c + "
269 "( 7 * {( 1/4 * a + ( 3/4 * c + 3/4 ) ) } + -21/4 ) ) )",
270 "a,b,c", &all_vars
, &nvar
, &nparam
, options
->MaxRays
);
271 Free_ParamNames(all_vars
, nvar
+nparam
);
272 point
[1] = evalue_read_from_str("( -7/4 * a + ( 7/4 * c + "
273 "( 7 * {( 1/4 * a + ( 3/4 * c + 1/2 ) ) } + -1/2 ) ) )",
274 "a,b,c", &all_vars
, &nvar
, &nparam
, options
->MaxRays
);
275 Free_ParamNames(all_vars
, nvar
+nparam
);
276 point
[2] = evalue_read_from_str("( -7/4 * a + ( 7/4 * c + "
277 "( 7 * {( 1/4 * a + ( 3/4 * c + 1/4 ) ) } + 17/4 ) ) )",
278 "a,b,c", &all_vars
, &nvar
, &nparam
, options
->MaxRays
);
279 Free_ParamNames(all_vars
, nvar
+nparam
);
280 point
[3] = evalue_read_from_str("( -7/4 * a + ( 7/4 * c + "
281 "( 7 * {( 1/4 * a + ( 3/4 * c + 0 ) ) } + 9 ) ) )",
282 "a,b,c", &all_vars
, &nvar
, &nparam
, options
->MaxRays
);
283 Free_ParamNames(all_vars
, nvar
+nparam
);
285 lattice_point(&V
, rays
, lambda
, &num
, 4, options
);
286 Matrix_Free(V
.Vertex
);
288 for (int i
= 0; i
< 4; ++i
) {
289 assert(eequal(num
.E
[i
], point
[i
]));
290 evalue_free(point
[i
]);
291 evalue_free(num
.E
[i
]);
297 static int test_icounter(struct barvinok_options
*options
)
303 set_from_string(n_coeff
, "[-2/1 1/1]");
304 set_from_string(n_power
, "[[2 6][3 6]]");
305 d_power
.SetDims(0, 2);
306 cnt
.reduce(n_coeff
, n_power
, d_power
);
307 assert(value_cmp_si(mpq_numref(cnt
.count
), -1) == 0);
308 assert(value_cmp_si(mpq_denref(cnt
.count
), 1) == 0);
312 static int test_infinite_counter(struct barvinok_options
*options
)
314 Matrix
*M
= matrix_read_from_str("1 3\n 1 1 0\n");
315 Polyhedron
*ctx
= Constraints2Polyhedron(M
, options
->MaxRays
);
318 /* (1 -1/2 x^5 - 1/2 x^7)/(1-x) */
319 infinite_counter
*cnt
= new infinite_counter(1, 1);
324 set_from_string(n_coeff
, "[1/1 -1/2 -1/2]");
325 set_from_string(n_power
, "[[0][5][7]]");
326 set_from_string(d_power
, "[[1]]");
327 cnt
->reduce(n_coeff
, n_power
, d_power
);
328 assert(value_cmp_si(mpq_numref(cnt
->count
[0]), 6) == 0);
329 assert(value_cmp_si(mpq_denref(cnt
->count
[0]), 1) == 0);
330 assert(value_cmp_si(mpq_numref(cnt
->count
[1]), 0) == 0);
331 assert(value_cmp_si(mpq_denref(cnt
->count
[1]), 1) == 0);
333 Polyhedron_Free(ctx
);
335 M
= matrix_read_from_str("2 4\n 1 1 0 0\n 1 0 1 0\n");
336 ctx
= Constraints2Polyhedron(M
, options
->MaxRays
);
339 /* (1 - xy)/((1-x)(1-xy)) */
340 cnt
= new infinite_counter(2, 3);
342 set_from_string(n_coeff
, "[1/1 -1/1]");
343 set_from_string(n_power
, "[[0 0][1 1]]");
344 set_from_string(d_power
, "[[1 0][1 1]]");
345 cnt
->reduce(n_coeff
, n_power
, d_power
);
346 assert(value_cmp_si(mpq_numref(cnt
->count
[1]), 0) != 0);
347 assert(value_cmp_si(mpq_numref(cnt
->count
[2]), 0) == 0);
348 assert(value_cmp_si(mpq_denref(cnt
->count
[2]), 1) == 0);
349 assert(value_cmp_si(mpq_numref(cnt
->count
[3]), 0) == 0);
350 assert(value_cmp_si(mpq_denref(cnt
->count
[3]), 1) == 0);
353 cnt
= new infinite_counter(2, 2);
355 set_from_string(n_coeff
, "[-1/2 1/1 -1/3]");
356 set_from_string(n_power
, "[[2 6][3 6]]");
357 d_power
.SetDims(0, 2);
358 cnt
->reduce(n_coeff
, n_power
, d_power
);
359 assert(value_cmp_si(mpq_numref(cnt
->count
[0]), 1) == 0);
360 assert(value_cmp_si(mpq_denref(cnt
->count
[0]), 6) == 0);
361 assert(value_cmp_si(mpq_numref(cnt
->count
[1]), 0) == 0);
362 assert(value_cmp_si(mpq_denref(cnt
->count
[1]), 1) == 0);
363 assert(value_cmp_si(mpq_numref(cnt
->count
[2]), 0) == 0);
364 assert(value_cmp_si(mpq_denref(cnt
->count
[2]), 1) == 0);
367 cnt
= new infinite_counter(2, 2);
369 set_from_string(n_coeff
, "[1/1]");
370 set_from_string(n_power
, "[[0 11]]");
371 set_from_string(d_power
, "[[0 1]]");
372 cnt
->reduce(n_coeff
, n_power
, d_power
);
373 assert(value_cmp_si(mpq_numref(cnt
->count
[1]), 0) != 0);
374 assert(value_cmp_si(mpq_numref(cnt
->count
[2]), 0) == 0);
375 assert(value_cmp_si(mpq_denref(cnt
->count
[2]), 1) == 0);
378 Polyhedron_Free(ctx
);
383 static int test_series(struct barvinok_options
*options
)
389 M
= matrix_read_from_str(
393 P
= Constraints2Polyhedron(M
, options
->MaxRays
);
395 C
= Universe_Polyhedron(1);
396 gf
= barvinok_series_with_options(P
, C
, options
);
399 gen_fun
*sum
= gf
->summate(1, options
);
406 int test_todd(struct barvinok_options
*options
)
408 tcounter
t(2, options
->max_index
);
409 assert(value_cmp_si(t
.todd
.coeff
->p
[0], 1) == 0);
410 assert(value_cmp_si(t
.todd
.coeff
->p
[1], -3) == 0);
411 assert(value_cmp_si(t
.todd
.coeff
->p
[2], 3) == 0);
412 assert(value_cmp_si(t
.todd_denom
->p
[0], 1) == 0);
413 assert(value_cmp_si(t
.todd_denom
->p
[1], 6) == 0);
414 assert(value_cmp_si(t
.todd_denom
->p
[2], 36) == 0);
417 set_from_string(lambda
, "[1 -1]");
418 zz2values(lambda
, t
.lambda
->p
);
421 set_from_string(rays
, "[[-1 0][-1 1]]");
426 set_from_string(v
, "[2 0 1]");
427 Vector
*vertex
= Vector_Alloc(3);
428 zz2values(v
, vertex
->p
);
430 t
.handle(rays
, vertex
->p
, one
, 1, options
);
431 assert(value_cmp_si(mpq_numref(t
.count
), 71) == 0);
432 assert(value_cmp_si(mpq_denref(t
.count
), 24) == 0);
434 set_from_string(rays
, "[[0 -1][1 -1]]");
435 set_from_string(v
, "[0 2 1]");
436 zz2values(v
, vertex
->p
);
438 t
.handle(rays
, vertex
->p
, one
, 1, options
);
439 assert(value_cmp_si(mpq_numref(t
.count
), 71) == 0);
440 assert(value_cmp_si(mpq_denref(t
.count
), 12) == 0);
442 set_from_string(rays
, "[[1 0][0 1]]");
443 set_from_string(v
, "[0 0 1]");
444 zz2values(v
, vertex
->p
);
446 t
.handle(rays
, vertex
->p
, one
, 1, options
);
447 assert(value_cmp_si(mpq_numref(t
.count
), 6) == 0);
448 assert(value_cmp_si(mpq_denref(t
.count
), 1) == 0);
454 int test_bernoulli(struct barvinok_options
*options
)
456 struct bernoulli_coef
*bernoulli_coef
;
457 struct poly_list
*faulhaber
, *bernoulli
;
458 bernoulli_coef
= bernoulli_coef_compute(2);
459 faulhaber
= faulhaber_compute(4);
460 bernoulli_coef
= bernoulli_coef_compute(8);
461 assert(value_cmp_si(bernoulli_coef
->num
->p
[6], 1) == 0);
462 assert(value_cmp_si(bernoulli_coef
->den
->p
[6], 42) == 0);
463 assert(value_cmp_si(faulhaber
->poly
[3]->p
[0], 0) == 0);
464 assert(value_cmp_si(faulhaber
->poly
[3]->p
[1], 0) == 0);
465 assert(value_cmp_si(faulhaber
->poly
[3]->p
[2], 1) == 0);
466 assert(value_cmp_si(faulhaber
->poly
[3]->p
[3], -2) == 0);
467 assert(value_cmp_si(faulhaber
->poly
[3]->p
[4], 1) == 0);
468 assert(value_cmp_si(faulhaber
->poly
[3]->p
[5], 4) == 0);
470 bernoulli
= bernoulli_compute(6);
471 assert(value_cmp_si(bernoulli
->poly
[6]->p
[0], 1) == 0);
472 assert(value_cmp_si(bernoulli
->poly
[6]->p
[1], 0) == 0);
473 assert(value_cmp_si(bernoulli
->poly
[6]->p
[2], -21) == 0);
474 assert(value_cmp_si(bernoulli
->poly
[6]->p
[3], 0) == 0);
475 assert(value_cmp_si(bernoulli
->poly
[6]->p
[4], 105) == 0);
476 assert(value_cmp_si(bernoulli
->poly
[6]->p
[5], -126) == 0);
477 assert(value_cmp_si(bernoulli
->poly
[6]->p
[6], 42) == 0);
478 assert(value_cmp_si(bernoulli
->poly
[6]->p
[7], 42) == 0);
480 unsigned nvar
, nparam
;
481 const char **all_vars
;
482 evalue
*base
, *sum1
, *sum2
;
483 base
= evalue_read_from_str("(1 * n + 1)", NULL
, &all_vars
, &nvar
, &nparam
,
486 sum1
= evalue_polynomial(faulhaber
->poly
[3], base
);
487 Free_ParamNames(all_vars
, nvar
+nparam
);
489 sum2
= evalue_read_from_str("(1/4 * n^4 + 1/2 * n^3 + 1/4 * n^2)",
490 NULL
, &all_vars
, &nvar
, &nparam
,
492 Free_ParamNames(all_vars
, nvar
+nparam
);
493 assert(eequal(sum1
, sum2
));
500 int test_bernoulli_sum(struct barvinok_options
*options
)
502 int summation
= options
->summation
;
503 options
->summation
= BV_SUM_BERNOULLI
;
505 unsigned nvar
, nparam
;
506 const char **all_vars
;
507 evalue
*e
, *sum1
, *sum2
;
508 e
= evalue_read_from_str("i + -1 >= 0\n -i + n >= 0\n\n 1 + (-1 *i) + i^2",
509 "i", &all_vars
, &nvar
, &nparam
,
511 Free_ParamNames(all_vars
, nvar
+nparam
);
513 sum1
= barvinok_summate(e
, 1, options
);
514 sum2
= evalue_read_from_str("n -1 >= 0\n\n (1/3 * n^3 + 2/3 * n)",
515 NULL
, &all_vars
, &nvar
, &nparam
,
517 Free_ParamNames(all_vars
, nvar
+nparam
);
521 assert(EVALUE_IS_ZERO(*sum1
));
525 e
= evalue_read_from_str("-i + -1 >= 0\n i + n >= 0\n\n 1 + i + i^2",
526 "i", &all_vars
, &nvar
, &nparam
,
528 Free_ParamNames(all_vars
, nvar
+nparam
);
529 sum1
= barvinok_summate(e
, 1, options
);
533 assert(EVALUE_IS_ZERO(*sum1
));
539 e
= evalue_read_from_str("i + 4 >= 0\n -i + n >= 0\n\n i",
540 "i", &all_vars
, &nvar
, &nparam
,
542 Free_ParamNames(all_vars
, nvar
+nparam
);
543 sum1
= barvinok_summate(e
, 1, options
);
544 sum2
= evalue_read_from_str("n + 0 >= 0\n\n (1/2 * n^2 + 1/2 * n + (-10))\n"
545 "n + 4 >= 0\n -n -1 >= 0\n\n (1/2 * n^2 + 1/2 * n + (-10))",
546 NULL
, &all_vars
, &nvar
, &nparam
,
548 Free_ParamNames(all_vars
, nvar
+nparam
);
552 assert(EVALUE_IS_ZERO(*sum1
));
557 e
= evalue_read_from_str("i -5 >= 0\n -i + n >= 0\n j -1 >= 0\n i -j >= 0\n"
558 "k -1 >= 0\n j -k >= 0\n\n1",
559 "i,j,k", &all_vars
, &nvar
, &nparam
,
561 Free_ParamNames(all_vars
, nvar
+nparam
);
562 sum1
= barvinok_summate(e
, 3, options
);
563 sum2
= evalue_read_from_str("n -5 >= 0\n\n"
564 "1/6 * n^3 + 1/2 * n^2 + 1/3 * n + -20",
565 NULL
, &all_vars
, &nvar
, &nparam
,
567 Free_ParamNames(all_vars
, nvar
+nparam
);
571 assert(EVALUE_IS_ZERO(*sum1
));
576 options
->summation
= summation
;
580 int test_hilbert(struct barvinok_options
*options
)
583 Matrix
*M
= matrix_read_from_str(
587 Polyhedron
*P
= Constraints2Polyhedron(M
, options
->MaxRays
);
590 M
= Cone_Hilbert_Basis(P
, options
->MaxRays
);
591 assert(M
->NbRows
== 5);
592 assert(M
->NbColumns
== 3);
595 M
= Cone_Integer_Hull(P
, NULL
, 0, options
);
596 assert(M
->NbRows
== 4);
597 assert(M
->NbColumns
== 3);
605 int test_ilp(struct barvinok_options
*options
)
607 Matrix
*M
= matrix_read_from_str(
611 Polyhedron
*P
= Constraints2Polyhedron(M
, options
->MaxRays
);
613 Vector
*obj
= Vector_Alloc(2);
614 value_set_si(obj
->p
[0], 7);
615 value_set_si(obj
->p
[1], -1);
620 value_set_si(min
, 1);
621 value_set_si(max
, 17);
622 Vector
*opt
= Polyhedron_Integer_Minimum(P
, obj
->p
, min
, max
,
625 assert(value_cmp_si(opt
->p
[0], 1) == 0);
626 assert(value_cmp_si(opt
->p
[1], 1) == 0);
627 assert(value_cmp_si(opt
->p
[2], 1) == 0);
637 int test_hull(struct barvinok_options
*options
)
639 Matrix
*M
= matrix_read_from_str(
645 Polyhedron
*P
= Constraints2Polyhedron(M
, options
->MaxRays
);
648 Matrix
*hull
= Polyhedron_Integer_Hull(P
, options
);
650 assert(hull
->NbRows
== 4);
651 M
= Matrix_Alloc(hull
->NbRows
, 1+hull
->NbColumns
);
652 for (int i
= 0; i
< hull
->NbRows
; ++i
) {
653 value_set_si(M
->p
[i
][0], 1);
654 Vector_Copy(hull
->p
[i
], M
->p
[i
]+1, hull
->NbColumns
);
657 Polyhedron
*H
= Constraints2Polyhedron(M
, options
->MaxRays
);
660 M
= matrix_read_from_str(
666 P
= Constraints2Polyhedron(M
, options
->MaxRays
);
668 assert(PolyhedronIncludes(P
, H
) && PolyhedronIncludes(H
, P
));
672 M
= matrix_read_from_str(
677 P
= Constraints2Polyhedron(M
, options
->MaxRays
);
680 hull
= Polyhedron_Integer_Hull(P
, options
);
682 assert(hull
->NbRows
== 0);
687 static int test_laurent(struct barvinok_options
*options
)
689 unsigned nvar
, nparam
;
690 const char **all_vars
;
691 evalue
*e
, *sum
, *res
;
693 e
= evalue_read_from_str(" x1 >= 0\n"
695 " -x1 -x2 + 2 >= 0\n"
698 "x1,x2", &all_vars
, &nvar
, &nparam
,
700 Free_ParamNames(all_vars
, nvar
+nparam
);
702 int summation
= options
->summation
;
703 options
->summation
= BV_SUM_LAURENT
;
704 sum
= barvinok_summate(e
, nvar
, options
);
705 options
->summation
= summation
;
707 res
= evalue_read_from_str("(6 * N + 4 * M)",
708 "", &all_vars
, &nvar
, &nparam
,
710 Free_ParamNames(all_vars
, nvar
+nparam
);
712 assert(value_zero_p(sum
->d
));
713 assert(sum
->x
.p
->type
== partition
);
714 assert(sum
->x
.p
->size
== 2);
716 assert(eequal(res
, &sum
->x
.p
->arr
[1]));
724 /* Check that Polyhedron_Reduced_Basis produces a result
725 * of the expected dimensions (without crashing).
727 static int test_basis_reduction(struct barvinok_options
*options
)
732 M
= matrix_read_from_str(
738 P
= Constraints2Polyhedron(M
, options
->MaxRays
);
741 M
= Polyhedron_Reduced_Basis(P
, options
);
744 assert(M
->NbRows
== 2);
745 assert(M
->NbColumns
== 2);
753 int main(int argc
, char **argv
)
755 struct barvinok_options
*options
= barvinok_options_new_with_defaults();
756 test_equalities(options
);
757 test_evalue_read(options
);
759 test_evalue(options
);
760 test_substitute(options
);
761 test_specialization(options
);
762 test_lattice_points(options
);
763 test_icounter(options
);
764 test_infinite_counter(options
);
765 test_series(options
);
767 test_bernoulli(options
);
768 test_bernoulli_sum(options
);
769 test_hilbert(options
);
772 test_laurent(options
);
773 test_basis_reduction(options
);
774 barvinok_options_free(options
);