barvinok 0.32.1
[barvinok.git] / polytope_lattice_width.c
blobae4663c0b28a556dad7965a448186e7a8c138527
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 struct isl_arg options_arg[] = {
13 ISL_ARG_CHILD(struct arguments, barvinok, NULL, barvinok_options_arg, NULL)
14 ISL_ARG_BOOL(struct arguments, direction, 'd', "direction", 0,
15 "print width directions")
16 ISL_ARG_END
19 ISL_ARG_DEF(options, struct arguments, options_arg)
21 int main(int argc, char **argv)
23 Polyhedron *P, *C;
24 Matrix *M;
25 const char **param_name;
26 struct arguments *options = options_new_with_defaults();
27 struct width_direction_array *dirs;
28 int i;
30 argc = options_parse(options, argc, argv, ISL_ARG_ALL);
32 M = Matrix_Read();
33 assert(M);
34 P = Constraints2Polyhedron(M, options->barvinok->MaxRays);
35 Matrix_Free(M);
36 M = Matrix_Read();
37 assert(M);
38 C = Constraints2Polyhedron(M, options->barvinok->MaxRays);
39 Matrix_Free(M);
40 param_name = Read_ParamNames(stdin, C->Dimension);
42 dirs = Polyhedron_Lattice_Width_Directions(P, C, options->barvinok);
43 for (i = 0; i < dirs->n; ++i) {
44 evalue *E;
46 Print_Domain(stdout, dirs->wd[i].domain, param_name);
47 if (options->direction)
48 Vector_Print(stdout, P_VALUE_FMT, dirs->wd[i].dir);
49 E = affine2evalue(dirs->wd[i].width->p,
50 dirs->wd[i].width->p[C->Dimension+1],
51 C->Dimension);
52 print_evalue(stdout, E, param_name);
53 evalue_free(E);
55 free_width_direction_array(dirs);
57 Free_ParamNames(param_name, C->Dimension);
58 Polyhedron_Free(P);
59 Polyhedron_Free(C);
60 options_free(options);
62 return 0;