polylib 7.01
ehrhart_ranking.c
Go to the documentation of this file.
1/* Program for testing the ranking function. */
2
3#include <stdio.h>
4#include <string.h>
5#include <stdlib.h>
6
7#include <polylib/polylib.h>
8#include <polylib/ranking.h>
9
10int main( int argc, char **argv)
11{
12 char **param_name = NULL;
13 Matrix *M;
14 Polyhedron *P, *D, *C;
15 Enumeration *e, *en;
16
17 int nb_parms;
18
19#ifdef EP_EVALUATION
20 Value *p, *tmp;
21 int k;
22#endif
23
24 M = Matrix_Read();
26 Matrix_Free(M);
27 M = Matrix_Read();
29 Matrix_Free(M);
30 M = Matrix_Read();
32 Matrix_Free(M);
33
34 nb_parms = D->Dimension;
35
36 /* Read the name of the parameters */
37 param_name = Read_ParamNames(stdin,nb_parms);
38
39 /* compute a polynomial approximation of the Ehrhart polynomial */
40 printf("============ Ranking function ============\n");
42 C, POL_NO_DUAL);
43
47
48 for (en=e; en; en=en->next) {
49 Print_Domain(stdout,en->ValidityDomain, param_name);
50 print_evalue(stdout,&en->EP, param_name);
51 printf( "\n-----------------------------------\n" );
52 }
53
54
55#ifdef EP_EVALUATION
56 if( isatty(0) && nb_parms != 0)
57 { /* no tty input or no polyhedron -> no evaluation. */
58 printf("Evaluation of the Ehrhart polynomial :\n");
59 p = (Value *)malloc(sizeof(Value) * (nb_parms));
60 for(i=0;i<nb_parms;i++)
61 value_init(p[i]);
62 FOREVER {
63 fflush(stdin);
64 printf("Enter %d parameters : ",nb_parms);
65 for(k=0;k<nb_parms;++k) {
66 scanf("%s",str);
67 value_read(p[k],str);
68 }
69 fprintf(stdout,"EP( ");
70 value_print(stdout,VALUE_FMT,p[0]);
71 for(k=1;k<nb_parms;++k) {
72 fprintf(stdout,",");
73 value_print(stdout,VALUE_FMT,p[k]);
74 }
75 fprintf(stdout," ) = ");
76 value_print(stdout,VALUE_FMT,*(tmp=compute_poly(en,p)));
77 free(tmp);
78 fprintf(stdout,"\n");
79 }
80 }
81#endif /* EP_EVALUATION */
82
83 while( e )
84 {
85 free_evalue_refs( &(e->EP) );
87 en = e ->next;
88 free( e );
89 e = en;
90 }
91 Free_ParamNames(param_name, nb_parms);
92 return 0;
93}
#define VALUE_FMT
Definition: arithmetique.h:295
int Value
Definition: arithmetique.h:294
#define value_read(val, str)
Definition: arithmetique.h:489
#define value_print(Dst, fmt, val)
Definition: arithmetique.h:490
#define value_init(val)
Definition: arithmetique.h:484
void print_evalue(FILE *DST, evalue *e, char **pname)
Definition: ehrhart.c:169
void free_evalue_refs(evalue *e)
releases all memory referenced by e.
Definition: ehrhart.c:115
int main(int argc, char **argv)
Value * compute_poly(Enumeration *en, Value *list_args)
Definition: eval_ehrhart.c:137
Matrix * Matrix_Read(void)
Definition: matrix.c:218
void Matrix_Free(Matrix *Mat)
Definition: matrix.c:69
char ** Read_ParamNames(FILE *in, int m)
Definition: param.c:14
void Free_ParamNames(char **params, int m)
Definition: param.c:63
void Polyhedron_Free(Polyhedron *Pol)
Definition: polyhedron.c:1621
Polyhedron * Constraints2Polyhedron(Matrix *Constraints, unsigned NbMaxRays)
Given a matrix of constraints ('Constraints'), construct and return a polyhedron.
Definition: polyhedron.c:1912
void Print_Domain(FILE *DST, Polyhedron *D, char **pname)
Definition: polyparam.c:1682
Enumeration * Polyhedron_LexSmallerEnumerate(Polyhedron *P, Polyhedron *D, unsigned dim, Polyhedron *C, unsigned MAXRAYS)
Returns the number of points in P that are lexicographically smaller than a given point in D.
Definition: ranking.c:179
Polyhedron * ValidityDomain
Definition: types.h:210
evalue EP
Definition: types.h:211
struct _enumeration * next
Definition: types.h:212
Definition: types.h:88
unsigned Dimension
Definition: types.h:110
#define POL_NO_DUAL
Definition: types.h:75
#define FOREVER
Definition: types.h:48