doc: document extra occ operations
[barvinok.git] / barvinok_series.cc
blob4f1bae65ac3d27f8e0fdaf557f264eccb62120f0
1 #include <unistd.h>
2 #include <gmp.h>
3 #include <NTL/mat_ZZ.h>
4 extern "C" {
5 #include <polylib/polylibgmp.h>
6 #include <barvinok/evalue.h>
8 #include <barvinok/util.h>
9 #include <barvinok/barvinok.h>
10 #include "config.h"
12 /* The input of this example program is the same as that of testehrhart
13 * in the PolyLib distribution, i.e., a polytope in combined
14 * data and parameter space, a context polytope in parameter space
15 * and (optionally) the names of the parameters.
16 * Both polytopes are in PolyLib notation.
19 #ifdef HAVE_GROWING_CHERNIKOVA
20 #define MAXRAYS 0
21 #else
22 #define MAXRAYS 600
23 #endif
25 #ifndef HAVE_GETOPT_H
26 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
27 #else
28 #include <getopt.h>
29 struct option options[] = {
30 { "explicit", no_argument, 0, 'e' },
31 { "version", no_argument, 0, 'V' },
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, "eV", options, &ind)) != -1) {
47 switch (c) {
48 case 'e':
49 function = 1;
50 break;
51 case 'V':
52 printf(barvinok_version());
53 exit(0);
54 break;
58 M = Matrix_Read();
59 A = Constraints2Polyhedron(M, MAXRAYS);
60 Matrix_Free(M);
61 M = Matrix_Read();
62 C = Constraints2Polyhedron(M, MAXRAYS);
63 Matrix_Free(M);
64 Polyhedron_Print(stdout, P_VALUE_FMT, A);
65 Polyhedron_Print(stdout, P_VALUE_FMT, C);
66 param_name = Read_ParamNames(stdin, C->Dimension);
67 gf = barvinok_series(A, C, MAXRAYS);
68 gf->print(std::cout, C->Dimension, param_name);
69 puts("");
70 if (function) {
71 EP = *gf;
72 print_evalue(stdout, EP, param_name);
74 delete gf;
75 Free_ParamNames(param_name, C->Dimension);
76 Polyhedron_Free(A);
77 Polyhedron_Free(C);
78 return 0;