1 #include <barvinok/polylib.h>
2 #include <barvinok/evalue.h>
3 #include <barvinok/options.h>
4 #include "lattice_width.h"
8 struct argp_option argp_options
[] = {
9 { "direction", 'd', 0, 0, "print width directions" },
14 struct barvinok_options
*options
;
18 error_t
parse_opt(int key
, char *arg
, struct argp_state
*state
)
20 struct arguments
*arguments
= state
->input
;
24 state
->child_inputs
[0] = arguments
->options
;
25 arguments
->direction
= 0;
28 arguments
->direction
= 1;
31 return ARGP_ERR_UNKNOWN
;
36 int main(int argc
, char **argv
)
41 struct arguments arguments
;
42 static struct argp_child argp_children
[] = {
43 { &barvinok_argp
, 0, 0, 0 },
46 static struct argp argp
= { argp_options
, parse_opt
, 0, 0, argp_children
};
47 struct barvinok_options
*options
= barvinok_options_new_with_defaults();
48 struct width_direction_array
*dirs
;
51 arguments
.options
= options
;
53 set_program_name(argv
[0]);
54 argp_parse(&argp
, argc
, argv
, 0, 0, &arguments
);
58 P
= Constraints2Polyhedron(M
, options
->MaxRays
);
62 C
= Constraints2Polyhedron(M
, options
->MaxRays
);
64 param_name
= Read_ParamNames(stdin
, C
->Dimension
);
66 dirs
= Polyhedron_Lattice_Width_Directions(P
, C
, options
);
67 for (i
= 0; i
< dirs
->n
; ++i
) {
70 Print_Domain(stdout
, dirs
->wd
[i
].domain
, param_name
);
71 if (arguments
.direction
)
72 Vector_Print(stdout
, P_VALUE_FMT
, dirs
->wd
[i
].dir
);
73 E
= affine2evalue(dirs
->wd
[i
].width
->p
,
74 dirs
->wd
[i
].width
->p
[C
->Dimension
+1],
76 print_evalue(stdout
, E
, param_name
);
79 free_width_direction_array(dirs
);
81 Free_ParamNames(param_name
, C
->Dimension
);
84 barvinok_options_free(options
);