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>
24 int main( int argc
, char **argv
)
27 const char **param_name
= NULL
;
32 Matrix
* Validity_Lattice
;
42 nb_parms
= C1
->NbColumns
-2;
44 fprintf( stderr
, "Not enough parameters !\n" );
48 /* Read the name of the parameters */
49 param_name
= Read_ParamNames(stdin
,nb_parms
);
51 /* compute a polynomial approximation of the Ehrhart polynomial */
52 printf("============ Ehrhart polynomial quick approximation ============\n");
53 e
= Ehrhart_Quick_Apx(P1
, C1
, &Validity_Lattice
, 1024);
58 show_matrix(Validity_Lattice
);
59 for( en
=e
; en
; en
=en
->next
) {
60 Print_Domain(stdout
,en
->ValidityDomain
, param_name
);
61 print_evalue(stdout
,&en
->EP
, param_name
);
62 printf( "\n-----------------------------------\n" );
66 if( isatty(0) && nb_parms
!= 0)
67 { /* no tty input or no polyhedron -> no evaluation. */
68 printf("Evaluation of the Ehrhart polynomial :\n");
69 p
= (Value
*)malloc(sizeof(Value
) * (nb_parms
));
70 for(i
=0;i
<nb_parms
;i
++)
74 printf("Enter %d parameters : ",nb_parms
);
75 for(k
=0;k
<nb_parms
;++k
) {
79 fprintf(stdout
,"EP( ");
80 value_print(stdout
,VALUE_FMT
,p
[0]);
81 for(k
=1;k
<nb_parms
;++k
) {
83 value_print(stdout
,VALUE_FMT
,p
[k
]);
85 fprintf(stdout
," ) = ");
86 value_print(stdout
,VALUE_FMT
,*(tmp
=compute_poly(en
,p
)));
91 #endif /* EP_EVALUATION */
95 free_evalue_refs( &(e
->EP
) );
96 Polyhedron_Free( e
->ValidityDomain
);
101 Free_ParamNames(param_name
, nb_parms
);