verify_options_set_range_pwqp.c: use isl_pw_qpolynomial_dim
[barvinok.git] / polytope_lattice_width.c
blobd1e2b677ef026377301a51070cc8ab143c9007d4
1 #include <assert.h>
2 #include <barvinok/polylib.h>
3 #include <barvinok/evalue.h>
4 #include <barvinok/options.h>
5 #include "lattice_width.h"
7 struct arguments {
8 struct barvinok_options *barvinok;
9 int direction;
12 ISL_ARGS_START(struct arguments, options_args)
13 ISL_ARG_CHILD(struct arguments, barvinok, NULL, &barvinok_options_args, NULL)
14 ISL_ARG_BOOL(struct arguments, direction, 'd', "direction", 0,
15 "print width directions")
16 ISL_ARGS_END
18 ISL_ARG_DEF(options, struct arguments, options_args)
20 int main(int argc, char **argv)
22 Polyhedron *P, *C;
23 Matrix *M;
24 const char **param_name;
25 struct arguments *options = options_new_with_defaults();
26 struct width_direction_array *dirs;
27 int i;
29 argc = options_parse(options, argc, argv, ISL_ARG_ALL);
31 M = Matrix_Read();
32 assert(M);
33 P = Constraints2Polyhedron(M, options->barvinok->MaxRays);
34 Matrix_Free(M);
35 M = Matrix_Read();
36 assert(M);
37 C = Constraints2Polyhedron(M, options->barvinok->MaxRays);
38 Matrix_Free(M);
39 param_name = Read_ParamNames(stdin, C->Dimension);
41 dirs = Polyhedron_Lattice_Width_Directions(P, C, options->barvinok);
42 for (i = 0; i < dirs->n; ++i) {
43 evalue *E;
45 Print_Domain(stdout, dirs->wd[i].domain, param_name);
46 if (options->direction)
47 Vector_Print(stdout, P_VALUE_FMT, dirs->wd[i].dir);
48 E = affine2evalue(dirs->wd[i].width->p,
49 dirs->wd[i].width->p[C->Dimension+1],
50 C->Dimension);
51 print_evalue(stdout, E, param_name);
52 evalue_free(E);
54 free_width_direction_array(dirs);
56 Free_ParamNames(param_name, C->Dimension);
57 Polyhedron_Free(P);
58 Polyhedron_Free(C);
59 options_free(options);
61 return 0;