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
22 #if defined(__cplusplus)
28 * All structures are reference counted to allow reuse without duplication.
29 * A *_copy operation will increase the reference count, while a *_free
30 * operation will decrease the reference count and only actually release
31 * the structures when the reference count drops to zero.
33 * Functions that return an isa structure will in general _destroy_
34 * all argument isa structures (the obvious execption begin the _copy
35 * functions). A pointer passed to such a function may therefore
36 * never be used after the function call. If you want to keep a
37 * reference to the old structure(s), use the appropriate _copy function.
40 /* A "basic map" is a relation between two sets of variables,
41 * called the "in" and "out" variables.
43 * It is implemented as a set with two extra fields:
44 * n_in is the number of in variables
45 * n_out is the number of out variables
46 * n_in + n_out should be equal to set.dim
49 struct isl_basic_map
{
51 #define ISL_BASIC_MAP_FINAL (1 << 0)
52 #define ISL_BASIC_MAP_EMPTY (1 << 1)
53 #define ISL_BASIC_MAP_NO_IMPLICIT (1 << 2)
54 #define ISL_BASIC_MAP_NO_REDUNDANT (1 << 3)
55 #define ISL_BASIC_MAP_RATIONAL (1 << 4)
56 #define ISL_BASIC_MAP_NORMALIZED (1 << 5)
57 #define ISL_BASIC_MAP_NORMALIZED_DIVS (1 << 6)
58 #define ISL_BASIC_MAP_ALL_EQUALITIES (1 << 7)
77 struct isl_vec
*sample
;
80 struct isl_blk block2
;
82 typedef struct isl_basic_map isl_basic_map
;
84 typedef struct isl_basic_set isl_basic_set
;
86 /* A "map" is a (disjoint) union of basic maps.
88 * Currently, the isl_set structure is identical to the isl_map structure
89 * and the library depends on this correspondence internally.
90 * However, users should not depend on this correspondence.
94 #define ISL_MAP_DISJOINT (1 << 0)
95 #define ISL_MAP_NORMALIZED (1 << 1)
105 struct isl_basic_map
*p
[1];
107 typedef struct isl_map isl_map
;
109 typedef struct isl_set isl_set
;
111 unsigned isl_basic_map_n_in(const struct isl_basic_map
*bmap
);
112 unsigned isl_basic_map_n_out(const struct isl_basic_map
*bmap
);
113 unsigned isl_basic_map_n_param(const struct isl_basic_map
*bmap
);
114 unsigned isl_basic_map_n_div(const struct isl_basic_map
*bmap
);
115 unsigned isl_basic_map_total_dim(const struct isl_basic_map
*bmap
);
116 unsigned isl_basic_map_dim(const struct isl_basic_map
*bmap
,
117 enum isl_dim_type type
);
119 unsigned isl_map_n_in(const struct isl_map
*map
);
120 unsigned isl_map_n_out(const struct isl_map
*map
);
121 unsigned isl_map_n_param(const struct isl_map
*map
);
122 unsigned isl_map_dim(const struct isl_map
*map
, enum isl_dim_type type
);
124 struct isl_dim
*isl_basic_map_get_dim(struct isl_basic_map
*bmap
);
125 struct isl_dim
*isl_map_get_dim(struct isl_map
*map
);
127 struct isl_basic_map
*isl_basic_map_alloc(struct isl_ctx
*ctx
,
128 unsigned nparam
, unsigned in
, unsigned out
, unsigned extra
,
129 unsigned n_eq
, unsigned n_ineq
);
130 __isl_give isl_basic_map
*isl_basic_map_identity(__isl_take isl_dim
*set_dim
);
131 struct isl_basic_map
*isl_basic_map_identity_like(struct isl_basic_map
*model
);
132 struct isl_basic_map
*isl_basic_map_finalize(struct isl_basic_map
*bmap
);
133 void isl_basic_map_free(__isl_take isl_basic_map
*bmap
);
134 __isl_give isl_basic_map
*isl_basic_map_copy(__isl_keep isl_basic_map
*bmap
);
135 struct isl_basic_map
*isl_basic_map_extend(struct isl_basic_map
*base
,
136 unsigned nparam
, unsigned n_in
, unsigned n_out
, unsigned extra
,
137 unsigned n_eq
, unsigned n_ineq
);
138 struct isl_basic_map
*isl_basic_map_extend_constraints(
139 struct isl_basic_map
*base
, unsigned n_eq
, unsigned n_ineq
);
140 struct isl_basic_map
*isl_basic_map_equal(
141 struct isl_dim
*dim
, unsigned n_equal
);
142 struct isl_basic_map
*isl_basic_map_less_at(struct isl_dim
*dim
, unsigned pos
);
143 struct isl_basic_map
*isl_basic_map_more_at(struct isl_dim
*dim
, unsigned pos
);
144 __isl_give isl_basic_map
*isl_basic_map_empty(__isl_take isl_dim
*dim
);
145 struct isl_basic_map
*isl_basic_map_empty_like(struct isl_basic_map
*model
);
146 struct isl_basic_map
*isl_basic_map_empty_like_map(struct isl_map
*model
);
147 __isl_give isl_basic_map
*isl_basic_map_universe(__isl_take isl_dim
*dim
);
148 __isl_give isl_basic_map
*isl_basic_map_universe_like(
149 __isl_keep isl_basic_map
*bmap
);
150 struct isl_basic_map
*isl_basic_map_convex_hull(struct isl_basic_map
*bmap
);
152 __isl_give isl_basic_map
*isl_basic_map_intersect_domain(
153 __isl_take isl_basic_map
*bmap
,
154 __isl_take isl_basic_set
*bset
);
155 __isl_give isl_basic_map
*isl_basic_map_intersect_range(
156 __isl_take isl_basic_map
*bmap
,
157 __isl_take isl_basic_set
*bset
);
158 __isl_give isl_basic_map
*isl_basic_map_intersect(
159 __isl_take isl_basic_map
*bmap1
,
160 __isl_take isl_basic_map
*bmap2
);
161 __isl_give isl_map
*isl_basic_map_union(
162 __isl_take isl_basic_map
*bmap1
,
163 __isl_take isl_basic_map
*bmap2
);
164 __isl_give isl_basic_map
*isl_basic_map_apply_domain(
165 __isl_take isl_basic_map
*bmap1
,
166 __isl_take isl_basic_map
*bmap2
);
167 __isl_give isl_basic_map
*isl_basic_map_apply_range(
168 __isl_take isl_basic_map
*bmap1
,
169 __isl_take isl_basic_map
*bmap2
);
170 __isl_give isl_basic_map
*isl_basic_map_affine_hull(
171 __isl_take isl_basic_map
*bmap
);
172 struct isl_basic_map
*isl_basic_map_reverse(struct isl_basic_map
*bmap
);
173 __isl_give isl_basic_set
*isl_basic_map_domain(__isl_take isl_basic_map
*bmap
);
174 __isl_give isl_basic_set
*isl_basic_map_range(__isl_take isl_basic_map
*bmap
);
175 struct isl_basic_map
*isl_basic_map_remove(struct isl_basic_map
*bmap
,
176 enum isl_dim_type type
, unsigned first
, unsigned n
);
177 struct isl_basic_map
*isl_basic_map_from_basic_set(struct isl_basic_set
*bset
,
178 struct isl_dim
*dim
);
179 struct isl_basic_set
*isl_basic_set_from_basic_map(struct isl_basic_map
*bmap
);
180 __isl_give isl_basic_map
*isl_basic_map_sample(__isl_take isl_basic_map
*bmap
);
181 struct isl_basic_map
*isl_basic_map_simplify(struct isl_basic_map
*bmap
);
182 struct isl_basic_map
*isl_basic_map_detect_equalities(
183 struct isl_basic_map
*bmap
);
184 __isl_give isl_basic_map
*isl_basic_map_read_from_file(isl_ctx
*ctx
,
185 FILE *input
, int nparam
);
186 __isl_give isl_basic_map
*isl_basic_map_read_from_str(isl_ctx
*ctx
,
187 const char *str
, int nparam
);
188 __isl_give isl_map
*isl_map_read_from_file(struct isl_ctx
*ctx
,
189 FILE *input
, int nparam
);
190 __isl_give isl_map
*isl_map_read_from_str(isl_ctx
*ctx
,
191 const char *str
, int nparam
);
192 #define ISL_FORMAT_ISL 0
193 #define ISL_FORMAT_POLYLIB 1
194 #define ISL_FORMAT_OMEGA 3
195 void isl_basic_map_print(__isl_keep isl_basic_map
*bmap
, FILE *out
, int indent
,
196 const char *prefix
, const char *suffix
, unsigned output_format
);
197 void isl_map_print(__isl_keep isl_map
*map
, FILE *out
, int indent
,
198 unsigned output_format
);
199 struct isl_basic_map
*isl_basic_map_fix_si(struct isl_basic_map
*bmap
,
200 enum isl_dim_type type
, unsigned pos
, int value
);
201 __isl_give isl_basic_map
*isl_basic_map_lower_bound_si(
202 __isl_take isl_basic_map
*bmap
,
203 enum isl_dim_type type
, unsigned pos
, int value
);
205 struct isl_basic_map
*isl_basic_map_sum(
206 struct isl_basic_map
*bmap1
, struct isl_basic_map
*bmap2
);
207 struct isl_basic_map
*isl_basic_map_neg(struct isl_basic_map
*bmap
);
208 struct isl_basic_map
*isl_basic_map_floordiv(struct isl_basic_map
*bmap
,
211 struct isl_map
*isl_map_sum(struct isl_map
*map1
, struct isl_map
*map2
);
212 struct isl_map
*isl_map_neg(struct isl_map
*map
);
213 struct isl_map
*isl_map_floordiv(struct isl_map
*map
, isl_int d
);
215 int isl_basic_map_is_equal(
216 __isl_keep isl_basic_map
*bmap1
,
217 __isl_keep isl_basic_map
*bmap2
);
219 __isl_give isl_map
*isl_basic_map_partial_lexmax(
220 __isl_take isl_basic_map
*bmap
, __isl_take isl_basic_set
*dom
,
221 __isl_give isl_set
**empty
);
222 __isl_give isl_map
*isl_basic_map_partial_lexmin(
223 __isl_take isl_basic_map
*bmap
, __isl_take isl_basic_set
*dom
,
224 __isl_give isl_set
**empty
);
225 __isl_give isl_map
*isl_map_partial_lexmax(
226 __isl_take isl_map
*map
, __isl_take isl_set
*dom
,
227 __isl_give isl_set
**empty
);
228 __isl_give isl_map
*isl_map_partial_lexmin(
229 __isl_take isl_map
*map
, __isl_take isl_set
*dom
,
230 __isl_give isl_set
**empty
);
231 __isl_give isl_map
*isl_basic_map_lexmin(__isl_take isl_basic_map
*bmap
);
232 __isl_give isl_map
*isl_basic_map_lexmax(__isl_take isl_basic_map
*bmap
);
233 __isl_give isl_map
*isl_map_lexmin(__isl_take isl_map
*map
);
234 __isl_give isl_map
*isl_map_lexmax(__isl_take isl_map
*map
);
235 int isl_basic_map_foreach_lexmin(__isl_keep isl_basic_map
*bmap
,
236 int (*fn
)(__isl_take isl_basic_set
*dom
, __isl_take isl_mat
*map
,
240 void isl_basic_map_dump(__isl_keep isl_basic_map
*bmap
, FILE *out
, int indent
);
242 struct isl_basic_map
*isl_map_copy_basic_map(struct isl_map
*map
);
243 __isl_give isl_map
*isl_map_drop_basic_map(__isl_take isl_map
*map
,
244 __isl_keep isl_basic_map
*bmap
);
246 int isl_basic_map_fast_is_fixed(struct isl_basic_map
*bmap
,
247 enum isl_dim_type type
, unsigned pos
, isl_int
*val
);
249 int isl_basic_map_is_universe(__isl_keep isl_basic_map
*bmap
);
250 int isl_basic_map_fast_is_empty(__isl_keep isl_basic_map
*bmap
);
251 int isl_basic_map_is_empty(__isl_keep isl_basic_map
*bmap
);
252 int isl_basic_map_is_subset(__isl_keep isl_basic_map
*bmap1
,
253 __isl_keep isl_basic_map
*bmap2
);
254 int isl_basic_map_is_strict_subset(__isl_keep isl_basic_map
*bmap1
,
255 __isl_keep isl_basic_map
*bmap2
);
257 struct isl_map
*isl_map_alloc(struct isl_ctx
*ctx
,
258 unsigned nparam
, unsigned in
, unsigned out
, int n
,
260 __isl_give isl_map
*isl_map_universe(__isl_take isl_dim
*dim
);
261 __isl_give isl_map
*isl_map_empty(__isl_take isl_dim
*dim
);
262 struct isl_map
*isl_map_empty_like(struct isl_map
*model
);
263 struct isl_map
*isl_map_empty_like_basic_map(struct isl_basic_map
*model
);
264 struct isl_map
*isl_map_dup(struct isl_map
*map
);
265 __isl_give isl_map
*isl_map_add_basic_map(__isl_take isl_map
*map
,
266 __isl_take isl_basic_map
*bmap
);
267 __isl_give isl_map
*isl_map_identity(__isl_take isl_dim
*set_dim
);
268 struct isl_map
*isl_map_identity_like(struct isl_map
*model
);
269 struct isl_map
*isl_map_identity_like_basic_map(struct isl_basic_map
*model
);
270 __isl_give isl_map
*isl_map_lex_lt(__isl_take isl_dim
*set_dim
);
271 __isl_give isl_map
*isl_map_lex_le(__isl_take isl_dim
*set_dim
);
272 __isl_give isl_map
*isl_map_lex_gt(__isl_take isl_dim
*set_dim
);
273 __isl_give isl_map
*isl_map_lex_ge(__isl_take isl_dim
*set_dim
);
274 struct isl_map
*isl_map_finalize(struct isl_map
*map
);
275 void isl_map_free(__isl_take isl_map
*map
);
276 __isl_give isl_map
*isl_map_copy(__isl_keep isl_map
*map
);
277 struct isl_map
*isl_map_extend(struct isl_map
*base
,
278 unsigned nparam
, unsigned n_in
, unsigned n_out
);
279 struct isl_map
*isl_map_reverse(struct isl_map
*map
);
280 __isl_give isl_map
*isl_map_union(
281 __isl_take isl_map
*map1
,
282 __isl_take isl_map
*map2
);
283 struct isl_map
*isl_map_union_disjoint(
284 struct isl_map
*map1
, struct isl_map
*map2
);
285 __isl_give isl_map
*isl_map_intersect_domain(
286 __isl_take isl_map
*map
,
287 __isl_take isl_set
*set
);
288 __isl_give isl_map
*isl_map_intersect_range(
289 __isl_take isl_map
*map
,
290 __isl_take isl_set
*set
);
291 __isl_give isl_map
*isl_map_apply_domain(
292 __isl_take isl_map
*map1
,
293 __isl_take isl_map
*map2
);
294 __isl_give isl_map
*isl_map_apply_range(
295 __isl_take isl_map
*map1
,
296 __isl_take isl_map
*map2
);
297 struct isl_map
*isl_map_product(struct isl_map
*map1
, struct isl_map
*map2
);
298 __isl_give isl_map
*isl_map_intersect(__isl_take isl_map
*map1
,
299 __isl_take isl_map
*map2
);
300 __isl_give isl_map
*isl_map_subtract(
301 __isl_take isl_map
*map1
,
302 __isl_take isl_map
*map2
);
303 struct isl_map
*isl_map_fix_input_si(struct isl_map
*map
,
304 unsigned input
, int value
);
305 struct isl_map
*isl_map_fix_si(struct isl_map
*map
,
306 enum isl_dim_type type
, unsigned pos
, int value
);
307 __isl_give isl_map
*isl_map_lower_bound_si(__isl_take isl_map
*map
,
308 enum isl_dim_type type
, unsigned pos
, int value
);
309 struct isl_basic_set
*isl_basic_map_deltas(struct isl_basic_map
*bmap
);
310 struct isl_set
*isl_map_deltas(struct isl_map
*map
);
311 struct isl_map
*isl_map_detect_equalities(struct isl_map
*map
);
312 __isl_give isl_basic_map
*isl_map_affine_hull(__isl_take isl_map
*map
);
313 __isl_give isl_basic_map
*isl_map_convex_hull(__isl_take isl_map
*map
);
314 __isl_give isl_basic_map
*isl_basic_map_add(__isl_take isl_basic_map
*bmap
,
315 enum isl_dim_type type
, unsigned n
);
316 __isl_give isl_map
*isl_map_add(__isl_take isl_map
*map
,
317 enum isl_dim_type type
, unsigned n
);
318 __isl_give isl_basic_map
*isl_basic_map_project_out(
319 __isl_take isl_basic_map
*bmap
,
320 enum isl_dim_type type
, unsigned first
, unsigned n
);
321 __isl_give isl_map
*isl_map_project_out(__isl_take isl_map
*map
,
322 enum isl_dim_type type
, unsigned first
, unsigned n
);
323 struct isl_map
*isl_map_remove(struct isl_map
*map
,
324 enum isl_dim_type type
, unsigned first
, unsigned n
);
325 struct isl_map
*isl_map_remove_inputs(struct isl_map
*map
,
326 unsigned first
, unsigned n
);
328 __isl_give isl_set
*isl_map_domain(__isl_take isl_map
*bmap
);
329 __isl_give isl_set
*isl_map_range(__isl_take isl_map
*map
);
330 __isl_give isl_map
*isl_map_from_basic_map(__isl_take isl_basic_map
*bmap
);
331 __isl_give isl_map
*isl_map_from_domain(__isl_take isl_set
*set
);
332 struct isl_map
*isl_map_from_range(struct isl_set
*set
);
333 __isl_give isl_map
*isl_map_from_domain_and_range(__isl_take isl_set
*domain
,
334 __isl_take isl_set
*range
);
335 struct isl_map
*isl_map_from_set(struct isl_set
*set
, struct isl_dim
*dim
);
336 struct isl_set
*isl_set_from_map(struct isl_map
*map
);
337 __isl_give isl_basic_map
*isl_map_sample(__isl_take isl_map
*map
);
339 int isl_map_fast_is_empty(__isl_keep isl_map
*map
);
340 int isl_map_fast_is_universe(__isl_keep isl_map
*map
);
341 int isl_map_is_empty(__isl_keep isl_map
*map
);
342 int isl_map_is_subset(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
343 int isl_map_is_strict_subset(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
344 int isl_map_is_equal(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
346 __isl_give isl_map
*isl_basic_map_compute_divs(__isl_take isl_basic_map
*bmap
);
347 __isl_give isl_map
*isl_map_compute_divs(__isl_take isl_map
*map
);
348 __isl_give isl_map
*isl_map_align_divs(__isl_take isl_map
*map
);
350 void isl_map_dump(__isl_keep isl_map
*map
, FILE *out
, int indent
);
352 int isl_map_fast_input_is_fixed(struct isl_map
*map
,
353 unsigned in
, isl_int
*val
);
354 int isl_map_fast_is_fixed(struct isl_map
*map
,
355 enum isl_dim_type type
, unsigned pos
, isl_int
*val
);
357 __isl_give isl_basic_map
*isl_basic_map_gist(__isl_take isl_basic_map
*bmap
,
358 __isl_take isl_basic_map
*context
);
360 __isl_give isl_map
*isl_map_coalesce(__isl_take isl_map
*map
);
362 int isl_map_fast_is_equal(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
364 int isl_map_foreach_basic_map(__isl_keep isl_map
*map
,
365 int (*fn
)(__isl_take isl_basic_map
*bmap
, void *user
), void *user
);
367 __isl_give isl_map
*isl_set_lifting(__isl_take isl_set
*set
);
369 __isl_give isl_map
*isl_map_power(__isl_take isl_map
*map
, unsigned param
,
371 __isl_give isl_map
*isl_map_transitive_closure(__isl_take isl_map
*map
,
374 #if defined(__cplusplus)