00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include <ctype.h>
00014 #include <string.h>
00015 #include <unistd.h>
00016 #include <assert.h>
00017
00018 #include <polylib/polylib.h>
00019 #include <polylib/homogenization.h>
00020 #include "config.h"
00021
00022 #ifndef HAVE_GETOPT_H
00023 #define getopt_long(a,b,c,d,e) getopt(a,b,c)
00024 #else
00025 #include <getopt.h>
00026 struct option options[] = {
00027 { "homogenized", no_argument, 0, 'h' },
00028 { 0, 0, 0, 0 }
00029 };
00030 #endif
00031
00032 #define WS 0
00033
00034
00035
00036
00037
00038
00039
00040
00041 #define EPRINT_ALL_VALIDITY_CONSTRAINTS
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 #define REDUCE_DEGREE
00085
00086
00087
00088
00089
00090
00091
00092 #define ALL_OVERFLOW_WARNINGS
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 int main(int argc, char **argv)
00113 {
00114 int i;
00115 char str[1024];
00116 Matrix *C1, *P1;
00117 Polyhedron *C, *P;
00118 Enumeration *en;
00119 const char **param_name;
00120 int c, ind = 0;
00121 int hom = 0;
00122
00123 #ifdef EP_EVALUATION
00124 Value *p, *tmp;
00125 int k;
00126 #endif
00127
00128 while ((c = getopt_long(argc, argv, "h", options, &ind)) != -1) {
00129 switch (c) {
00130 case 'h':
00131 hom = 1;
00132 break;
00133 }
00134 }
00135
00136 P1 = Matrix_Read();
00137 C1 = Matrix_Read();
00138 if(C1->NbColumns < 2) {
00139 fprintf( stderr, "Not enough parameters !\n" );
00140 exit(0);
00141 }
00142 if (hom) {
00143 Matrix *C2, *P2;
00144 P2 = AddANullColumn(P1);
00145 Matrix_Free(P1);
00146 P1 = P2;
00147 C2 = AddANullColumn(C1);
00148 Matrix_Free(C1);
00149 C1 = C2;
00150 }
00151 P = Constraints2Polyhedron(P1,WS);
00152 C = Constraints2Polyhedron(C1,WS);
00153 Matrix_Free(P1);
00154 Matrix_Free(C1);
00155
00156
00157 param_name = Read_ParamNames(stdin,C->Dimension - hom);
00158 if (hom) {
00159 const char **param_name2;
00160 param_name2 = (const char**)malloc(sizeof(char*) * (C->Dimension));
00161 for (i = 0; i < C->Dimension - 1; i++)
00162 param_name2[i] = param_name[i];
00163 param_name2[C->Dimension-1] = "_H";
00164 free(param_name);
00165 param_name=param_name2;
00166 }
00167
00168 en = Polyhedron_Enumerate(P,C,WS,param_name);
00169
00170 if (hom) {
00171 Enumeration *en2;
00172
00173 printf("inhomogeneous form:\n");
00174
00175 dehomogenize_enumeration(en, C->Dimension, WS);
00176 for (en2 = en; en2; en2 = en2->next) {
00177 Print_Domain(stdout, en2->ValidityDomain, param_name);
00178 print_evalue(stdout, &en2->EP, param_name);
00179 }
00180 }
00181
00182 #ifdef EP_EVALUATION
00183 if( isatty(0) && C->Dimension != 0)
00184 {
00185 printf("Evaluation of the Ehrhart polynomial :\n");
00186 p = (Value *)malloc(sizeof(Value) * (C->Dimension));
00187 for(i=0;i<C->Dimension;i++)
00188 value_init(p[i]);
00189 FOREVER {
00190 fflush(stdin);
00191 printf("Enter %d parameters : ",C->Dimension);
00192 for(k=0;k<C->Dimension;++k) {
00193 scanf("%s",str);
00194 value_read(p[k],str);
00195 }
00196 fprintf(stdout,"EP( ");
00197 value_print(stdout,VALUE_FMT,p[0]);
00198 for(k=1;k<C->Dimension;++k) {
00199 fprintf(stdout,",");
00200 value_print(stdout,VALUE_FMT,p[k]);
00201 }
00202 fprintf(stdout," ) = ");
00203 value_print(stdout,VALUE_FMT,*(tmp=compute_poly(en,p)));
00204 free(tmp);
00205 fprintf(stdout,"\n");
00206 }
00207 }
00208 #endif
00209
00210 Enumeration_Free(en);
00211 Free_ParamNames(param_name, C->Dimension-hom);
00212 Polyhedron_Free( P );
00213 Polyhedron_Free( C );
00214
00215 return 0;
00216 }
00217