move "constant" constant part outside of fractional part
[barvinok.git] / barvinok_enumerate_e.c
blobbf0d41cbeb468e46b1a3bb5f50729aed036f31b5
1 #include <unistd.h>
2 #include <sys/times.h>
3 #include <getopt.h>
4 #include <polylib/polylibgmp.h>
5 #include "ev_operations.h"
6 #include <util.h>
7 #include <barvinok.h>
9 /* The input of this example program is a polytope in combined
10 * data and parameter space followed by two lines indicating
11 * the number of existential variables and parameters respectively.
12 * The first lines starts with "E ", followed by a number.
13 * The second lines starts with "P ", followed by a number.
14 * These two lines are (optionally) followed by the names of the parameters.
15 * The polytope is in PolyLib notation.
18 struct option options[] = {
19 { "convert", no_argument, 0, 'c' },
20 { "range", no_argument, 0, 'r' },
21 { 0, 0, 0, 0 }
24 int main(int argc, char **argv)
26 Polyhedron *A;
27 Matrix *M;
28 char **param_name;
29 int exist, nparam;
30 char s[128];
31 evalue *EP;
32 int c, ind = 0;
33 int range = 0;
34 int convert = 0;
36 while ((c = getopt_long(argc, argv, "cr", options, &ind)) != -1) {
37 switch (c) {
38 case 'c':
39 convert = 1;
40 break;
41 case 'r':
42 range = 1;
43 break;
47 M = Matrix_Read();
48 A = Constraints2Polyhedron(M, 600);
49 Matrix_Free(M);
51 fgets(s, 128, stdin);
52 while ((*s=='#') || (sscanf(s, "E %d", &exist)<1))
53 fgets(s, 128, stdin);
55 fgets(s, 128, stdin);
56 while ((*s=='#') || (sscanf(s, "P %d", &nparam)<1))
57 fgets(s, 128, stdin);
59 Polyhedron_Print(stdout, P_VALUE_FMT, A);
60 printf("exist: %d, nparam: %d\n", exist, nparam);
61 param_name = Read_ParamNames(stdin, nparam);
62 EP = barvinok_enumerate_e(A, exist, nparam, 600);
63 reduce_evalue(EP);
64 evalue_combine(EP);
65 if (range)
66 evalue_range_reduction(EP);
67 print_evalue(stdout, EP, param_name);
68 if (convert) {
69 evalue_mod2table(EP, nparam);
70 print_evalue(stdout, EP, param_name);
72 free_evalue_refs(EP);
73 free(EP);
74 Free_ParamNames(param_name, nparam);
75 Polyhedron_Free(A);
76 return 0;