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
21 #include <isl_printer.h>
23 #if defined(__cplusplus)
29 * All structures are reference counted to allow reuse without duplication.
30 * A *_copy operation will increase the reference count, while a *_free
31 * operation will decrease the reference count and only actually release
32 * the structures when the reference count drops to zero.
34 * Functions that return an isa structure will in general _destroy_
35 * all argument isa structures (the obvious execption begin the _copy
36 * functions). A pointer passed to such a function may therefore
37 * never be used after the function call. If you want to keep a
38 * reference to the old structure(s), use the appropriate _copy function.
41 /* A "basic map" is a relation between two sets of variables,
42 * called the "in" and "out" variables.
44 * It is implemented as a set with two extra fields:
45 * n_in is the number of in variables
46 * n_out is the number of out variables
47 * n_in + n_out should be equal to set.dim
50 struct isl_basic_map
{
52 #define ISL_BASIC_MAP_FINAL (1 << 0)
53 #define ISL_BASIC_MAP_EMPTY (1 << 1)
54 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
55 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
56 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
57 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
58 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
59 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
78 struct isl_vec
*sample
;
81 struct isl_blk block2
;
83 typedef struct isl_basic_map isl_basic_map
;
85 typedef struct isl_basic_set isl_basic_set
;
87 /* A "map" is a (disjoint) union of basic maps.
89 * Currently, the isl_set structure is identical to the isl_map structure
90 * and the library depends on this correspondence internally.
91 * However, users should not depend on this correspondence.
95 #define ISL_MAP_DISJOINT (1 << 0)
96 #define ISL_MAP_NORMALIZED (1 << 1)
106 struct isl_basic_map
*p
[1];
108 typedef struct isl_map isl_map
;
110 typedef struct isl_set isl_set
;
112 unsigned isl_basic_map_n_in(const struct isl_basic_map
*bmap
);
113 unsigned isl_basic_map_n_out(const struct isl_basic_map
*bmap
);
114 unsigned isl_basic_map_n_param(const struct isl_basic_map
*bmap
);
115 unsigned isl_basic_map_n_div(const struct isl_basic_map
*bmap
);
116 unsigned isl_basic_map_total_dim(const struct isl_basic_map
*bmap
);
117 unsigned isl_basic_map_dim(const struct isl_basic_map
*bmap
,
118 enum isl_dim_type type
);
120 unsigned isl_map_n_in(const struct isl_map
*map
);
121 unsigned isl_map_n_out(const struct isl_map
*map
);
122 unsigned isl_map_n_param(const struct isl_map
*map
);
123 unsigned isl_map_dim(const struct isl_map
*map
, enum isl_dim_type type
);
125 isl_ctx
*isl_map_get_ctx(__isl_keep isl_map
*map
);
126 __isl_give isl_dim
*isl_basic_map_get_dim(__isl_keep isl_basic_map
*bmap
);
127 __isl_give isl_dim
*isl_map_get_dim(__isl_keep isl_map
*map
);
129 __isl_give isl_basic_map
*isl_basic_map_set_tuple_name(
130 __isl_take isl_basic_map
*bmap
, enum isl_dim_type type
, const char *s
);
131 __isl_give isl_map
*isl_map_set_tuple_name(__isl_take isl_map
*map
,
132 enum isl_dim_type type
, const char *s
);
133 __isl_give isl_basic_map
*isl_basic_map_set_dim_name(
134 __isl_take isl_basic_map
*bmap
,
135 enum isl_dim_type type
, unsigned pos
, const char *s
);
136 __isl_give isl_map
*isl_map_set_dim_name(__isl_take isl_map
*map
,
137 enum isl_dim_type type
, unsigned pos
, const char *s
);
139 int isl_basic_map_is_rational(__isl_keep isl_basic_map
*bmap
);
141 struct isl_basic_map
*isl_basic_map_alloc(struct isl_ctx
*ctx
,
142 unsigned nparam
, unsigned in
, unsigned out
, unsigned extra
,
143 unsigned n_eq
, unsigned n_ineq
);
144 __isl_give isl_basic_map
*isl_basic_map_identity(__isl_take isl_dim
*set_dim
);
145 struct isl_basic_map
*isl_basic_map_identity_like(struct isl_basic_map
*model
);
146 struct isl_basic_map
*isl_basic_map_finalize(struct isl_basic_map
*bmap
);
147 void isl_basic_map_free(__isl_take isl_basic_map
*bmap
);
148 __isl_give isl_basic_map
*isl_basic_map_copy(__isl_keep isl_basic_map
*bmap
);
149 struct isl_basic_map
*isl_basic_map_extend(struct isl_basic_map
*base
,
150 unsigned nparam
, unsigned n_in
, unsigned n_out
, unsigned extra
,
151 unsigned n_eq
, unsigned n_ineq
);
152 struct isl_basic_map
*isl_basic_map_extend_constraints(
153 struct isl_basic_map
*base
, unsigned n_eq
, unsigned n_ineq
);
154 struct isl_basic_map
*isl_basic_map_equal(
155 struct isl_dim
*dim
, unsigned n_equal
);
156 struct isl_basic_map
*isl_basic_map_less_at(struct isl_dim
*dim
, unsigned pos
);
157 struct isl_basic_map
*isl_basic_map_more_at(struct isl_dim
*dim
, unsigned pos
);
158 __isl_give isl_basic_map
*isl_basic_map_empty(__isl_take isl_dim
*dim
);
159 struct isl_basic_map
*isl_basic_map_empty_like(struct isl_basic_map
*model
);
160 struct isl_basic_map
*isl_basic_map_empty_like_map(struct isl_map
*model
);
161 __isl_give isl_basic_map
*isl_basic_map_universe(__isl_take isl_dim
*dim
);
162 __isl_give isl_basic_map
*isl_basic_map_universe_like(
163 __isl_keep isl_basic_map
*bmap
);
164 __isl_give isl_basic_map
*isl_basic_map_remove_redundancies(
165 __isl_take isl_basic_map
*bmap
);
166 __isl_give isl_basic_map
*isl_map_simple_hull(__isl_take isl_map
*map
);
168 __isl_give isl_basic_map
*isl_basic_map_intersect_domain(
169 __isl_take isl_basic_map
*bmap
,
170 __isl_take isl_basic_set
*bset
);
171 __isl_give isl_basic_map
*isl_basic_map_intersect_range(
172 __isl_take isl_basic_map
*bmap
,
173 __isl_take isl_basic_set
*bset
);
174 __isl_give isl_basic_map
*isl_basic_map_intersect(
175 __isl_take isl_basic_map
*bmap1
,
176 __isl_take isl_basic_map
*bmap2
);
177 __isl_give isl_map
*isl_basic_map_union(
178 __isl_take isl_basic_map
*bmap1
,
179 __isl_take isl_basic_map
*bmap2
);
180 __isl_give isl_basic_map
*isl_basic_map_apply_domain(
181 __isl_take isl_basic_map
*bmap1
,
182 __isl_take isl_basic_map
*bmap2
);
183 __isl_give isl_basic_map
*isl_basic_map_apply_range(
184 __isl_take isl_basic_map
*bmap1
,
185 __isl_take isl_basic_map
*bmap2
);
186 __isl_give isl_basic_map
*isl_basic_map_affine_hull(
187 __isl_take isl_basic_map
*bmap
);
188 __isl_give isl_basic_map
*isl_basic_map_reverse(__isl_take isl_basic_map
*bmap
);
189 __isl_give isl_basic_set
*isl_basic_map_domain(__isl_take isl_basic_map
*bmap
);
190 __isl_give isl_basic_set
*isl_basic_map_range(__isl_take isl_basic_map
*bmap
);
191 struct isl_basic_map
*isl_basic_map_remove(struct isl_basic_map
*bmap
,
192 enum isl_dim_type type
, unsigned first
, unsigned n
);
193 struct isl_basic_map
*isl_basic_map_from_basic_set(struct isl_basic_set
*bset
,
194 struct isl_dim
*dim
);
195 struct isl_basic_set
*isl_basic_set_from_basic_map(struct isl_basic_map
*bmap
);
196 __isl_give isl_basic_map
*isl_basic_map_sample(__isl_take isl_basic_map
*bmap
);
197 struct isl_basic_map
*isl_basic_map_simplify(struct isl_basic_map
*bmap
);
198 struct isl_basic_map
*isl_basic_map_detect_equalities(
199 struct isl_basic_map
*bmap
);
200 __isl_give isl_basic_map
*isl_basic_map_read_from_file(isl_ctx
*ctx
,
201 FILE *input
, int nparam
);
202 __isl_give isl_basic_map
*isl_basic_map_read_from_str(isl_ctx
*ctx
,
203 const char *str
, int nparam
);
204 __isl_give isl_map
*isl_map_read_from_file(struct isl_ctx
*ctx
,
205 FILE *input
, int nparam
);
206 __isl_give isl_map
*isl_map_read_from_str(isl_ctx
*ctx
,
207 const char *str
, int nparam
);
208 void isl_basic_map_print(__isl_keep isl_basic_map
*bmap
, FILE *out
, int indent
,
209 const char *prefix
, const char *suffix
, unsigned output_format
);
210 void isl_map_print(__isl_keep isl_map
*map
, FILE *out
, int indent
,
211 unsigned output_format
);
212 __isl_give isl_printer
*isl_printer_print_basic_map(
213 __isl_take isl_printer
*printer
, __isl_keep isl_basic_map
*bmap
);
214 __isl_give isl_printer
*isl_printer_print_map(__isl_take isl_printer
*printer
,
215 __isl_keep isl_map
*map
);
216 struct isl_basic_map
*isl_basic_map_fix_si(struct isl_basic_map
*bmap
,
217 enum isl_dim_type type
, unsigned pos
, int value
);
218 __isl_give isl_basic_map
*isl_basic_map_lower_bound_si(
219 __isl_take isl_basic_map
*bmap
,
220 enum isl_dim_type type
, unsigned pos
, int value
);
222 struct isl_basic_map
*isl_basic_map_sum(
223 struct isl_basic_map
*bmap1
, struct isl_basic_map
*bmap2
);
224 struct isl_basic_map
*isl_basic_map_neg(struct isl_basic_map
*bmap
);
225 struct isl_basic_map
*isl_basic_map_floordiv(struct isl_basic_map
*bmap
,
228 struct isl_map
*isl_map_sum(struct isl_map
*map1
, struct isl_map
*map2
);
229 struct isl_map
*isl_map_neg(struct isl_map
*map
);
230 struct isl_map
*isl_map_floordiv(struct isl_map
*map
, isl_int d
);
232 int isl_basic_map_is_equal(
233 __isl_keep isl_basic_map
*bmap1
,
234 __isl_keep isl_basic_map
*bmap2
);
236 __isl_give isl_map
*isl_basic_map_partial_lexmax(
237 __isl_take isl_basic_map
*bmap
, __isl_take isl_basic_set
*dom
,
238 __isl_give isl_set
**empty
);
239 __isl_give isl_map
*isl_basic_map_partial_lexmin(
240 __isl_take isl_basic_map
*bmap
, __isl_take isl_basic_set
*dom
,
241 __isl_give isl_set
**empty
);
242 __isl_give isl_map
*isl_map_partial_lexmax(
243 __isl_take isl_map
*map
, __isl_take isl_set
*dom
,
244 __isl_give isl_set
**empty
);
245 __isl_give isl_map
*isl_map_partial_lexmin(
246 __isl_take isl_map
*map
, __isl_take isl_set
*dom
,
247 __isl_give isl_set
**empty
);
248 __isl_give isl_map
*isl_basic_map_lexmin(__isl_take isl_basic_map
*bmap
);
249 __isl_give isl_map
*isl_basic_map_lexmax(__isl_take isl_basic_map
*bmap
);
250 __isl_give isl_map
*isl_map_lexmin(__isl_take isl_map
*map
);
251 __isl_give isl_map
*isl_map_lexmax(__isl_take isl_map
*map
);
252 int isl_basic_map_foreach_lexmin(__isl_keep isl_basic_map
*bmap
,
253 int (*fn
)(__isl_take isl_basic_set
*dom
, __isl_take isl_mat
*map
,
257 void isl_basic_map_dump(__isl_keep isl_basic_map
*bmap
, FILE *out
, int indent
);
259 struct isl_basic_map
*isl_map_copy_basic_map(struct isl_map
*map
);
260 __isl_give isl_map
*isl_map_drop_basic_map(__isl_take isl_map
*map
,
261 __isl_keep isl_basic_map
*bmap
);
263 int isl_basic_map_fast_is_fixed(struct isl_basic_map
*bmap
,
264 enum isl_dim_type type
, unsigned pos
, isl_int
*val
);
266 int isl_basic_map_image_is_bounded(__isl_keep isl_basic_map
*bmap
);
267 int isl_basic_map_is_universe(__isl_keep isl_basic_map
*bmap
);
268 int isl_basic_map_fast_is_empty(__isl_keep isl_basic_map
*bmap
);
269 int isl_basic_map_is_empty(__isl_keep isl_basic_map
*bmap
);
270 int isl_basic_map_is_subset(__isl_keep isl_basic_map
*bmap1
,
271 __isl_keep isl_basic_map
*bmap2
);
272 int isl_basic_map_is_strict_subset(__isl_keep isl_basic_map
*bmap1
,
273 __isl_keep isl_basic_map
*bmap2
);
275 struct isl_map
*isl_map_alloc(struct isl_ctx
*ctx
,
276 unsigned nparam
, unsigned in
, unsigned out
, int n
,
278 __isl_give isl_map
*isl_map_universe(__isl_take isl_dim
*dim
);
279 __isl_give isl_map
*isl_map_empty(__isl_take isl_dim
*dim
);
280 struct isl_map
*isl_map_empty_like(struct isl_map
*model
);
281 struct isl_map
*isl_map_empty_like_basic_map(struct isl_basic_map
*model
);
282 struct isl_map
*isl_map_dup(struct isl_map
*map
);
283 __isl_give isl_map
*isl_map_add_basic_map(__isl_take isl_map
*map
,
284 __isl_take isl_basic_map
*bmap
);
285 __isl_give isl_map
*isl_map_identity(__isl_take isl_dim
*set_dim
);
286 struct isl_map
*isl_map_identity_like(struct isl_map
*model
);
287 struct isl_map
*isl_map_identity_like_basic_map(struct isl_basic_map
*model
);
288 __isl_give isl_map
*isl_map_lex_lt_first(__isl_take isl_dim
*dim
, unsigned n
);
289 __isl_give isl_map
*isl_map_lex_le_first(__isl_take isl_dim
*dim
, unsigned n
);
290 __isl_give isl_map
*isl_map_lex_lt(__isl_take isl_dim
*set_dim
);
291 __isl_give isl_map
*isl_map_lex_le(__isl_take isl_dim
*set_dim
);
292 __isl_give isl_map
*isl_map_lex_gt_first(__isl_take isl_dim
*dim
, unsigned n
);
293 __isl_give isl_map
*isl_map_lex_ge_first(__isl_take isl_dim
*dim
, unsigned n
);
294 __isl_give isl_map
*isl_map_lex_gt(__isl_take isl_dim
*set_dim
);
295 __isl_give isl_map
*isl_map_lex_ge(__isl_take isl_dim
*set_dim
);
296 struct isl_map
*isl_map_finalize(struct isl_map
*map
);
297 void isl_map_free(__isl_take isl_map
*map
);
298 __isl_give isl_map
*isl_map_copy(__isl_keep isl_map
*map
);
299 struct isl_map
*isl_map_extend(struct isl_map
*base
,
300 unsigned nparam
, unsigned n_in
, unsigned n_out
);
301 __isl_give isl_map
*isl_map_reverse(__isl_take isl_map
*map
);
302 __isl_give isl_map
*isl_map_union(
303 __isl_take isl_map
*map1
,
304 __isl_take isl_map
*map2
);
305 struct isl_map
*isl_map_union_disjoint(
306 struct isl_map
*map1
, struct isl_map
*map2
);
307 __isl_give isl_map
*isl_map_intersect_domain(
308 __isl_take isl_map
*map
,
309 __isl_take isl_set
*set
);
310 __isl_give isl_map
*isl_map_intersect_range(
311 __isl_take isl_map
*map
,
312 __isl_take isl_set
*set
);
313 __isl_give isl_map
*isl_map_apply_domain(
314 __isl_take isl_map
*map1
,
315 __isl_take isl_map
*map2
);
316 __isl_give isl_map
*isl_map_apply_range(
317 __isl_take isl_map
*map1
,
318 __isl_take isl_map
*map2
);
319 struct isl_map
*isl_map_product(struct isl_map
*map1
, struct isl_map
*map2
);
320 __isl_give isl_map
*isl_map_intersect(__isl_take isl_map
*map1
,
321 __isl_take isl_map
*map2
);
322 __isl_give isl_map
*isl_map_subtract(
323 __isl_take isl_map
*map1
,
324 __isl_take isl_map
*map2
);
325 struct isl_map
*isl_map_fix_input_si(struct isl_map
*map
,
326 unsigned input
, int value
);
327 struct isl_map
*isl_map_fix_si(struct isl_map
*map
,
328 enum isl_dim_type type
, unsigned pos
, int value
);
329 __isl_give isl_map
*isl_map_lower_bound_si(__isl_take isl_map
*map
,
330 enum isl_dim_type type
, unsigned pos
, int value
);
331 __isl_give isl_basic_set
*isl_basic_map_deltas(__isl_take isl_basic_map
*bmap
);
332 __isl_give isl_set
*isl_map_deltas(__isl_take isl_map
*map
);
333 struct isl_map
*isl_map_detect_equalities(struct isl_map
*map
);
334 __isl_give isl_basic_map
*isl_map_affine_hull(__isl_take isl_map
*map
);
335 __isl_give isl_basic_map
*isl_map_convex_hull(__isl_take isl_map
*map
);
336 __isl_give isl_basic_map
*isl_basic_map_add(__isl_take isl_basic_map
*bmap
,
337 enum isl_dim_type type
, unsigned n
);
338 __isl_give isl_map
*isl_map_add(__isl_take isl_map
*map
,
339 enum isl_dim_type type
, unsigned n
);
340 __isl_give isl_map
*isl_map_insert(__isl_take isl_map
*map
,
341 enum isl_dim_type type
, unsigned pos
, unsigned n
);
342 __isl_give isl_basic_map
*isl_basic_map_move_dims(
343 __isl_take isl_basic_map
*bmap
,
344 enum isl_dim_type dst_type
, unsigned dst_pos
,
345 enum isl_dim_type src_type
, unsigned src_pos
, unsigned n
);
346 __isl_give isl_map
*isl_map_move_dims(__isl_take isl_map
*map
,
347 enum isl_dim_type dst_type
, unsigned dst_pos
,
348 enum isl_dim_type src_type
, unsigned src_pos
, unsigned n
);
349 __isl_give isl_basic_map
*isl_basic_map_project_out(
350 __isl_take isl_basic_map
*bmap
,
351 enum isl_dim_type type
, unsigned first
, unsigned n
);
352 __isl_give isl_map
*isl_map_project_out(__isl_take isl_map
*map
,
353 enum isl_dim_type type
, unsigned first
, unsigned n
);
354 struct isl_map
*isl_map_remove(struct isl_map
*map
,
355 enum isl_dim_type type
, unsigned first
, unsigned n
);
356 struct isl_map
*isl_map_remove_inputs(struct isl_map
*map
,
357 unsigned first
, unsigned n
);
359 int isl_basic_set_is_wrapping(__isl_keep isl_basic_set
*bset
);
360 int isl_set_is_wrapping(__isl_keep isl_set
*set
);
361 __isl_give isl_basic_set
*isl_basic_map_wrap(__isl_take isl_basic_map
*bmap
);
362 __isl_give isl_set
*isl_map_wrap(__isl_take isl_map
*map
);
363 __isl_give isl_basic_map
*isl_basic_set_unwrap(__isl_take isl_basic_set
*bset
);
364 __isl_give isl_map
*isl_set_unwrap(__isl_take isl_set
*set
);
365 __isl_give isl_set
*isl_map_domain(__isl_take isl_map
*bmap
);
366 __isl_give isl_set
*isl_map_range(__isl_take isl_map
*map
);
367 __isl_give isl_map
*isl_map_from_basic_map(__isl_take isl_basic_map
*bmap
);
368 __isl_give isl_map
*isl_map_from_domain(__isl_take isl_set
*set
);
369 struct isl_map
*isl_map_from_range(struct isl_set
*set
);
370 __isl_give isl_map
*isl_map_from_domain_and_range(__isl_take isl_set
*domain
,
371 __isl_take isl_set
*range
);
372 struct isl_map
*isl_map_from_set(struct isl_set
*set
, struct isl_dim
*dim
);
373 struct isl_set
*isl_set_from_map(struct isl_map
*map
);
374 __isl_give isl_basic_map
*isl_map_sample(__isl_take isl_map
*map
);
376 int isl_map_fast_is_empty(__isl_keep isl_map
*map
);
377 int isl_map_fast_is_universe(__isl_keep isl_map
*map
);
378 int isl_map_is_empty(__isl_keep isl_map
*map
);
379 int isl_map_is_subset(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
380 int isl_map_is_strict_subset(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
381 int isl_map_is_equal(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
382 int isl_map_is_single_valued(__isl_keep isl_map
*map
);
383 int isl_map_is_bijective(__isl_keep isl_map
*map
);
384 int isl_map_is_translation(__isl_keep isl_map
*map
);
385 int isl_map_has_equal_dim(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
387 __isl_give isl_map
*isl_map_make_disjoint(__isl_take isl_map
*map
);
388 __isl_give isl_map
*isl_basic_map_compute_divs(__isl_take isl_basic_map
*bmap
);
389 __isl_give isl_map
*isl_map_compute_divs(__isl_take isl_map
*map
);
390 __isl_give isl_map
*isl_map_align_divs(__isl_take isl_map
*map
);
392 void isl_map_dump(__isl_keep isl_map
*map
, FILE *out
, int indent
);
394 int isl_map_fast_input_is_fixed(struct isl_map
*map
,
395 unsigned in
, isl_int
*val
);
396 int isl_map_fast_is_fixed(struct isl_map
*map
,
397 enum isl_dim_type type
, unsigned pos
, isl_int
*val
);
399 __isl_give isl_basic_map
*isl_basic_map_gist(__isl_take isl_basic_map
*bmap
,
400 __isl_take isl_basic_map
*context
);
401 __isl_give isl_map
*isl_map_gist(__isl_take isl_map
*map
,
402 __isl_take isl_map
*context
);
403 __isl_give isl_map
*isl_map_gist_basic_map(__isl_take isl_map
*map
,
404 __isl_take isl_basic_map
*context
);
406 __isl_give isl_map
*isl_map_coalesce(__isl_take isl_map
*map
);
408 int isl_map_fast_is_equal(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
410 int isl_map_foreach_basic_map(__isl_keep isl_map
*map
,
411 int (*fn
)(__isl_take isl_basic_map
*bmap
, void *user
), void *user
);
413 __isl_give isl_map
*isl_set_lifting(__isl_take isl_set
*set
);
415 __isl_give isl_map
*isl_map_power(__isl_take isl_map
*map
, unsigned param
,
417 __isl_give isl_map
*isl_map_reaching_path_lengths(__isl_take isl_map
*map
,
419 __isl_give isl_map
*isl_map_transitive_closure(__isl_take isl_map
*map
,
422 #if defined(__cplusplus)