Main Page | Class List | File List | Class Members | File Members

types.h

Go to the documentation of this file.
00001 /* types-polylib.h
00002      COPYRIGHT
00003           Both this software and its documentation are
00004 
00005               Copyright 1993, IRISA /Universite de Rennes I - France
00006               Copyright 1996,1997,1998, Doran Wilde and Vincent Loechner
00007               All rights reserved.
00008 
00009           Permission is granted to copy, use, and distribute
00010           for any commercial or noncommercial purpose under the terms
00011           of the GNU General Public license, version 2, June 1991
00012           (see file : LICENSING).
00013 */
00014 
00015 #ifndef _types_polylib_h_
00016 #define _types_polylib_h_
00017 
00018 #ifdef GNUMP
00019 #include<gmp.h>
00020 #endif 
00021 
00022 /*********************** USER DEFINES ******************************/
00023 
00024 /* first parameter name char.  */
00025 #define FIRST_PARAMETER_NAME 'P'
00026 
00027 /******************* END OF USER DEFINES ***************************/
00028 
00029 
00030 #define PCHAR (FIRST_PARAMETER_NAME-1)
00031 #define MAXNOOFRAYS 200 
00032 
00033 #if defined(LINEAR_VALUE_IS_LONGLONG)
00034 #define P_VALUE_FMT "%4lld "
00035 #elif defined(LINEAR_VALUE_IS_LONG)
00036 #define P_VALUE_FMT "%4ld "
00037 #elif defined(LINEAR_VALUE_IS_CHARS)
00038 #define P_VALUE_FMT "%s "
00039 #elif defined(LINEAR_VALUE_IS_INT) 
00040 #define P_VALUE_FMT "%4d "
00041 #else  /* GNUMP */
00042 #define P_VALUE_FMT "%4s"
00043 #endif
00044 
00045 /* Used in lower_upper_bounds */
00046 #define LB_INFINITY 1
00047 #define UB_INFINITY 2
00048 
00049 /* MSB, TOP, and NEXT are defined over integer type, not on value type */
00050 /* Put a one in the most significant bit of an int (portable) */
00051 #define MSB ((unsigned)(((unsigned)1)<<(sizeof(int)*8-1)))
00052 
00053 /* Largest representable positive number */
00054 #define TOP ((int)(MSB-1))
00055 
00056 /* Right shift the one bit in b and increment j if the last bit in b is one */
00057 #define NEXT(j,b) { if (!((b)>>=1)) { (b)=MSB; (j)++; } }
00058 
00059 /* Status of last Polyhedron operation */
00060 extern int Pol_status;
00061 
00062 typedef struct  {
00063   unsigned Size;
00064   Value *p;
00065 } Vector;
00066 
00067 typedef struct matrix {
00068   unsigned NbRows, NbColumns;
00069   Value **p;
00070   Value *p_Init;
00071   int p_Init_size;      /* needed to free the memory allocated by mpz_init */
00072 } Matrix;
00073 
00074 typedef struct polyhedron { 
00075   unsigned Dimension, NbConstraints, NbRays, NbEq, NbBid;
00076   Value **Constraint;
00077   Value **Ray;
00078   Value *p_Init;
00079   int p_Init_size;
00080   struct polyhedron *next;
00081 } Polyhedron;
00082 
00083 typedef struct interval {
00084   Value MaxN, MaxD;
00085   Value MinN, MinD; 
00086   int MaxI, MinI;
00087 } Interval;
00088 
00089 /* Test whether P is an empty polyhedron */
00090 #define emptyQ(P) (P->NbRays==0)
00091 
00092 /* Test whether P is a universe polyheron */
00093 #define universeQ(P) (P->Dimension==P->NbLines)
00094 
00095 typedef struct _Param_Vertex {          
00096   Matrix *Vertex; /* Each row is a coordinate of the vertex. The first  */
00097                   /* "m" values of each row are the coefficients of the */
00098                   /* parameters. The (m+1)th value is the constant, the */
00099                   /* The (m+2)th value is the common denominator.       */
00100   Matrix *Domain; /* Constraints on parameters (in Polyhedral format)   */
00101   struct _Param_Vertex *next;          /* Pointer to the next structure */
00102 } Param_Vertices;
00103 
00104 typedef struct _Param_Domain {
00105   unsigned *F;         /* Bit array of faces */
00106   Polyhedron *Domain;  /* Pointer to Domain (constraints on parameters) */
00107   struct _Param_Domain *next; /* Pointer to the next structure  */
00108 } Param_Domain;
00109 
00110 typedef struct _Param_Polyhedron {
00111         int nbV;            /* Number of parameterized vertices            */
00112         Param_Vertices *V;  /* Pointer to the list of parameteric vertices */
00113         Param_Domain *D;    /* Pointer to the list of validity domains     */
00114 } Param_Polyhedron;
00115 
00116 #define FORALL_PVertex_in_ParamPolyhedron(_V, _D, _P)   \
00117 {     int _i, _ix;                                   \
00118       unsigned _bx;                                  \
00119       for( _i=0, _ix=0, _bx=MSB, _V=_P->V ;            \
00120            _V && (_i<_P->nbV) ; _i++, _V=_V->next )      \
00121       {       if (_D->F[_ix] & _bx)                   \
00122               {
00123 
00124 #define END_FORALL_PVertex_in_ParamPolyhedron  \
00125               }                                \
00126               NEXT(_ix, _bx);                  \
00127       }                                        \
00128 }
00129 
00130 /* Data structures for pseudo-polynomial */
00131 
00132 typedef enum { polynomial, periodic, evector } enode_type;
00133 
00134 typedef struct _evalue {
00135   Value d;              /* denominator */
00136   union {
00137     Value n;            /* numerator (if denominator != 0) */
00138     struct _enode *p;   /* pointer   (if denominator == 0) */
00139   } x;
00140 } evalue;
00141 
00142 typedef struct _enode {
00143   enode_type type;      /* polynomial or periodic or evector */
00144   int size;             /* number of attached pointers */
00145   int pos;              /* parameter position */
00146   evalue arr[1];        /* array of rational/pointer */
00147 } enode;
00148 
00149 typedef struct _enumeration {
00150   
00151   Polyhedron *ValidityDomain;    /* contraints on the parameters     */
00152   evalue EP;                     /* dimension = combined space       */
00153   struct _enumeration *next;     /* Ehrhart Polynomial, corresponding
00154                                     to parameter values inside the
00155                                     domain ValidityDomain below      */
00156 } Enumeration;
00157 
00158 /*-----------------------------Example Usage------------------------------*/
00159 /* enode *e                                                               */
00160 /*     e->type = polynomial     e->type = periodic   e->type = evector    */
00161 /*     e->size = degree+1       e->size = period     e->size = length     */
00162 /*     e->pos  = [1..nb_param]                                            */
00163 /*     e->arr[i].d = denominator (Value)                                  */
00164 /*     e->arr[i].x.p = pointer to another enode (if denominator is zero)  */
00165 /*     e->arr[i].x.n = numerator (Value) (if denominator is non-zero)     */
00166 /*------------------------------------------------------------------------*/
00167 
00168 /*------------------------------------------------------------------------*/
00169 /* This representation has the following advantages:                      */
00170 /*   -- its dynamic, it can grow/shrink easily                            */
00171 /*   -- it is easy to evaluate for a given context (values of parameters) */
00172 /*   -- it allows pseudo-polynomial to be reduced with rules              */
00173 /*   -- it can be constructed recursively                                 */
00174 /*------------------------------------------------------------------------*/
00175 
00176 /* *********************** |Represnting Z-Polyhedron| ******************* */
00177 
00178 
00179 typedef enum {False = 0, True = 1} Bool;
00180 typedef Matrix Lattice;
00181 typedef struct LatticeUnion {
00182   Lattice *M;
00183   struct LatticeUnion *next;
00184 } LatticeUnion;
00185 
00186 typedef struct ZPolyhedron {
00187   Lattice *Lat ;
00188   Polyhedron *P;
00189   struct ZPolyhedron *next;
00190 } ZPolyhedron;
00191 
00192 #ifndef FOREVER
00193 #define FOREVER for(;;)
00194 #endif
00195 
00196 #endif /* _types_polylib_h_ */
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208 

Generated on Mon Sep 12 14:48:29 2005 for polylib by doxygen 1.3.5