barvinok_enumerate: more accurate polynomial approximation
[barvinok.git] / barvinok_count.c
blobe29131d84062c32cbe82d9ba88d9479e0db8112d
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <strings.h>
4 #include <barvinok/util.h>
5 #include <barvinok/barvinok.h>
6 #include "argp.h"
8 #define PRINT_STATS (BV_OPT_LAST+1)
10 struct argp_option argp_options[] = {
11 { "print-stats", PRINT_STATS, 0, 0 },
12 { 0 }
15 struct arguments {
16 struct barvinok_options *options;
17 int print_stats;
20 error_t parse_opt(int key, char *arg, struct argp_state *state)
22 struct arguments *arguments = state->input;
24 switch (key) {
25 case ARGP_KEY_INIT:
26 state->child_inputs[0] = arguments->options;
27 break;
28 case PRINT_STATS:
29 arguments->print_stats = 1;
30 break;
31 default:
32 return ARGP_ERR_UNKNOWN;
34 return 0;
37 int main(int argc, char **argv)
39 Value cb;
40 Polyhedron *A;
41 struct arguments arguments;
42 static struct argp_child argp_children[] = {
43 { &barvinok_argp, 0, 0, 0 },
44 { 0 }
46 static struct argp argp = { argp_options, parse_opt, 0, 0, argp_children };
47 struct barvinok_options *options = barvinok_options_new_with_defaults();
49 arguments.print_stats = 0;
50 arguments.options = options;
52 argp_parse(&argp, argc, argv, 0, 0, &arguments);
54 A = Polyhedron_Read(options->MaxRays);
55 value_init(cb);
56 Polyhedron_Print(stdout, P_VALUE_FMT, A);
57 barvinok_count_with_options(A, &cb, options);
58 value_print(stdout, P_VALUE_FMT, cb);
59 puts("");
60 if (arguments.print_stats)
61 barvinok_stats_print(options->stats, stdout);
62 value_clear(cb);
63 Polyhedron_Free(A);
64 barvinok_options_free(options);
65 return 0;