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 <polylib/polylibgmp.h>
20 #include <barvinok/evalue.h>
21 #include <barvinok/barvinok.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); \
33 #ifndef PRINT_ALL_RESULTS
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
) {
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*/
65 #ifdef PRINT_ALL_RESULTS
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
);
79 #ifdef PRINT_ALL_RESULTS
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
);
120 #ifdef PRINT_ALL_RESULTS
127 !(lower_upper_bounds(1+pos
, CS
, &z
[S
->Dimension
-nparam
], &LB
, &UB
));
129 for(value_assign(tmp
,LB
); value_le(tmp
,UB
); value_increment(tmp
,tmp
)) {
131 #ifndef PRINT_ALL_RESULTS
132 k
= VALUE_TO_INT(tmp
);
133 if(!pos
&& !(k
%st
)) {
139 value_assign(z
[pos
+S
->Dimension
-nparam
+1],tmp
);
140 if(!check_poly(S
, CS
->next
, en
, nparam
, pos
+1, z
)) {
141 value_clear(c
); value_clear(tmp
);
147 value_set_si(z
[pos
+S
->Dimension
-nparam
+1],0);
149 value_clear(c
); value_clear(tmp
);