00001 #include <stdio.h>
00002 #include <string.h>
00003 #include <stdlib.h>
00004
00005 #include <polylib/polylib.h>
00006
00007 int main( int argc, char **argv)
00008 {
00009 int i;
00010 const char **param_name = NULL;
00011 Matrix *C1, *P1;
00012 Polyhedron *P, *C;
00013 Enumeration *e, *en;
00014
00015 Matrix * Validity_Lattice;
00016 int nb_parms;
00017
00018 #ifdef EP_EVALUATION
00019 Value *p, *tmp;
00020 int k;
00021 #endif
00022
00023 P1 = Matrix_Read();
00024 C1 = Matrix_Read();
00025 nb_parms = C1->NbColumns-2;
00026 if(nb_parms < 0) {
00027 fprintf( stderr, "Not enough parameters !\n" );
00028 exit(0);
00029 }
00030
00031
00032 param_name = Read_ParamNames(stdin,nb_parms);
00033
00034
00035 printf("============ Ehrhart polynomial quick approximation ============\n");
00036 e = Ehrhart_Quick_Apx(P1, C1, &Validity_Lattice, 1024);
00037
00038 Matrix_Free(C1);
00039 Matrix_Free(P1);
00040
00041 show_matrix(Validity_Lattice);
00042 for( en=e ; en ; en=en->next ) {
00043 Print_Domain(stdout,en->ValidityDomain, param_name);
00044 print_evalue(stdout,&en->EP, param_name);
00045 printf( "\n-----------------------------------\n" );
00046 }
00047
00048 #ifdef EP_EVALUATION
00049 if( isatty(0) && nb_parms != 0)
00050 {
00051 printf("Evaluation of the Ehrhart polynomial :\n");
00052 p = (Value *)malloc(sizeof(Value) * (nb_parms));
00053 for(i=0;i<nb_parms;i++)
00054 value_init(p[i]);
00055 FOREVER {
00056 fflush(stdin);
00057 printf("Enter %d parameters : ",nb_parms);
00058 for(k=0;k<nb_parms;++k) {
00059 scanf("%s",str);
00060 value_read(p[k],str);
00061 }
00062 fprintf(stdout,"EP( ");
00063 value_print(stdout,VALUE_FMT,p[0]);
00064 for(k=1;k<nb_parms;++k) {
00065 fprintf(stdout,",");
00066 value_print(stdout,VALUE_FMT,p[k]);
00067 }
00068 fprintf(stdout," ) = ");
00069 value_print(stdout,VALUE_FMT,*(tmp=compute_poly(en,p)));
00070 free(tmp);
00071 fprintf(stdout,"\n");
00072 }
00073 }
00074 #endif
00075
00076 while( e )
00077 {
00078 free_evalue_refs( &(e->EP) );
00079 Polyhedron_Free( e->ValidityDomain );
00080 en = e ->next;
00081 free( e );
00082 e = en;
00083 }
00084 Free_ParamNames(param_name, nb_parms);
00085 return 0;
00086 }