polylib 5.22.8
types.h
Go to the documentation of this file.
1/* types-polylib.h
2 COPYRIGHT
3 Both this software and its documentation are
4
5 Copyright 1993, IRISA /Universite de Rennes I - France
6 Copyright 1996,1997,1998, Doran Wilde and Vincent Loechner
7 All rights reserved.
8
9*/
10
11#ifndef _types_polylib_h_
12#define _types_polylib_h_
13
14#ifdef GNUMP
15#include <gmp.h>
16#endif
17
18#include <limits.h>
19
20/*********************** USER DEFINES ******************************/
21
22/* first parameter name char. */
23#define FIRST_PARAMETER_NAME 'P'
24
25/******************* END OF USER DEFINES ***************************/
26
27#define PCHAR (FIRST_PARAMETER_NAME - 1)
28#define MAXNOOFRAYS 200
29
30#if defined(LINEAR_VALUE_IS_LONGLONG)
31#define P_VALUE_FMT "%4lld "
32#elif defined(LINEAR_VALUE_IS_LONG)
33#define P_VALUE_FMT "%4ld "
34#elif defined(LINEAR_VALUE_IS_CHARS)
35#define P_VALUE_FMT "%s "
36#elif defined(LINEAR_VALUE_IS_INT)
37#define P_VALUE_FMT "%4d "
38#else /* GNUMP */
39#define P_VALUE_FMT "%4s "
40#endif
41
42/* Used in lower_upper_bounds */
43#define LB_INFINITY 1
44#define UB_INFINITY 2
45
46/* MSB, TOP, and NEXT are defined over integer type, not on value type */
47/* Put a one in the most significant bit of an int (portable) */
48#define MSB ((unsigned)(((unsigned)1) << (sizeof(int) * 8 - 1)))
49
50/* Largest representable positive number */
51#define TOP ((int)(MSB - 1))
52
53/* Right shift the one bit in b and increment j if the last bit in b is one */
54#define NEXT(j, b) \
55 { \
56 if (!((b) >>= 1)) { \
57 (b) = MSB; \
58 (j)++; \
59 } \
60 }
61
62/* Status of last Polyhedron operation */
63extern int Pol_status;
64
65#define POL_HIGH_BIT (UINT_MAX - (UINT_MAX >> 1))
66#define POL_NO_DUAL (POL_HIGH_BIT | 0x0001)
67#define POL_INTEGER (POL_HIGH_BIT | 0x0002)
68#define POL_ISSET(flags, f) ((flags & f) == f)
69
70typedef struct {
71 unsigned Size;
72 Value *p;
73} Vector;
74
75typedef struct matrix {
76 unsigned NbRows, NbColumns;
77 Value **p;
78 Value *p_Init;
79 int p_Init_size; /* needed to free the memory allocated by mpz_init */
81
82/* Macros to init/set/clear/test flags. */
83#define FL_INIT(l, f) (l) = (f) /* Specific flags location. */
84#define FL_SET(l, f) ((l) |= (f))
85#define FL_CLR(l, f) ((l) &= ~(f))
86#define FL_ISSET(l, f) ((l) & (f))
87
88#define F_INIT(p, f) FL_INIT((p)->flags, f) /* Structure element flags. */
89#define F_SET(p, f) FL_SET((p)->flags, f)
90#define F_CLR(p, f) FL_CLR((p)->flags, f)
91#define F_ISSET(p, f) FL_ISSET((p)->flags, f)
92
93typedef struct polyhedron {
95 Value **Constraint;
96 Value **Ray;
97 Value *p_Init;
100#define POL_INEQUALITIES 0x00000001
101#define POL_FACETS 0x00000002
102#define POL_POINTS 0x00000004
103#define POL_VERTICES 0x00000008
104/* The flags field contains "valid" information,
105 * i.e., the structure was created by PolyLib.
106 */
107#define POL_VALID 0x00000010
108 unsigned flags;
110
111typedef struct interval {
112 Value MaxN, MaxD;
113 Value MinN, MinD;
114 int MaxI, MinI;
116
117/* Test whether P is an empty polyhedron */
118#define emptyQ(P) \
119 ((F_ISSET(P, POL_INEQUALITIES) && P->NbEq > P->Dimension) || \
120 (F_ISSET(P, POL_POINTS) && P->NbRays == 0))
121
122/* Test whether P is a universe polyheron */
123#define universeQ(P) (P->Dimension == P->NbBid)
124
125typedef struct _Param_Vertex {
126 Matrix *Vertex; /* Each row is a coordinate of the vertex. The first */
127 /* "m" values of each row are the coefficients of the */
128 /* parameters. The (m+1)th value is the constant, the */
129 /* The (m+2)th value is the common denominator. */
130 Matrix *Domain; /* Constraints on parameters (in Polyhedral format) */
131 unsigned *Facets; /* Bit array of facets defining the vertex. */
132 struct _Param_Vertex *next; /* Pointer to the next structure */
134
135typedef struct _Param_Domain {
136 unsigned *F; /* Bit array of faces */
137 Polyhedron *Domain; /* Pointer to Domain (constraints on parameters) */
138 struct _Param_Domain *next; /* Pointer to the next structure */
140
141typedef struct _Param_Polyhedron {
142 int nbV; /* Number of parameterized vertices */
143 Param_Vertices *V; /* Pointer to the list of parameteric vertices */
144 Param_Domain *D; /* Pointer to the list of validity domains */
145 Matrix *Constraints; /* Constraints referred to by V->Facets */
146 Matrix *Rays; /* Lines/rays (non parametric) */
148
149#define FORALL_PVertex_in_ParamPolyhedron(_V, _D, _P) \
150 { \
151 int _i, _ix; \
152 unsigned _bx; \
153 for (_i = 0, _ix = 0, _bx = MSB, _V = _P->V; _V && (_i < _P->nbV); \
154 _i++, _V = _V->next) { \
155 if (_D->F[_ix] & _bx) {
156
157#define END_FORALL_PVertex_in_ParamPolyhedron \
158 } \
159 NEXT(_ix, _bx); \
160 } \
161 }
162
163/* Data structures for pseudo-polynomial */
164
166
167#ifdef CLN
168#define POLY_UNION_OR_STRUCT struct
169#else
170#define POLY_UNION_OR_STRUCT union
171#endif
172
173typedef struct _evalue {
174 Value d; /* denominator */
176 Value n; /* numerator (if denominator != 0) */
177 struct _enode *p; /* pointer (if denominator == 0) */
178 }
181
182typedef struct _enode {
183 enode_type type; /* polynomial or periodic or evector */
184 int size; /* number of attached pointers */
185 int pos; /* parameter position */
186 evalue arr[1]; /* array of rational/pointer */
188
189typedef struct _enumeration {
190
191 Polyhedron *ValidityDomain; /* contraints on the parameters */
192 evalue EP; /* dimension = combined space */
193 struct _enumeration *next; /* Ehrhart Polynomial, corresponding
194 to parameter values inside the
195 domain ValidityDomain below */
197
198/*-----------------------------Example Usage------------------------------*/
199/* enode *e */
200/* e->type = polynomial e->type = periodic e->type = evector */
201/* e->size = degree+1 e->size = period e->size = length */
202/* e->pos = [1..nb_param] */
203/* e->arr[i].d = denominator (Value) */
204/* e->arr[i].x.p = pointer to another enode (if denominator is zero) */
205/* e->arr[i].x.n = numerator (Value) (if denominator is non-zero) */
206/*------------------------------------------------------------------------*/
207
208/*------------------------------------------------------------------------*/
209/* This representation has the following advantages: */
210/* -- its dynamic, it can grow/shrink easily */
211/* -- it is easy to evaluate for a given context (values of parameters) */
212/* -- it allows pseudo-polynomial to be reduced with rules */
213/* -- it can be constructed recursively */
214/*------------------------------------------------------------------------*/
215
216/* *********************** |Represnting Z-Polyhedron| ******************* */
217
218typedef enum { False = 0, True = 1 } Bool;
220typedef struct LatticeUnion {
224
225typedef struct ZPolyhedron {
230
231#ifndef FOREVER
232#define FOREVER for (;;)
233#endif
234
235#endif /* _types_polylib_h_ */
static int n
Definition: polyparam.c:276
struct LatticeUnion * next
Definition: types.h:222
Lattice * M
Definition: types.h:221
Definition: types.h:70
unsigned Size
Definition: types.h:71
Value * p
Definition: types.h:72
struct ZPolyhedron * next
Definition: types.h:228
Lattice * Lat
Definition: types.h:226
Polyhedron * P
Definition: types.h:227
struct _Param_Domain * next
Definition: types.h:138
Polyhedron * Domain
Definition: types.h:137
unsigned * F
Definition: types.h:136
Param_Vertices * V
Definition: types.h:143
Param_Domain * D
Definition: types.h:144
Matrix * Rays
Definition: types.h:146
Matrix * Constraints
Definition: types.h:145
Matrix * Domain
Definition: types.h:130
struct _Param_Vertex * next
Definition: types.h:132
Matrix * Vertex
Definition: types.h:126
unsigned * Facets
Definition: types.h:131
Definition: types.h:182
int pos
Definition: types.h:185
evalue arr[1]
Definition: types.h:186
enode_type type
Definition: types.h:183
int size
Definition: types.h:184
Polyhedron * ValidityDomain
Definition: types.h:191
evalue EP
Definition: types.h:192
struct _enumeration * next
Definition: types.h:193
Definition: types.h:173
POLY_UNION_OR_STRUCT
Definition: types.h:175
struct _enode * p
Definition: types.h:177
Value d
Definition: types.h:174
Value MinD
Definition: types.h:113
int MaxI
Definition: types.h:114
Value MaxN
Definition: types.h:112
int MinI
Definition: types.h:114
Value MinN
Definition: types.h:113
Value MaxD
Definition: types.h:112
Definition: types.h:75
unsigned NbRows
Definition: types.h:76
Value ** p
Definition: types.h:77
int p_Init_size
Definition: types.h:79
unsigned NbColumns
Definition: types.h:76
Value * p_Init
Definition: types.h:78
Value ** Ray
Definition: types.h:96
unsigned Dimension
Definition: types.h:94
unsigned NbConstraints
Definition: types.h:94
Value * p_Init
Definition: types.h:97
unsigned NbRays
Definition: types.h:94
unsigned NbBid
Definition: types.h:94
struct polyhedron * next
Definition: types.h:99
Value ** Constraint
Definition: types.h:95
unsigned flags
Definition: types.h:108
int p_Init_size
Definition: types.h:98
unsigned NbEq
Definition: types.h:94
enode_type
Definition: types.h:165
@ periodic
Definition: types.h:165
@ polynomial
Definition: types.h:165
@ evector
Definition: types.h:165
struct _Param_Vertex Param_Vertices
struct _Param_Domain Param_Domain
Bool
Definition: types.h:218
@ True
Definition: types.h:218
@ False
Definition: types.h:218
struct _enumeration Enumeration
struct _Param_Polyhedron Param_Polyhedron
struct polyhedron Polyhedron
struct LatticeUnion LatticeUnion
struct matrix Matrix
int Pol_status
Definition: polyhedron.c:72
struct interval Interval
Matrix Lattice
Definition: types.h:219
struct _enode enode
struct _evalue evalue
struct ZPolyhedron ZPolyhedron