1 #include <barvinok/barvinok.h>
2 #include <barvinok/util.h>
6 /* The input of this example program is similar to that of ehrhart_union
7 * in the PolyLib distribution, the difference being that the number of
8 * polytopes in the union needs to be specified explicitly.
9 * The input starts with this number, followed by this number of
10 * polytopes in combined data and parameter space, a context polytope
11 * in parameter space and (optionally) the names of the parameters.
12 * All polytopes are in PolyLib notation.
15 struct argp_option argp_options
[] = {
16 { "series", 's', 0, 0, "compute rational generating function" },
22 struct barvinok_options
*barvinok
;
25 static error_t
parse_opt(int key
, char *arg
, struct argp_state
*state
)
27 struct arguments
*options
= (struct arguments
*) state
->input
;
31 state
->child_inputs
[0] = options
->barvinok
;
38 return ARGP_ERR_UNKNOWN
;
44 int main(int argc
, char **argv
)
47 Polyhedron
*C
, *D
= NULL
;
49 const char **param_name
;
53 struct arguments options
;
54 static struct argp_child argp_children
[] = {
55 { &barvinok_argp
, 0, 0, 0 },
58 static struct argp argp
= { argp_options
, parse_opt
, 0, 0, argp_children
};
59 struct barvinok_options
*bv_options
= barvinok_options_new_with_defaults();
61 options
.barvinok
= bv_options
;
62 set_program_name(argv
[0]);
63 argp_parse(&argp
, argc
, argv
, 0, 0, &options
);
66 while ((*s
=='#') || (sscanf(s
, "%d", &npol
)<1))
69 for (i
= 0; i
< npol
; ++i
) {
72 P
= Constraints2Polyhedron(M
, bv_options
->MaxRays
);
74 D
= DomainConcat(P
, D
);
77 C
= Constraints2Polyhedron(M
, bv_options
->MaxRays
);
79 Polyhedron_Print(stdout
, P_VALUE_FMT
, D
);
80 Polyhedron_Print(stdout
, P_VALUE_FMT
, C
);
81 param_name
= Read_ParamNames(stdin
, C
->Dimension
);
84 gf
= barvinok_enumerate_union_series(D
, C
, bv_options
->MaxRays
);
85 gf
->print(std::cout
, C
->Dimension
, param_name
);
90 EP
= barvinok_enumerate_union(D
, C
, bv_options
->MaxRays
);
91 print_evalue(stdout
, EP
, param_name
);
94 Free_ParamNames(param_name
, C
->Dimension
);
97 barvinok_options_free(bv_options
);