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