4 #include <barvinok/util.h>
5 #include <barvinok/barvinok.h>
8 /* The input of this example program is a polytope in PolyLib notation,
9 * i.e., an n by d+2 matrix of the n constraints A x + b >= 0 defining
10 * the polytope * sitting in a d-dimensional space. The first column
11 * is 1 for an inequality and 0 for an equality. b is placed in the
13 * Alternatively, if the matrix is preceded by the word "vertices"
14 * on a line by itself, it will be interpreted as a list of vertices
15 * in PolyLib notation, i.e., an n by (d+2) matrix, where n is
16 * the number of vertices/rays and d the dimension. The first column is
17 * 0 for lines and 1 for vertices/rays. The final column is the denominator
18 * or 0 for rays. Note that for barvinok_ehrhart, the first column
23 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
26 struct option options
[] = {
27 { "convert", no_argument
, 0, 'c' },
28 { "floor", no_argument
, 0, 'f' },
29 { "series", no_argument
, 0, 's' },
30 { "version", no_argument
, 0, 'V' },
35 int main(int argc
, char **argv
)
37 Polyhedron
*A
, *C
, *U
;
43 barvinok_options
*bv_options
= barvinok_options_new_with_defaults();
45 while ((c
= getopt_long(argc
, argv
, "sfcV", options
, &ind
)) != -1) {
57 printf(barvinok_version());
63 A
= Polyhedron_Read(bv_options
->MaxRays
);
64 param_name
= Read_ParamNames(stdin
, 1);
65 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
66 C
= Cone_over_Polyhedron(A
);
67 U
= Universe_Polyhedron(1);
70 gf
= barvinok_series_with_options(C
, U
, bv_options
);
71 gf
->print(std::cout
, U
->Dimension
, param_name
);
76 /* A (conceptually) obvious optimization would be to pass in
77 * the parametric vertices, which are just n times the original
78 * vertices, rather than letting barvinok_enumerate_ev (re)compute
79 * them through Polyhedron2Param_SimplifiedDomain.
81 EP
= barvinok_enumerate_with_options(C
, U
, bv_options
);
82 print_evalue(stdout
, EP
, param_name
);
84 fprintf(stderr
, "WARNING: floor conversion not supported\n");
85 evalue_frac2floor2(EP
, 0);
86 print_evalue(stdout
, EP
, param_name
);
88 evalue_mod2table(EP
, C
->Dimension
);
89 print_evalue(stdout
, EP
, param_name
);
94 Free_ParamNames(param_name
, 1);
98 barvinok_options_free(bv_options
);