1 /* Program for testing the ranking function. */
7 #include <polylib/polylib.h>
8 #include <polylib/ranking.h>
10 int main( int argc
, char **argv
)
13 const char **param_name
= NULL
;
15 Polyhedron
*P
, *D
, *C
;
26 P
= Constraints2Polyhedron(M
, POL_NO_DUAL
);
29 D
= Constraints2Polyhedron(M
, POL_NO_DUAL
);
32 C
= Constraints2Polyhedron(M
, POL_NO_DUAL
);
35 nb_parms
= D
->Dimension
;
37 /* Read the name of the parameters */
38 param_name
= Read_ParamNames(stdin
,nb_parms
);
40 /* compute a polynomial approximation of the Ehrhart polynomial */
41 printf("============ Ranking function ============\n");
42 e
= Polyhedron_LexSmallerEnumerate(P
, D
, D
->Dimension
-C
->Dimension
,
49 for (en
=e
; en
; en
=en
->next
) {
50 Print_Domain(stdout
,en
->ValidityDomain
, param_name
);
51 print_evalue(stdout
,&en
->EP
, param_name
);
52 printf( "\n-----------------------------------\n" );
57 if( isatty(0) && nb_parms
!= 0)
58 { /* no tty input or no polyhedron -> no evaluation. */
59 printf("Evaluation of the Ehrhart polynomial :\n");
60 p
= (Value
*)malloc(sizeof(Value
) * (nb_parms
));
61 for(i
=0;i
<nb_parms
;i
++)
65 printf("Enter %d parameters : ",nb_parms
);
66 for(k
=0;k
<nb_parms
;++k
) {
70 fprintf(stdout
,"EP( ");
71 value_print(stdout
,VALUE_FMT
,p
[0]);
72 for(k
=1;k
<nb_parms
;++k
) {
74 value_print(stdout
,VALUE_FMT
,p
[k
]);
76 fprintf(stdout
," ) = ");
77 value_print(stdout
,VALUE_FMT
,*(tmp
=compute_poly(en
,p
)));
82 #endif /* EP_EVALUATION */
86 free_evalue_refs( &(e
->EP
) );
87 Polyhedron_Free( e
->ValidityDomain
);
92 Free_ParamNames(param_name
, nb_parms
);