lexmin.cc: indicator: reorder member initializer list to match field order
[barvinok.git] / barvinok_ehrhart.cc
blob5d4b90620fa657b3f99b243d4297959eea567775
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <strings.h>
4 #include <barvinok/util.h>
5 #include <barvinok/barvinok.h>
6 #include "evalue_convert.h"
7 #include "barvinok_ehrhart_options.h"
9 /* The input of this example program is a polytope in PolyLib notation,
10 * i.e., an n by d+2 matrix of the n constraints A x + b >= 0 defining
11 * the polytope * sitting in a d-dimensional space. The first column
12 * is 1 for an inequality and 0 for an equality. b is placed in the
13 * final column.
14 * Alternatively, if the matrix is preceded by the word "vertices"
15 * on a line by itself, it will be interpreted as a list of vertices
16 * in PolyLib notation, i.e., an n by (d+2) matrix, where n is
17 * the number of vertices/rays and d the dimension. The first column is
18 * 0 for lines and 1 for vertices/rays. The final column is the denominator
19 * or 0 for rays. Note that for barvinok_ehrhart, the first column
20 * should always be 1.
23 int main(int argc, char **argv)
25 Polyhedron *A, *C, *U;
26 const char **param_name;
27 int print_solution = 1;
28 struct ehrhart_options *options = ehrhart_options_new_with_defaults();
30 argc = ehrhart_options_parse(options, argc, argv, ISL_ARG_ALL);
32 A = Polyhedron_Read(options->barvinok->MaxRays);
33 param_name = Read_ParamNames(stdin, 1);
34 Polyhedron_Print(stdout, P_VALUE_FMT, A);
35 C = Cone_over_Polyhedron(A);
36 U = Universe_Polyhedron(1);
37 if (options->series) {
38 gen_fun *gf;
39 gf = barvinok_series_with_options(C, U, options->barvinok);
40 gf->print(std::cout, U->Dimension, param_name);
41 puts("");
42 delete gf;
43 } else {
44 evalue *EP;
45 /* A (conceptually) obvious optimization would be to pass in
46 * the parametric vertices, which are just n times the original
47 * vertices, rather than letting barvinok_enumerate_ev (re)compute
48 * them through Polyhedron2Param_SimplifiedDomain.
50 EP = barvinok_enumerate_with_options(C, U, options->barvinok);
51 assert(EP);
52 if (evalue_convert(EP, options->convert, options->barvinok->verbose,
53 C->Dimension, param_name))
54 print_solution = 0;
55 if (print_solution)
56 print_evalue(stdout, EP, param_name);
57 evalue_free(EP);
59 Free_ParamNames(param_name, 1);
60 Polyhedron_Free(A);
61 Polyhedron_Free(C);
62 Polyhedron_Free(U);
63 ehrhart_options_free(options);
64 return 0;