force installation of (possibly) new version
[barvinok.git] / barvinok_enumerate_e.c
blobfab609cff87d51f65f8ad3f63fa00ded68e37f5e
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>
8 /* The input of this example program is a polytope in combined
9 * data and parameter space followed by two lines indicating
10 * the number of existential variables and parameters respectively.
11 * The first lines starts with "E ", followed by a number.
12 * The second lines starts with "P ", followed by a number.
13 * These two lines are (optionally) followed by the names of the parameters.
14 * The polytope is in PolyLib notation.
17 #ifndef HAVE_GETOPT_H
18 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
19 #else
20 #include <getopt.h>
21 struct option options[] = {
22 { "convert", no_argument, 0, 'c' },
23 { "range", no_argument, 0, 'r' },
24 { 0, 0, 0, 0 }
26 #endif
28 int main(int argc, char **argv)
30 Polyhedron *A;
31 Matrix *M;
32 char **param_name;
33 int exist, nparam;
34 char s[128];
35 evalue *EP;
36 int c, ind = 0;
37 int range = 0;
38 int convert = 0;
40 while ((c = getopt_long(argc, argv, "cr", options, &ind)) != -1) {
41 switch (c) {
42 case 'c':
43 convert = 1;
44 break;
45 case 'r':
46 range = 1;
47 break;
51 M = Matrix_Read();
52 A = Constraints2Polyhedron(M, 600);
53 Matrix_Free(M);
55 fgets(s, 128, stdin);
56 while ((*s=='#') || (sscanf(s, "E %d", &exist)<1))
57 fgets(s, 128, stdin);
59 fgets(s, 128, stdin);
60 while ((*s=='#') || (sscanf(s, "P %d", &nparam)<1))
61 fgets(s, 128, stdin);
63 Polyhedron_Print(stdout, P_VALUE_FMT, A);
64 printf("exist: %d, nparam: %d\n", exist, nparam);
65 param_name = Read_ParamNames(stdin, nparam);
66 EP = barvinok_enumerate_e(A, exist, nparam, 600);
67 reduce_evalue(EP);
68 evalue_combine(EP);
69 if (range)
70 evalue_range_reduction(EP);
71 print_evalue(stdout, EP, param_name);
72 if (convert) {
73 evalue_mod2table(EP, nparam);
74 print_evalue(stdout, EP, param_name);
76 free_evalue_refs(EP);
77 free(EP);
78 Free_ParamNames(param_name, nparam);
79 Polyhedron_Free(A);
80 return 0;