update isl for support for recent versions of clang
[barvinok.git] / barvinok / util.h
blobdfec2ea8d130eca25a41cd8699c66b27497c3463
1 #ifndef UTIL_H
2 #define UTIL_H
4 #include <barvinok/polylib.h>
5 #include <barvinok/evalue.h>
7 #if defined(__cplusplus)
8 extern "C" {
9 #endif
11 #ifdef POL_NO_DUAL
12 #define emptyQ2(P) \
13 ((F_ISSET(P, POL_INEQUALITIES) && P->NbEq > P->Dimension) || \
14 (F_ISSET(P, POL_POINTS) && P->NbRays == 0))
15 #define POL_HAS(P,f) (F_ISSET(P, f))
16 #define POL_SET(P,f) (F_SET(P, f))
18 #define POL_UNSET(flags,f) do { \
19 if (POL_ISSET(flags, POL_HIGH_BIT)) \
20 flags = (flags & ~(f)) | POL_HIGH_BIT; \
21 } while(0)
22 #else
23 #define POL_NO_DUAL 0
24 #define emptyQ2(P) emptyQ(P)
25 #define POL_ENSURE_FACETS(P) /* nothing */
26 #define POL_ENSURE_VERTICES(P) /* nothing */
27 #define POL_INEQUALITIES 0
28 #define POL_POINTS 0
29 #define POL_FACETS 0
30 #define POL_VERTICES 0
31 #define POL_VALID 0
32 #define POL_HAS(P,f) (1)
33 #define POL_SET(P,f) /* nothing */
35 #define POL_UNSET(P,f) /* nothing */
36 #endif
38 #ifndef POL_INTEGER
39 #define POL_INTEGER 0
40 #endif
42 struct barvinok_options;
44 int random_int(int max);
45 Polyhedron *Polyhedron_Read(unsigned MaxRays);
46 Polyhedron* Polyhedron_Polar(Polyhedron *P, unsigned NbMaxRays);
47 void Polyhedron_Polarize(Polyhedron *P);
48 Polyhedron* supporting_cone(Polyhedron *P, int v);
49 unsigned *supporting_constraints(Matrix *Constraints, Param_Vertices *v, int *n);
50 Polyhedron* supporting_cone_p(Polyhedron *P, Param_Vertices *v);
51 Polyhedron* triangulate_cone(Polyhedron *P, unsigned NbMaxCons);
52 Polyhedron* triangulate_cone_with_options(Polyhedron *P,
53 struct barvinok_options *options);
54 void check_triangulization(Polyhedron *P, Polyhedron *T);
55 Polyhedron *remove_equalities(Polyhedron *P, unsigned MaxRays);
56 Polyhedron *remove_equalities_p(Polyhedron *P, unsigned nvar, Matrix **factor,
57 unsigned MaxRays);
58 void manual_count(Polyhedron *P, Value* result);
59 Polyhedron* Polyhedron_Factor(Polyhedron *P, unsigned nparam, Matrix **T,
60 unsigned NbMaxRays);
61 Polyhedron *Factor_Context(Polyhedron *F, unsigned nparam, unsigned MaxRays);
62 void Line_Length(Polyhedron *P, Value *len);
63 struct barvinok_options;
64 evalue* ParamLine_Length(Polyhedron *P, Polyhedron *C,
65 struct barvinok_options *options);
66 void Extended_Euclid(Value a, Value b, Value *x, Value *y, Value *g);
67 int unimodular_complete(Matrix *M, int row);
68 void neg_left_hermite(Matrix *A, Matrix **H_p, Matrix **Q_p, Matrix **U_p);
69 Bool isIdentity(Matrix *M);
70 void Param_Polyhedron_Print(FILE* DST, Param_Polyhedron *PP,
71 const char **param_names);
72 void Enumeration_Print(FILE *Dst, Enumeration *en, const char **params);
73 void Enumeration_Free(Enumeration *en);
74 void Enumeration_mod2table(Enumeration *en, unsigned nparam);
75 size_t Enumeration_size(Enumeration *en);
76 int DomainIncludes(Polyhedron *Pol1, Polyhedron *Pol2);
77 int line_minmax(Polyhedron *I, Value *min, Value *max);
78 void count_points_e (int pos, Polyhedron *P, int exist, int nparam,
79 Value *context, Value *res);
80 int DomainContains(Polyhedron *P, Value *list_args, int len,
81 unsigned MaxRays, int set);
82 Polyhedron* Polyhedron_Project(Polyhedron *P, int dim);
83 Polyhedron *DomainConcat(Polyhedron *head, Polyhedron *tail);
85 /* only defined if PolyLib has RankingConstraints */
86 evalue *barvinok_lexsmaller_ev(Polyhedron *P, Polyhedron *D, unsigned dim,
87 Polyhedron *C, unsigned MaxRays);
88 Enumeration *barvinok_lexsmaller(Polyhedron *P, Polyhedron *D, unsigned dim,
89 Polyhedron *C, unsigned MaxRays);
91 Matrix *align_matrix(Matrix *M, int nrows);
93 char **util_generate_names(int n, const char *prefix);
94 void util_free_names(int n, char **names);
95 void Polyhedron_pprint(FILE *out, Polyhedron *P, int dim, int nparam,
96 char **iter_names, char **param_names);
98 Polyhedron *Cone_over_Polyhedron(Polyhedron *P);
100 Matrix *compress_variables(Matrix *Equalities, unsigned nparam);
101 Matrix *left_inverse(Matrix *M, Matrix **Eq);
103 int Polyhedron_has_revlex_positive_rays(Polyhedron *P, unsigned nparam);
104 int Polyhedron_is_unbounded(Polyhedron *P, unsigned nparam, unsigned MaxRays);
106 void Polyhedron_ExchangeColumns(Polyhedron *P, int Column1, int Column2);
108 void Matrix_Transposition(Matrix *M);
110 int Last_Non_Zero(Value *p, unsigned len);
112 /* n is the total number of times fn will be called */
113 typedef void (*for_each_lower_upper_bound_init)(unsigned n, void *data);
114 /* M contains the constraints on the remaining variables
115 * lower is the constraint in the original domain representing the lower bound
116 * upper is the constraint in the original domain representing the upper bound
118 typedef void (*for_each_lower_upper_bound_fn)
119 (Matrix *M, Value *lower, Value *upper, void *data);
120 void for_each_lower_upper_bound(Polyhedron *P,
121 for_each_lower_upper_bound_init init,
122 for_each_lower_upper_bound_fn fn,
123 void *cb_data);
125 void Polyhedron_Matrix_View(Polyhedron *P, Matrix *M, unsigned rows);
127 const char *barvinok_version();
129 #if defined(__cplusplus)
131 #endif
133 #endif