Merge with master
[barvinok.git] / barvinok_series.cc
blobf488875a6b9c8d54a273567f9174bb5b9f4b40e8
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 { 0, 0, 0, 0 }
34 #endif
36 int main(int argc, char **argv)
38 Polyhedron *A, *C;
39 Matrix *M;
40 evalue *EP;
41 char **param_name;
42 gen_fun *gf;
43 int c, ind = 0;
44 int function = 0;
46 while ((c = getopt_long(argc, argv, "e", options, &ind)) != -1) {
47 switch (c) {
48 case 'e':
49 function = 1;
50 break;
54 M = Matrix_Read();
55 A = Constraints2Polyhedron(M, MAXRAYS);
56 Matrix_Free(M);
57 M = Matrix_Read();
58 C = Constraints2Polyhedron(M, MAXRAYS);
59 Matrix_Free(M);
60 Polyhedron_Print(stdout, P_VALUE_FMT, A);
61 Polyhedron_Print(stdout, P_VALUE_FMT, C);
62 param_name = Read_ParamNames(stdin, C->Dimension);
63 gf = barvinok_series(A, C, MAXRAYS);
64 gf->print(C->Dimension, param_name);
65 puts("");
66 if (function) {
67 EP = *gf;
68 print_evalue(stdout, EP, param_name);
70 delete gf;
71 Free_ParamNames(param_name, C->Dimension);
72 Polyhedron_Free(A);
73 Polyhedron_Free(C);
74 return 0;