2 This file is part of PolyLib.
4 PolyLib is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 PolyLib is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with PolyLib. If not, see <http://www.gnu.org/licenses/>.
22 #include <polylib/polylib.h>
25 int main( int argc
, char **argv
)
28 const char **param_name
;
33 Matrix
* Validity_Lattice
;
43 nb_parms
= C1
->NbColumns
-2;
45 fprintf( stderr
, "Not enough parameters !\n" );
49 /* Read the name of the parameters */
50 param_name
= Read_ParamNames(stdin
,nb_parms
);
52 /* inflate the polyhedron, so that the inflated EP approximation will be an
53 upper bound for the EP's polyhedron. */
54 mpolyhedron_inflate(P1
,nb_parms
);
56 /* compute a polynomial approximation of the Ehrhart polynomial */
57 e
= Ehrhart_Quick_Apx(P1
, C1
, &Validity_Lattice
, 1024);
62 printf("============ Ehrhart polynomial quick polynomial upper bound ============\n");
63 show_matrix(Validity_Lattice
);
64 for( en
=e
; en
; en
=en
->next
) {
65 Print_Domain(stdout
,en
->ValidityDomain
, param_name
);
66 print_evalue(stdout
,&en
->EP
, param_name
);
67 printf( "\n-----------------------------------\n" );
71 if( isatty(0) && nb_parms
!= 0)
72 { /* no tty input or no polyhedron -> no evaluation. */
73 printf("Evaluation of the Ehrhart polynomial :\n");
74 p
= (Value
*)malloc(sizeof(Value
) * (nb_parms
));
75 for(i
=0;i
<nb_parms
;i
++)
79 printf("Enter %d parameters : ",nb_parms
);
80 for(k
=0;k
<nb_parms
;++k
) {
84 fprintf(stdout
,"EP( ");
85 value_print(stdout
,VALUE_FMT
,p
[0]);
86 for(k
=1;k
<nb_parms
;++k
) {
88 value_print(stdout
,VALUE_FMT
,p
[k
]);
90 fprintf(stdout
," ) = ");
91 value_print(stdout
,VALUE_FMT
,*(tmp
=compute_poly(en
,p
)));
96 #endif /* EP_EVALUATION */
100 free_evalue_refs( &(e
->EP
) );
101 Polyhedron_Free( e
->ValidityDomain
);
106 Free_ParamNames(param_name
, nb_parms
);