add missing assert.h #includes
[barvinok.git] / barvinok_enumerate.c
blobe8a02d3579fa394d57833ed056002e3ba93906f1
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <barvinok/evalue.h>
4 #include <barvinok/util.h>
5 #include <barvinok/barvinok.h>
6 #include "config.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 { "floor", no_argument, 0, 'f' },
22 { "size", no_argument, 0, 's' },
23 { "version", no_argument, 0, 'V' },
24 { 0, 0, 0, 0 }
26 #endif
28 int main(int argc, char **argv)
30 Polyhedron *A, *C;
31 Matrix *M;
32 evalue *EP;
33 char **param_name;
34 int c, ind = 0;
35 int convert = 0;
36 int floor = 0;
37 int size = 0;
38 struct barvinok_options *bv_options = barvinok_options_new_with_defaults();
40 while ((c = getopt_long(argc, argv, "fcsV", options, &ind)) != -1) {
41 switch (c) {
42 case 'c':
43 convert = 1;
44 break;
45 case 'f':
46 floor = 1;
47 break;
48 case 's':
49 size = 1;
50 break;
51 case 'V':
52 printf(barvinok_version());
53 exit(0);
54 break;
58 M = Matrix_Read();
59 A = Constraints2Polyhedron(M, bv_options->MaxRays);
60 Matrix_Free(M);
61 M = Matrix_Read();
62 C = Constraints2Polyhedron(M, bv_options->MaxRays);
63 Matrix_Free(M);
64 Polyhedron_Print(stdout, P_VALUE_FMT, A);
65 Polyhedron_Print(stdout, P_VALUE_FMT, C);
66 param_name = Read_ParamNames(stdin, C->Dimension);
67 EP = barvinok_enumerate_with_options(A, C, bv_options);
68 print_evalue(stdout, EP, param_name);
69 if (size)
70 printf("\nSize: %d\n", evalue_size(EP));
71 if (floor) {
72 fprintf(stderr, "WARNING: floor conversion not supported\n");
73 evalue_frac2floor2(EP, 0);
74 print_evalue(stdout, EP, param_name);
75 } else if (convert) {
76 evalue_mod2table(EP, C->Dimension);
77 print_evalue(stdout, EP, param_name);
78 if (size)
79 printf("\nSize: %d\n", evalue_size(EP));
81 free_evalue_refs(EP);
82 free(EP);
83 Free_ParamNames(param_name, C->Dimension);
84 Polyhedron_Free(A);
85 Polyhedron_Free(C);
86 free(bv_options);
87 return 0;