doc: mention restriction of barvinok_enumerate_scarf_series
[barvinok.git] / barvinok_enumerate.c
blobc1e5351f972f4d0dc3e151e8e9ddd79b3a71fb50
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <polylib/polylibgmp.h>
4 #include <barvinok/evalue.h>
5 #include <barvinok/util.h>
6 #include <barvinok/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 #ifndef HAVE_GETOPT_H
17 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
18 #else
19 #include <getopt.h>
20 struct option options[] = {
21 { "convert", no_argument, 0, 'c' },
22 { "floor", no_argument, 0, 'f' },
23 { "size", no_argument, 0, 's' },
24 { "version", no_argument, 0, 'V' },
25 { 0, 0, 0, 0 }
27 #endif
29 int main(int argc, char **argv)
31 Polyhedron *A, *C;
32 Matrix *M;
33 evalue *EP;
34 char **param_name;
35 int c, ind = 0;
36 int convert = 0;
37 int floor = 0;
38 int size = 0;
39 struct barvinok_options *bv_options = barvinok_options_new_with_defaults();
41 while ((c = getopt_long(argc, argv, "fcsV", options, &ind)) != -1) {
42 switch (c) {
43 case 'c':
44 convert = 1;
45 break;
46 case 'f':
47 floor = 1;
48 break;
49 case 's':
50 size = 1;
51 break;
52 case 'V':
53 printf(barvinok_version());
54 exit(0);
55 break;
59 M = Matrix_Read();
60 A = Constraints2Polyhedron(M, bv_options->MaxRays);
61 Matrix_Free(M);
62 M = Matrix_Read();
63 C = Constraints2Polyhedron(M, bv_options->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_with_options(A, C, bv_options);
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 free(bv_options);
88 return 0;