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