2 #include <barvinok/polylib.h>
3 #include <barvinok/evalue.h>
4 #include <barvinok/options.h>
5 #include "lattice_width.h"
9 struct argp_option argp_options
[] = {
10 { "direction", 'd', 0, 0, "print width directions" },
15 struct barvinok_options
*options
;
19 error_t
parse_opt(int key
, char *arg
, struct argp_state
*state
)
21 struct arguments
*arguments
= state
->input
;
25 state
->child_inputs
[0] = arguments
->options
;
26 arguments
->direction
= 0;
29 arguments
->direction
= 1;
32 return ARGP_ERR_UNKNOWN
;
37 int main(int argc
, char **argv
)
42 struct arguments arguments
;
43 static struct argp_child argp_children
[] = {
44 { &barvinok_argp
, 0, 0, 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
;
52 arguments
.options
= options
;
54 set_program_name(argv
[0]);
55 argp_parse(&argp
, argc
, argv
, 0, 0, &arguments
);
59 P
= Constraints2Polyhedron(M
, options
->MaxRays
);
63 C
= Constraints2Polyhedron(M
, options
->MaxRays
);
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
) {
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],
77 print_evalue(stdout
, E
, param_name
);
80 free_width_direction_array(dirs
);
82 Free_ParamNames(param_name
, C
->Dimension
);
85 barvinok_options_free(options
);