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