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

ehrhart.c File Reference

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

Go to the source code of this file.

Defines

#define EPRINT_ALL_VALIDITY_CONSTRAINTS
 define this to print all constraints on the validity domains if not defined, only new constraints (not in validity domain given by the user) are printed

#define REDUCE_DEGREE
 Reduce the degree of resulting polynomials.

#define ALL_OVERFLOW_WARNINGS
 define this to print one warning message per domain overflow these overflows should no longer happen since version 4.20

#define MAXITER   100
 This procedure finds an integer point contained in polyhedron D / first checks for positive values, then for negative values returns TRUE on success.


Functions

enodenew_enode (enode_type type, int size, int pos)
 EHRHART POLYNOMIAL SYMBOLIC ALGEBRA SYSTEM.

void free_evalue_refs (evalue *e)
 releases all memory referenced by e.

enodeecopy (enode *e)
void print_evalue (FILE *DST, evalue *e, char **pname)
void print_enode (FILE *DST, enode *p, char **pname)
 prints the enode to DST

int eequal (evalue *e1, evalue *e2)
void reduce_evalue (evalue *e)
void emul (evalue *e1, evalue *e2, evalue *res)
 multiplies two evalues and puts the result in res

void eadd (evalue *e1, evalue *res)
 adds one evalue to evalue 'res.

void edot (enode *v1, enode *v2, evalue *res)
 computes the inner product of two vectors.

void aep_evalue (evalue *e, int *ref)
 local recursive function used in the following ref contains the new position for each old index position

void addeliminatedparams_evalue (evalue *e, Matrix *CT)
 Comments.

int cherche_min (Value *min, Polyhedron *D, int pos)
PolyhedronPolyhedron_Preprocess (Polyhedron *D, Value *size, unsigned MAXRAYS)
 This procedure finds the smallest parallelepiped of size 'size[i]' for every dimension i, contained in polyhedron D If this is not possible, an empty polyhedron is returned.

PolyhedronPolyhedron_Preprocess2 (Polyhedron *D, Value *size, Value *lcm, unsigned MAXRAYS)
 This procedure finds an hypercube of size 'size', containing polyhedron D increases size and lcm if necessary (and not "too big") If this is not possible, an empty polyhedron is returned.

Polyhedronold_Polyhedron_Preprocess (Polyhedron *D, Value size, unsigned MAXRAYS)
 This procedure adds additional constraints to D so that as each parameter is scanned, it will have a minimum of 'size' points If this is not possible, an empty polyhedron is returned.

void count_points (int pos, Polyhedron *P, Value *context, Value *res)
 PROCEDURES TO COMPUTE ENUMERATION.

enodeP_Enum (Polyhedron *L, Polyhedron *LQ, Value *context, int pos, int nb_param, int dim, Value *lcm, char **param_name)
void Scan_Vertices (Param_Polyhedron *PP, Param_Domain *Q, Matrix *CT, Value *lcm, int nbp, char **param_name)
EnumerationEnumerate_NoParameters (Polyhedron *P, Polyhedron *C, Matrix *CT, Polyhedron *CEq, unsigned MAXRAYS, char **param_name)
 Procedure to count points in a non-parameterized polytope.

EnumerationPolyhedron_Enumerate (Polyhedron *Pi, Polyhedron *C, unsigned MAXRAYS, char **param_name)
 Procedure to count points in a parameterized polytope.

void Enumeration_Free (Enumeration *en)

Variables

int overflow_warning_flag = 1


Define Documentation

#define ALL_OVERFLOW_WARNINGS
 

define this to print one warning message per domain overflow these overflows should no longer happen since version 4.20

Definition at line 76 of file ehrhart.c.

#define EPRINT_ALL_VALIDITY_CONSTRAINTS
 

define this to print all constraints on the validity domains if not defined, only new constraints (not in validity domain given by the user) are printed

Definition at line 52 of file ehrhart.c.

#define MAXITER   100
 

This procedure finds an integer point contained in polyhedron D / first checks for positive values, then for negative values returns TRUE on success.

Result is in min. returns FALSE if no integer point is found

This is the maximum number of iterations for a given parameter to find a integer point inside the context. Kind of weird. cherche_min should

Parameters:
min 
D 
pos 

Definition at line 619 of file ehrhart.c.

Referenced by cherche_min().

#define REDUCE_DEGREE
 

Reduce the degree of resulting polynomials.

Definition at line 70 of file ehrhart.c.


Function Documentation

void addeliminatedparams_evalue evalue e,
Matrix CT
[static]
 

Comments.

Definition at line 573 of file ehrhart.c.

References aep_evalue(), _evalue::d, enode, evalue, Matrix, matrix::NbColumns, matrix::NbRows, matrix::p, value_notzero_p, and _evalue::x.

Referenced by Polyhedron_Enumerate().

void aep_evalue evalue e,
int *  ref
[static]
 

local recursive function used in the following ref contains the new position for each old index position

Parameters:
e pointer to an evalue
ref transformation Matrix

Definition at line 553 of file ehrhart.c.

References _enode::arr, _evalue::d, enode, evalue, _enode::pos, _enode::size, value_notzero_p, and _evalue::x.

Referenced by addeliminatedparams_evalue().

int cherche_min Value min,
Polyhedron D,
int  pos
 

Definition at line 620 of file ehrhart.c.

References polyhedron::Dimension, LB_INFINITY, lower_upper_bounds(), MAXITER, min, polyhedron::next, P_VALUE_FMT, Polyhedron, UB_INFINITY, Value, value_assign, value_clear, value_decrement, value_ge, value_increment, value_init, value_le, value_neg_p, value_pos_p, value_print, and value_set_si.

Referenced by Polyhedron_Preprocess().

void count_points int  pos,
Polyhedron P,
Value context,
Value res
 

PROCEDURES TO COMPUTE ENUMERATION.

recursive procedure, recurse for each imbriquation

Parameters:
pos index position of current loop index (1..hdim-1)
P loop domain
context context values for fixed indices
Returns:
the number of integer points in this polyhedron

Definition at line 1128 of file ehrhart.c.

References count_points(), emptyQ, lower_upper_bounds(), polyhedron::next, P_VALUE_FMT, Polyhedron, Value, value_add_int, value_addto, value_assign, value_clear, value_increment, value_init, value_le, value_lt, value_notmone_p, value_print, value_set_si, and value_substract.

void eadd evalue e1,
evalue res
 

adds one evalue to evalue 'res.

result = res + e1

Parameters:
e1 an evalue
res 

Definition at line 393 of file ehrhart.c.

References _enode::arr, _evalue::d, eadd(), ecopy(), enode, evalue, free_evalue_refs(), Gcd(), periodic, polynomial, Value, value_addto, value_clear, value_division, value_init, value_multiply, value_notone_p, value_notzero_p, value_zero_p, and _evalue::x.

enode* ecopy enode e  ) 
 

Parameters:
e pointer to an evalue
Returns:
description

Definition at line 149 of file ehrhart.c.

References _enode::arr, _evalue::d, ecopy(), enode, new_enode(), _enode::pos, _enode::size, _enode::type, value_assign, value_init, value_zero_p, and _evalue::x.

void edot enode v1,
enode v2,
evalue res
 

computes the inner product of two vectors.

Result = result (evalue) = v1.v2 (dot product)

Parameters:
v1 an enode (vector)
v2 an enode (vector of constants)
res result (evalue)

Definition at line 509 of file ehrhart.c.

References _enode::arr, _evalue::d, eadd(), emul(), enode, evalue, evector, free_evalue_refs(), _enode::size, _enode::type, value_init, value_set_si, and _evalue::x.

int eequal evalue e1,
evalue e2
[static]
 

Parameters:
e1 pointers to evalues
e2 pointers to evalues
Returns:
1 (true) if they are equal, 0 (false) if not

Definition at line 242 of file ehrhart.c.

References _enode::arr, _evalue::d, enode, evalue, _enode::pos, _enode::size, _enode::type, value_ne, value_notzero_p, and _evalue::x.

Referenced by reduce_evalue().

void emul evalue e1,
evalue e2,
evalue res
[static]
 

multiplies two evalues and puts the result in res

Parameters:
e1 pointer to an evalue
e2 pointer to a constant evalue
res pointer to result evalue = e1 * e2

Definition at line 351 of file ehrhart.c.

References _enode::arr, _evalue::d, enode, evalue, Gcd(), new_enode(), _enode::pos, _enode::size, _enode::type, Value, value_clear, value_division, value_init, value_multiply, value_notone_p, value_notzero_p, value_set_si, value_zero_p, and _evalue::x.

Referenced by edot().

Enumeration* Enumerate_NoParameters Polyhedron P,
Polyhedron C,
Matrix CT,
Polyhedron CEq,
unsigned  MAXRAYS,
char **  param_name
 

Procedure to count points in a non-parameterized polytope.

Parameters:
P Polyhedron to count
C Parameter Context domain
CT Matrix to transform context to original CEq additionnal equalities in context
MAXRAYS workspace size
param_name parameter names

Definition at line 1708 of file ehrhart.c.

References assert, CATCH, _evalue::d, polyhedron::Dimension, Domain_Free(), DomainIntersection(), emptyQ, Enumeration, _enumeration::EP, Matrix, MAXRAYS, polyhedron::NbRays, new_enode(), _enumeration::next, overflow_error, overflow_warning_flag, P_Enum(), P_VALUE_FMT, Polyhedron, Polyhedron_Free(), Polyhedron_Preimage(), Polyhedron_Print(), Polyhedron_Scan(), polynomial, Print_Domain(), print_evalue(), polyhedron::Ray, TRY, UNCATCH, Universe_Polyhedron(), _enumeration::ValidityDomain, Value, value_clear, value_init, value_notone_p, value_print, value_set_si, value_zero_p, Vector_Set(), and _evalue::x.

Referenced by Polyhedron_Enumerate().

void Enumeration_Free Enumeration en  ) 
 

Definition at line 2145 of file ehrhart.c.

References Enumeration, _enumeration::EP, free_evalue_refs(), _enumeration::next, Polyhedron_Free(), and _enumeration::ValidityDomain.

void free_evalue_refs evalue e  ) 
 

releases all memory referenced by e.

(recursive)

Parameters:
e pointer to an evalue

Definition at line 121 of file ehrhart.c.

References _enode::arr, _evalue::d, enode, evalue, free_evalue_refs(), _enode::size, value_clear, value_notzero_p, and _evalue::x.

enode* new_enode enode_type  type,
int  size,
int  pos
 

EHRHART POLYNOMIAL SYMBOLIC ALGEBRA SYSTEM.

The newly allocated enode can be freed with a simple free(x)

Parameters:
type : enode type
size : degree+1 for polynomial, period for periodic
pos : 1..nb_param, position of parameter
Returns:
a newly allocated enode

Definition at line 96 of file ehrhart.c.

References _enode::arr, _evalue::d, enode, evalue, _enode::pos, _enode::size, _enode::type, value_init, value_set_si, and _evalue::x.

Polyhedron* old_Polyhedron_Preprocess Polyhedron D,
Value  size,
unsigned  MAXRAYS
 

This procedure adds additional constraints to D so that as each parameter is scanned, it will have a minimum of 'size' points If this is not possible, an empty polyhedron is returned.

Parameters:
D 
size 
MAXRAYS 

Definition at line 1047 of file ehrhart.c.

References AddConstraints(), polyhedron::Constraint, polyhedron::Dimension, Gcd(), Matrix, Matrix_Alloc(), Matrix_Free(), MAXRAYS, polyhedron::NbConstraints, matrix::p, matrix::p_Init, Polyhedron, Value, value_absolute, value_addto, value_assign, value_clear, value_division, value_init, value_multiply, value_negz_p, value_notzero_p, value_oppose, value_posz_p, value_set_si, Vector_Combine(), and Vector_Normalize().

enode* P_Enum Polyhedron L,
Polyhedron LQ,
Value context,
int  pos,
int  nb_param,
int  dim,
Value lcm,
char **  param_name
[static]
 

Definition at line 1226 of file ehrhart.c.

References _enode::arr, count_points(), _evalue::d, edot(), enode, evector, Gauss(), Gcd(), LB_INFINITY, lower_upper_bounds(), Matrix, Matrix_Alloc(), Matrix_Free(), Matrix_Print(), new_enode(), polyhedron::next, overflow_warning_flag, matrix::p, P_VALUE_FMT, periodic, Polyhedron, polynomial, print_enode(), print_evalue(), UB_INFINITY, Value, value_add_int, value_addto, value_assign, value_clear, value_division, VALUE_FMT, value_gt, value_increment, value_init, value_lt, value_modulus, value_multiply, value_neg_p, value_notzero_p, value_pos_p, value_print, value_set_si, value_sub_int, value_substract, VALUE_TO_INT, value_zero_p, and _evalue::x.

Referenced by Enumerate_NoParameters(), and Polyhedron_Enumerate().

Enumeration* Polyhedron_Enumerate Polyhedron Pi,
Polyhedron C,
unsigned  MAXRAYS,
char **  param_name
 

Procedure to count points in a parameterized polytope.

Parameters:
P Polyhedron to enumerate
C Context Domain
MAXRAYS size of workspace
param_name parameter names (array of strings), may be NULL
Returns:
a list of validity domains + evalues EP

Definition at line 1831 of file ehrhart.c.

References addeliminatedparams_evalue(), assert, CATCH, _Param_Polyhedron::D, _evalue::d, polyhedron::Dimension, _Param_Domain::Domain, Domain_Free(), DomainIntersection(), DomainSimplify(), emptyQ, Enumerate_NoParameters(), Enumeration, _enumeration::EP, Matrix, MAXRAYS, matrix::NbColumns, polyhedron::NbEq, matrix::NbRows, _Param_Domain::next, _enumeration::next, overflow_error, overflow_warning_flag, P_Enum(), P_VALUE_FMT, Param_Domain, Param_Polyhedron, Polyhedron, Polyhedron2Param_SimplifiedDomain(), Polyhedron_Free(), Polyhedron_Preimage(), Polyhedron_Preprocess(), Polyhedron_Preprocess2(), Polyhedron_Print(), Polyhedron_Scan(), PolyhedronIncludes(), Print_Domain(), print_evalue(), reduce_evalue(), Scan_Vertices(), TRY, UNCATCH, Universe_Polyhedron(), _enumeration::ValidityDomain, Value, value_clear, value_init, value_multiply, value_notzero_p, value_print, value_set_si, value_zero_p, Vector_Set(), and _evalue::x.

Polyhedron* Polyhedron_Preprocess Polyhedron D,
Value size,
unsigned  MAXRAYS
 

This procedure finds the smallest parallelepiped of size 'size[i]' for every dimension i, contained in polyhedron D If this is not possible, an empty polyhedron is returned.

written by vin100, 2000, for version 4.19 modified 2002, version 5.10

It first finds the coordinates of the lexicographically smallest edge of the hypercube, obtained by transforming the constraints of D (by adding 'size' as many times as there are negative coeficients in each constraint), and finding the lexicographical min of this polyhedron. Then it builds the hypercube and returns it.

Parameters:
D 
size 
MAXRAYS 

Definition at line 728 of file ehrhart.c.

References cherche_min(), polyhedron::Constraint, Constraints2Polyhedron(), polyhedron::Dimension, Domain_Free(), emptyQ, Matrix, Matrix_Alloc(), Matrix_Free(), Matrix_Print(), MAXRAYS, min, polyhedron::NbConstraints, matrix::NbRows, matrix::p, P_VALUE_FMT, Polyhedron, Polyhedron_Free(), Polyhedron_Print(), Polyhedron_Scan(), Universe_Polyhedron(), Value, value_addto, value_clear, value_init, value_multiply, value_ne, value_neg_p, value_oppose, value_print, value_set_si, value_sub_int, value_zero_p, and Vector_Copy().

Referenced by Polyhedron_Enumerate().

Polyhedron* Polyhedron_Preprocess2 Polyhedron D,
Value size,
Value lcm,
unsigned  MAXRAYS
 

This procedure finds an hypercube of size 'size', containing polyhedron D increases size and lcm if necessary (and not "too big") If this is not possible, an empty polyhedron is returned.

written by vin100, 2001, for version 4.19

Parameters:
D 
size 
lcm 
MAXRAYS 

Definition at line 885 of file ehrhart.c.

References Constraints2Polyhedron(), polyhedron::Dimension, Matrix, Matrix_Alloc(), Matrix_Free(), Matrix_Print(), MAXRAYS, polyhedron::NbRays, matrix::p, P_VALUE_FMT, Polyhedron, polyhedron::Ray, s, Value, value_add_int, value_addto, value_assign, value_clear, value_division, VALUE_FMT, value_gt, value_init, value_le, value_lt, value_multiply, value_oppose, value_print, value_set_si, value_sub_int, value_substract, and value_zero_p.

Referenced by Polyhedron_Enumerate().

void print_enode FILE *  DST,
enode p,
char **  pname
 

prints the enode to DST

Parameters:
DST destination file
p pointer to enode to be printed
pname array of strings, name of the parameters

Definition at line 197 of file ehrhart.c.

References _enode::arr, enode, evector, periodic, polynomial, _enode::pos, print_evalue(), _enode::size, and _enode::type.

void print_evalue FILE *  DST,
evalue e,
char **  pname
 

Parameters:
DST destination file
e pointer to evalue to be printed

Definition at line 173 of file ehrhart.c.

References _evalue::d, evalue, print_enode(), VALUE_FMT, value_notone_p, value_notzero_p, value_print, and _evalue::x.

void reduce_evalue evalue e  ) 
 

Parameters:
e pointer to an evalue

Definition at line 276 of file ehrhart.c.

References _enode::arr, _evalue::d, eequal(), enode, evalue, free_evalue_refs(), periodic, polynomial, reduce_evalue(), _enode::size, _enode::type, value_clear, value_notzero_p, value_one_p, value_zero_p, and _evalue::x.

void Scan_Vertices Param_Polyhedron PP,
Param_Domain Q,
Matrix CT,
Value lcm,
int  nbp,
char **  param_name
[static]
 

Definition at line 1631 of file ehrhart.c.

References _Param_Domain::F, Gcd(), Matrix, Matrix_Free(), MSB, _Param_Polyhedron::nbV, NEXT, Param_Domain, Param_Polyhedron, Param_Vertices, Print_Vertex(), _Param_Polyhedron::V, Value, value_assign, value_clear, value_division, value_init, value_multiply, value_notone_p, value_notzero_p, value_set_si, and VertexCT().

Referenced by Polyhedron_Enumerate().


Variable Documentation

int overflow_warning_flag = 1
 

Definition at line 80 of file ehrhart.c.

Referenced by Enumerate_NoParameters(), P_Enum(), and Polyhedron_Enumerate().


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