update pet for support for recent clangs
[barvinok.git] / barvinok_union.cc
blob255908ee0c42bfe04f4035fa4f43ff3c27a85c41
1 #include <barvinok/barvinok.h>
2 #include <barvinok/util.h>
3 #include "barvinok_union_options.h"
5 /* The input of this example program is similar to that of ehrhart_union
6 * in the PolyLib distribution, the difference being that the number of
7 * polytopes in the union needs to be specified explicitly.
8 * The input starts with this number, followed by this number of
9 * polytopes in combined data and parameter space, a context polytope
10 * in parameter space and (optionally) the names of the parameters.
11 * All polytopes are in PolyLib notation.
15 int main(int argc, char **argv)
17 Matrix *M;
18 Polyhedron *C, *D = NULL;
19 int i, npol;
20 const char **param_name;
21 char s[128];
22 int c, ind = 0;
23 struct union_options *options = union_options_new_with_defaults();
25 argc = union_options_parse(options, argc, argv, ISL_ARG_ALL);
27 fgets(s, 128, stdin);
28 while ((*s=='#') || (sscanf(s, "%d", &npol)<1))
29 fgets(s, 128, stdin);
31 for (i = 0; i < npol; ++i) {
32 Polyhedron *P;
33 M = Matrix_Read();
34 P = Constraints2Polyhedron(M, options->barvinok->MaxRays);
35 Matrix_Free(M);
36 D = DomainConcat(P, D);
38 M = Matrix_Read();
39 C = Constraints2Polyhedron(M, options->barvinok->MaxRays);
40 Matrix_Free(M);
41 Polyhedron_Print(stdout, P_VALUE_FMT, D);
42 Polyhedron_Print(stdout, P_VALUE_FMT, C);
43 param_name = Read_ParamNames(stdin, C->Dimension);
44 if (options->series) {
45 gen_fun *gf;
46 gf = barvinok_enumerate_union_series(D, C, options->barvinok->MaxRays);
47 gf->print(std::cout, C->Dimension, param_name);
48 puts("");
49 delete gf;
50 } else {
51 evalue *EP;
52 EP = barvinok_enumerate_union(D, C, options->barvinok->MaxRays);
53 print_evalue(stdout, EP, param_name);
54 evalue_free(EP);
56 Free_ParamNames(param_name, C->Dimension);
57 Domain_Free(D);
58 Polyhedron_Free(C);
59 union_options_free(options);
60 return 0;