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
15 #include <isl/point.h>
17 #if defined(__cplusplus)
21 /* A "basic set" is a basic map with a zero-dimensional
24 struct isl_basic_set {
26 #define ISL_BASIC_SET_FINAL (1 << 0)
27 #define ISL_BASIC_SET_EMPTY (1 << 1)
28 #define ISL_BASIC_SET_NO_IMPLICIT (1 << 2)
29 #define ISL_BASIC_SET_NO_REDUNDANT (1 << 3)
30 #define ISL_BASIC_SET_RATIONAL (1 << 4)
31 #define ISL_BASIC_SET_NORMALIZED (1 << 5)
32 #define ISL_BASIC_SET_NORMALIZED_DIVS (1 << 6)
33 #define ISL_BASIC_SET_ALL_EQUALITIES (1 << 7)
52 struct isl_vec *sample;
55 struct isl_blk block2;
58 /* A "set" is a (possibly disjoint) union of basic sets.
60 * See the documentation of isl_map.
64 #define ISL_SET_DISJOINT (1 << 0)
65 #define ISL_SET_NORMALIZED (1 << 1)
75 struct isl_basic_set *p[1];
78 unsigned isl_basic_set_n_dim(const struct isl_basic_set *bset);
79 unsigned isl_basic_set_n_param(const struct isl_basic_set *bset);
80 unsigned isl_basic_set_total_dim(const struct isl_basic_set *bset);
81 unsigned isl_basic_set_dim(const struct isl_basic_set *bset,
82 enum isl_dim_type type);
84 unsigned isl_set_n_dim(const struct isl_set *set);
85 unsigned isl_set_n_param(const struct isl_set *set);
86 unsigned isl_set_dim(const struct isl_set *set, enum isl_dim_type type);
88 isl_ctx *isl_basic_set_get_ctx(__isl_keep isl_basic_set *bset);
89 isl_ctx *isl_set_get_ctx(__isl_keep isl_set *set);
90 __isl_give isl_dim *isl_basic_set_get_dim(__isl_keep isl_basic_set *bset);
91 __isl_give isl_dim *isl_set_get_dim(__isl_keep isl_set *set);
92 __isl_give isl_set *isl_set_reset_dim(__isl_take isl_set *set,
93 __isl_take isl_dim *dim);
95 const char *isl_set_get_tuple_name(__isl_keep isl_set *set);
96 __isl_give isl_set *isl_set_set_tuple_name(__isl_take isl_set *set,
98 __isl_give isl_basic_set *isl_basic_set_set_dim_name(
99 __isl_take isl_basic_set *bset,
100 enum isl_dim_type type, unsigned pos, const char *s);
101 const char *isl_set_get_dim_name(__isl_keep isl_set *set,
102 enum isl_dim_type type, unsigned pos);
103 __isl_give isl_set *isl_set_set_dim_name(__isl_take isl_set *set,
104 enum isl_dim_type type, unsigned pos, const char *s);
106 struct isl_basic_set *isl_basic_set_alloc(struct isl_ctx *ctx,
107 unsigned nparam, unsigned dim, unsigned extra,
108 unsigned n_eq, unsigned n_ineq);
109 struct isl_basic_set *isl_basic_set_extend(struct isl_basic_set *base,
110 unsigned nparam, unsigned dim, unsigned extra,
111 unsigned n_eq, unsigned n_ineq);
112 struct isl_basic_set *isl_basic_set_extend_constraints(
113 struct isl_basic_set *base, unsigned n_eq, unsigned n_ineq);
114 struct isl_basic_set *isl_basic_set_finalize(struct isl_basic_set *bset);
115 void isl_basic_set_free(__isl_take isl_basic_set *bset);
116 __isl_give isl_basic_set *isl_basic_set_copy(__isl_keep isl_basic_set *bset);
117 struct isl_basic_set *isl_basic_set_dup(struct isl_basic_set *bset);
118 __isl_give isl_basic_set *isl_basic_set_empty(__isl_take isl_dim *dim);
119 struct isl_basic_set *isl_basic_set_empty_like(struct isl_basic_set *bset);
120 __isl_give isl_basic_set *isl_basic_set_universe(__isl_take isl_dim *dim);
121 struct isl_basic_set *isl_basic_set_universe_like(struct isl_basic_set *bset);
122 __isl_give isl_basic_set *isl_basic_set_universe_like_set(
123 __isl_keep isl_set *model);
124 struct isl_basic_set *isl_basic_set_interval(struct isl_ctx *ctx,
125 isl_int min, isl_int max);
126 struct isl_basic_set *isl_basic_set_positive_orthant(struct isl_dim *dims);
127 void isl_basic_set_dump(__isl_keep isl_basic_set *bset,
128 FILE *out, int indent);
129 struct isl_basic_set *isl_basic_set_swap_vars(
130 struct isl_basic_set *bset, unsigned n);
131 __isl_give isl_basic_set *isl_basic_set_intersect(
132 __isl_take isl_basic_set *bset1,
133 __isl_take isl_basic_set *bset2);
134 __isl_give isl_basic_set *isl_basic_set_apply(
135 __isl_take isl_basic_set *bset,
136 __isl_take isl_basic_map *bmap);
137 __isl_give isl_basic_set *isl_basic_set_affine_hull(
138 __isl_take isl_basic_set *bset);
139 __isl_give isl_basic_set *isl_basic_set_remove_dims(
140 __isl_take isl_basic_set *bset,
141 enum isl_dim_type type, unsigned first, unsigned n);
142 struct isl_basic_set *isl_basic_set_simplify(struct isl_basic_set *bset);
143 __isl_give isl_basic_set *isl_basic_set_detect_equalities(
144 __isl_take isl_basic_set *bset);
145 struct isl_basic_set *isl_basic_set_product(struct isl_basic_set_list *list);
147 __isl_give isl_basic_set *isl_basic_set_read_from_file(isl_ctx *ctx,
148 FILE *input, int nparam);
149 __isl_give isl_basic_set *isl_basic_set_read_from_str(isl_ctx *ctx,
150 const char *str, int nparam);
151 __isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx,
152 FILE *input, int nparam);
153 __isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx,
154 const char *str, int nparam);
155 __isl_give isl_printer *isl_printer_print_basic_set(
156 __isl_take isl_printer *printer, __isl_keep isl_basic_set *bset);
157 __isl_give isl_printer *isl_printer_print_set(__isl_take isl_printer *printer,
158 __isl_keep isl_set *map);
159 void isl_basic_set_print(__isl_keep isl_basic_set *bset, FILE *out, int indent,
160 const char *prefix, const char *suffix, unsigned output_format);
161 void isl_set_print(__isl_keep struct isl_set *set, FILE *out, int indent,
162 unsigned output_format);
163 __isl_give isl_basic_set *isl_basic_set_fix(__isl_take isl_basic_set *bset,
164 enum isl_dim_type type, unsigned pos, isl_int value);
165 struct isl_basic_set *isl_basic_set_fix_si(struct isl_basic_set *bset,
166 enum isl_dim_type type, unsigned pos, int value);
167 __isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set,
168 enum isl_dim_type type, unsigned pos, int value);
169 __isl_give isl_set *isl_set_lower_bound_si(__isl_take isl_set *set,
170 enum isl_dim_type type, unsigned pos, int value);
172 struct isl_basic_set *isl_basic_set_from_underlying_set(
173 struct isl_basic_set *bset, struct isl_basic_set *like);
174 struct isl_set *isl_set_from_underlying_set(
175 struct isl_set *set, struct isl_basic_set *like);
176 struct isl_set *isl_set_to_underlying_set(struct isl_set *set);
178 int isl_basic_set_is_equal(
179 struct isl_basic_set *bset1, struct isl_basic_set *bset2);
181 __isl_give isl_set *isl_basic_set_partial_lexmin(
182 __isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
183 __isl_give isl_set **empty);
184 __isl_give isl_set *isl_basic_set_partial_lexmax(
185 __isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
186 __isl_give isl_set **empty);
187 __isl_give isl_set *isl_set_partial_lexmin(
188 __isl_take isl_set *set, __isl_take isl_set *dom,
189 __isl_give isl_set **empty);
190 __isl_give isl_set *isl_set_partial_lexmax(
191 __isl_take isl_set *set, __isl_take isl_set *dom,
192 __isl_give isl_set **empty);
193 __isl_give isl_set *isl_basic_set_lexmin(__isl_take isl_basic_set *bset);
194 __isl_give isl_set *isl_basic_set_lexmax(__isl_take isl_basic_set *bset);
195 __isl_give isl_set *isl_set_lexmin(__isl_take isl_set *set);
196 __isl_give isl_set *isl_set_lexmax(__isl_take isl_set *set);
197 __isl_give isl_set *isl_basic_set_union(
198 __isl_take isl_basic_set *bset1,
199 __isl_take isl_basic_set *bset2);
201 int isl_basic_set_compare_at(struct isl_basic_set *bset1,
202 struct isl_basic_set *bset2, int pos);
203 int isl_set_follows_at(__isl_keep isl_set *set1,
204 __isl_keep isl_set *set2, int pos);
206 int isl_basic_set_dims_get_sign(__isl_keep isl_basic_set *bset,
207 enum isl_dim_type type, unsigned pos, unsigned n, int *signs);
209 int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
210 int isl_basic_set_fast_is_empty(__isl_keep isl_basic_set *bset);
211 int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
212 int isl_basic_set_is_bounded(__isl_keep isl_basic_set *bset);
214 struct isl_set *isl_set_alloc(struct isl_ctx *ctx,
215 unsigned nparam, unsigned dim, int n, unsigned flags);
216 struct isl_set *isl_set_extend(struct isl_set *base,
217 unsigned nparam, unsigned dim);
218 __isl_give isl_set *isl_set_empty(__isl_take isl_dim *dim);
219 struct isl_set *isl_set_empty_like(struct isl_set *set);
220 __isl_give isl_set *isl_set_universe(__isl_take isl_dim *dim);
221 __isl_give isl_set *isl_set_universe_like(__isl_keep isl_set *model);
222 __isl_give isl_set *isl_set_add_basic_set(__isl_take isl_set *set,
223 __isl_take isl_basic_set *bset);
224 struct isl_set *isl_set_finalize(struct isl_set *set);
225 __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set);
226 void isl_set_free(__isl_take isl_set *set);
227 struct isl_set *isl_set_dup(struct isl_set *set);
228 __isl_give isl_set *isl_set_from_basic_set(__isl_take isl_basic_set *bset);
229 __isl_give isl_basic_set *isl_set_sample(__isl_take isl_set *set);
230 __isl_give isl_point *isl_basic_set_sample_point(__isl_take isl_basic_set *bset);
231 __isl_give isl_point *isl_set_sample_point(__isl_take isl_set *set);
232 __isl_give isl_set *isl_set_detect_equalities(__isl_take isl_set *set);
233 __isl_give isl_basic_set *isl_set_affine_hull(__isl_take isl_set *set);
234 __isl_give isl_basic_set *isl_set_convex_hull(__isl_take isl_set *set);
235 __isl_give isl_basic_set *isl_set_polyhedral_hull(__isl_take isl_set *set);
236 __isl_give isl_basic_set *isl_set_simple_hull(__isl_take isl_set *set);
237 struct isl_basic_set *isl_set_bounded_simple_hull(struct isl_set *set);
238 __isl_give isl_set *isl_set_recession_cone(__isl_take isl_set *set);
240 struct isl_set *isl_set_union_disjoint(
241 struct isl_set *set1, struct isl_set *set2);
242 __isl_give isl_set *isl_set_union(
243 __isl_take isl_set *set1,
244 __isl_take isl_set *set2);
245 struct isl_set *isl_set_product(struct isl_set *set1, struct isl_set *set2);
246 __isl_give isl_set *isl_set_flat_product(__isl_take isl_set *set1,
247 __isl_take isl_set *set2);
248 __isl_give isl_set *isl_set_intersect(
249 __isl_take isl_set *set1,
250 __isl_take isl_set *set2);
251 __isl_give isl_set *isl_set_subtract(
252 __isl_take isl_set *set1,
253 __isl_take isl_set *set2);
254 __isl_give isl_set *isl_set_complement(__isl_take isl_set *set);
255 __isl_give isl_set *isl_set_apply(
256 __isl_take isl_set *set,
257 __isl_take isl_map *map);
258 __isl_give isl_set *isl_set_fix(__isl_take isl_set *set,
259 enum isl_dim_type type, unsigned pos, isl_int value);
260 struct isl_set *isl_set_fix_dim_si(struct isl_set *set,
261 unsigned dim, int value);
262 struct isl_set *isl_set_lower_bound_dim(struct isl_set *set,
263 unsigned dim, isl_int value);
264 __isl_give isl_set *isl_set_insert(__isl_take isl_set *set,
265 enum isl_dim_type type, unsigned pos, unsigned n);
266 __isl_give isl_basic_set *isl_basic_set_add(__isl_take isl_basic_set *bset,
267 enum isl_dim_type type, unsigned n);
268 __isl_give isl_set *isl_set_add_dims(__isl_take isl_set *set,
269 enum isl_dim_type type, unsigned n);
270 __isl_give isl_basic_set *isl_basic_set_move_dims(__isl_take isl_basic_set *bset,
271 enum isl_dim_type dst_type, unsigned dst_pos,
272 enum isl_dim_type src_type, unsigned src_pos, unsigned n);
273 __isl_give isl_set *isl_set_move_dims(__isl_take isl_set *set,
274 enum isl_dim_type dst_type, unsigned dst_pos,
275 enum isl_dim_type src_type, unsigned src_pos, unsigned n);
276 __isl_give isl_basic_set *isl_basic_set_project_out(
277 __isl_take isl_basic_set *bset,
278 enum isl_dim_type type, unsigned first, unsigned n);
279 __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
280 enum isl_dim_type type, unsigned first, unsigned n);
281 __isl_give isl_basic_set *isl_basic_set_remove_divs(
282 __isl_take isl_basic_set *bset);
283 struct isl_set *isl_set_eliminate_dims(struct isl_set *set,
284 unsigned first, unsigned n);
285 __isl_give isl_set *isl_set_remove_dims(__isl_take isl_set *bset,
286 enum isl_dim_type type, unsigned first, unsigned n);
287 __isl_give isl_set *isl_set_remove_divs_involving_dims(__isl_take isl_set *set,
288 enum isl_dim_type type, unsigned first, unsigned n);
289 __isl_give isl_set *isl_set_remove_divs(__isl_take isl_set *set);
290 __isl_give isl_set *isl_set_split_dims(__isl_take isl_set *set,
291 enum isl_dim_type type, unsigned first, unsigned n);
293 void isl_set_dump(__isl_keep isl_set *set, FILE *out, int indent);
294 struct isl_set *isl_set_swap_vars(struct isl_set *set, unsigned n);
295 int isl_set_fast_is_empty(__isl_keep isl_set *set);
296 int isl_set_fast_is_universe(__isl_keep isl_set *set);
297 int isl_set_is_empty(__isl_keep isl_set *set);
298 int isl_set_is_bounded(__isl_keep isl_set *set);
299 int isl_set_is_subset(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
300 int isl_set_is_strict_subset(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
301 int isl_set_is_equal(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
302 int isl_set_is_singleton(__isl_keep isl_set *set);
303 int isl_set_is_box(__isl_keep isl_set *set);
304 int isl_set_has_equal_dim(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
306 __isl_give isl_set *isl_set_sum(__isl_take isl_set *set1,
307 __isl_take isl_set *set2);
308 __isl_give isl_set *isl_set_neg(__isl_take isl_set *set);
310 __isl_give isl_set *isl_set_make_disjoint(__isl_take isl_set *set);
311 struct isl_set *isl_basic_set_compute_divs(struct isl_basic_set *bset);
312 __isl_give isl_set *isl_set_compute_divs(__isl_take isl_set *set);
313 __isl_give isl_set *isl_set_align_divs(__isl_take isl_set *set);
315 struct isl_basic_set *isl_set_copy_basic_set(struct isl_set *set);
316 struct isl_set *isl_set_drop_basic_set(struct isl_set *set,
317 struct isl_basic_set *bset);
319 int isl_basic_set_fast_dim_is_fixed(struct isl_basic_set *bset, unsigned dim,
322 int isl_set_fast_dim_is_fixed(struct isl_set *set, unsigned dim, isl_int *val);
323 int isl_set_fast_dim_has_fixed_lower_bound(struct isl_set *set,
324 unsigned dim, isl_int *val);
325 int isl_set_dim_is_bounded(__isl_keep isl_set *set,
326 enum isl_dim_type type, unsigned pos);
328 __isl_give isl_basic_set *isl_basic_set_gist(__isl_take isl_basic_set *bset,
329 __isl_take isl_basic_set *context);
330 __isl_give isl_set *isl_set_gist_basic_set(__isl_take isl_set *set,
331 __isl_take isl_basic_set *context);
332 __isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
333 __isl_take isl_set *context);
334 int isl_basic_set_dim_residue_class(struct isl_basic_set *bset,
335 int pos, isl_int *modulo, isl_int *residue);
336 int isl_set_dim_residue_class(struct isl_set *set,
337 int pos, isl_int *modulo, isl_int *residue);
339 __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
341 int isl_set_fast_is_equal(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
342 int isl_set_fast_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
344 uint32_t isl_set_get_hash(struct isl_set *set);
346 int isl_set_dim_is_unique(struct isl_set *set, unsigned dim);
348 int isl_set_n_basic_set(__isl_keep isl_set *set);
349 int isl_set_foreach_basic_set(__isl_keep isl_set *set,
350 int (*fn)(__isl_take isl_basic_set *bset, void *user), void *user);
352 int isl_set_foreach_point(__isl_keep isl_set *set,
353 int (*fn)(__isl_take isl_point *pnt, void *user), void *user);
354 int isl_set_count(__isl_keep isl_set *set, isl_int *count);
355 int isl_set_count_upto(__isl_keep isl_set *set, isl_int max, isl_int *count);
357 __isl_give isl_basic_set *isl_basic_set_from_point(__isl_take isl_point *pnt);
358 __isl_give isl_set *isl_set_from_point(__isl_take isl_point *pnt);
359 __isl_give isl_basic_set *isl_basic_set_box_from_points(
360 __isl_take isl_point *pnt1, __isl_take isl_point *pnt2);
361 __isl_give isl_set *isl_set_box_from_points(__isl_take isl_point *pnt1,
362 __isl_take isl_point *pnt2);
364 __isl_give isl_basic_set *isl_basic_set_lift(__isl_take isl_basic_set *bset);
365 __isl_give isl_set *isl_set_lift(__isl_take isl_set *set);
367 __isl_give isl_map *isl_set_lex_le_set(__isl_take isl_set *set1,
368 __isl_take isl_set *set2);
369 __isl_give isl_map *isl_set_lex_lt_set(__isl_take isl_set *set1,
370 __isl_take isl_set *set2);
371 __isl_give isl_map *isl_set_lex_ge_set(__isl_take isl_set *set1,
372 __isl_take isl_set *set2);
373 __isl_give isl_map *isl_set_lex_gt_set(__isl_take isl_set *set1,
374 __isl_take isl_set *set2);
376 int isl_set_size(__isl_keep isl_set *set);
378 __isl_give isl_basic_set *isl_basic_set_from_constraint_matrices(
379 __isl_take isl_dim *dim,
380 __isl_take isl_mat *eq, __isl_take isl_mat *ineq, enum isl_dim_type c1,
381 enum isl_dim_type c2, enum isl_dim_type c3, enum isl_dim_type c4);
383 __isl_give isl_mat *isl_basic_set_reduced_basis(__isl_keep isl_basic_set *bset);
385 #if defined(__cplusplus)