00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef _types_polylib_h_
00033 #define _types_polylib_h_
00034
00035 #ifdef GNUMP
00036 #include<gmp.h>
00037 #endif
00038
00039 #include <limits.h>
00040
00041
00042
00043
00044 #define FIRST_PARAMETER_NAME 'P'
00045
00046
00047
00048
00049 #define PCHAR (FIRST_PARAMETER_NAME-1)
00050 #define MAXNOOFRAYS 200
00051
00052 #if defined(LINEAR_VALUE_IS_LONGLONG)
00053 #define P_VALUE_FMT "%4lld "
00054 #elif defined(LINEAR_VALUE_IS_LONG)
00055 #define P_VALUE_FMT "%4ld "
00056 #elif defined(LINEAR_VALUE_IS_CHARS)
00057 #define P_VALUE_FMT "%s "
00058 #elif defined(LINEAR_VALUE_IS_INT)
00059 #define P_VALUE_FMT "%4d "
00060 #else
00061 #define P_VALUE_FMT "%4s "
00062 #endif
00063
00064
00065 #define LB_INFINITY 1
00066 #define UB_INFINITY 2
00067
00068
00069
00070 #define MSB ((unsigned)(((unsigned)1)<<(sizeof(int)*8-1)))
00071
00072
00073 #define TOP ((int)(MSB-1))
00074
00075
00076 #define NEXT(j,b) { if (!((b)>>=1)) { (b)=MSB; (j)++; } }
00077
00078
00079 extern int Pol_status;
00080
00081 #define POL_HIGH_BIT (UINT_MAX - (UINT_MAX >> 1))
00082 #define POL_NO_DUAL (POL_HIGH_BIT | 0x0001)
00083 #define POL_INTEGER (POL_HIGH_BIT | 0x0002)
00084 #define POL_ISSET(flags,f) ((flags & f) == f)
00085
00086 typedef struct {
00087 unsigned Size;
00088 Value *p;
00089 } Vector;
00090
00091 typedef struct matrix {
00092 unsigned NbRows, NbColumns;
00093 Value **p;
00094 Value *p_Init;
00095 int p_Init_size;
00096 } Matrix;
00097
00098
00099 #define FL_INIT(l, f) (l) = (f)
00100 #define FL_SET(l, f) ((l) |= (f))
00101 #define FL_CLR(l, f) ((l) &= ~(f))
00102 #define FL_ISSET(l, f) ((l) & (f))
00103
00104 #define F_INIT(p, f) FL_INIT((p)->flags, f)
00105 #define F_SET(p, f) FL_SET((p)->flags, f)
00106 #define F_CLR(p, f) FL_CLR((p)->flags, f)
00107 #define F_ISSET(p, f) FL_ISSET((p)->flags, f)
00108
00109 typedef struct polyhedron {
00110 unsigned Dimension, NbConstraints, NbRays, NbEq, NbBid;
00111 Value **Constraint;
00112 Value **Ray;
00113 Value *p_Init;
00114 int p_Init_size;
00115 struct polyhedron *next;
00116 #define POL_INEQUALITIES 0x00000001
00117 #define POL_FACETS 0x00000002
00118 #define POL_POINTS 0x00000004
00119 #define POL_VERTICES 0x00000008
00120
00121
00122
00123 #define POL_VALID 0x00000010
00124 unsigned flags;
00125 } Polyhedron;
00126
00127 typedef struct interval {
00128 Value MaxN, MaxD;
00129 Value MinN, MinD;
00130 int MaxI, MinI;
00131 } Interval;
00132
00133
00134 #define emptyQ(P) \
00135 ((F_ISSET(P, POL_INEQUALITIES) && P->NbEq > P->Dimension) || \
00136 (F_ISSET(P, POL_POINTS) && P->NbRays == 0))
00137
00138
00139 #define universeQ(P) (P->Dimension==P->NbBid)
00140
00141 typedef struct _Param_Vertex {
00142 Matrix *Vertex;
00143
00144
00145
00146 Matrix *Domain;
00147 unsigned *Facets;
00148 struct _Param_Vertex *next;
00149 } Param_Vertices;
00150
00151 typedef struct _Param_Domain {
00152 unsigned *F;
00153 Polyhedron *Domain;
00154 struct _Param_Domain *next;
00155 } Param_Domain;
00156
00157 typedef struct _Param_Polyhedron {
00158 int nbV;
00159 Param_Vertices *V;
00160 Param_Domain *D;
00161 Matrix *Constraints;
00162 Matrix *Rays;
00163 } Param_Polyhedron;
00164
00165 #define FORALL_PVertex_in_ParamPolyhedron(_V, _D, _P) \
00166 { int _i, _ix; \
00167 unsigned _bx; \
00168 for( _i=0, _ix=0, _bx=MSB, _V=_P->V ; \
00169 _V && (_i<_P->nbV) ; _i++, _V=_V->next ) \
00170 { if (_D->F[_ix] & _bx) \
00171 {
00172
00173 #define END_FORALL_PVertex_in_ParamPolyhedron \
00174 } \
00175 NEXT(_ix, _bx); \
00176 } \
00177 }
00178
00179
00180
00181 typedef enum { polynomial, periodic, evector } enode_type;
00182
00183 #ifdef CLN
00184 #define POLY_UNION_OR_STRUCT struct
00185 #else
00186 #define POLY_UNION_OR_STRUCT union
00187 #endif
00188
00189 typedef struct _evalue {
00190 Value d;
00191 POLY_UNION_OR_STRUCT {
00192 Value n;
00193 struct _enode *p;
00194 } x;
00195 } evalue;
00196
00197 typedef struct _enode {
00198 enode_type type;
00199 int size;
00200 int pos;
00201 evalue arr[1];
00202 } enode;
00203
00204 typedef struct _enumeration {
00205
00206 Polyhedron *ValidityDomain;
00207 evalue EP;
00208 struct _enumeration *next;
00209
00210
00211 } Enumeration;
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 typedef enum {False = 0, True = 1} Bool;
00235 typedef Matrix Lattice;
00236 typedef struct LatticeUnion {
00237 Lattice *M;
00238 struct LatticeUnion *next;
00239 } LatticeUnion;
00240
00241 typedef struct ZPolyhedron {
00242 Lattice *Lat ;
00243 Polyhedron *P;
00244 struct ZPolyhedron *next;
00245 } ZPolyhedron;
00246
00247 #ifndef FOREVER
00248 #define FOREVER for(;;)
00249 #endif
00250
00251 #endif