barvinok_enumerate: make sure the input polyhedra are fully specified.
[barvinok.git] / barvinok_series.cc
blob1fece936088d49aef8569eb0dcfd2b31c40e9776
1 #include <unistd.h>
2 #include <gmp.h>
3 #include <NTL/mat_ZZ.h>
4 extern "C" {
5 #include <polylib/polylibgmp.h>
6 #include "ev_operations.h"
8 #include <util.h>
9 #include <barvinok.h>
10 #include <barvinok2.h>
11 #include "config.h"
13 /* The input of this example program is the same as that of testehrhart
14 * in the PolyLib distribution, i.e., a polytope in combined
15 * data and parameter space, a context polytope in parameter space
16 * and (optionally) the names of the parameters.
17 * Both polytopes are in PolyLib notation.
20 #ifdef HAVE_GROWING_CHERNIKOVA
21 #define MAXRAYS 0
22 #else
23 #define MAXRAYS 600
24 #endif
26 #ifndef HAVE_GETOPT_H
27 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
28 #else
29 #include <getopt.h>
30 struct option options[] = {
31 { "explicit", no_argument, 0, 'e' },
32 { "version", no_argument, 0, 'V' },
33 { 0, 0, 0, 0 }
35 #endif
37 int main(int argc, char **argv)
39 Polyhedron *A, *C;
40 Matrix *M;
41 evalue *EP;
42 char **param_name;
43 gen_fun *gf;
44 int c, ind = 0;
45 int function = 0;
47 while ((c = getopt_long(argc, argv, "eV", options, &ind)) != -1) {
48 switch (c) {
49 case 'e':
50 function = 1;
51 break;
52 case 'V':
53 printf(barvinok_version());
54 exit(0);
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 gf = barvinok_series(A, C, MAXRAYS);
69 gf->print(C->Dimension, param_name);
70 puts("");
71 if (function) {
72 EP = *gf;
73 print_evalue(stdout, EP, param_name);
75 delete gf;
76 Free_ParamNames(param_name, C->Dimension);
77 Polyhedron_Free(A);
78 Polyhedron_Free(C);
79 return 0;