gen_fun::Hadamard_product: don't assume equalities are independent
[barvinok.git] / barvinok_enumerate.c
blob2c5bebf0713736792ca0afb4fadd0d95ee5daef2
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 #ifdef HAVE_GROWING_CHERNIKOVA
17 #define MAXRAYS POL_NO_DUAL
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 { "version", no_argument, 0, 'V' },
31 { 0, 0, 0, 0 }
33 #endif
35 int main(int argc, char **argv)
37 Polyhedron *A, *C;
38 Matrix *M;
39 evalue *EP;
40 char **param_name;
41 int c, ind = 0;
42 int convert = 0;
43 int floor = 0;
44 int size = 0;
46 while ((c = getopt_long(argc, argv, "fcsV", options, &ind)) != -1) {
47 switch (c) {
48 case 'c':
49 convert = 1;
50 break;
51 case 'f':
52 floor = 1;
53 break;
54 case 's':
55 size = 1;
56 break;
57 case 'V':
58 printf(barvinok_version());
59 exit(0);
60 break;
64 M = Matrix_Read();
65 A = Constraints2Polyhedron(M, MAXRAYS);
66 Matrix_Free(M);
67 M = Matrix_Read();
68 C = Constraints2Polyhedron(M, MAXRAYS);
69 Matrix_Free(M);
70 Polyhedron_Print(stdout, P_VALUE_FMT, A);
71 Polyhedron_Print(stdout, P_VALUE_FMT, C);
72 param_name = Read_ParamNames(stdin, C->Dimension);
73 EP = barvinok_enumerate_ev(A, C, MAXRAYS);
74 print_evalue(stdout, EP, param_name);
75 if (size)
76 printf("\nSize: %d\n", evalue_size(EP));
77 if (floor) {
78 fprintf(stderr, "WARNING: floor conversion not supported\n");
79 evalue_frac2floor(EP);
80 print_evalue(stdout, EP, param_name);
81 } else if (convert) {
82 evalue_mod2table(EP, C->Dimension);
83 print_evalue(stdout, EP, param_name);
84 if (size)
85 printf("\nSize: %d\n", evalue_size(EP));
87 free_evalue_refs(EP);
88 free(EP);
89 Free_ParamNames(param_name, C->Dimension);
90 Polyhedron_Free(A);
91 Polyhedron_Free(C);
92 return 0;