also dump recently added denominator
[barvinok.git] / barvinok_series.cc
blob374f06bced5f6da57e5e7f77463cba613f67d81c
1 #include <unistd.h>
2 #include <sys/times.h>
3 #include <gmp.h>
4 #include <NTL/mat_ZZ.h>
5 extern "C" {
6 #include <polylib/polylibgmp.h>
7 #include "ev_operations.h"
9 #include <util.h>
10 #include <barvinok.h>
11 #include <barvinok2.h>
12 #include "config.h"
14 /* The input of this example program is the same as that of testehrhart
15 * in the PolyLib distribution, i.e., a polytope in combined
16 * data and parameter space, a context polytope in parameter space
17 * and (optionally) the names of the parameters.
18 * Both polytopes are in PolyLib notation.
21 #ifdef HAVE_GROWING_CHERNIKOVA
22 #define MAXRAYS 0
23 #else
24 #define MAXRAYS 600
25 #endif
27 #ifndef HAVE_GETOPT_H
28 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
29 #else
30 #include <getopt.h>
31 struct option options[] = {
32 { "explicit", no_argument, 0, 'e' },
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, "e", options, &ind)) != -1) {
48 switch (c) {
49 case 'e':
50 function = 1;
51 break;
55 M = Matrix_Read();
56 A = Constraints2Polyhedron(M, MAXRAYS);
57 Matrix_Free(M);
58 M = Matrix_Read();
59 C = Constraints2Polyhedron(M, MAXRAYS);
60 Matrix_Free(M);
61 Polyhedron_Print(stdout, P_VALUE_FMT, A);
62 Polyhedron_Print(stdout, P_VALUE_FMT, C);
63 param_name = Read_ParamNames(stdin, C->Dimension);
64 gf = barvinok_series(A, C, MAXRAYS);
65 gf->print(C->Dimension, param_name);
66 puts("");
67 if (function) {
68 EP = *gf;
69 print_evalue(stdout, EP, param_name);
71 Free_ParamNames(param_name, C->Dimension);
72 Polyhedron_Free(A);
73 Polyhedron_Free(C);
74 return 0;