1 /*************************************************/
3 /* program to compare effective number of points */
4 /* in a polytope with the corresponding */
5 /* evaluation of the Ehrhart polynomial. */
6 /* Parameters vary in range -RANGE to RANGE */
7 /* (define below) by default. */
8 /* Can be overridden by specifying */
9 /* -r<RANGE>, or -m<min> and -M<max> */
11 /* written by Vincent Loechner (c) 2000. */
12 /* loechner@icps.u-strasbg.fr */
13 /*************************************************/
19 #include <barvinok/evalue.h>
20 #include <barvinok/barvinok.h>
21 #include "verif_ehrhart.h"
24 #ifndef HAVE_COUNT_POINTS4
25 #define count_points(a,b,c,d) { \
26 int cc = count_points(a,b,c); \
27 value_set_si(*d,cc); \
35 /****************************************************/
36 /* function check_poly : */
37 /* scans the parameter space from Min to Max (all */
38 /* directions). Computes the number of points in */
39 /* the polytope using both methods, and compare them*/
40 /* returns 1 on success */
41 /****************************************************/
43 int check_poly(Polyhedron
*S
,Polyhedron
*CS
,Enumeration
*en
,
44 int nparam
, int pos
, Value
*z
, int print_all
)
50 value_init(c
); value_init(tmp
);
56 /* Computes the ehrhart polynomial */
57 value_assign(c
,*(ctmp
=compute_poly(en
,&z
[S
->Dimension
-nparam
+1])));
60 /* if c=0 we may be out of context. */
61 /* scanning is useless in this case*/
65 value_print(stdout
,VALUE_FMT
,z
[S
->Dimension
-nparam
+1]);
66 for(k
=S
->Dimension
-nparam
+2;k
<=S
->Dimension
;++k
) {
68 value_print(stdout
,VALUE_FMT
,z
[k
]);
71 value_print(stdout
,VALUE_FMT
,c
);
75 /* Manually count the number of points */
76 count_points(1,S
,z
,&tmp
);
79 value_print(stdout
, P_VALUE_FMT
, tmp
);
86 fprintf(stderr
,"Error !\n");
87 fprintf(stderr
,"EP( ");
88 value_print(stderr
,VALUE_FMT
,z
[S
->Dimension
-nparam
+1]);
89 for(k
=S
->Dimension
-nparam
+2;k
<=S
->Dimension
;++k
) {
91 value_print(stderr
,VALUE_FMT
,z
[k
]);
93 fprintf(stderr
," ) should be ");
94 value_print(stderr
,VALUE_FMT
,tmp
);
95 fprintf(stderr
,", while EP eval gives ");
96 value_print(stderr
,VALUE_FMT
,c
);
97 fprintf(stderr
,".\n");
100 Enumeration_Print(stderr
, en
, params
);
103 if (in_domain(ee
->ValidityDomain
,&z
[S
->Dimension
-nparam
+1])) {
104 Print_Domain(stderr
, ee
->ValidityDomain
, params
);
105 print_evalue(stderr
, &ee
->EP
, params
);
110 #ifndef DONT_BREAK_ON_ERROR
111 value_clear(c
); value_clear(tmp
);
116 } else if (print_all
)
121 !(lower_upper_bounds(1+pos
, CS
, &z
[S
->Dimension
-nparam
], &LB
, &UB
));
123 for(value_assign(tmp
,LB
); value_le(tmp
,UB
); value_increment(tmp
,tmp
)) {
126 k
= VALUE_TO_INT(tmp
);
127 if(!pos
&& !(k
%st
)) {
133 value_assign(z
[pos
+S
->Dimension
-nparam
+1],tmp
);
134 if (!check_poly(S
, CS
->next
, en
, nparam
, pos
+1, z
, print_all
)) {
135 value_clear(c
); value_clear(tmp
);
141 value_set_si(z
[pos
+S
->Dimension
-nparam
+1],0);
143 value_clear(c
); value_clear(tmp
);