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 */
63
extern
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
70
typedef
struct
{
71
unsigned
Size
;
72
Value *
p
;
73
}
Vector
;
74
75
typedef
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 */
80
}
Matrix
;
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
93
typedef
struct
polyhedron
{
94
unsigned
Dimension
,
NbConstraints
,
NbRays
,
NbEq
,
NbBid
;
95
Value **
Constraint
;
96
Value **
Ray
;
97
Value *
p_Init
;
98
int
p_Init_size
;
99
struct
polyhedron
*
next
;
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
;
109
}
Polyhedron
;
110
111
typedef
struct
interval
{
112
Value
MaxN
,
MaxD
;
113
Value
MinN
,
MinD
;
114
int
MaxI
,
MinI
;
115
}
Interval
;
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
125
typedef
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 */
133
}
Param_Vertices
;
134
135
typedef
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 */
139
}
Param_Domain
;
140
141
typedef
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) */
147
}
Param_Polyhedron
;
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
165
typedef
enum
{
polynomial
,
periodic
,
evector
}
enode_type
;
166
167
#ifdef CLN
168
#define POLY_UNION_OR_STRUCT struct
169
#else
170
#define POLY_UNION_OR_STRUCT union
171
#endif
172
173
typedef
struct
_evalue
{
174
Value
d
;
/* denominator */
175
POLY_UNION_OR_STRUCT
{
176
Value
n
;
/* numerator (if denominator != 0) */
177
struct
_enode
*
p
;
/* pointer (if denominator == 0) */
178
}
179
x
;
180
}
evalue
;
181
182
typedef
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 */
187
}
enode
;
188
189
typedef
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 */
196
}
Enumeration
;
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
218
typedef
enum
{
False
= 0,
True
= 1 }
Bool
;
219
typedef
Matrix
Lattice
;
220
typedef
struct
LatticeUnion
{
221
Lattice
*
M
;
222
struct
LatticeUnion
*
next
;
223
}
LatticeUnion
;
224
225
typedef
struct
ZPolyhedron
{
226
Lattice
*
Lat
;
227
Polyhedron
*
P
;
228
struct
ZPolyhedron
*
next
;
229
}
ZPolyhedron
;
230
231
#ifndef FOREVER
232
#define FOREVER for (;;)
233
#endif
234
235
#endif
/* _types_polylib_h_ */
n
static int n
Definition:
polyparam.c:276
LatticeUnion
Definition:
types.h:220
LatticeUnion::next
struct LatticeUnion * next
Definition:
types.h:222
LatticeUnion::M
Lattice * M
Definition:
types.h:221
Vector
Definition:
types.h:70
Vector::Size
unsigned Size
Definition:
types.h:71
Vector::p
Value * p
Definition:
types.h:72
ZPolyhedron
Definition:
types.h:225
ZPolyhedron::next
struct ZPolyhedron * next
Definition:
types.h:228
ZPolyhedron::Lat
Lattice * Lat
Definition:
types.h:226
ZPolyhedron::P
Polyhedron * P
Definition:
types.h:227
_Param_Domain
Definition:
types.h:135
_Param_Domain::next
struct _Param_Domain * next
Definition:
types.h:138
_Param_Domain::Domain
Polyhedron * Domain
Definition:
types.h:137
_Param_Domain::F
unsigned * F
Definition:
types.h:136
_Param_Polyhedron
Definition:
types.h:141
_Param_Polyhedron::V
Param_Vertices * V
Definition:
types.h:143
_Param_Polyhedron::D
Param_Domain * D
Definition:
types.h:144
_Param_Polyhedron::Rays
Matrix * Rays
Definition:
types.h:146
_Param_Polyhedron::nbV
int nbV
Definition:
types.h:142
_Param_Polyhedron::Constraints
Matrix * Constraints
Definition:
types.h:145
_Param_Vertex
Definition:
types.h:125
_Param_Vertex::Domain
Matrix * Domain
Definition:
types.h:130
_Param_Vertex::next
struct _Param_Vertex * next
Definition:
types.h:132
_Param_Vertex::Vertex
Matrix * Vertex
Definition:
types.h:126
_Param_Vertex::Facets
unsigned * Facets
Definition:
types.h:131
_enode
Definition:
types.h:182
_enode::pos
int pos
Definition:
types.h:185
_enode::arr
evalue arr[1]
Definition:
types.h:186
_enode::type
enode_type type
Definition:
types.h:183
_enode::size
int size
Definition:
types.h:184
_enumeration
Definition:
types.h:189
_enumeration::ValidityDomain
Polyhedron * ValidityDomain
Definition:
types.h:191
_enumeration::EP
evalue EP
Definition:
types.h:192
_enumeration::next
struct _enumeration * next
Definition:
types.h:193
_evalue
Definition:
types.h:173
_evalue::x
x
Definition:
types.h:179
_evalue::POLY_UNION_OR_STRUCT
POLY_UNION_OR_STRUCT
Definition:
types.h:175
_evalue::p
struct _enode * p
Definition:
types.h:177
_evalue::d
Value d
Definition:
types.h:174
interval
Definition:
types.h:111
interval::MinD
Value MinD
Definition:
types.h:113
interval::MaxI
int MaxI
Definition:
types.h:114
interval::MaxN
Value MaxN
Definition:
types.h:112
interval::MinI
int MinI
Definition:
types.h:114
interval::MinN
Value MinN
Definition:
types.h:113
interval::MaxD
Value MaxD
Definition:
types.h:112
matrix
Definition:
types.h:75
matrix::NbRows
unsigned NbRows
Definition:
types.h:76
matrix::p
Value ** p
Definition:
types.h:77
matrix::p_Init_size
int p_Init_size
Definition:
types.h:79
matrix::NbColumns
unsigned NbColumns
Definition:
types.h:76
matrix::p_Init
Value * p_Init
Definition:
types.h:78
polyhedron
Definition:
types.h:93
polyhedron::Ray
Value ** Ray
Definition:
types.h:96
polyhedron::Dimension
unsigned Dimension
Definition:
types.h:94
polyhedron::NbConstraints
unsigned NbConstraints
Definition:
types.h:94
polyhedron::p_Init
Value * p_Init
Definition:
types.h:97
polyhedron::NbRays
unsigned NbRays
Definition:
types.h:94
polyhedron::NbBid
unsigned NbBid
Definition:
types.h:94
polyhedron::next
struct polyhedron * next
Definition:
types.h:99
polyhedron::Constraint
Value ** Constraint
Definition:
types.h:95
polyhedron::flags
unsigned flags
Definition:
types.h:108
polyhedron::p_Init_size
int p_Init_size
Definition:
types.h:98
polyhedron::NbEq
unsigned NbEq
Definition:
types.h:94
enode_type
enode_type
Definition:
types.h:165
periodic
@ periodic
Definition:
types.h:165
polynomial
@ polynomial
Definition:
types.h:165
evector
@ evector
Definition:
types.h:165
Param_Vertices
struct _Param_Vertex Param_Vertices
Param_Domain
struct _Param_Domain Param_Domain
Bool
Bool
Definition:
types.h:218
True
@ True
Definition:
types.h:218
False
@ False
Definition:
types.h:218
Enumeration
struct _enumeration Enumeration
Param_Polyhedron
struct _Param_Polyhedron Param_Polyhedron
Polyhedron
struct polyhedron Polyhedron
LatticeUnion
struct LatticeUnion LatticeUnion
Matrix
struct matrix Matrix
Pol_status
int Pol_status
Definition:
polyhedron.c:72
Interval
struct interval Interval
Lattice
Matrix Lattice
Definition:
types.h:219
enode
struct _enode enode
evalue
struct _evalue evalue
ZPolyhedron
struct ZPolyhedron ZPolyhedron
include
polylib
types.h
Generated by
1.9.4