check for getopt
[barvinok.git] / barvinok_enumerate.c
blob2cba1961e18df20f5090e297d7fd1e208510e313
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 the same as that of testehrhart
9 * in the PolyLib distribution, i.e., a polytope in combined
10 * data and parameter space, a context polytope in parameter space
11 * and (optionally) the names of the parameters.
12 * Both polytopes are in PolyLib notation.
15 #ifndef HAVE_GETOPT_H
16 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
17 #else
18 #include <getopt.h>
19 struct option options[] = {
20 { "convert", no_argument, 0, 'c' },
21 { "size", no_argument, 0, 's' },
22 { 0, 0, 0, 0 }
24 #endif
26 int main(int argc, char **argv)
28 Polyhedron *A, *C;
29 Matrix *M;
30 Enumeration *en;
31 char **param_name;
32 int c, ind = 0;
33 int convert = 0;
34 int size = 0;
36 while ((c = getopt_long(argc, argv, "cs", options, &ind)) != -1) {
37 switch (c) {
38 case 'c':
39 convert = 1;
40 break;
41 case 's':
42 size = 1;
43 break;
47 M = Matrix_Read();
48 A = Constraints2Polyhedron(M, 600);
49 Matrix_Free(M);
50 M = Matrix_Read();
51 C = Constraints2Polyhedron(M, 600);
52 Matrix_Free(M);
53 Polyhedron_Print(stdout, P_VALUE_FMT, A);
54 Polyhedron_Print(stdout, P_VALUE_FMT, C);
55 param_name = Read_ParamNames(stdin, C->Dimension);
56 en = barvinok_enumerate(A, C, 600);
57 Enumeration_Print(stdout, en, param_name);
58 if (size)
59 printf("\nSize: %d\n", Enumeration_size(en));
60 if (convert) {
61 Enumeration_mod2table(en, C->Dimension);
62 Enumeration_Print(stdout, en, param_name);
63 if (size)
64 printf("\nSize: %d\n", Enumeration_size(en));
66 Enumeration_Free(en);
67 Free_ParamNames(param_name, C->Dimension);
68 Polyhedron_Free(A);
69 Polyhedron_Free(C);
70 return 0;