Merge branch 'maint'
[isl.git] / isl_map_private.h
blob415965fd0ee9650bdd7bbfd2ad674322f66f23f2
1 /*
2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8 */
10 #ifndef ISL_MAP_PRIVATE_H
11 #define ISL_MAP_PRIVATE_H
13 #define isl_basic_set isl_basic_map
14 #define isl_set isl_map
15 #include <isl/set.h>
16 #include <isl/map.h>
17 #include <isl_reordering.h>
18 #include <isl/vec.h>
20 /* A "basic map" is a relation between two sets of variables,
21 * called the "in" and "out" variables.
22 * A "basic set" is a basic map with a zero-dimensional
23 * domain.
25 * It is implemented as a set with two extra fields:
26 * n_in is the number of in variables
27 * n_out is the number of out variables
28 * n_in + n_out should be equal to set.dim
30 struct isl_basic_map {
31 int ref;
32 #define ISL_BASIC_MAP_FINAL (1 << 0)
33 #define ISL_BASIC_MAP_EMPTY (1 << 1)
34 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
35 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
36 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
37 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
38 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
39 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
40 #define ISL_BASIC_SET_FINAL (1 << 0)
41 #define ISL_BASIC_SET_EMPTY (1 << 1)
42 #define ISL_BASIC_SET_NO_IMPLICIT (1 << 2)
43 #define ISL_BASIC_SET_NO_REDUNDANT (1 << 3)
44 #define ISL_BASIC_SET_RATIONAL (1 << 4)
45 #define ISL_BASIC_SET_NORMALIZED (1 << 5)
46 #define ISL_BASIC_SET_NORMALIZED_DIVS (1 << 6)
47 #define ISL_BASIC_SET_ALL_EQUALITIES (1 << 7)
48 unsigned flags;
50 struct isl_ctx *ctx;
52 struct isl_dim *dim;
53 unsigned extra;
55 unsigned n_eq;
56 unsigned n_ineq;
58 size_t c_size;
59 isl_int **eq;
60 isl_int **ineq;
62 unsigned n_div;
64 isl_int **div;
66 struct isl_vec *sample;
68 struct isl_blk block;
69 struct isl_blk block2;
72 /* A "map" is a (possibly disjoint) union of basic maps.
73 * A "set" is a (possibly disjoint) union of basic sets.
75 * Currently, the isl_set structure is identical to the isl_map structure
76 * and the library depends on this correspondence internally.
77 * However, users should not depend on this correspondence.
79 struct isl_map {
80 int ref;
81 #define ISL_MAP_DISJOINT (1 << 0)
82 #define ISL_MAP_NORMALIZED (1 << 1)
83 #define ISL_SET_DISJOINT (1 << 0)
84 #define ISL_SET_NORMALIZED (1 << 1)
85 unsigned flags;
87 struct isl_ctx *ctx;
89 struct isl_dim *dim;
91 int n;
93 size_t size;
94 struct isl_basic_map *p[1];
97 __isl_give isl_map *isl_map_realign(__isl_take isl_map *map,
98 __isl_take isl_reordering *r);
99 __isl_give isl_set *isl_set_realign(__isl_take isl_set *set,
100 __isl_take isl_reordering *r);
102 __isl_give isl_map *isl_map_reset(__isl_take isl_map *map,
103 enum isl_dim_type type);
105 __isl_give isl_basic_set *isl_basic_set_reset_dim(
106 __isl_take isl_basic_set *bset, __isl_take isl_dim *dim);
107 __isl_give isl_basic_map *isl_basic_map_reset_dim(
108 __isl_take isl_basic_map *bmap, __isl_take isl_dim *dim);
109 __isl_give isl_map *isl_map_reset_dim(__isl_take isl_map *map,
110 __isl_take isl_dim *dim);
112 unsigned isl_basic_map_offset(struct isl_basic_map *bmap,
113 enum isl_dim_type type);
114 unsigned isl_basic_set_offset(struct isl_basic_set *bset,
115 enum isl_dim_type type);
117 int isl_basic_map_may_be_set(__isl_keep isl_basic_map *bmap);
118 int isl_map_may_be_set(__isl_keep isl_map *map);
119 int isl_map_compatible_domain(struct isl_map *map, struct isl_set *set);
120 int isl_basic_map_compatible_domain(struct isl_basic_map *bmap,
121 struct isl_basic_set *bset);
122 int isl_basic_map_compatible_range(struct isl_basic_map *bmap,
123 struct isl_basic_set *bset);
125 struct isl_basic_map *isl_basic_map_extend_dim(struct isl_basic_map *base,
126 struct isl_dim *dim, unsigned extra,
127 unsigned n_eq, unsigned n_ineq);
128 struct isl_basic_set *isl_basic_set_extend_dim(struct isl_basic_set *base,
129 struct isl_dim *dim, unsigned extra,
130 unsigned n_eq, unsigned n_ineq);
131 struct isl_basic_set *isl_basic_set_add_constraints(struct isl_basic_set *bset1,
132 struct isl_basic_set *bset2, unsigned pos);
134 struct isl_map *isl_map_grow(struct isl_map *map, int n);
135 struct isl_set *isl_set_grow(struct isl_set *set, int n);
137 int isl_basic_set_contains(struct isl_basic_set *bset, struct isl_vec *vec);
138 int isl_basic_map_contains(struct isl_basic_map *bmap, struct isl_vec *vec);
140 struct isl_basic_set *isl_basic_set_alloc_dim(struct isl_dim *dim,
141 unsigned extra, unsigned n_eq, unsigned n_ineq);
142 struct isl_set *isl_set_alloc_dim(struct isl_dim *dim, int n, unsigned flags);
143 struct isl_basic_map *isl_basic_map_alloc_dim(struct isl_dim *dim,
144 unsigned extra, unsigned n_eq, unsigned n_ineq);
145 struct isl_map *isl_map_alloc_dim(struct isl_dim *dim, int n, unsigned flags);
147 unsigned isl_basic_map_total_dim(const struct isl_basic_map *bmap);
149 int isl_basic_map_alloc_equality(struct isl_basic_map *bmap);
150 int isl_basic_set_alloc_equality(struct isl_basic_set *bset);
151 int isl_basic_set_free_inequality(struct isl_basic_set *bset, unsigned n);
152 int isl_basic_map_free_equality(struct isl_basic_map *bmap, unsigned n);
153 int isl_basic_set_free_equality(struct isl_basic_set *bset, unsigned n);
154 int isl_basic_set_alloc_inequality(struct isl_basic_set *bset);
155 int isl_basic_map_alloc_inequality(struct isl_basic_map *bmap);
156 int isl_basic_map_free_inequality(struct isl_basic_map *bmap, unsigned n);
157 int isl_basic_map_alloc_div(struct isl_basic_map *bmap);
158 int isl_basic_set_alloc_div(struct isl_basic_set *bset);
159 int isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n);
160 int isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n);
161 void isl_basic_map_inequality_to_equality(
162 struct isl_basic_map *bmap, unsigned pos);
163 int isl_basic_map_drop_equality(struct isl_basic_map *bmap, unsigned pos);
164 int isl_basic_set_drop_equality(struct isl_basic_set *bset, unsigned pos);
165 int isl_basic_set_drop_inequality(struct isl_basic_set *bset, unsigned pos);
166 int isl_basic_map_drop_inequality(struct isl_basic_map *bmap, unsigned pos);
167 __isl_give isl_basic_set *isl_basic_set_add_eq(__isl_take isl_basic_set *bset,
168 isl_int *eq);
169 __isl_give isl_basic_map *isl_basic_map_add_eq(__isl_take isl_basic_map *bmap,
170 isl_int *eq);
171 __isl_give isl_basic_set *isl_basic_set_add_ineq(__isl_take isl_basic_set *bset,
172 isl_int *ineq);
173 __isl_give isl_basic_map *isl_basic_map_add_ineq(__isl_take isl_basic_map *bmap,
174 isl_int *ineq);
176 int isl_inequality_negate(struct isl_basic_map *bmap, unsigned pos);
178 struct isl_basic_set *isl_basic_set_cow(struct isl_basic_set *bset);
179 struct isl_basic_map *isl_basic_map_cow(struct isl_basic_map *bmap);
180 struct isl_set *isl_set_cow(struct isl_set *set);
181 struct isl_map *isl_map_cow(struct isl_map *map);
183 struct isl_basic_map *isl_basic_map_set_to_empty(struct isl_basic_map *bmap);
184 struct isl_basic_set *isl_basic_set_set_to_empty(struct isl_basic_set *bset);
185 struct isl_basic_set *isl_basic_set_order_divs(struct isl_basic_set *bset);
186 void isl_basic_map_swap_div(struct isl_basic_map *bmap, int a, int b);
187 struct isl_basic_map *isl_basic_map_order_divs(struct isl_basic_map *bmap);
188 __isl_give isl_map *isl_map_order_divs(__isl_take isl_map *map);
189 struct isl_basic_map *isl_basic_map_align_divs(
190 struct isl_basic_map *dst, struct isl_basic_map *src);
191 struct isl_basic_set *isl_basic_set_align_divs(
192 struct isl_basic_set *dst, struct isl_basic_set *src);
193 struct isl_basic_map *isl_basic_map_gauss(
194 struct isl_basic_map *bmap, int *progress);
195 struct isl_basic_set *isl_basic_set_gauss(
196 struct isl_basic_set *bset, int *progress);
197 __isl_give isl_basic_set *isl_basic_set_sort_constraints(
198 __isl_take isl_basic_set *bset);
199 int isl_basic_map_plain_cmp(const __isl_keep isl_basic_map *bmap1,
200 const __isl_keep isl_basic_map *bmap2);
201 int isl_basic_set_plain_is_equal(__isl_keep isl_basic_set *bset1,
202 __isl_keep isl_basic_set *bset2);
203 int isl_basic_map_plain_is_equal(__isl_keep isl_basic_map *bmap1,
204 __isl_keep isl_basic_map *bmap2);
205 struct isl_basic_map *isl_basic_map_normalize_constraints(
206 struct isl_basic_map *bmap);
207 struct isl_basic_set *isl_basic_set_normalize_constraints(
208 struct isl_basic_set *bset);
209 struct isl_basic_map *isl_basic_map_implicit_equalities(
210 struct isl_basic_map *bmap);
211 struct isl_basic_set *isl_basic_map_underlying_set(struct isl_basic_map *bmap);
212 __isl_give isl_basic_set *isl_basic_set_underlying_set(
213 __isl_take isl_basic_set *bset);
214 struct isl_set *isl_map_underlying_set(struct isl_map *map);
215 struct isl_basic_map *isl_basic_map_overlying_set(struct isl_basic_set *bset,
216 struct isl_basic_map *like);
217 __isl_give isl_basic_set *isl_basic_set_drop_constraints_involving(
218 __isl_take isl_basic_set *bset, unsigned first, unsigned n);
219 __isl_give isl_basic_set *isl_basic_set_drop(__isl_take isl_basic_set *bset,
220 enum isl_dim_type type, unsigned first, unsigned n);
221 struct isl_basic_map *isl_basic_map_drop(struct isl_basic_map *bmap,
222 enum isl_dim_type type, unsigned first, unsigned n);
223 struct isl_set *isl_set_drop(struct isl_set *set,
224 enum isl_dim_type type, unsigned first, unsigned n);
225 struct isl_basic_set *isl_basic_set_drop_dims(
226 struct isl_basic_set *bset, unsigned first, unsigned n);
227 struct isl_set *isl_set_drop_dims(
228 struct isl_set *set, unsigned first, unsigned n);
229 struct isl_map *isl_map_drop_inputs(
230 struct isl_map *map, unsigned first, unsigned n);
231 struct isl_map *isl_map_drop(struct isl_map *map,
232 enum isl_dim_type type, unsigned first, unsigned n);
234 struct isl_map *isl_map_remove_empty_parts(struct isl_map *map);
235 struct isl_set *isl_set_remove_empty_parts(struct isl_set *set);
237 struct isl_set *isl_set_normalize(struct isl_set *set);
239 struct isl_set *isl_set_drop_vars(
240 struct isl_set *set, unsigned first, unsigned n);
242 struct isl_basic_map *isl_basic_map_eliminate_vars(
243 struct isl_basic_map *bmap, unsigned pos, unsigned n);
244 struct isl_basic_set *isl_basic_set_eliminate_vars(
245 struct isl_basic_set *bset, unsigned pos, unsigned n);
247 __isl_give isl_map *isl_map_eliminate(__isl_take isl_map *map,
248 enum isl_dim_type type, unsigned first, unsigned n);
249 __isl_give isl_set *isl_set_eliminate(__isl_take isl_set *set,
250 enum isl_dim_type type, unsigned first, unsigned n);
252 int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
253 isl_int *c, isl_int *opt_n, isl_int *opt_d);
255 int isl_basic_map_add_div_constraints(struct isl_basic_map *bmap, unsigned div);
256 struct isl_basic_map *isl_basic_map_drop_redundant_divs(
257 struct isl_basic_map *bmap);
258 struct isl_basic_set *isl_basic_set_drop_redundant_divs(
259 struct isl_basic_set *bset);
261 struct isl_basic_set *isl_basic_set_recession_cone(struct isl_basic_set *bset);
262 struct isl_basic_set *isl_basic_set_lineality_space(struct isl_basic_set *bset);
264 struct isl_basic_set *isl_basic_set_set_rational(struct isl_basic_set *bset);
265 __isl_give isl_basic_map *isl_basic_map_set_rational(
266 __isl_take isl_basic_map *bmap);
268 struct isl_mat;
270 struct isl_basic_set *isl_basic_set_preimage(struct isl_basic_set *bset,
271 struct isl_mat *mat);
272 struct isl_set *isl_set_preimage(struct isl_set *set, struct isl_mat *mat);
274 __isl_give isl_basic_set *isl_basic_set_transform_dims(
275 __isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned first,
276 __isl_take isl_mat *trans);
278 isl_int *isl_set_wrap_facet(__isl_keep isl_set *set,
279 isl_int *facet, isl_int *ridge);
281 int isl_basic_map_contains_point(__isl_keep isl_basic_map *bmap,
282 __isl_keep isl_point *point);
283 int isl_set_contains_point(__isl_keep isl_set *set, __isl_keep isl_point *point);
285 int isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
286 unsigned first, unsigned n, int *signs);
287 int isl_set_foreach_orthant(__isl_keep isl_set *set,
288 int (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
289 void *user);
291 int isl_basic_map_add_div_constraints_var(__isl_keep isl_basic_map *bmap,
292 unsigned pos, isl_int *div);
293 int isl_basic_set_add_div_constraints_var(__isl_keep isl_basic_set *bset,
294 unsigned pos, isl_int *div);
295 int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
296 isl_int *constraint, unsigned div);
298 __isl_give isl_basic_set *isl_basic_set_from_local_space(
299 __isl_take isl_local_space *ls);
300 __isl_give isl_basic_map *isl_basic_map_from_local_space(
301 __isl_take isl_local_space *ls);
302 __isl_give isl_basic_set *isl_basic_set_expand_divs(
303 __isl_take isl_basic_set *bset, __isl_take isl_mat *div, int *exp);
305 #endif