polyhedron.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <polylib/polylib.h>

Go to the source code of this file.

Classes

struct  SatMatrix

Defines

#define WSIZE   (8*sizeof(int))
#define bexchange(a, b, l)
#define exchange(a, b, t)   { (t)=(a); (a)=(b); (b)=(t); }
#define SMVector_Copy(p1, p2, length)   memcpy((char *)(p2), (char *)(p1), (int)((length)*sizeof(int)))
#define SMVector_Init(p1, length)   memset((char *)(p1), 0, (int)((length)*sizeof(int)))

Functions

void errormsg1 (const char *f, const char *msgname, const char *msg)
static SatMatrixSMAlloc (int rows, int cols)
static void SMFree (SatMatrix **matrix)
static void SMPrint (SatMatrix *matrix)
static void SatVector_OR (int *p1, int *p2, int *p3, unsigned length)
static void Combine (Value *p1, Value *p2, Value *p3, int pos, unsigned length)
static SatMatrixTransformSat (Matrix *Mat, Matrix *Ray, SatMatrix *Sat)
static void RaySort (Matrix *Ray, SatMatrix *Sat, int NbBid, int NbRay, int *equal_bound, int *sup_bound, unsigned RowSize1, unsigned RowSize2, unsigned bx, unsigned jx)
static void SatMatrix_Extend (SatMatrix *Sat, Matrix *Mat, unsigned rows)
static int Chernikova (Matrix *Mat, Matrix *Ray, SatMatrix *Sat, unsigned NbBid, unsigned NbMaxRays, unsigned FirstConstraint, unsigned dual)
static int Gauss4 (Value **p, int NbEq, int NbRows, int Dimension)
int Gauss (Matrix *Mat, int NbEq, int Dimension)
static PolyhedronRemove_Redundants (Matrix *Mat, Matrix *Ray, SatMatrix *Sat, unsigned *Filter)
PolyhedronPolyhedron_Alloc (unsigned Dimension, unsigned NbConstraints, unsigned NbRays)
void Polyhedron_Free (Polyhedron *Pol)
void Domain_Free (Polyhedron *Pol)
void Polyhedron_Print (FILE *Dst, const char *Format, const Polyhedron *Pol)
void PolyPrint (Polyhedron *Pol)
PolyhedronEmpty_Polyhedron (unsigned Dimension)
PolyhedronUniverse_Polyhedron (unsigned Dimension)
static void SortConstraints (Matrix *Constraints, unsigned NbEq)
static int ImplicitEqualities (Matrix *Constraints, unsigned NbEq)
PolyhedronConstraints2Polyhedron (Matrix *Constraints, unsigned NbMaxRays)
 Given a matrix of constraints ('Constraints'), construct and return a polyhedron.
MatrixPolyhedron2Constraints (Polyhedron *Pol)
PolyhedronRays2Polyhedron (Matrix *Ray, unsigned NbMaxConstrs)
 Given a matrix of rays 'Ray', create and return a polyhedron.
void Polyhedron_Compute_Dual (Polyhedron *P)
static SatMatrixBuildSat (Matrix *Mat, Matrix *Ray, unsigned NbConstraints, unsigned NbMaxRays)
PolyhedronAddConstraints (Value *Con, unsigned NbConstraints, Polyhedron *Pol, unsigned NbMaxRays)
int PolyhedronIncludes (Polyhedron *Pol1, Polyhedron *Pol2)
PolyhedronAddPolyToDomain (Polyhedron *Pol, Polyhedron *PolDomain)
PolyhedronSubConstraint (Value *Con, Polyhedron *Pol, unsigned NbMaxRays, int Pass)
PolyhedronDomainIntersection (Polyhedron *Pol1, Polyhedron *Pol2, unsigned NbMaxRays)
MatrixPolyhedron2Rays (Polyhedron *Pol)
PolyhedronAddRays (Value *AddedRays, unsigned NbAddedRays, Polyhedron *Pol, unsigned NbMaxConstrs)
PolyhedronDomainAddRays (Polyhedron *Pol, Matrix *Ray, unsigned NbMaxConstrs)
PolyhedronPolyhedron_Copy (Polyhedron *Pol)
PolyhedronDomain_Copy (Polyhedron *Pol)
static void addToFilter (int k, unsigned *Filter, SatMatrix *Sat, Value *tmpR, Value *tmpC, int NbRays, int NbConstraints)
static void FindSimple (Polyhedron *P1, Polyhedron *P2, unsigned *Filter, unsigned NbMaxRays)
static int SimplifyConstraints (Polyhedron *Pol1, Polyhedron *Pol2, unsigned *Filter, unsigned NbMaxRays)
static void SimplifyEqualities (Polyhedron *Pol1, Polyhedron *Pol2, unsigned *Filter)
PolyhedronDomainSimplify (Polyhedron *Pol1, Polyhedron *Pol2, unsigned NbMaxRays)
PolyhedronStras_DomainSimplify (Polyhedron *Pol1, Polyhedron *Pol2, unsigned NbMaxRays)
PolyhedronDomainUnion (Polyhedron *Pol1, Polyhedron *Pol2, unsigned NbMaxRays)
PolyhedronDomainConvex (Polyhedron *Pol, unsigned NbMaxConstrs)
PolyhedronDomainDifference (Polyhedron *Pol1, Polyhedron *Pol2, unsigned NbMaxRays)
Polyhedronalign_context (Polyhedron *Pol, int align_dimension, int NbMaxRays)
PolyhedronPolyhedron_Scan (Polyhedron *D, Polyhedron *C, unsigned NbMaxRays)
int lower_upper_bounds (int pos, Polyhedron *P, Value *context, Value *LBp, Value *UBp)
static void Rays_Mult (Value **A, Matrix *B, Value **C, unsigned NbRays)
static void Rays_Mult_Transpose (Value **A, Matrix *B, Value **C, unsigned NbRays)
PolyhedronPolyhedron_Preimage (Polyhedron *Pol, Matrix *Func, unsigned NbMaxRays)
PolyhedronDomainPreimage (Polyhedron *Pol, Matrix *Func, unsigned NbMaxRays)
PolyhedronPolyhedron_Image (Polyhedron *Pol, Matrix *Func, unsigned NbMaxConstrs)
PolyhedronDomainImage (Polyhedron *Pol, Matrix *Func, unsigned NbMaxConstrs)
IntervalDomainCost (Polyhedron *Pol, Value *Cost)
PolyhedronDomainAddConstraints (Polyhedron *Pol, Matrix *Mat, unsigned NbMaxRays)
PolyhedronDisjoint_Domain (Polyhedron *P, int flag, unsigned NbMaxRays)
void Polyhedron_PrintConstraints (FILE *Dst, const char *Format, Polyhedron *Pol)
void Domain_PrintConstraints (FILE *Dst, const char *Format, Polyhedron *Pol)
static Polyhedronp_simplify_constraints (Polyhedron *P, Vector *row, Value *g, unsigned MaxRays)
PolyhedronDomainConstraintSimplify (Polyhedron *P, unsigned MaxRays)

Variables

int Pol_status

Define Documentation

#define bexchange ( a,
b,
 ) 
Value:
{\
  char *t = (char *)malloc(l*sizeof(char));\
  memcpy((t), (char *)(a), (int)(l));\
  memcpy((char *)(a), (char *)(b), (int)(l));\
  memcpy((char *)(b), (t), (int)(l));\
  free(t); \
}

Definition at line 71 of file polyhedron.c.

Referenced by RaySort(), and Remove_Redundants().

#define exchange ( a,
b,
 )     { (t)=(a); (a)=(b); (b)=(t); }

Definition at line 80 of file polyhedron.c.

Referenced by Remove_Redundants().

#define SMVector_Copy ( p1,
p2,
length   )     memcpy((char *)(p2), (char *)(p1), (int)((length)*sizeof(int)))

Definition at line 199 of file polyhedron.c.

Referenced by Chernikova().

#define SMVector_Init ( p1,
length   )     memset((char *)(p1), 0, (int)((length)*sizeof(int)))
#define WSIZE   (8*sizeof(int))

Definition at line 69 of file polyhedron.c.

Referenced by addToFilter(), and Chernikova().


Function Documentation

Polyhedron* AddConstraints ( Value *  Con,
unsigned  NbConstraints,
Polyhedron Pol,
unsigned  NbMaxRays 
)
Polyhedron* AddPolyToDomain ( Polyhedron Pol,
Polyhedron PolDomain 
)
Polyhedron* AddRays ( Value *  AddedRays,
unsigned  NbAddedRays,
Polyhedron Pol,
unsigned  NbMaxConstrs 
)
static void addToFilter ( int  k,
unsigned *  Filter,
SatMatrix Sat,
Value *  tmpR,
Value *  tmpC,
int  NbRays,
int  NbConstraints 
) [static]

Definition at line 2861 of file polyhedron.c.

References MSB, NEXT, SatMatrix::p, value_decrement, value_posz_p, value_set_si, and WSIZE.

Referenced by FindSimple().

Polyhedron* align_context ( Polyhedron Pol,
int  align_dimension,
int  NbMaxRays 
)
static SatMatrix* BuildSat ( Matrix Mat,
Matrix Ray,
unsigned  NbConstraints,
unsigned  NbMaxRays 
) [static]
static int Chernikova ( Matrix Mat,
Matrix Ray,
SatMatrix Sat,
unsigned  NbBid,
unsigned  NbMaxRays,
unsigned  FirstConstraint,
unsigned  dual 
) [static]
static void Combine ( Value *  p1,
Value *  p2,
Value *  p3,
int  pos,
unsigned  length 
) [static]
Polyhedron* Constraints2Polyhedron ( Matrix Constraints,
unsigned  NbMaxRays 
)

Given a matrix of constraints ('Constraints'), construct and return a polyhedron.

Parameters:
Constraints Constraints (may be modified!)
NbMaxRays Estimated number of rays in the ray matrix of the polyhedron.
Returns:
newly allocated Polyhedron

Definition at line 1906 of file polyhedron.c.

References any_exception_error, CATCH, Chernikova(), polyhedron::Constraint, ConstraintSimplify(), Empty_Polyhedron(), errormsg1(), ExchangeRows(), F_SET, First_Non_Zero(), Gauss(), ImplicitEqualities(), Matrix_Alloc(), Matrix_Free(), Matrix_Print(), matrix::NbColumns, polyhedron::NbEq, SatMatrix::NbRows, matrix::NbRows, matrix::p, SatMatrix::p_init, matrix::p_Init, POL_INEQUALITIES, POL_INTEGER, POL_ISSET, POL_NO_DUAL, POL_VALID, Polyhedron_Alloc(), Polyhedron_Free(), Polyhedron_Print(), polyhedron::Ray, Remove_Redundants(), RETHROW, Sat, SMAlloc(), SMFree(), SMPrint(), SMVector_Init, SortConstraints(), TRY, UNCATCH, Universe_Polyhedron(), value_clear, value_init, value_notzero_p, value_set_si, value_zero_p, Vector_Copy(), and Vector_Set().

Referenced by AddConstraints(), dehomogenize_polyhedron(), DomainSimplify(), Ehrhart_Quick_Apx(), Elim_Columns(), eliminable_vars(), Enumeration_zero(), Find_m_faces(), homogenize(), LexSmaller(), main(), Param_Vertices_Print(), Polyhedron_Compute_Dual(), Polyhedron_Preimage(), Polyhedron_Preprocess(), Polyhedron_Preprocess2(), Polyhedron_Remove_parm_eqs(), Recession_Cone(), Stras_DomainSimplify(), test_Constraints_fullDimensionize(), test_Constraints_Remove_parm_eqs(), test_Polyhedron_Remove_parm_eqs(), and Union_Read().

Polyhedron* Disjoint_Domain ( Polyhedron P,
int  flag,
unsigned  NbMaxRays 
)
Polyhedron* Domain_Copy ( Polyhedron Pol  ) 
void Domain_Free ( Polyhedron Pol  ) 
void Domain_PrintConstraints ( FILE *  Dst,
const char *  Format,
Polyhedron Pol 
)

Definition at line 4638 of file polyhedron.c.

References polyhedron::next, and Polyhedron_PrintConstraints().

Polyhedron* DomainAddConstraints ( Polyhedron Pol,
Matrix Mat,
unsigned  NbMaxRays 
)
Polyhedron* DomainAddRays ( Polyhedron Pol,
Matrix Ray,
unsigned  NbMaxConstrs 
)
Polyhedron* DomainConstraintSimplify ( Polyhedron P,
unsigned  MaxRays 
)
Polyhedron* DomainConvex ( Polyhedron Pol,
unsigned  NbMaxConstrs 
)
Interval* DomainCost ( Polyhedron Pol,
Value *  Cost 
)
Polyhedron* DomainDifference ( Polyhedron Pol1,
Polyhedron Pol2,
unsigned  NbMaxRays 
)
Polyhedron* DomainImage ( Polyhedron Pol,
Matrix Func,
unsigned  NbMaxConstrs 
)
Polyhedron* DomainIntersection ( Polyhedron Pol1,
Polyhedron Pol2,
unsigned  NbMaxRays 
)
Polyhedron* DomainPreimage ( Polyhedron Pol,
Matrix Func,
unsigned  NbMaxRays 
)
Polyhedron* DomainSimplify ( Polyhedron Pol1,
Polyhedron Pol2,
unsigned  NbMaxRays 
)
Polyhedron* DomainUnion ( Polyhedron Pol1,
Polyhedron Pol2,
unsigned  NbMaxRays 
)
Polyhedron* Empty_Polyhedron ( unsigned  Dimension  ) 
void errormsg1 ( const char *  f,
const char *  msgname,
const char *  msg 
)

Definition at line 46 of file errormsg.c.

static void FindSimple ( Polyhedron P1,
Polyhedron P2,
unsigned *  Filter,
unsigned  NbMaxRays 
) [static]
int Gauss ( Matrix Mat,
int  NbEq,
int  Dimension 
)
static int Gauss4 ( Value **  p,
int  NbEq,
int  NbRows,
int  Dimension 
) [static]
static int ImplicitEqualities ( Matrix Constraints,
unsigned  NbEq 
) [static]
int lower_upper_bounds ( int  pos,
Polyhedron P,
Value *  context,
Value *  LBp,
Value *  UBp 
)
static Polyhedron* p_simplify_constraints ( Polyhedron P,
Vector row,
Value *  g,
unsigned  MaxRays 
) [static]
Matrix* Polyhedron2Constraints ( Polyhedron Pol  ) 
Matrix* Polyhedron2Rays ( Polyhedron Pol  ) 
Polyhedron* Polyhedron_Alloc ( unsigned  Dimension,
unsigned  NbConstraints,
unsigned  NbRays 
)
void Polyhedron_Compute_Dual ( Polyhedron P  ) 
Polyhedron* Polyhedron_Copy ( Polyhedron Pol  ) 
void Polyhedron_Free ( Polyhedron Pol  ) 
Polyhedron* Polyhedron_Image ( Polyhedron Pol,
Matrix Func,
unsigned  NbMaxConstrs 
)
Polyhedron* Polyhedron_Preimage ( Polyhedron Pol,
Matrix Func,
unsigned  NbMaxRays 
)
void Polyhedron_Print ( FILE *  Dst,
const char *  Format,
const Polyhedron Pol 
)
void Polyhedron_PrintConstraints ( FILE *  Dst,
const char *  Format,
Polyhedron Pol 
)
Polyhedron* Polyhedron_Scan ( Polyhedron D,
Polyhedron C,
unsigned  NbMaxRays 
)
int PolyhedronIncludes ( Polyhedron Pol1,
Polyhedron Pol2 
)
void PolyPrint ( Polyhedron Pol  ) 

Definition at line 1704 of file polyhedron.c.

References Polyhedron_Print().

Polyhedron* Rays2Polyhedron ( Matrix Ray,
unsigned  NbMaxConstrs 
)

Given a matrix of rays 'Ray', create and return a polyhedron.

Parameters:
Ray Rays (may be modified!)
NbMaxConstrs Estimated number of constraints in the polyhedron.
Returns:
newly allocated Polyhedron

Definition at line 2083 of file polyhedron.c.

References any_exception_error, CATCH, Chernikova(), Empty_Polyhedron(), errormsg1(), Matrix_Alloc(), Matrix_Free(), Matrix_Print(), matrix::NbColumns, matrix::NbRows, matrix::p, matrix::p_Init, POL_ISSET, POL_NO_DUAL, Polyhedron_Free(), Polyhedron_Print(), Remove_Redundants(), RETHROW, Sat, SMAlloc(), SMFree(), SMPrint(), SMVector_Init, TransformSat(), TRY, UNCATCH, value_set_si, and Vector_Set().

Referenced by main(), Polyhedron_Image(), and traite_m_face().

static void Rays_Mult ( Value **  A,
Matrix B,
Value **  C,
unsigned  NbRays 
) [static]
static void Rays_Mult_Transpose ( Value **  A,
Matrix B,
Value **  C,
unsigned  NbRays 
) [static]
static void RaySort ( Matrix Ray,
SatMatrix Sat,
int  NbBid,
int  NbRay,
int *  equal_bound,
int *  sup_bound,
unsigned  RowSize1,
unsigned  RowSize2,
unsigned  bx,
unsigned  jx 
) [static]

Definition at line 305 of file polyhedron.c.

References bexchange, SatMatrix::p, matrix::p, value_neg_p, value_zero_p, and Vector_Exchange().

Referenced by Chernikova().

static Polyhedron* Remove_Redundants ( Matrix Mat,
Matrix Ray,
SatMatrix Sat,
unsigned *  Filter 
) [static]
static void SatMatrix_Extend ( SatMatrix Sat,
Matrix Mat,
unsigned  rows 
) [static]

Definition at line 354 of file polyhedron.c.

References errormsg1(), SatMatrix::NbRows, matrix::NbRows, SatMatrix::p, and SatMatrix::p_init.

Referenced by Chernikova().

static void SatVector_OR ( int *  p1,
int *  p2,
int *  p3,
unsigned  length 
) [static]

Definition at line 180 of file polyhedron.c.

Referenced by Chernikova().

static int SimplifyConstraints ( Polyhedron Pol1,
Polyhedron Pol2,
unsigned *  Filter,
unsigned  NbMaxRays 
) [static]
static void SimplifyEqualities ( Polyhedron Pol1,
Polyhedron Pol2,
unsigned *  Filter 
) [static]
static SatMatrix* SMAlloc ( int  rows,
int  cols 
) [static]
static void SMFree ( SatMatrix **  matrix  )  [static]
static void SMPrint ( SatMatrix matrix  )  [static]
static void SortConstraints ( Matrix Constraints,
unsigned  NbEq 
) [static]
Polyhedron* Stras_DomainSimplify ( Polyhedron Pol1,
Polyhedron Pol2,
unsigned  NbMaxRays 
)
Polyhedron* SubConstraint ( Value *  Con,
Polyhedron Pol,
unsigned  NbMaxRays,
int  Pass 
)
static SatMatrix* TransformSat ( Matrix Mat,
Matrix Ray,
SatMatrix Sat 
) [static]

Definition at line 266 of file polyhedron.c.

References MSB, matrix::NbRows, NEXT, SatMatrix::p, SatMatrix::p_init, SMAlloc(), and SMVector_Init.

Referenced by AddRays(), and Rays2Polyhedron().

Polyhedron* Universe_Polyhedron ( unsigned  Dimension  ) 

Variable Documentation


Generated on Wed Nov 25 17:45:27 2009 for polylib by  doxygen 1.6.1