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
, unsigned nparam
);
186 struct isl_basic_map
*isl_basic_map_fix_si(struct isl_basic_map
*bmap
,
187 enum isl_dim_type type
, unsigned pos
, int value
);
189 struct isl_basic_map
*isl_basic_map_sum(
190 struct isl_basic_map
*bmap1
, struct isl_basic_map
*bmap2
);
191 struct isl_basic_map
*isl_basic_map_neg(struct isl_basic_map
*bmap
);
192 struct isl_basic_map
*isl_basic_map_floordiv(struct isl_basic_map
*bmap
,
195 struct isl_map
*isl_map_sum(struct isl_map
*map1
, struct isl_map
*map2
);
196 struct isl_map
*isl_map_neg(struct isl_map
*map
);
197 struct isl_map
*isl_map_floordiv(struct isl_map
*map
, isl_int d
);
199 int isl_basic_map_is_equal(
200 __isl_keep isl_basic_map
*bmap1
,
201 __isl_keep isl_basic_map
*bmap2
);
203 __isl_give isl_map
*isl_basic_map_partial_lexmax(
204 __isl_take isl_basic_map
*bmap
, __isl_take isl_basic_set
*dom
,
205 __isl_give isl_set
**empty
);
206 __isl_give isl_map
*isl_basic_map_partial_lexmin(
207 __isl_take isl_basic_map
*bmap
, __isl_take isl_basic_set
*dom
,
208 __isl_give isl_set
**empty
);
209 __isl_give isl_map
*isl_basic_map_lexmin(__isl_take isl_basic_map
*bmap
);
210 __isl_give isl_map
*isl_basic_map_lexmax(__isl_take isl_basic_map
*bmap
);
211 int isl_basic_map_foreach_lexmin(__isl_keep isl_basic_map
*bmap
,
212 int (*fn
)(__isl_take isl_basic_set
*dom
, __isl_take isl_mat
*map
,
216 void isl_basic_map_dump(__isl_keep isl_basic_map
*bmap
, FILE *out
, int indent
);
218 struct isl_basic_map
*isl_map_copy_basic_map(struct isl_map
*map
);
219 __isl_give isl_map
*isl_map_drop_basic_map(__isl_take isl_map
*map
,
220 __isl_keep isl_basic_map
*bmap
);
222 int isl_basic_map_fast_is_fixed(struct isl_basic_map
*bmap
,
223 enum isl_dim_type type
, unsigned pos
, isl_int
*val
);
225 int isl_basic_map_is_universe(__isl_keep isl_basic_map
*bmap
);
226 int isl_basic_map_fast_is_empty(__isl_keep isl_basic_map
*bmap
);
227 int isl_basic_map_is_empty(__isl_keep isl_basic_map
*bmap
);
228 int isl_basic_map_is_subset(__isl_keep isl_basic_map
*bmap1
,
229 __isl_keep isl_basic_map
*bmap2
);
230 int isl_basic_map_is_strict_subset(__isl_keep isl_basic_map
*bmap1
,
231 __isl_keep isl_basic_map
*bmap2
);
233 struct isl_map
*isl_map_alloc(struct isl_ctx
*ctx
,
234 unsigned nparam
, unsigned in
, unsigned out
, int n
,
236 __isl_give isl_map
*isl_map_universe(__isl_take isl_dim
*dim
);
237 __isl_give isl_map
*isl_map_empty(__isl_take isl_dim
*dim
);
238 struct isl_map
*isl_map_empty_like(struct isl_map
*model
);
239 struct isl_map
*isl_map_empty_like_basic_map(struct isl_basic_map
*model
);
240 struct isl_map
*isl_map_dup(struct isl_map
*map
);
241 struct isl_map
*isl_map_add(struct isl_map
*map
, struct isl_basic_map
*bmap
);
242 __isl_give isl_map
*isl_map_identity(__isl_take isl_dim
*set_dim
);
243 struct isl_map
*isl_map_identity_like(struct isl_map
*model
);
244 struct isl_map
*isl_map_identity_like_basic_map(struct isl_basic_map
*model
);
245 __isl_give isl_map
*isl_map_lex_lt(__isl_take isl_dim
*set_dim
);
246 __isl_give isl_map
*isl_map_lex_le(__isl_take isl_dim
*set_dim
);
247 __isl_give isl_map
*isl_map_lex_gt(__isl_take isl_dim
*set_dim
);
248 __isl_give isl_map
*isl_map_lex_ge(__isl_take isl_dim
*set_dim
);
249 struct isl_map
*isl_map_finalize(struct isl_map
*map
);
250 void isl_map_free(__isl_take isl_map
*map
);
251 __isl_give isl_map
*isl_map_copy(__isl_keep isl_map
*map
);
252 struct isl_map
*isl_map_extend(struct isl_map
*base
,
253 unsigned nparam
, unsigned n_in
, unsigned n_out
);
254 struct isl_map
*isl_map_reverse(struct isl_map
*map
);
255 __isl_give isl_map
*isl_map_union(
256 __isl_take isl_map
*map1
,
257 __isl_take isl_map
*map2
);
258 struct isl_map
*isl_map_union_disjoint(
259 struct isl_map
*map1
, struct isl_map
*map2
);
260 __isl_give isl_map
*isl_map_intersect_domain(
261 __isl_take isl_map
*map
,
262 __isl_take isl_set
*set
);
263 __isl_give isl_map
*isl_map_intersect_range(
264 __isl_take isl_map
*map
,
265 __isl_take isl_set
*set
);
266 __isl_give isl_map
*isl_map_apply_domain(
267 __isl_take isl_map
*map1
,
268 __isl_take isl_map
*map2
);
269 __isl_give isl_map
*isl_map_apply_range(
270 __isl_take isl_map
*map1
,
271 __isl_take isl_map
*map2
);
272 struct isl_map
*isl_map_product(struct isl_map
*map1
, struct isl_map
*map2
);
273 __isl_give isl_map
*isl_map_intersect(__isl_take isl_map
*map1
,
274 __isl_take isl_map
*map2
);
275 __isl_give isl_map
*isl_map_subtract(
276 __isl_take isl_map
*map1
,
277 __isl_take isl_map
*map2
);
278 struct isl_map
*isl_map_fix_input_si(struct isl_map
*map
,
279 unsigned input
, int value
);
280 struct isl_map
*isl_map_fix_si(struct isl_map
*map
,
281 enum isl_dim_type type
, unsigned pos
, int value
);
282 struct isl_basic_set
*isl_basic_map_deltas(struct isl_basic_map
*bmap
);
283 struct isl_set
*isl_map_deltas(struct isl_map
*map
);
284 struct isl_map
*isl_map_detect_equalities(struct isl_map
*map
);
285 __isl_give isl_basic_map
*isl_map_affine_hull(__isl_take isl_map
*map
);
286 __isl_give isl_basic_map
*isl_map_convex_hull(__isl_take isl_map
*map
);
287 struct isl_map
*isl_map_remove(struct isl_map
*map
,
288 enum isl_dim_type type
, unsigned first
, unsigned n
);
289 struct isl_map
*isl_map_remove_inputs(struct isl_map
*map
,
290 unsigned first
, unsigned n
);
292 __isl_give isl_set
*isl_map_domain(__isl_take isl_map
*bmap
);
293 __isl_give isl_set
*isl_map_range(__isl_take isl_map
*map
);
294 __isl_give isl_map
*isl_map_from_basic_map(__isl_take isl_basic_map
*bmap
);
295 struct isl_map
*isl_map_from_range(struct isl_set
*set
);
296 struct isl_map
*isl_map_from_set(struct isl_set
*set
, struct isl_dim
*dim
);
297 struct isl_set
*isl_set_from_map(struct isl_map
*map
);
298 __isl_give isl_basic_map
*isl_map_sample(__isl_take isl_map
*map
);
300 int isl_map_fast_is_empty(__isl_keep isl_map
*map
);
301 int isl_map_fast_is_universe(__isl_keep isl_map
*map
);
302 int isl_map_is_empty(__isl_keep isl_map
*map
);
303 int isl_map_is_subset(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
304 int isl_map_is_strict_subset(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
305 int isl_map_is_equal(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
307 void isl_map_dump(__isl_keep isl_map
*map
, FILE *out
, int indent
);
309 int isl_map_fast_input_is_fixed(struct isl_map
*map
,
310 unsigned in
, isl_int
*val
);
311 int isl_map_fast_is_fixed(struct isl_map
*map
,
312 enum isl_dim_type type
, unsigned pos
, isl_int
*val
);
314 __isl_give isl_basic_map
*isl_basic_map_gist(__isl_take isl_basic_map
*bmap
,
315 __isl_take isl_basic_map
*context
);
317 __isl_give isl_map
*isl_map_coalesce(__isl_take isl_map
*map
);
319 int isl_map_fast_is_equal(__isl_keep isl_map
*map1
, __isl_keep isl_map
*map2
);
321 int isl_map_foreach_basic_map(__isl_keep isl_map
*map
,
322 int (*fn
)(__isl_take isl_basic_map
*bmap
, void *user
), void *user
);
324 __isl_give isl_map
*isl_set_lifting(__isl_take isl_set
*set
);
326 #if defined(__cplusplus)