lattice_point.h: make self-contained
[barvinok.git] / evalue_convert.c
blobb7f2f44d0196f912c17fca1872523d71c0511aab
1 #include "evalue_convert.h"
3 static struct argp_option argp_options[] = {
4 { "convert", 'c', 0, 0, "convert fractionals to periodics" },
5 { "combine", 'C', 0, 0 },
6 { "floor", 'f', 0, 0, "convert fractionals to floorings" },
7 { "range-reduction", 'R', 0, 0 },
9 };
11 static error_t parse_opt(int key, char *arg, struct argp_state *state)
13 struct convert_options *options = state->input;
15 switch (key) {
16 case ARGP_KEY_INIT:
17 options->floor = 0;
18 options->convert = 0;
19 options->combine = 0;
20 options->range = 0;
21 break;
22 case ARGP_KEY_FINI:
23 break;
24 case 'f':
25 options->floor = 1;
26 break;
27 case 'c':
28 options->convert = 1;
29 break;
30 case 'C':
31 options->combine = 1;
32 break;
33 case 'R':
34 options->range = 1;
35 break;
36 default:
37 return ARGP_ERR_UNKNOWN;
39 return 0;
42 struct argp convert_argp = {
43 argp_options, parse_opt, 0, 0
46 void evalue_convert(evalue *EP, struct convert_options *options, unsigned nparam,
47 char **params)
49 if (options->combine)
50 evalue_combine(EP);
51 if (options->range)
52 evalue_range_reduction(EP);
53 if (params)
54 print_evalue(stdout, EP, params);
55 if (options->floor) {
56 fprintf(stderr, "WARNING: floor conversion not supported\n");
57 evalue_frac2floor2(EP, 0);
58 if (params)
59 print_evalue(stdout, EP, params);
60 } else if (options->convert) {
61 evalue_mod2table(EP, nparam);
62 if (params)
63 print_evalue(stdout, EP, params);