bernstein: bernsteinExpansion: accept list of polynomials
[barvinok.git] / verify.c
bloba4d870bd9b7d39a7472bd5baff0bca7e6f74f8af
1 #include <stdlib.h>
2 #include "verify.h"
4 /* RANGE : normal range for evalutations (-RANGE -> RANGE) */
5 #define RANGE 50
7 /* SRANGE : small range for evalutations */
8 #define SRANGE 15
10 /* if dimension >= BIDDIM, use SRANGE */
11 #define BIGDIM 5
13 /* VSRANGE : very small range for evalutations */
14 #define VSRANGE 5
16 /* if dimension >= VBIDDIM, use VSRANGE */
17 #define VBIGDIM 8
19 static struct argp_option argp_options[] = {
20 { "verify", 'T', 0, 0 },
21 { "print-all", 'A', 0, 0 },
22 { "continue-on-error", 'C', 0, 0 },
23 { "min", 'm', "int", 0 },
24 { "max", 'M', "int", 0 },
25 { "range", 'r', "int", 0 },
26 { 0 }
29 static error_t parse_opt(int key, char *arg, struct argp_state *state)
31 struct verify_options *options = state->input;
33 switch (key) {
34 case ARGP_KEY_INIT:
35 options->verify = 0;
36 options->print_all = 0;
37 options->m = INT_MAX;
38 options->M = INT_MIN;
39 break;
40 case ARGP_KEY_FINI:
41 break;
42 case 'T':
43 options->verify = 1;
44 break;
45 case 'A':
46 options->print_all = 1;
47 break;
48 case 'C':
49 options->continue_on_error = 1;
50 break;
51 case 'm':
52 options->m = atoi(arg);
53 options->verify = 1;
54 break;
55 case 'M':
56 options->M = atoi(arg);
57 options->verify = 1;
58 break;
59 case 'r':
60 options->M = atoi(arg);
61 options->m = -options->M;
62 options->verify = 1;
63 break;
64 default:
65 return ARGP_ERR_UNKNOWN;
67 return 0;
70 void verify_options_set_range(struct verify_options *options, Polyhedron *P)
72 int r;
74 if (P->Dimension >= VBIGDIM)
75 r = VSRANGE;
76 else if (P->Dimension >= BIGDIM)
77 r = SRANGE;
78 else
79 r = RANGE;
80 if (options->M == INT_MIN)
81 options->M = r;
82 if (options->m == INT_MAX)
83 options->m = -r;
85 if (options->verify && options->m > options->M) {
86 fprintf(stderr,"Nothing to do: min > max !\n");
87 exit(0);
91 struct argp verify_argp = {
92 argp_options, parse_opt, 0, 0