initial support for Ehrhart series
[barvinok.git] / barvinok_enumerate.c
blobe3417b1eddb760af7039f991c5483e1617a72640
1 #include <unistd.h>
2 #include <sys/times.h>
3 #include <polylib/polylibgmp.h>
4 #include "ev_operations.h"
5 #include <util.h>
6 #include <barvinok.h>
7 #include "config.h"
9 /* The input of this example program is the same as that of testehrhart
10 * in the PolyLib distribution, i.e., a polytope in combined
11 * data and parameter space, a context polytope in parameter space
12 * and (optionally) the names of the parameters.
13 * Both polytopes are in PolyLib notation.
16 #ifdef HAVE_GROWING_CHERNIKOVA
17 #define MAXRAYS 0
18 #else
19 #define MAXRAYS 600
20 #endif
22 #ifndef HAVE_GETOPT_H
23 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
24 #else
25 #include <getopt.h>
26 struct option options[] = {
27 { "convert", no_argument, 0, 'c' },
28 { "size", no_argument, 0, 's' },
29 { 0, 0, 0, 0 }
31 #endif
33 int main(int argc, char **argv)
35 Polyhedron *A, *C;
36 Matrix *M;
37 Enumeration *en;
38 char **param_name;
39 int c, ind = 0;
40 int convert = 0;
41 int size = 0;
43 while ((c = getopt_long(argc, argv, "cs", options, &ind)) != -1) {
44 switch (c) {
45 case 'c':
46 convert = 1;
47 break;
48 case 's':
49 size = 1;
50 break;
54 M = Matrix_Read();
55 A = Constraints2Polyhedron(M, MAXRAYS);
56 Matrix_Free(M);
57 M = Matrix_Read();
58 C = Constraints2Polyhedron(M, MAXRAYS);
59 Matrix_Free(M);
60 Polyhedron_Print(stdout, P_VALUE_FMT, A);
61 Polyhedron_Print(stdout, P_VALUE_FMT, C);
62 param_name = Read_ParamNames(stdin, C->Dimension);
63 en = barvinok_enumerate(A, C, MAXRAYS);
64 Enumeration_Print(stdout, en, param_name);
65 if (size)
66 printf("\nSize: %d\n", Enumeration_size(en));
67 if (convert) {
68 Enumeration_mod2table(en, C->Dimension);
69 Enumeration_Print(stdout, en, param_name);
70 if (size)
71 printf("\nSize: %d\n", Enumeration_size(en));
73 Enumeration_Free(en);
74 Free_ParamNames(param_name, C->Dimension);
75 Polyhedron_Free(A);
76 Polyhedron_Free(C);
77 return 0;