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 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 char **param_name2 = (char**)malloc(sizeof(char*) * (C->Dimension));
00160 for (i = 0; i < C->Dimension - 1; i++)
00161 param_name2[i] = param_name[i];
00162 param_name2[C->Dimension-1] = "_H";
00163 free(param_name);
00164 param_name=param_name2;
00165 }
00166
00167 en = Polyhedron_Enumerate(P,C,WS,param_name);
00168
00169 if (hom) {
00170 Enumeration *en2;
00171
00172 printf("inhomogeneous form:\n");
00173
00174 dehomogenize_enumeration(en, C->Dimension, WS);
00175 for (en2 = en; en2; en2 = en2->next) {
00176 Print_Domain(stdout, en2->ValidityDomain, param_name);
00177 print_evalue(stdout, &en2->EP, param_name);
00178 }
00179 }
00180
00181 #ifdef EP_EVALUATION
00182 if( isatty(0) && C->Dimension != 0)
00183 {
00184 printf("Evaluation of the Ehrhart polynomial :\n");
00185 p = (Value *)malloc(sizeof(Value) * (C->Dimension));
00186 for(i=0;i<C->Dimension;i++)
00187 value_init(p[i]);
00188 FOREVER {
00189 fflush(stdin);
00190 printf("Enter %d parameters : ",C->Dimension);
00191 for(k=0;k<C->Dimension;++k) {
00192 scanf("%s",str);
00193 value_read(p[k],str);
00194 }
00195 fprintf(stdout,"EP( ");
00196 value_print(stdout,VALUE_FMT,p[0]);
00197 for(k=1;k<C->Dimension;++k) {
00198 fprintf(stdout,",");
00199 value_print(stdout,VALUE_FMT,p[k]);
00200 }
00201 fprintf(stdout," ) = ");
00202 value_print(stdout,VALUE_FMT,*(tmp=compute_poly(en,p)));
00203 free(tmp);
00204 fprintf(stdout,"\n");
00205 }
00206 }
00207 #endif
00208
00209 Enumeration_Free(en);
00210 for( i=0 ; i < C->Dimension - hom; i++ )
00211 free( param_name[i] );
00212 free(param_name);
00213 Polyhedron_Free( P );
00214 Polyhedron_Free( C );
00215
00216 return 0;
00217 }
00218