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"
23 #undef CS /* for Solaris 10 */
26 #ifndef HAVE_COUNT_POINTS4
27 #define count_points(a,b,c,d) { \
28 int cc = count_points(a,b,c); \
29 value_set_si(*d,cc); \
37 /****************************************************/
38 /* function check_poly : */
39 /* scans the parameter space from Min to Max (all */
40 /* directions). Computes the number of points in */
41 /* the polytope using both methods, and compare them*/
42 /* returns 1 on success */
43 /****************************************************/
45 int check_poly(Polyhedron
*S
,Polyhedron
*CS
,Enumeration
*en
,
46 int nparam
, int pos
, Value
*z
, int print_all
)
52 value_init(c
); value_init(tmp
);
58 /* Computes the ehrhart polynomial */
59 value_assign(c
,*(ctmp
=compute_poly(en
,&z
[S
->Dimension
-nparam
+1])));
62 /* if c=0 we may be out of context. */
63 /* scanning is useless in this case*/
67 value_print(stdout
,VALUE_FMT
,z
[S
->Dimension
-nparam
+1]);
68 for(k
=S
->Dimension
-nparam
+2;k
<=S
->Dimension
;++k
) {
70 value_print(stdout
,VALUE_FMT
,z
[k
]);
73 value_print(stdout
,VALUE_FMT
,c
);
77 /* Manually count the number of points */
78 count_points(1,S
,z
,&tmp
);
81 value_print(stdout
, P_VALUE_FMT
, tmp
);
88 fprintf(stderr
,"Error !\n");
89 fprintf(stderr
,"EP( ");
90 value_print(stderr
,VALUE_FMT
,z
[S
->Dimension
-nparam
+1]);
91 for(k
=S
->Dimension
-nparam
+2;k
<=S
->Dimension
;++k
) {
93 value_print(stderr
,VALUE_FMT
,z
[k
]);
95 fprintf(stderr
," ) should be ");
96 value_print(stderr
,VALUE_FMT
,tmp
);
97 fprintf(stderr
,", while EP eval gives ");
98 value_print(stderr
,VALUE_FMT
,c
);
99 fprintf(stderr
,".\n");
102 Enumeration_Print(stderr
, en
, params
);
105 if (in_domain(ee
->ValidityDomain
,&z
[S
->Dimension
-nparam
+1])) {
106 Print_Domain(stderr
, ee
->ValidityDomain
, params
);
107 print_evalue(stderr
, &ee
->EP
, params
);
112 #ifndef DONT_BREAK_ON_ERROR
113 value_clear(c
); value_clear(tmp
);
118 } else if (print_all
)
123 !(lower_upper_bounds(1+pos
, CS
, &z
[S
->Dimension
-nparam
], &LB
, &UB
));
125 for(value_assign(tmp
,LB
); value_le(tmp
,UB
); value_increment(tmp
,tmp
)) {
128 k
= VALUE_TO_INT(tmp
);
129 if(!pos
&& !(k
%st
)) {
135 value_assign(z
[pos
+S
->Dimension
-nparam
+1],tmp
);
136 if (!check_poly(S
, CS
->next
, en
, nparam
, pos
+1, z
, print_all
)) {
137 value_clear(c
); value_clear(tmp
);
143 value_set_si(z
[pos
+S
->Dimension
-nparam
+1],0);
145 value_clear(c
); value_clear(tmp
);