evalue.c: Polyhedron_Insert: add missing return type
[barvinok.git] / polytope_lattice_width.c
blobcff1d0ea6e1ba72c7b8be03654d492e09ba0b177
1 #include <assert.h>
2 #include <barvinok/polylib.h>
3 #include <barvinok/evalue.h>
4 #include <barvinok/options.h>
5 #include "lattice_width.h"
6 #include "argp.h"
7 #include "progname.h"
9 struct argp_option argp_options[] = {
10 { "direction", 'd', 0, 0, "print width directions" },
11 { 0 }
14 struct arguments {
15 struct barvinok_options *options;
16 int direction;
19 error_t parse_opt(int key, char *arg, struct argp_state *state)
21 struct arguments *arguments = state->input;
23 switch (key) {
24 case ARGP_KEY_INIT:
25 state->child_inputs[0] = arguments->options;
26 arguments->direction = 0;
27 break;
28 case 'd':
29 arguments->direction = 1;
30 break;
31 default:
32 return ARGP_ERR_UNKNOWN;
34 return 0;
37 int main(int argc, char **argv)
39 Polyhedron *P, *C;
40 Matrix *M;
41 const char **param_name;
42 struct arguments arguments;
43 static struct argp_child argp_children[] = {
44 { &barvinok_argp, 0, 0, 0 },
45 { 0 }
47 static struct argp argp = { argp_options, parse_opt, 0, 0, argp_children };
48 struct barvinok_options *options = barvinok_options_new_with_defaults();
49 struct width_direction_array *dirs;
50 int i;
52 arguments.options = options;
54 set_program_name(argv[0]);
55 argp_parse(&argp, argc, argv, 0, 0, &arguments);
57 M = Matrix_Read();
58 assert(M);
59 P = Constraints2Polyhedron(M, options->MaxRays);
60 Matrix_Free(M);
61 M = Matrix_Read();
62 assert(M);
63 C = Constraints2Polyhedron(M, options->MaxRays);
64 Matrix_Free(M);
65 param_name = Read_ParamNames(stdin, C->Dimension);
67 dirs = Polyhedron_Lattice_Width_Directions(P, C, options);
68 for (i = 0; i < dirs->n; ++i) {
69 evalue *E;
71 Print_Domain(stdout, dirs->wd[i].domain, param_name);
72 if (arguments.direction)
73 Vector_Print(stdout, P_VALUE_FMT, dirs->wd[i].dir);
74 E = affine2evalue(dirs->wd[i].width->p,
75 dirs->wd[i].width->p[C->Dimension+1],
76 C->Dimension);
77 print_evalue(stdout, E, param_name);
78 evalue_free(E);
80 free_width_direction_array(dirs);
82 Free_ParamNames(param_name, C->Dimension);
83 Polyhedron_Free(P);
84 Polyhedron_Free(C);
85 barvinok_options_free(options);
87 return 0;