4 #include <barvinok/polylib.h>
5 #include <barvinok/util.h>
6 #include <barvinok/barvinok.h>
7 #include "evalue_convert.h"
8 #include "barvinok_ehrhart_options.h"
10 /* The input of this example program is a polytope in PolyLib notation,
11 * i.e., an n by d+2 matrix of the n constraints A x + b >= 0 defining
12 * the polytope * sitting in a d-dimensional space. The first column
13 * is 1 for an inequality and 0 for an equality. b is placed in the
15 * Alternatively, if the matrix is preceded by the word "vertices"
16 * on a line by itself, it will be interpreted as a list of vertices
17 * in PolyLib notation, i.e., an n by (d+2) matrix, where n is
18 * the number of vertices/rays and d the dimension. The first column is
19 * 0 for lines and 1 for vertices/rays. The final column is the denominator
20 * or 0 for rays. Note that for barvinok_ehrhart, the first column
24 int main(int argc
, char **argv
)
26 Polyhedron
*A
, *C
, *U
;
27 const char **param_name
;
28 int print_solution
= 1;
29 struct ehrhart_options
*options
= ehrhart_options_new_with_defaults();
31 argc
= ehrhart_options_parse(options
, argc
, argv
, ISL_ARG_ALL
);
33 A
= Polyhedron_Read(options
->barvinok
->MaxRays
);
34 param_name
= Read_ParamNames(stdin
, 1);
35 Polyhedron_Print(stdout
, P_VALUE_FMT
, A
);
36 C
= Cone_over_Polyhedron(A
);
37 U
= Universe_Polyhedron(1);
38 if (options
->series
) {
40 gf
= barvinok_series_with_options(C
, U
, options
->barvinok
);
41 gf
->print(std::cout
, U
->Dimension
, param_name
);
46 /* A (conceptually) obvious optimization would be to pass in
47 * the parametric vertices, which are just n times the original
48 * vertices, rather than letting barvinok_enumerate_ev (re)compute
49 * them through Polyhedron2Param_SimplifiedDomain.
51 EP
= barvinok_enumerate_with_options(C
, U
, options
->barvinok
);
53 if (evalue_convert(EP
, options
->convert
, options
->barvinok
->verbose
,
54 C
->Dimension
, param_name
))
57 print_evalue(stdout
, EP
, param_name
);
60 Free_ParamNames(param_name
, 1);
64 ehrhart_options_free(options
);