options.c: add argp parse
[barvinok.git] / barvinok_series.cc
blobd9c6c72c0c0f78ad70e402b464c840f8c5795581
1 #include <unistd.h>
2 #include <gmp.h>
3 #include <NTL/mat_ZZ.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 0
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 { "explicit", no_argument, 0, 'e' },
28 { "version", no_argument, 0, 'V' },
29 { 0, 0, 0, 0 }
31 #endif
33 int main(int argc, char **argv)
35 Polyhedron *A, *C;
36 Matrix *M;
37 evalue *EP;
38 char **param_name;
39 gen_fun *gf;
40 int c, ind = 0;
41 int function = 0;
43 while ((c = getopt_long(argc, argv, "eV", options, &ind)) != -1) {
44 switch (c) {
45 case 'e':
46 function = 1;
47 break;
48 case 'V':
49 printf(barvinok_version());
50 exit(0);
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(std::cout, C->Dimension, param_name);
66 puts("");
67 if (function) {
68 EP = *gf;
69 print_evalue(stdout, EP, param_name);
71 delete gf;
72 Free_ParamNames(param_name, C->Dimension);
73 Polyhedron_Free(A);
74 Polyhedron_Free(C);
75 return 0;