conversion from genfun to evalue
[barvinok.git] / barvinok_enumerate.c
blobf69ab067e27a2a0acde7d16c1759288b037c10b1
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 { "floor", no_argument, 0, 'f' },
29 { "size", no_argument, 0, 's' },
30 { 0, 0, 0, 0 }
32 #endif
34 int main(int argc, char **argv)
36 Polyhedron *A, *C;
37 Matrix *M;
38 evalue *EP;
39 char **param_name;
40 int c, ind = 0;
41 int convert = 0;
42 int floor = 0;
43 int size = 0;
45 while ((c = getopt_long(argc, argv, "fcs", options, &ind)) != -1) {
46 switch (c) {
47 case 'c':
48 convert = 1;
49 break;
50 case 'f':
51 floor = 1;
52 break;
53 case 's':
54 size = 1;
55 break;
59 M = Matrix_Read();
60 A = Constraints2Polyhedron(M, MAXRAYS);
61 Matrix_Free(M);
62 M = Matrix_Read();
63 C = Constraints2Polyhedron(M, MAXRAYS);
64 Matrix_Free(M);
65 Polyhedron_Print(stdout, P_VALUE_FMT, A);
66 Polyhedron_Print(stdout, P_VALUE_FMT, C);
67 param_name = Read_ParamNames(stdin, C->Dimension);
68 EP = barvinok_enumerate_ev(A, C, MAXRAYS);
69 print_evalue(stdout, EP, param_name);
70 if (size)
71 printf("\nSize: %d\n", evalue_size(EP));
72 if (floor) {
73 fprintf(stderr, "WARNING: floor conversion not supported\n");
74 evalue_frac2floor(EP);
75 print_evalue(stdout, EP, param_name);
76 } else if (convert) {
77 evalue_mod2table(EP, C->Dimension);
78 print_evalue(stdout, EP, param_name);
79 if (size)
80 printf("\nSize: %d\n", evalue_size(EP));
82 free_evalue_refs(EP);
83 free(EP);
84 Free_ParamNames(param_name, C->Dimension);
85 Polyhedron_Free(A);
86 Polyhedron_Free(C);
87 return 0;