3 C<isl> is a thread-safe C library for manipulating
4 sets and relations of integer points bounded by affine constraints.
5 The descriptions of the sets and relations may involve
6 both parameters and existentially quantified variables.
7 All computations are performed in exact integer arithmetic
9 The C<isl> library offers functionality that is similar
10 to that offered by the C<Omega> and C<Omega+> libraries,
11 but the underlying algorithms are in most cases completely different.
13 The library is by no means complete and some fairly basic
14 functionality is still missing.
15 Still, even in its current form, the library has been successfully
16 used as a backend polyhedral library for the polyhedral
17 scanner C<CLooG> and as part of an equivalence checker of
18 static affine programs.
19 For bug reports, feature requests and questions,
20 visit the the discussion group at
21 L<http://groups.google.com/group/isl-development>.
23 =head2 Backward Incompatible Changes
25 =head3 Changes since isl-0.02
29 =item * The old printing functions have been deprecated
30 and replaced by C<isl_printer> functions, see L<Input and Output>.
32 =item * Most functions related to dependence analysis have acquired
33 an extra C<must> argument. To obtain the old behavior, this argument
34 should be given the value 1. See L<Dependence Analysis>.
40 The source of C<isl> can be obtained either as a tarball
41 or from the git repository. Both are available from
42 L<http://freshmeat.net/projects/isl/>.
43 The installation process depends on how you obtained
46 =head2 Installation from the git repository
50 =item 1 Clone or update the repository
52 The first time the source is obtained, you need to clone
55 git clone git://repo.or.cz/isl.git
57 To obtain updates, you need to pull in the latest changes
61 =item 2 Generate C<configure>
67 After performing the above steps, continue
68 with the L<Common installation instructions>.
70 =head2 Common installation instructions
76 Building C<isl> requires C<GMP>, including its headers files.
77 Your distribution may not provide these header files by default
78 and you may need to install a package called C<gmp-devel> or something
79 similar. Alternatively, C<GMP> can be built from
80 source, available from L<http://gmplib.org/>.
84 C<isl> uses the standard C<autoconf> C<configure> script.
89 optionally followed by some configure options.
90 A complete list of options can be obtained by running
94 Below we discuss some of the more common options.
96 C<isl> can optionally use C<piplib>, but no
97 C<piplib> functionality is currently used by default.
98 The C<--with-piplib> option can
99 be used to specify which C<piplib>
100 library to use, either an installed version (C<system>),
101 an externally built version (C<build>)
102 or no version (C<no>). The option C<build> is mostly useful
103 in C<configure> scripts of larger projects that bundle both C<isl>
110 Installation prefix for C<isl>
112 =item C<--with-gmp-prefix>
114 Installation prefix for C<GMP> (architecture-independent files).
116 =item C<--with-gmp-exec-prefix>
118 Installation prefix for C<GMP> (architecture-dependent files).
120 =item C<--with-piplib>
122 Which copy of C<piplib> to use, either C<no> (default), C<system> or C<build>.
124 =item C<--with-piplib-prefix>
126 Installation prefix for C<system> C<piplib> (architecture-independent files).
128 =item C<--with-piplib-exec-prefix>
130 Installation prefix for C<system> C<piplib> (architecture-dependent files).
132 =item C<--with-piplib-builddir>
134 Location where C<build> C<piplib> was built.
142 =item 4 Install (optional)
150 =head2 Initialization
152 All manipulations of integer sets and relations occur within
153 the context of an C<isl_ctx>.
154 A given C<isl_ctx> can only be used within a single thread.
155 All arguments of a function are required to have been allocated
156 within the same context.
157 There are currently no functions available for moving an object
158 from one C<isl_ctx> to another C<isl_ctx>. This means that
159 there is currently no way of safely moving an object from one
160 thread to another, unless the whole C<isl_ctx> is moved.
162 An C<isl_ctx> can be allocated using C<isl_ctx_alloc> and
163 freed using C<isl_ctx_free>.
164 All objects allocated within an C<isl_ctx> should be freed
165 before the C<isl_ctx> itself is freed.
167 isl_ctx *isl_ctx_alloc();
168 void isl_ctx_free(isl_ctx *ctx);
172 All operations on integers, mainly the coefficients
173 of the constraints describing the sets and relations,
174 are performed in exact integer arithmetic using C<GMP>.
175 However, to allow future versions of C<isl> to optionally
176 support fixed integer arithmetic, all calls to C<GMP>
177 are wrapped inside C<isl> specific macros.
178 The basic type is C<isl_int> and the following operations
179 are available on this type.
180 The meanings of these operations are essentially the same
181 as their C<GMP> C<mpz_> counterparts.
182 As always with C<GMP> types, C<isl_int>s need to be
183 initialized with C<isl_int_init> before they can be used
184 and they need to be released with C<isl_int_clear>
189 =item isl_int_init(i)
191 =item isl_int_clear(i)
193 =item isl_int_set(r,i)
195 =item isl_int_set_si(r,i)
197 =item isl_int_abs(r,i)
199 =item isl_int_neg(r,i)
201 =item isl_int_swap(i,j)
203 =item isl_int_swap_or_set(i,j)
205 =item isl_int_add_ui(r,i,j)
207 =item isl_int_sub_ui(r,i,j)
209 =item isl_int_add(r,i,j)
211 =item isl_int_sub(r,i,j)
213 =item isl_int_mul(r,i,j)
215 =item isl_int_mul_ui(r,i,j)
217 =item isl_int_addmul(r,i,j)
219 =item isl_int_submul(r,i,j)
221 =item isl_int_gcd(r,i,j)
223 =item isl_int_lcm(r,i,j)
225 =item isl_int_divexact(r,i,j)
227 =item isl_int_cdiv_q(r,i,j)
229 =item isl_int_fdiv_q(r,i,j)
231 =item isl_int_fdiv_r(r,i,j)
233 =item isl_int_fdiv_q_ui(r,i,j)
235 =item isl_int_read(r,s)
237 =item isl_int_print(out,i,width)
241 =item isl_int_cmp(i,j)
243 =item isl_int_cmp_si(i,si)
245 =item isl_int_eq(i,j)
247 =item isl_int_ne(i,j)
249 =item isl_int_lt(i,j)
251 =item isl_int_le(i,j)
253 =item isl_int_gt(i,j)
255 =item isl_int_ge(i,j)
257 =item isl_int_abs_eq(i,j)
259 =item isl_int_abs_ne(i,j)
261 =item isl_int_abs_lt(i,j)
263 =item isl_int_abs_gt(i,j)
265 =item isl_int_abs_ge(i,j)
267 =item isl_int_is_zero(i)
269 =item isl_int_is_one(i)
271 =item isl_int_is_negone(i)
273 =item isl_int_is_pos(i)
275 =item isl_int_is_neg(i)
277 =item isl_int_is_nonpos(i)
279 =item isl_int_is_nonneg(i)
281 =item isl_int_is_divisible_by(i,j)
285 =head2 Sets and Relations
287 C<isl> uses six types of objects for representing sets and relations,
288 C<isl_basic_set>, C<isl_basic_map>, C<isl_set>, C<isl_map>,
289 C<isl_union_set> and C<isl_union_map>.
290 C<isl_basic_set> and C<isl_basic_map> represent sets and relations that
291 can be described as a conjunction of affine constraints, while
292 C<isl_set> and C<isl_map> represent unions of
293 C<isl_basic_set>s and C<isl_basic_map>s, respectively.
294 However, all C<isl_basic_set>s or C<isl_basic_map>s in the union need
295 to have the same dimension. C<isl_union_set>s and C<isl_union_map>s
296 represent unions of C<isl_set>s or C<isl_map>s of I<different> dimensions,
297 where dimensions with different space names
298 (see L<Dimension Specifications>) are considered different as well.
299 The difference between sets and relations (maps) is that sets have
300 one set of variables, while relations have two sets of variables,
301 input variables and output variables.
303 =head2 Memory Management
305 Since a high-level operation on sets and/or relations usually involves
306 several substeps and since the user is usually not interested in
307 the intermediate results, most functions that return a new object
308 will also release all the objects passed as arguments.
309 If the user still wants to use one or more of these arguments
310 after the function call, she should pass along a copy of the
311 object rather than the object itself.
312 The user is then responsible for make sure that the original
313 object gets used somewhere else or is explicitly freed.
315 The arguments and return values of all documents functions are
316 annotated to make clear which arguments are released and which
317 arguments are preserved. In particular, the following annotations
324 C<__isl_give> means that a new object is returned.
325 The user should make sure that the returned pointer is
326 used exactly once as a value for an C<__isl_take> argument.
327 In between, it can be used as a value for as many
328 C<__isl_keep> arguments as the user likes.
329 There is one exception, and that is the case where the
330 pointer returned is C<NULL>. Is this case, the user
331 is free to use it as an C<__isl_take> argument or not.
335 C<__isl_take> means that the object the argument points to
336 is taken over by the function and may no longer be used
337 by the user as an argument to any other function.
338 The pointer value must be one returned by a function
339 returning an C<__isl_give> pointer.
340 If the user passes in a C<NULL> value, then this will
341 be treated as an error in the sense that the function will
342 not perform its usual operation. However, it will still
343 make sure that all the the other C<__isl_take> arguments
348 C<__isl_keep> means that the function will only use the object
349 temporarily. After the function has finished, the user
350 can still use it as an argument to other functions.
351 A C<NULL> value will be treated in the same way as
352 a C<NULL> value for an C<__isl_take> argument.
356 =head2 Dimension Specifications
358 Whenever a new set or relation is created from scratch,
359 its dimension needs to be specified using an C<isl_dim>.
362 __isl_give isl_dim *isl_dim_alloc(isl_ctx *ctx,
363 unsigned nparam, unsigned n_in, unsigned n_out);
364 __isl_give isl_dim *isl_dim_set_alloc(isl_ctx *ctx,
365 unsigned nparam, unsigned dim);
366 __isl_give isl_dim *isl_dim_copy(__isl_keep isl_dim *dim);
367 void isl_dim_free(__isl_take isl_dim *dim);
368 unsigned isl_dim_size(__isl_keep isl_dim *dim,
369 enum isl_dim_type type);
371 The dimension specification used for creating a set
372 needs to be created using C<isl_dim_set_alloc>, while
373 that for creating a relation
374 needs to be created using C<isl_dim_alloc>.
375 C<isl_dim_size> can be used
376 to find out the number of dimensions of each type in
377 a dimension specification, where type may be
378 C<isl_dim_param>, C<isl_dim_in> (only for relations),
379 C<isl_dim_out> (only for relations), C<isl_dim_set>
380 (only for sets) or C<isl_dim_all>.
382 It is often useful to create objects that live in the
383 same space as some other object. This can be accomplished
384 by creating the new objects
385 (see L<Creating New Sets and Relations> or
386 L<Creating New (Piecewise) Quasipolynomials>) based on the dimension
387 specification of the original object.
390 __isl_give isl_dim *isl_basic_set_get_dim(
391 __isl_keep isl_basic_set *bset);
392 __isl_give isl_dim *isl_set_get_dim(__isl_keep isl_set *set);
394 #include <isl_union_set.h>
395 __isl_give isl_dim *isl_union_set_get_dim(
396 __isl_keep isl_union_set *uset);
399 __isl_give isl_dim *isl_basic_map_get_dim(
400 __isl_keep isl_basic_map *bmap);
401 __isl_give isl_dim *isl_map_get_dim(__isl_keep isl_map *map);
403 #include <isl_union_map.h>
404 __isl_give isl_dim *isl_union_map_get_dim(
405 __isl_keep isl_union_map *umap);
407 #include <isl_polynomial.h>
408 __isl_give isl_dim *isl_qpolynomial_get_dim(
409 __isl_keep isl_qpolynomial *qp);
410 __isl_give isl_dim *isl_pw_qpolynomial_get_dim(
411 __isl_keep isl_pw_qpolynomial *pwqp);
412 __isl_give isl_dim *isl_union_pw_qpolynomial_get_dim(
413 __isl_keep isl_union_pw_qpolynomial *upwqp);
414 __isl_give isl_dim *isl_union_pw_qpolynomial_fold_get_dim(
415 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
417 The names of the individual dimensions may be set or read off
418 using the following functions.
421 __isl_give isl_dim *isl_dim_set_name(__isl_take isl_dim *dim,
422 enum isl_dim_type type, unsigned pos,
423 __isl_keep const char *name);
424 __isl_keep const char *isl_dim_get_name(__isl_keep isl_dim *dim,
425 enum isl_dim_type type, unsigned pos);
427 Note that C<isl_dim_get_name> returns a pointer to some internal
428 data structure, so the result can only be used while the
429 corresponding C<isl_dim> is alive.
430 Also note that every function that operates on two sets or relations
431 requires that both arguments have the same parameters. This also
432 means that if one of the arguments has named parameters, then the
433 other needs to have named parameters too and the names need to match.
435 The names of entire spaces may be set or read off
436 using the following functions.
439 __isl_give isl_dim *isl_dim_set_tuple_name(
440 __isl_take isl_dim *dim,
441 enum isl_dim_type type, const char *s);
442 const char *isl_dim_get_tuple_name(__isl_keep isl_dim *dim,
443 enum isl_dim_type type);
445 The C<dim> argument needs to be one of C<isl_dim_in>, C<isl_dim_out>
446 or C<isl_dim_set>. As with C<isl_dim_get_name>,
447 the C<isl_dim_get_tuple_name> function returns a pointer to some internal
449 Binary operations require the corresponding spaces of their arguments
450 to have the same name.
452 Spaces can be nested. In particular, the domain of a set or
453 the domain or range of a relation can be a nested relation.
454 The following functions can be used to construct and deconstruct
455 such nested dimension specifications.
458 int isl_dim_is_wrapping(__isl_keep isl_dim *dim);
459 __isl_give isl_dim *isl_dim_wrap(__isl_take isl_dim *dim);
460 __isl_give isl_dim *isl_dim_unwrap(__isl_take isl_dim *dim);
462 The input to C<isl_dim_is_wrapping> and C<isl_dim_unwrap> should
463 be the dimension specification of a set, while that of
464 C<isl_dim_wrap> should be the dimension specification of a relation.
465 Conversely, the output of C<isl_dim_unwrap> is the dimension specification
466 of a relation, while that of C<isl_dim_wrap> is the dimension specification
469 =head2 Input and Output
471 C<isl> supports its own input/output format, which is similar
472 to the C<Omega> format, but also supports the C<PolyLib> format
477 The C<isl> format is similar to that of C<Omega>, but has a different
478 syntax for describing the parameters and allows for the definition
479 of an existentially quantified variable as the integer division
480 of an affine expression.
481 For example, the set of integers C<i> between C<0> and C<n>
482 such that C<i % 10 <= 6> can be described as
484 [n] -> { [i] : exists (a = [i/10] : 0 <= i and i <= n and
487 A set or relation can have several disjuncts, separated
488 by the keyword C<or>. Each disjunct is either a conjunction
489 of constraints or a projection (C<exists>) of a conjunction
490 of constraints. The constraints are separated by the keyword
493 =head3 C<PolyLib> format
495 If the represented set is a union, then the first line
496 contains a single number representing the number of disjuncts.
497 Otherwise, a line containing the number C<1> is optional.
499 Each disjunct is represented by a matrix of constraints.
500 The first line contains two numbers representing
501 the number of rows and columns,
502 where the number of rows is equal to the number of constraints
503 and the number of columns is equal to two plus the number of variables.
504 The following lines contain the actual rows of the constraint matrix.
505 In each row, the first column indicates whether the constraint
506 is an equality (C<0>) or inequality (C<1>). The final column
507 corresponds to the constant term.
509 If the set is parametric, then the coefficients of the parameters
510 appear in the last columns before the constant column.
511 The coefficients of any existentially quantified variables appear
512 between those of the set variables and those of the parameters.
517 __isl_give isl_basic_set *isl_basic_set_read_from_file(
518 isl_ctx *ctx, FILE *input, int nparam);
519 __isl_give isl_basic_set *isl_basic_set_read_from_str(
520 isl_ctx *ctx, const char *str, int nparam);
521 __isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx,
522 FILE *input, int nparam);
523 __isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx,
524 const char *str, int nparam);
527 __isl_give isl_basic_map *isl_basic_map_read_from_file(
528 isl_ctx *ctx, FILE *input, int nparam);
529 __isl_give isl_basic_map *isl_basic_map_read_from_str(
530 isl_ctx *ctx, const char *str, int nparam);
531 __isl_give isl_map *isl_map_read_from_file(
532 struct isl_ctx *ctx, FILE *input, int nparam);
533 __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx,
534 const char *str, int nparam);
536 The input format is autodetected and may be either the C<PolyLib> format
537 or the C<isl> format.
538 C<nparam> specifies how many of the final columns in
539 the C<PolyLib> format correspond to parameters.
540 If input is given in the C<isl> format, then the number
541 of parameters needs to be equal to C<nparam>.
542 If C<nparam> is negative, then any number of parameters
543 is accepted in the C<isl> format and zero parameters
544 are assumed in the C<PolyLib> format.
548 Before anything can be printed, an C<isl_printer> needs to
551 __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx,
553 __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx);
554 void isl_printer_free(__isl_take isl_printer *printer);
555 __isl_give char *isl_printer_get_str(
556 __isl_keep isl_printer *printer);
558 The behavior of the printer can be modified in various ways
560 __isl_give isl_printer *isl_printer_set_output_format(
561 __isl_take isl_printer *p, int output_format);
562 __isl_give isl_printer *isl_printer_set_indent(
563 __isl_take isl_printer *p, int indent);
564 __isl_give isl_printer *isl_printer_set_prefix(
565 __isl_take isl_printer *p, const char *prefix);
566 __isl_give isl_printer *isl_printer_set_suffix(
567 __isl_take isl_printer *p, const char *suffix);
569 The C<output_format> may be either C<ISL_FORMAT_ISL>, C<ISL_FORMAT_OMEGA>
570 or C<ISL_FORMAT_POLYLIB> and defaults to C<ISL_FORMAT_ISL>.
571 Each line in the output is indented by C<indent> spaces
572 (default: 0), prefixed by C<prefix> and suffixed by C<suffix>.
573 In the C<PolyLib> format output,
574 the coefficients of the existentially quantified variables
575 appear between those of the set variables and those
578 To actually print something, use
581 __isl_give isl_printer *isl_printer_print_basic_set(
582 __isl_take isl_printer *printer,
583 __isl_keep isl_basic_set *bset);
584 __isl_give isl_printer *isl_printer_print_set(
585 __isl_take isl_printer *printer,
586 __isl_keep isl_set *set);
589 __isl_give isl_printer *isl_printer_print_basic_map(
590 __isl_take isl_printer *printer,
591 __isl_keep isl_basic_map *bmap);
592 __isl_give isl_printer *isl_printer_print_map(
593 __isl_take isl_printer *printer,
594 __isl_keep isl_map *map);
596 #include <isl_union_set.h>
597 __isl_give isl_printer *isl_printer_print_union_set(
598 __isl_take isl_printer *p,
599 __isl_keep isl_union_set *uset);
601 #include <isl_union_map.h>
602 __isl_give isl_printer *isl_printer_print_union_map(
603 __isl_take isl_printer *p,
604 __isl_keep isl_union_map *umap);
606 When called on a file printer, the following function flushes
607 the file. When called on a string printer, the buffer is cleared.
609 __isl_give isl_printer *isl_printer_flush(
610 __isl_take isl_printer *p);
612 =head2 Creating New Sets and Relations
614 C<isl> has functions for creating some standard sets and relations.
618 =item * Empty sets and relations
620 __isl_give isl_basic_set *isl_basic_set_empty(
621 __isl_take isl_dim *dim);
622 __isl_give isl_basic_map *isl_basic_map_empty(
623 __isl_take isl_dim *dim);
624 __isl_give isl_set *isl_set_empty(
625 __isl_take isl_dim *dim);
626 __isl_give isl_map *isl_map_empty(
627 __isl_take isl_dim *dim);
628 __isl_give isl_union_set *isl_union_set_empty(
629 __isl_take isl_dim *dim);
630 __isl_give isl_union_map *isl_union_map_empty(
631 __isl_take isl_dim *dim);
633 For C<isl_union_set>s and C<isl_union_map>s, the dimensions specification
634 is only used to specify the parameters.
636 =item * Universe sets and relations
638 __isl_give isl_basic_set *isl_basic_set_universe(
639 __isl_take isl_dim *dim);
640 __isl_give isl_basic_map *isl_basic_map_universe(
641 __isl_take isl_dim *dim);
642 __isl_give isl_set *isl_set_universe(
643 __isl_take isl_dim *dim);
644 __isl_give isl_map *isl_map_universe(
645 __isl_take isl_dim *dim);
647 =item * Identity relations
649 __isl_give isl_basic_map *isl_basic_map_identity(
650 __isl_take isl_dim *set_dim);
651 __isl_give isl_map *isl_map_identity(
652 __isl_take isl_dim *set_dim);
654 These functions take a dimension specification for a B<set>
655 and return an identity relation between two such sets.
657 =item * Lexicographic order
659 __isl_give isl_map *isl_map_lex_lt(
660 __isl_take isl_dim *set_dim);
661 __isl_give isl_map *isl_map_lex_le(
662 __isl_take isl_dim *set_dim);
663 __isl_give isl_map *isl_map_lex_gt(
664 __isl_take isl_dim *set_dim);
665 __isl_give isl_map *isl_map_lex_ge(
666 __isl_take isl_dim *set_dim);
667 __isl_give isl_map *isl_map_lex_lt_first(
668 __isl_take isl_dim *dim, unsigned n);
669 __isl_give isl_map *isl_map_lex_le_first(
670 __isl_take isl_dim *dim, unsigned n);
671 __isl_give isl_map *isl_map_lex_gt_first(
672 __isl_take isl_dim *dim, unsigned n);
673 __isl_give isl_map *isl_map_lex_ge_first(
674 __isl_take isl_dim *dim, unsigned n);
676 The first four functions take a dimension specification for a B<set>
677 and return relations that express that the elements in the domain
678 are lexicographically less
679 (C<isl_map_lex_lt>), less or equal (C<isl_map_lex_le>),
680 greater (C<isl_map_lex_gt>) or greater or equal (C<isl_map_lex_ge>)
681 than the elements in the range.
682 The last four functions take a dimension specification for a map
683 and return relations that express that the first C<n> dimensions
684 in the domain are lexicographically less
685 (C<isl_map_lex_lt_first>), less or equal (C<isl_map_lex_le_first>),
686 greater (C<isl_map_lex_gt_first>) or greater or equal (C<isl_map_lex_ge_first>)
687 than the first C<n> dimensions in the range.
691 A basic set or relation can be converted to a set or relation
692 using the following functions.
694 __isl_give isl_set *isl_set_from_basic_set(
695 __isl_take isl_basic_set *bset);
696 __isl_give isl_map *isl_map_from_basic_map(
697 __isl_take isl_basic_map *bmap);
699 Sets and relations can be converted to union sets and relations
700 using the following functions.
702 __isl_give isl_union_map *isl_union_map_from_map(
703 __isl_take isl_map *map);
704 __isl_give isl_union_set *isl_union_set_from_set(
705 __isl_take isl_set *set);
707 Sets and relations can be copied and freed again using the following
710 __isl_give isl_basic_set *isl_basic_set_copy(
711 __isl_keep isl_basic_set *bset);
712 __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set);
713 __isl_give isl_union_set *isl_union_set_copy(
714 __isl_keep isl_union_set *uset);
715 __isl_give isl_basic_map *isl_basic_map_copy(
716 __isl_keep isl_basic_map *bmap);
717 __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
718 __isl_give isl_union_map *isl_union_map_copy(
719 __isl_keep isl_union_map *umap);
720 void isl_basic_set_free(__isl_take isl_basic_set *bset);
721 void isl_set_free(__isl_take isl_set *set);
722 void isl_union_set_free(__isl_take isl_union_set *uset);
723 void isl_basic_map_free(__isl_take isl_basic_map *bmap);
724 void isl_map_free(__isl_take isl_map *map);
725 void isl_union_map_free(__isl_take isl_union_map *umap);
727 Other sets and relations can be constructed by starting
728 from a universe set or relation, adding equality and/or
729 inequality constraints and then projecting out the
730 existentially quantified variables, if any.
731 Constraints can be constructed, manipulated and
732 added to basic sets and relations using the following functions.
734 #include <isl_constraint.h>
735 __isl_give isl_constraint *isl_equality_alloc(
736 __isl_take isl_dim *dim);
737 __isl_give isl_constraint *isl_inequality_alloc(
738 __isl_take isl_dim *dim);
739 void isl_constraint_set_constant(
740 __isl_keep isl_constraint *constraint, isl_int v);
741 void isl_constraint_set_coefficient(
742 __isl_keep isl_constraint *constraint,
743 enum isl_dim_type type, int pos, isl_int v);
744 __isl_give isl_basic_map *isl_basic_map_add_constraint(
745 __isl_take isl_basic_map *bmap,
746 __isl_take isl_constraint *constraint);
747 __isl_give isl_basic_set *isl_basic_set_add_constraint(
748 __isl_take isl_basic_set *bset,
749 __isl_take isl_constraint *constraint);
751 For example, to create a set containing the even integers
752 between 10 and 42, you would use the following code.
756 struct isl_constraint *c;
757 struct isl_basic_set *bset;
760 dim = isl_dim_set_alloc(ctx, 0, 2);
761 bset = isl_basic_set_universe(isl_dim_copy(dim));
763 c = isl_equality_alloc(isl_dim_copy(dim));
764 isl_int_set_si(v, -1);
765 isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
766 isl_int_set_si(v, 2);
767 isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
768 bset = isl_basic_set_add_constraint(bset, c);
770 c = isl_inequality_alloc(isl_dim_copy(dim));
771 isl_int_set_si(v, -10);
772 isl_constraint_set_constant(c, v);
773 isl_int_set_si(v, 1);
774 isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
775 bset = isl_basic_set_add_constraint(bset, c);
777 c = isl_inequality_alloc(dim);
778 isl_int_set_si(v, 42);
779 isl_constraint_set_constant(c, v);
780 isl_int_set_si(v, -1);
781 isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
782 bset = isl_basic_set_add_constraint(bset, c);
784 bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 1);
790 struct isl_basic_set *bset;
791 bset = isl_basic_set_read_from_str(ctx,
792 "{[i] : exists (a : i = 2a and i >= 10 and i <= 42)}", -1);
794 =head2 Inspecting Sets and Relations
796 Usually, the user should not have to care about the actual constraints
797 of the sets and maps, but should instead apply the abstract operations
798 explained in the following sections.
799 Occasionally, however, it may be required to inspect the individual
800 coefficients of the constraints. This section explains how to do so.
801 In these cases, it may also be useful to have C<isl> compute
802 an explicit representation of the existentially quantified variables.
804 __isl_give isl_set *isl_set_compute_divs(
805 __isl_take isl_set *set);
806 __isl_give isl_map *isl_map_compute_divs(
807 __isl_take isl_map *map);
808 __isl_give isl_union_set *isl_union_set_compute_divs(
809 __isl_take isl_union_set *uset);
810 __isl_give isl_union_map *isl_union_map_compute_divs(
811 __isl_take isl_union_map *umap);
813 This explicit representation defines the existentially quantified
814 variables as integer divisions of the other variables, possibly
815 including earlier existentially quantified variables.
816 An explicitly represented existentially quantified variable therefore
817 has a unique value when the values of the other variables are known.
818 If, furthermore, the same existentials, i.e., existentials
819 with the same explicit representations, should appear in the
820 same order in each of the disjuncts of a set or map, then the user should call
821 either of the following functions.
823 __isl_give isl_set *isl_set_align_divs(
824 __isl_take isl_set *set);
825 __isl_give isl_map *isl_map_align_divs(
826 __isl_take isl_map *map);
828 To iterate over all the sets or maps in a union set or map, use
830 int isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
831 int (*fn)(__isl_take isl_set *set, void *user),
833 int isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
834 int (*fn)(__isl_take isl_map *map, void *user),
837 To iterate over all the basic sets or maps in a set or map, use
839 int isl_set_foreach_basic_set(__isl_keep isl_set *set,
840 int (*fn)(__isl_take isl_basic_set *bset, void *user),
842 int isl_map_foreach_basic_map(__isl_keep isl_map *map,
843 int (*fn)(__isl_take isl_basic_map *bmap, void *user),
846 The callback function C<fn> should return 0 if successful and
847 -1 if an error occurs. In the latter case, or if any other error
848 occurs, the above functions will return -1.
850 It should be noted that C<isl> does not guarantee that
851 the basic sets or maps passed to C<fn> are disjoint.
852 If this is required, then the user should call one of
853 the following functions first.
855 __isl_give isl_set *isl_set_make_disjoint(
856 __isl_take isl_set *set);
857 __isl_give isl_map *isl_map_make_disjoint(
858 __isl_take isl_map *map);
860 To iterate over the constraints of a basic set or map, use
862 #include <isl_constraint.h>
864 int isl_basic_map_foreach_constraint(
865 __isl_keep isl_basic_map *bmap,
866 int (*fn)(__isl_take isl_constraint *c, void *user),
868 void isl_constraint_free(struct isl_constraint *c);
870 Again, the callback function C<fn> should return 0 if successful and
871 -1 if an error occurs. In the latter case, or if any other error
872 occurs, the above functions will return -1.
873 The constraint C<c> represents either an equality or an inequality.
874 Use the following function to find out whether a constraint
875 represents an equality. If not, it represents an inequality.
877 int isl_constraint_is_equality(
878 __isl_keep isl_constraint *constraint);
880 The coefficients of the constraints can be inspected using
881 the following functions.
883 void isl_constraint_get_constant(
884 __isl_keep isl_constraint *constraint, isl_int *v);
885 void isl_constraint_get_coefficient(
886 __isl_keep isl_constraint *constraint,
887 enum isl_dim_type type, int pos, isl_int *v);
889 The explicit representations of the existentially quantified
890 variables can be inspected using the following functions.
891 Note that the user is only allowed to use these functions
892 if the inspected set or map is the result of a call
893 to C<isl_set_compute_divs> or C<isl_map_compute_divs>.
895 __isl_give isl_div *isl_constraint_div(
896 __isl_keep isl_constraint *constraint, int pos);
897 void isl_div_get_constant(__isl_keep isl_div *div,
899 void isl_div_get_denominator(__isl_keep isl_div *div,
901 void isl_div_get_coefficient(__isl_keep isl_div *div,
902 enum isl_dim_type type, int pos, isl_int *v);
906 =head3 Unary Properties
912 The following functions test whether the given set or relation
913 contains any integer points. The ``fast'' variants do not perform
914 any computations, but simply check if the given set or relation
915 is already known to be empty.
917 int isl_basic_set_fast_is_empty(__isl_keep isl_basic_set *bset);
918 int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
919 int isl_set_is_empty(__isl_keep isl_set *set);
920 int isl_union_set_is_empty(__isl_keep isl_union_set *uset);
921 int isl_basic_map_fast_is_empty(__isl_keep isl_basic_map *bmap);
922 int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
923 int isl_map_fast_is_empty(__isl_keep isl_map *map);
924 int isl_map_is_empty(__isl_keep isl_map *map);
925 int isl_union_map_is_empty(__isl_keep isl_union_map *umap);
929 int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
930 int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
931 int isl_set_fast_is_universe(__isl_keep isl_set *set);
933 =item * Single-valuedness
935 int isl_map_is_single_valued(__isl_keep isl_map *map);
939 int isl_map_is_bijective(__isl_keep isl_map *map);
943 The followning functions check whether the domain of the given
944 (basic) set is a wrapped relation.
946 int isl_basic_set_is_wrapping(
947 __isl_keep isl_basic_set *bset);
948 int isl_set_is_wrapping(__isl_keep isl_set *set);
952 =head3 Binary Properties
958 int isl_set_fast_is_equal(__isl_keep isl_set *set1,
959 __isl_keep isl_set *set2);
960 int isl_set_is_equal(__isl_keep isl_set *set1,
961 __isl_keep isl_set *set2);
962 int isl_basic_map_is_equal(
963 __isl_keep isl_basic_map *bmap1,
964 __isl_keep isl_basic_map *bmap2);
965 int isl_map_is_equal(__isl_keep isl_map *map1,
966 __isl_keep isl_map *map2);
967 int isl_map_fast_is_equal(__isl_keep isl_map *map1,
968 __isl_keep isl_map *map2);
969 int isl_union_map_is_equal(
970 __isl_keep isl_union_map *umap1,
971 __isl_keep isl_union_map *umap2);
975 int isl_set_fast_is_disjoint(__isl_keep isl_set *set1,
976 __isl_keep isl_set *set2);
980 int isl_set_is_subset(__isl_keep isl_set *set1,
981 __isl_keep isl_set *set2);
982 int isl_set_is_strict_subset(
983 __isl_keep isl_set *set1,
984 __isl_keep isl_set *set2);
985 int isl_basic_map_is_subset(
986 __isl_keep isl_basic_map *bmap1,
987 __isl_keep isl_basic_map *bmap2);
988 int isl_basic_map_is_strict_subset(
989 __isl_keep isl_basic_map *bmap1,
990 __isl_keep isl_basic_map *bmap2);
991 int isl_map_is_subset(
992 __isl_keep isl_map *map1,
993 __isl_keep isl_map *map2);
994 int isl_map_is_strict_subset(
995 __isl_keep isl_map *map1,
996 __isl_keep isl_map *map2);
997 int isl_union_map_is_subset(
998 __isl_keep isl_union_map *umap1,
999 __isl_keep isl_union_map *umap2);
1000 int isl_union_map_is_strict_subset(
1001 __isl_keep isl_union_map *umap1,
1002 __isl_keep isl_union_map *umap2);
1006 =head2 Unary Operations
1012 __isl_give isl_set *isl_set_complement(
1013 __isl_take isl_set *set);
1017 __isl_give isl_basic_map *isl_basic_map_reverse(
1018 __isl_take isl_basic_map *bmap);
1019 __isl_give isl_map *isl_map_reverse(
1020 __isl_take isl_map *map);
1021 __isl_give isl_union_map *isl_union_map_reverse(
1022 __isl_take isl_union_map *umap);
1026 __isl_give isl_basic_set *isl_basic_set_project_out(
1027 __isl_take isl_basic_set *bset,
1028 enum isl_dim_type type, unsigned first, unsigned n);
1029 __isl_give isl_basic_map *isl_basic_map_project_out(
1030 __isl_take isl_basic_map *bmap,
1031 enum isl_dim_type type, unsigned first, unsigned n);
1032 __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
1033 enum isl_dim_type type, unsigned first, unsigned n);
1034 __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
1035 enum isl_dim_type type, unsigned first, unsigned n);
1036 __isl_give isl_basic_set *isl_basic_map_domain(
1037 __isl_take isl_basic_map *bmap);
1038 __isl_give isl_basic_set *isl_basic_map_range(
1039 __isl_take isl_basic_map *bmap);
1040 __isl_give isl_set *isl_map_domain(
1041 __isl_take isl_map *bmap);
1042 __isl_give isl_set *isl_map_range(
1043 __isl_take isl_map *map);
1044 __isl_give isl_union_set *isl_union_map_domain(
1045 __isl_take isl_union_map *umap);
1046 __isl_give isl_union_set *isl_union_map_range(
1047 __isl_take isl_union_map *umap);
1051 __isl_give isl_basic_set *isl_basic_map_deltas(
1052 __isl_take isl_basic_map *bmap);
1053 __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
1054 __isl_give isl_union_set *isl_union_map_deltas(
1055 __isl_take isl_union_map *umap);
1057 These functions return a (basic) set containing the differences
1058 between image elements and corresponding domain elements in the input.
1062 Simplify the representation of a set or relation by trying
1063 to combine pairs of basic sets or relations into a single
1064 basic set or relation.
1066 __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
1067 __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
1068 __isl_give isl_union_set *isl_union_set_coalesce(
1069 __isl_take isl_union_set *uset);
1070 __isl_give isl_union_map *isl_union_map_coalesce(
1071 __isl_take isl_union_map *umap);
1075 __isl_give isl_basic_set *isl_set_convex_hull(
1076 __isl_take isl_set *set);
1077 __isl_give isl_basic_map *isl_map_convex_hull(
1078 __isl_take isl_map *map);
1080 If the input set or relation has any existentially quantified
1081 variables, then the result of these operations is currently undefined.
1085 __isl_give isl_basic_set *isl_set_simple_hull(
1086 __isl_take isl_set *set);
1087 __isl_give isl_basic_map *isl_map_simple_hull(
1088 __isl_take isl_map *map);
1090 These functions compute a single basic set or relation
1091 that contains the whole input set or relation.
1092 In particular, the output is described by translates
1093 of the constraints describing the basic sets or relations in the input.
1097 (See \autoref{s:simple hull}.)
1103 __isl_give isl_basic_set *isl_basic_set_affine_hull(
1104 __isl_take isl_basic_set *bset);
1105 __isl_give isl_basic_set *isl_set_affine_hull(
1106 __isl_take isl_set *set);
1107 __isl_give isl_union_set *isl_union_set_affine_hull(
1108 __isl_take isl_union_set *uset);
1109 __isl_give isl_basic_map *isl_basic_map_affine_hull(
1110 __isl_take isl_basic_map *bmap);
1111 __isl_give isl_basic_map *isl_map_affine_hull(
1112 __isl_take isl_map *map);
1113 __isl_give isl_union_map *isl_union_map_affine_hull(
1114 __isl_take isl_union_map *umap);
1116 In case of union sets and relations, the affine hull is computed
1121 __isl_give isl_map *isl_map_power(__isl_take isl_map *map,
1122 unsigned param, int *exact);
1124 Compute a parametric representation for all positive powers I<k> of C<map>.
1125 The power I<k> is equated to the parameter at position C<param>.
1126 The result may be an overapproximation. If the result is exact,
1127 then C<*exact> is set to C<1>.
1128 The current implementation only produces exact results for particular
1129 cases of piecewise translations (i.e., piecewise uniform dependences).
1131 =item * Transitive closure
1133 __isl_give isl_map *isl_map_transitive_closure(
1134 __isl_take isl_map *map, int *exact);
1135 __isl_give isl_union_map *isl_union_map_transitive_closure(
1136 __isl_take isl_union_map *umap, int *exact);
1138 Compute the transitive closure of C<map>.
1139 The result may be an overapproximation. If the result is known to be exact,
1140 then C<*exact> is set to C<1>.
1141 The current implementation only produces exact results for particular
1142 cases of piecewise translations (i.e., piecewise uniform dependences).
1144 =item * Reaching path lengths
1146 __isl_give isl_map *isl_map_reaching_path_lengths(
1147 __isl_take isl_map *map, int *exact);
1149 Compute a relation that maps each element in the range of C<map>
1150 to the lengths of all paths composed of edges in C<map> that
1151 end up in the given element.
1152 The result may be an overapproximation. If the result is known to be exact,
1153 then C<*exact> is set to C<1>.
1154 To compute the I<maximal> path length, the resulting relation
1155 should be postprocessed by C<isl_map_lexmax>.
1156 In particular, if the input relation is a dependence relation
1157 (mapping sources to sinks), then the maximal path length corresponds
1158 to the free schedule.
1159 Note, however, that C<isl_map_lexmax> expects the maximum to be
1160 finite, so if the path lengths are unbounded (possibly due to
1161 the overapproximation), then you will get an error message.
1165 __isl_give isl_basic_set *isl_basic_map_wrap(
1166 __isl_take isl_basic_map *bmap);
1167 __isl_give isl_set *isl_map_wrap(
1168 __isl_take isl_map *map);
1169 __isl_give isl_union_set *isl_union_map_wrap(
1170 __isl_take isl_union_map *umap);
1171 __isl_give isl_basic_map *isl_basic_set_unwrap(
1172 __isl_take isl_basic_set *bset);
1173 __isl_give isl_map *isl_set_unwrap(
1174 __isl_take isl_set *set);
1175 __isl_give isl_union_map *isl_union_set_unwrap(
1176 __isl_take isl_union_set *uset);
1180 =head2 Binary Operations
1182 The two arguments of a binary operation not only need to live
1183 in the same C<isl_ctx>, they currently also need to have
1184 the same (number of) parameters.
1186 =head3 Basic Operations
1190 =item * Intersection
1192 __isl_give isl_basic_set *isl_basic_set_intersect(
1193 __isl_take isl_basic_set *bset1,
1194 __isl_take isl_basic_set *bset2);
1195 __isl_give isl_set *isl_set_intersect(
1196 __isl_take isl_set *set1,
1197 __isl_take isl_set *set2);
1198 __isl_give isl_union_set *isl_union_set_intersect(
1199 __isl_take isl_union_set *uset1,
1200 __isl_take isl_union_set *uset2);
1201 __isl_give isl_basic_map *isl_basic_map_intersect_domain(
1202 __isl_take isl_basic_map *bmap,
1203 __isl_take isl_basic_set *bset);
1204 __isl_give isl_basic_map *isl_basic_map_intersect_range(
1205 __isl_take isl_basic_map *bmap,
1206 __isl_take isl_basic_set *bset);
1207 __isl_give isl_basic_map *isl_basic_map_intersect(
1208 __isl_take isl_basic_map *bmap1,
1209 __isl_take isl_basic_map *bmap2);
1210 __isl_give isl_map *isl_map_intersect_domain(
1211 __isl_take isl_map *map,
1212 __isl_take isl_set *set);
1213 __isl_give isl_map *isl_map_intersect_range(
1214 __isl_take isl_map *map,
1215 __isl_take isl_set *set);
1216 __isl_give isl_map *isl_map_intersect(
1217 __isl_take isl_map *map1,
1218 __isl_take isl_map *map2);
1219 __isl_give isl_union_map *isl_union_map_intersect_domain(
1220 __isl_take isl_union_map *umap,
1221 __isl_take isl_union_set *uset);
1222 __isl_give isl_union_map *isl_union_map_intersect(
1223 __isl_take isl_union_map *umap1,
1224 __isl_take isl_union_map *umap2);
1228 __isl_give isl_set *isl_basic_set_union(
1229 __isl_take isl_basic_set *bset1,
1230 __isl_take isl_basic_set *bset2);
1231 __isl_give isl_map *isl_basic_map_union(
1232 __isl_take isl_basic_map *bmap1,
1233 __isl_take isl_basic_map *bmap2);
1234 __isl_give isl_set *isl_set_union(
1235 __isl_take isl_set *set1,
1236 __isl_take isl_set *set2);
1237 __isl_give isl_map *isl_map_union(
1238 __isl_take isl_map *map1,
1239 __isl_take isl_map *map2);
1240 __isl_give isl_union_set *isl_union_set_union(
1241 __isl_take isl_union_set *uset1,
1242 __isl_take isl_union_set *uset2);
1243 __isl_give isl_union_map *isl_union_map_union(
1244 __isl_take isl_union_map *umap1,
1245 __isl_take isl_union_map *umap2);
1247 =item * Set difference
1249 __isl_give isl_set *isl_set_subtract(
1250 __isl_take isl_set *set1,
1251 __isl_take isl_set *set2);
1252 __isl_give isl_map *isl_map_subtract(
1253 __isl_take isl_map *map1,
1254 __isl_take isl_map *map2);
1255 __isl_give isl_union_set *isl_union_set_subtract(
1256 __isl_take isl_union_set *uset1,
1257 __isl_take isl_union_set *uset2);
1258 __isl_give isl_union_map *isl_union_map_subtract(
1259 __isl_take isl_union_map *umap1,
1260 __isl_take isl_union_map *umap2);
1264 __isl_give isl_basic_set *isl_basic_set_apply(
1265 __isl_take isl_basic_set *bset,
1266 __isl_take isl_basic_map *bmap);
1267 __isl_give isl_set *isl_set_apply(
1268 __isl_take isl_set *set,
1269 __isl_take isl_map *map);
1270 __isl_give isl_union_set *isl_union_set_apply(
1271 __isl_take isl_union_set *uset,
1272 __isl_take isl_union_map *umap);
1273 __isl_give isl_basic_map *isl_basic_map_apply_domain(
1274 __isl_take isl_basic_map *bmap1,
1275 __isl_take isl_basic_map *bmap2);
1276 __isl_give isl_basic_map *isl_basic_map_apply_range(
1277 __isl_take isl_basic_map *bmap1,
1278 __isl_take isl_basic_map *bmap2);
1279 __isl_give isl_map *isl_map_apply_domain(
1280 __isl_take isl_map *map1,
1281 __isl_take isl_map *map2);
1282 __isl_give isl_map *isl_map_apply_range(
1283 __isl_take isl_map *map1,
1284 __isl_take isl_map *map2);
1285 __isl_give isl_union_map *isl_union_map_apply_range(
1286 __isl_take isl_union_map *umap1,
1287 __isl_take isl_union_map *umap2);
1289 =item * Simplification
1291 __isl_give isl_basic_set *isl_basic_set_gist(
1292 __isl_take isl_basic_set *bset,
1293 __isl_take isl_basic_set *context);
1294 __isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
1295 __isl_take isl_set *context);
1296 __isl_give isl_union_set *isl_union_set_gist(
1297 __isl_take isl_union_set *uset,
1298 __isl_take isl_union_set *context);
1299 __isl_give isl_basic_map *isl_basic_map_gist(
1300 __isl_take isl_basic_map *bmap,
1301 __isl_take isl_basic_map *context);
1302 __isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
1303 __isl_take isl_map *context);
1304 __isl_give isl_union_map *isl_union_map_gist(
1305 __isl_take isl_union_map *umap,
1306 __isl_take isl_union_map *context);
1308 The gist operation returns a set or relation that has the
1309 same intersection with the context as the input set or relation.
1310 Any implicit equality in the intersection is made explicit in the result,
1311 while all inequalities that are redundant with respect to the intersection
1313 In case of union sets and relations, the gist operation is performed
1318 =head3 Lexicographic Optimization
1320 Given a (basic) set C<set> (or C<bset>) and a zero-dimensional domain C<dom>,
1321 the following functions
1322 compute a set that contains the lexicographic minimum or maximum
1323 of the elements in C<set> (or C<bset>) for those values of the parameters
1324 that satisfy C<dom>.
1325 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
1326 that contains the parameter values in C<dom> for which C<set> (or C<bset>)
1328 In other words, the union of the parameter values
1329 for which the result is non-empty and of C<*empty>
1332 __isl_give isl_set *isl_basic_set_partial_lexmin(
1333 __isl_take isl_basic_set *bset,
1334 __isl_take isl_basic_set *dom,
1335 __isl_give isl_set **empty);
1336 __isl_give isl_set *isl_basic_set_partial_lexmax(
1337 __isl_take isl_basic_set *bset,
1338 __isl_take isl_basic_set *dom,
1339 __isl_give isl_set **empty);
1340 __isl_give isl_set *isl_set_partial_lexmin(
1341 __isl_take isl_set *set, __isl_take isl_set *dom,
1342 __isl_give isl_set **empty);
1343 __isl_give isl_set *isl_set_partial_lexmax(
1344 __isl_take isl_set *set, __isl_take isl_set *dom,
1345 __isl_give isl_set **empty);
1347 Given a (basic) set C<set> (or C<bset>), the following functions simply
1348 return a set containing the lexicographic minimum or maximum
1349 of the elements in C<set> (or C<bset>).
1350 In case of union sets, the optimum is computed per dimension.
1352 __isl_give isl_set *isl_basic_set_lexmin(
1353 __isl_take isl_basic_set *bset);
1354 __isl_give isl_set *isl_basic_set_lexmax(
1355 __isl_take isl_basic_set *bset);
1356 __isl_give isl_set *isl_set_lexmin(
1357 __isl_take isl_set *set);
1358 __isl_give isl_set *isl_set_lexmax(
1359 __isl_take isl_set *set);
1360 __isl_give isl_union_set *isl_union_set_lexmin(
1361 __isl_take isl_union_set *uset);
1362 __isl_give isl_union_set *isl_union_set_lexmax(
1363 __isl_take isl_union_set *uset);
1365 Given a (basic) relation C<map> (or C<bmap>) and a domain C<dom>,
1366 the following functions
1367 compute a relation that maps each element of C<dom>
1368 to the single lexicographic minimum or maximum
1369 of the elements that are associated to that same
1370 element in C<map> (or C<bmap>).
1371 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
1372 that contains the elements in C<dom> that do not map
1373 to any elements in C<map> (or C<bmap>).
1374 In other words, the union of the domain of the result and of C<*empty>
1377 __isl_give isl_map *isl_basic_map_partial_lexmax(
1378 __isl_take isl_basic_map *bmap,
1379 __isl_take isl_basic_set *dom,
1380 __isl_give isl_set **empty);
1381 __isl_give isl_map *isl_basic_map_partial_lexmin(
1382 __isl_take isl_basic_map *bmap,
1383 __isl_take isl_basic_set *dom,
1384 __isl_give isl_set **empty);
1385 __isl_give isl_map *isl_map_partial_lexmax(
1386 __isl_take isl_map *map, __isl_take isl_set *dom,
1387 __isl_give isl_set **empty);
1388 __isl_give isl_map *isl_map_partial_lexmin(
1389 __isl_take isl_map *map, __isl_take isl_set *dom,
1390 __isl_give isl_set **empty);
1392 Given a (basic) map C<map> (or C<bmap>), the following functions simply
1393 return a map mapping each element in the domain of
1394 C<map> (or C<bmap>) to the lexicographic minimum or maximum
1395 of all elements associated to that element.
1396 In case of union relations, the optimum is computed per dimension.
1398 __isl_give isl_map *isl_basic_map_lexmin(
1399 __isl_take isl_basic_map *bmap);
1400 __isl_give isl_map *isl_basic_map_lexmax(
1401 __isl_take isl_basic_map *bmap);
1402 __isl_give isl_map *isl_map_lexmin(
1403 __isl_take isl_map *map);
1404 __isl_give isl_map *isl_map_lexmax(
1405 __isl_take isl_map *map);
1406 __isl_give isl_union_map *isl_union_map_lexmin(
1407 __isl_take isl_union_map *umap);
1408 __isl_give isl_union_map *isl_union_map_lexmax(
1409 __isl_take isl_union_map *umap);
1413 Points are elements of a set. They can be used to construct
1414 simple sets (boxes) or they can be used to represent the
1415 individual elements of a set.
1416 The zero point (the origin) can be created using
1418 __isl_give isl_point *isl_point_zero(__isl_take isl_dim *dim);
1420 The coordinates of a point can be inspected, set and changed
1423 void isl_point_get_coordinate(__isl_keep isl_point *pnt,
1424 enum isl_dim_type type, int pos, isl_int *v);
1425 __isl_give isl_point *isl_point_set_coordinate(
1426 __isl_take isl_point *pnt,
1427 enum isl_dim_type type, int pos, isl_int v);
1429 __isl_give isl_point *isl_point_add_ui(
1430 __isl_take isl_point *pnt,
1431 enum isl_dim_type type, int pos, unsigned val);
1432 __isl_give isl_point *isl_point_sub_ui(
1433 __isl_take isl_point *pnt,
1434 enum isl_dim_type type, int pos, unsigned val);
1436 Points can be copied or freed using
1438 __isl_give isl_point *isl_point_copy(
1439 __isl_keep isl_point *pnt);
1440 void isl_point_free(__isl_take isl_point *pnt);
1442 A singleton set can be created from a point using
1444 __isl_give isl_set *isl_set_from_point(
1445 __isl_take isl_point *pnt);
1447 and a box can be created from two opposite extremal points using
1449 __isl_give isl_set *isl_set_box_from_points(
1450 __isl_take isl_point *pnt1,
1451 __isl_take isl_point *pnt2);
1453 All elements of a B<bounded> (union) set can be enumerated using
1454 the following functions.
1456 int isl_set_foreach_point(__isl_keep isl_set *set,
1457 int (*fn)(__isl_take isl_point *pnt, void *user),
1459 int isl_union_set_foreach_point(__isl_keep isl_union_set *uset,
1460 int (*fn)(__isl_take isl_point *pnt, void *user),
1463 The function C<fn> is called for each integer point in
1464 C<set> with as second argument the last argument of
1465 the C<isl_set_foreach_point> call. The function C<fn>
1466 should return C<0> on success and C<-1> on failure.
1467 In the latter case, C<isl_set_foreach_point> will stop
1468 enumerating and return C<-1> as well.
1469 If the enumeration is performed successfully and to completion,
1470 then C<isl_set_foreach_point> returns C<0>.
1472 To obtain a single point of a set, use
1474 __isl_give isl_point *isl_set_sample_point(
1475 __isl_take isl_set *set);
1477 If C<set> does not contain any (integer) points, then the
1478 resulting point will be ``void'', a property that can be
1481 int isl_point_is_void(__isl_keep isl_point *pnt);
1483 =head2 Piecewise Quasipolynomials
1485 A piecewise quasipolynomial is a particular kind of function that maps
1486 a parametric point to a rational value.
1487 More specifically, a quasipolynomial is a polynomial expression in greatest
1488 integer parts of affine expressions of parameters and variables.
1489 A piecewise quasipolynomial is a subdivision of a given parametric
1490 domain into disjoint cells with a quasipolynomial associated to
1491 each cell. The value of the piecewise quasipolynomial at a given
1492 point is the value of the quasipolynomial associated to the cell
1493 that contains the point. Outside of the union of cells,
1494 the value is assumed to be zero.
1495 For example, the piecewise quasipolynomial
1497 [n] -> { [x] -> ((1 + n) - x) : x <= n and x >= 0 }
1499 maps C<x> to C<1 + n - x> for values of C<x> between C<0> and C<n>.
1500 A given piecewise quasipolynomial has a fixed domain dimension.
1501 Union piecewise quasipolynomials are used to contain piecewise quasipolynomials
1502 defined over different domains.
1503 Piecewise quasipolynomials are mainly used by the C<barvinok>
1504 library for representing the number of elements in a parametric set or map.
1505 For example, the piecewise quasipolynomial above represents
1506 the number of points in the map
1508 [n] -> { [x] -> [y] : x,y >= 0 and 0 <= x + y <= n }
1510 =head3 Printing (Piecewise) Quasipolynomials
1512 Quasipolynomials and piecewise quasipolynomials can be printed
1513 using the following functions.
1515 __isl_give isl_printer *isl_printer_print_qpolynomial(
1516 __isl_take isl_printer *p,
1517 __isl_keep isl_qpolynomial *qp);
1519 __isl_give isl_printer *isl_printer_print_pw_qpolynomial(
1520 __isl_take isl_printer *p,
1521 __isl_keep isl_pw_qpolynomial *pwqp);
1523 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial(
1524 __isl_take isl_printer *p,
1525 __isl_keep isl_union_pw_qpolynomial *upwqp);
1527 The output format of the printer
1528 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
1529 For C<isl_printer_print_union_pw_qpolynomial>, only C<ISL_FORMAT_ISL>
1532 =head3 Creating New (Piecewise) Quasipolynomials
1534 Some simple quasipolynomials can be created using the following functions.
1535 More complicated quasipolynomials can be created by applying
1536 operations such as addition and multiplication
1537 on the resulting quasipolynomials
1539 __isl_give isl_qpolynomial *isl_qpolynomial_zero(
1540 __isl_take isl_dim *dim);
1541 __isl_give isl_qpolynomial *isl_qpolynomial_infty(
1542 __isl_take isl_dim *dim);
1543 __isl_give isl_qpolynomial *isl_qpolynomial_neginfty(
1544 __isl_take isl_dim *dim);
1545 __isl_give isl_qpolynomial *isl_qpolynomial_nan(
1546 __isl_take isl_dim *dim);
1547 __isl_give isl_qpolynomial *isl_qpolynomial_rat_cst(
1548 __isl_take isl_dim *dim,
1549 const isl_int n, const isl_int d);
1550 __isl_give isl_qpolynomial *isl_qpolynomial_div(
1551 __isl_take isl_div *div);
1552 __isl_give isl_qpolynomial *isl_qpolynomial_var(
1553 __isl_take isl_dim *dim,
1554 enum isl_dim_type type, unsigned pos);
1556 The zero piecewise quasipolynomial or a piecewise quasipolynomial
1557 with a single cell can be created using the following functions.
1558 Multiple of these single cell piecewise quasipolynomials can
1559 be combined to create more complicated piecewise quasipolynomials.
1561 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero(
1562 __isl_take isl_dim *dim);
1563 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_alloc(
1564 __isl_take isl_set *set,
1565 __isl_take isl_qpolynomial *qp);
1567 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_zero(
1568 __isl_take isl_dim *dim);
1569 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_from_pw_qpolynomial(
1570 __isl_take isl_pw_qpolynomial *pwqp);
1571 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add_pw_qpolynomial(
1572 __isl_take isl_union_pw_qpolynomial *upwqp,
1573 __isl_take isl_pw_qpolynomial *pwqp);
1575 Quasipolynomials can be copied and freed again using the following
1578 __isl_give isl_qpolynomial *isl_qpolynomial_copy(
1579 __isl_keep isl_qpolynomial *qp);
1580 void isl_qpolynomial_free(__isl_take isl_qpolynomial *qp);
1582 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy(
1583 __isl_keep isl_pw_qpolynomial *pwqp);
1584 void isl_pw_qpolynomial_free(
1585 __isl_take isl_pw_qpolynomial *pwqp);
1587 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_copy(
1588 __isl_keep isl_union_pw_qpolynomial *upwqp);
1589 void isl_union_pw_qpolynomial_free(
1590 __isl_take isl_union_pw_qpolynomial *upwqp);
1592 =head3 Inspecting (Piecewise) Quasipolynomials
1594 To iterate over all piecewise quasipolynomials in a union
1595 piecewise quasipolynomial, use the following function
1597 int isl_union_pw_qpolynomial_foreach_pw_qpolynomial(
1598 __isl_keep isl_union_pw_qpolynomial *upwqp,
1599 int (*fn)(__isl_take isl_pw_qpolynomial *pwqp, void *user),
1602 To iterate over the cells in a piecewise quasipolynomial,
1603 use either of the following two functions
1605 int isl_pw_qpolynomial_foreach_piece(
1606 __isl_keep isl_pw_qpolynomial *pwqp,
1607 int (*fn)(__isl_take isl_set *set,
1608 __isl_take isl_qpolynomial *qp,
1609 void *user), void *user);
1610 int isl_pw_qpolynomial_foreach_lifted_piece(
1611 __isl_keep isl_pw_qpolynomial *pwqp,
1612 int (*fn)(__isl_take isl_set *set,
1613 __isl_take isl_qpolynomial *qp,
1614 void *user), void *user);
1616 As usual, the function C<fn> should return C<0> on success
1617 and C<-1> on failure. The difference between
1618 C<isl_pw_qpolynomial_foreach_piece> and
1619 C<isl_pw_qpolynomial_foreach_lifted_piece> is that
1620 C<isl_pw_qpolynomial_foreach_lifted_piece> will first
1621 compute unique representations for all existentially quantified
1622 variables and then turn these existentially quantified variables
1623 into extra set variables, adapting the associated quasipolynomial
1624 accordingly. This means that the C<set> passed to C<fn>
1625 will not have any existentially quantified variables, but that
1626 the dimensions of the sets may be different for different
1627 invocations of C<fn>.
1629 To iterate over all terms in a quasipolynomial,
1632 int isl_qpolynomial_foreach_term(
1633 __isl_keep isl_qpolynomial *qp,
1634 int (*fn)(__isl_take isl_term *term,
1635 void *user), void *user);
1637 The terms themselves can be inspected and freed using
1640 unsigned isl_term_dim(__isl_keep isl_term *term,
1641 enum isl_dim_type type);
1642 void isl_term_get_num(__isl_keep isl_term *term,
1644 void isl_term_get_den(__isl_keep isl_term *term,
1646 int isl_term_get_exp(__isl_keep isl_term *term,
1647 enum isl_dim_type type, unsigned pos);
1648 __isl_give isl_div *isl_term_get_div(
1649 __isl_keep isl_term *term, unsigned pos);
1650 void isl_term_free(__isl_take isl_term *term);
1652 Each term is a product of parameters, set variables and
1653 integer divisions. The function C<isl_term_get_exp>
1654 returns the exponent of a given dimensions in the given term.
1655 The C<isl_int>s in the arguments of C<isl_term_get_num>
1656 and C<isl_term_get_den> need to have been initialized
1657 using C<isl_int_init> before calling these functions.
1659 =head3 Properties of (Piecewise) Quasipolynomials
1661 To check whether a quasipolynomial is actually a constant,
1662 use the following function.
1664 int isl_qpolynomial_is_cst(__isl_keep isl_qpolynomial *qp,
1665 isl_int *n, isl_int *d);
1667 If C<qp> is a constant and if C<n> and C<d> are not C<NULL>
1668 then the numerator and denominator of the constant
1669 are returned in C<*n> and C<*d>, respectively.
1671 =head3 Operations on (Piecewise) Quasipolynomials
1673 __isl_give isl_qpolynomial *isl_qpolynomial_neg(
1674 __isl_take isl_qpolynomial *qp);
1675 __isl_give isl_qpolynomial *isl_qpolynomial_add(
1676 __isl_take isl_qpolynomial *qp1,
1677 __isl_take isl_qpolynomial *qp2);
1678 __isl_give isl_qpolynomial *isl_qpolynomial_sub(
1679 __isl_take isl_qpolynomial *qp1,
1680 __isl_take isl_qpolynomial *qp2);
1681 __isl_give isl_qpolynomial *isl_qpolynomial_mul(
1682 __isl_take isl_qpolynomial *qp1,
1683 __isl_take isl_qpolynomial *qp2);
1685 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
1686 __isl_take isl_pw_qpolynomial *pwqp1,
1687 __isl_take isl_pw_qpolynomial *pwqp2);
1688 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub(
1689 __isl_take isl_pw_qpolynomial *pwqp1,
1690 __isl_take isl_pw_qpolynomial *pwqp2);
1691 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint(
1692 __isl_take isl_pw_qpolynomial *pwqp1,
1693 __isl_take isl_pw_qpolynomial *pwqp2);
1694 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg(
1695 __isl_take isl_pw_qpolynomial *pwqp);
1696 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
1697 __isl_take isl_pw_qpolynomial *pwqp1,
1698 __isl_take isl_pw_qpolynomial *pwqp2);
1700 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add(
1701 __isl_take isl_union_pw_qpolynomial *upwqp1,
1702 __isl_take isl_union_pw_qpolynomial *upwqp2);
1703 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
1704 __isl_take isl_union_pw_qpolynomial *upwqp1,
1705 __isl_take isl_union_pw_qpolynomial *upwqp2);
1706 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
1707 __isl_take isl_union_pw_qpolynomial *upwqp1,
1708 __isl_take isl_union_pw_qpolynomial *upwqp2);
1710 __isl_give isl_qpolynomial *isl_pw_qpolynomial_eval(
1711 __isl_take isl_pw_qpolynomial *pwqp,
1712 __isl_take isl_point *pnt);
1714 __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_eval(
1715 __isl_take isl_union_pw_qpolynomial *upwqp,
1716 __isl_take isl_point *pnt);
1718 __isl_give isl_set *isl_pw_qpolynomial_domain(
1719 __isl_take isl_pw_qpolynomial *pwqp);
1720 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_domain(
1721 __isl_take isl_pw_qpolynomial *pwpq,
1722 __isl_take isl_set *set);
1724 __isl_give isl_union_set *isl_union_pw_qpolynomial_domain(
1725 __isl_take isl_union_pw_qpolynomial *upwqp);
1726 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_intersect_domain(
1727 __isl_take isl_union_pw_qpolynomial *upwpq,
1728 __isl_take isl_union_set *uset);
1730 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_coalesce(
1731 __isl_take isl_union_pw_qpolynomial *upwqp);
1733 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist(
1734 __isl_take isl_pw_qpolynomial *pwqp,
1735 __isl_take isl_set *context);
1737 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist(
1738 __isl_take isl_union_pw_qpolynomial *upwqp,
1739 __isl_take isl_union_set *context);
1741 The gist operation applies the gist operation to each of
1742 the cells in the domain of the input piecewise quasipolynomial.
1743 In future, the operation will also exploit the context
1744 to simplify the quasipolynomials associated to each cell.
1746 =head2 Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions
1748 A piecewise quasipolynomial reduction is a piecewise
1749 reduction (or fold) of quasipolynomials.
1750 In particular, the reduction can be maximum or a minimum.
1751 The objects are mainly used to represent the result of
1752 an upper or lower bound on a quasipolynomial over its domain,
1753 i.e., as the result of the following function.
1755 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound(
1756 __isl_take isl_pw_qpolynomial *pwqp,
1757 enum isl_fold type, int *tight);
1759 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_bound(
1760 __isl_take isl_union_pw_qpolynomial *upwqp,
1761 enum isl_fold type, int *tight);
1763 The C<type> argument may be either C<isl_fold_min> or C<isl_fold_max>.
1764 If C<tight> is not C<NULL>, then C<*tight> is set to C<1>
1765 is the returned bound is known be tight, i.e., for each value
1766 of the parameters there is at least
1767 one element in the domain that reaches the bound.
1769 A (piecewise) quasipolynomial reduction can be copied or freed using the
1770 following functions.
1772 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_copy(
1773 __isl_keep isl_qpolynomial_fold *fold);
1774 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_copy(
1775 __isl_keep isl_pw_qpolynomial_fold *pwf);
1776 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_copy(
1777 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
1778 void isl_qpolynomial_fold_free(
1779 __isl_take isl_qpolynomial_fold *fold);
1780 void isl_pw_qpolynomial_fold_free(
1781 __isl_take isl_pw_qpolynomial_fold *pwf);
1782 void isl_union_pw_qpolynomial_fold_free(
1783 __isl_take isl_union_pw_qpolynomial_fold *upwf);
1785 =head3 Printing Piecewise Quasipolynomial Reductions
1787 Piecewise quasipolynomial reductions can be printed
1788 using the following function.
1790 __isl_give isl_printer *isl_printer_print_pw_qpolynomial_fold(
1791 __isl_take isl_printer *p,
1792 __isl_keep isl_pw_qpolynomial_fold *pwf);
1793 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial_fold(
1794 __isl_take isl_printer *p,
1795 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
1797 For C<isl_printer_print_pw_qpolynomial_fold>,
1798 output format of the printer
1799 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
1800 For C<isl_printer_print_union_pw_qpolynomial_fold>,
1801 output format of the printer
1802 needs to be set to either C<ISL_FORMAT_ISL>.
1804 =head3 Inspecting (Piecewise) Quasipolynomial Reductions
1806 To iterate over all piecewise quasipolynomial reductions in a union
1807 piecewise quasipolynomial reduction, use the following function
1809 int isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(
1810 __isl_keep isl_union_pw_qpolynomial_fold *upwf,
1811 int (*fn)(__isl_take isl_pw_qpolynomial_fold *pwf,
1812 void *user), void *user);
1814 To iterate over the cells in a piecewise quasipolynomial reduction,
1815 use either of the following two functions
1817 int isl_pw_qpolynomial_fold_foreach_piece(
1818 __isl_keep isl_pw_qpolynomial_fold *pwf,
1819 int (*fn)(__isl_take isl_set *set,
1820 __isl_take isl_qpolynomial_fold *fold,
1821 void *user), void *user);
1822 int isl_pw_qpolynomial_fold_foreach_lifted_piece(
1823 __isl_keep isl_pw_qpolynomial_fold *pwf,
1824 int (*fn)(__isl_take isl_set *set,
1825 __isl_take isl_qpolynomial_fold *fold,
1826 void *user), void *user);
1828 See L<Inspecting (Piecewise) Quasipolynomials> for an explanation
1829 of the difference between these two functions.
1831 To iterate over all quasipolynomials in a reduction, use
1833 int isl_qpolynomial_fold_foreach_qpolynomial(
1834 __isl_keep isl_qpolynomial_fold *fold,
1835 int (*fn)(__isl_take isl_qpolynomial *qp,
1836 void *user), void *user);
1838 =head3 Operations on Piecewise Quasipolynomial Reductions
1840 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
1841 __isl_take isl_pw_qpolynomial_fold *pwf1,
1842 __isl_take isl_pw_qpolynomial_fold *pwf2);
1844 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_add(
1845 __isl_take isl_union_pw_qpolynomial_fold *upwf1,
1846 __isl_take isl_union_pw_qpolynomial_fold *upwf2);
1848 __isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_eval(
1849 __isl_take isl_pw_qpolynomial_fold *pwf,
1850 __isl_take isl_point *pnt);
1852 __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_fold_eval(
1853 __isl_take isl_union_pw_qpolynomial_fold *upwf,
1854 __isl_take isl_point *pnt);
1856 __isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain(
1857 __isl_take isl_union_pw_qpolynomial_fold *upwf);
1858 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_intersect_domain(
1859 __isl_take isl_union_pw_qpolynomial_fold *upwf,
1860 __isl_take isl_union_set *uset);
1862 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_coalesce(
1863 __isl_take isl_pw_qpolynomial_fold *pwf);
1865 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_coalesce(
1866 __isl_take isl_union_pw_qpolynomial_fold *upwf);
1868 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist(
1869 __isl_take isl_pw_qpolynomial_fold *pwf,
1870 __isl_take isl_set *context);
1872 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_gist(
1873 __isl_take isl_union_pw_qpolynomial_fold *upwf,
1874 __isl_take isl_union_set *context);
1876 The gist operation applies the gist operation to each of
1877 the cells in the domain of the input piecewise quasipolynomial reduction.
1878 In future, the operation will also exploit the context
1879 to simplify the quasipolynomial reductions associated to each cell.
1881 =head2 Dependence Analysis
1883 C<isl> contains specialized functionality for performing
1884 array dataflow analysis. That is, given a I<sink> access relation
1885 and a collection of possible I<source> access relations,
1886 C<isl> can compute relations that describe
1887 for each iteration of the sink access, which iteration
1888 of which of the source access relations was the last
1889 to access the same data element before the given iteration
1891 To compute standard flow dependences, the sink should be
1892 a read, while the sources should be writes.
1893 If any of the source accesses are marked as being I<may>
1894 accesses, then there will be a dependence to the last
1895 I<must> access B<and> to any I<may> access that follows
1896 this last I<must> access.
1897 In particular, if I<all> sources are I<may> accesses,
1898 then memory based dependence analysis is performed.
1899 If, on the other hand, all sources are I<must> accesses,
1900 then value based dependence analysis is performed.
1902 #include <isl_flow.h>
1904 __isl_give isl_access_info *isl_access_info_alloc(
1905 __isl_take isl_map *sink,
1906 void *sink_user, isl_access_level_before fn,
1908 __isl_give isl_access_info *isl_access_info_add_source(
1909 __isl_take isl_access_info *acc,
1910 __isl_take isl_map *source, int must,
1913 __isl_give isl_flow *isl_access_info_compute_flow(
1914 __isl_take isl_access_info *acc);
1916 int isl_flow_foreach(__isl_keep isl_flow *deps,
1917 int (*fn)(__isl_take isl_map *dep, int must,
1918 void *dep_user, void *user),
1920 __isl_give isl_set *isl_flow_get_no_source(
1921 __isl_keep isl_flow *deps, int must);
1922 void isl_flow_free(__isl_take isl_flow *deps);
1924 The function C<isl_access_info_compute_flow> performs the actual
1925 dependence analysis. The other functions are used to construct
1926 the input for this function or to read off the output.
1928 The input is collected in an C<isl_access_info>, which can
1929 be created through a call to C<isl_access_info_alloc>.
1930 The arguments to this functions are the sink access relation
1931 C<sink>, a token C<sink_user> used to identify the sink
1932 access to the user, a callback function for specifying the
1933 relative order of source and sink accesses, and the number
1934 of source access relations that will be added.
1935 The callback function has type C<int (*)(void *first, void *second)>.
1936 The function is called with two user supplied tokens identifying
1937 either a source or the sink and it should return the shared nesting
1938 level and the relative order of the two accesses.
1939 In particular, let I<n> be the number of loops shared by
1940 the two accesses. If C<first> precedes C<second> textually,
1941 then the function should return I<2 * n + 1>; otherwise,
1942 it should return I<2 * n>.
1943 The sources can be added to the C<isl_access_info> by performing
1944 (at most) C<max_source> calls to C<isl_access_info_add_source>.
1945 C<must> indicates whether the source is a I<must> access
1946 or a I<may> access. Note that a multi-valued access relation
1947 should only be marked I<must> if every iteration in the domain
1948 of the relation accesses I<all> elements in its image.
1949 The C<source_user> token is again used to identify
1950 the source access. The range of the source access relation
1951 C<source> should have the same dimension as the range
1952 of the sink access relation.
1954 The result of the dependence analysis is collected in an
1955 C<isl_flow>. There may be elements in the domain of
1956 the sink access for which no preceding source access could be
1957 found or for which all preceding sources are I<may> accesses.
1958 The sets of these elements can be obtained through
1959 calls to C<isl_flow_get_no_source>, the first with C<must> set
1960 and the second with C<must> unset.
1961 In the case of standard flow dependence analysis,
1962 with the sink a read and the sources I<must> writes,
1963 the first set corresponds to the reads from uninitialized
1964 array elements and the second set is empty.
1965 The actual flow dependences can be extracted using
1966 C<isl_flow_foreach>. This function will call the user-specified
1967 callback function C<fn> for each B<non-empty> dependence between
1968 a source and the sink. The callback function is called
1969 with four arguments, the actual flow dependence relation
1970 mapping source iterations to sink iterations, a boolean that
1971 indicates whether it is a I<must> or I<may> dependence, a token
1972 identifying the source and an additional C<void *> with value
1973 equal to the third argument of the C<isl_flow_foreach> call.
1974 A dependence is marked I<must> if it originates from a I<must>
1975 source and if it is not followed by any I<may> sources.
1977 After finishing with an C<isl_flow>, the user should call
1978 C<isl_flow_free> to free all associated memory.
1980 =head2 Parametric Vertex Enumeration
1982 The parametric vertex enumeration described in this section
1983 is mainly intended to be used internally and by the C<barvinok>
1986 #include <isl_vertices.h>
1987 __isl_give isl_vertices *isl_basic_set_compute_vertices(
1988 __isl_keep isl_basic_set *bset);
1990 The function C<isl_basic_set_compute_vertices> performs the
1991 actual computation of the parametric vertices and the chamber
1992 decomposition and store the result in an C<isl_vertices> object.
1993 This information can be queried by either iterating over all
1994 the vertices or iterating over all the chambers or cells
1995 and then iterating over all vertices that are active on the chamber.
1997 int isl_vertices_foreach_vertex(
1998 __isl_keep isl_vertices *vertices,
1999 int (*fn)(__isl_take isl_vertex *vertex, void *user),
2002 int isl_vertices_foreach_cell(
2003 __isl_keep isl_vertices *vertices,
2004 int (*fn)(__isl_take isl_cell *cell, void *user),
2006 int isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
2007 int (*fn)(__isl_take isl_vertex *vertex, void *user),
2010 Other operations that can be performed on an C<isl_vertices> object are
2013 isl_ctx *isl_vertices_get_ctx(
2014 __isl_keep isl_vertices *vertices);
2015 int isl_vertices_get_n_vertices(
2016 __isl_keep isl_vertices *vertices);
2017 void isl_vertices_free(__isl_take isl_vertices *vertices);
2019 Vertices can be inspected and destroyed using the following functions.
2021 isl_ctx *isl_vertex_get_ctx(__isl_keep isl_vertex *vertex);
2022 int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
2023 __isl_give isl_basic_set *isl_vertex_get_domain(
2024 __isl_keep isl_vertex *vertex);
2025 __isl_give isl_basic_set *isl_vertex_get_expr(
2026 __isl_keep isl_vertex *vertex);
2027 void isl_vertex_free(__isl_take isl_vertex *vertex);
2029 C<isl_vertex_get_expr> returns a singleton parametric set describing
2030 the vertex, while C<isl_vertex_get_domain> returns the activity domain
2032 Note that C<isl_vertex_get_domain> and C<isl_vertex_get_expr> return
2033 B<rational> basic sets, so they should mainly be used for inspection
2034 and should not be mixed with integer sets.
2036 Chambers can be inspected and destroyed using the following functions.
2038 isl_ctx *isl_cell_get_ctx(__isl_keep isl_cell *cell);
2039 __isl_give isl_basic_set *isl_cell_get_domain(
2040 __isl_keep isl_cell *cell);
2041 void isl_cell_free(__isl_take isl_cell *cell);
2045 Although C<isl> is mainly meant to be used as a library,
2046 it also contains some basic applications that use some
2047 of the functionality of C<isl>.
2048 The input may be specified in either the L<isl format>
2049 or the L<PolyLib format>.
2051 =head2 C<isl_polyhedron_sample>
2053 C<isl_polyhedron_sample> takes a polyhedron as input and prints
2054 an integer element of the polyhedron, if there is any.
2055 The first column in the output is the denominator and is always
2056 equal to 1. If the polyhedron contains no integer points,
2057 then a vector of length zero is printed.
2061 C<isl_pip> takes the same input as the C<example> program
2062 from the C<piplib> distribution, i.e., a set of constraints
2063 on the parameters, a line containing only -1 and finally a set
2064 of constraints on a parametric polyhedron.
2065 The coefficients of the parameters appear in the last columns
2066 (but before the final constant column).
2067 The output is the lexicographic minimum of the parametric polyhedron.
2068 As C<isl> currently does not have its own output format, the output
2069 is just a dump of the internal state.
2071 =head2 C<isl_polyhedron_minimize>
2073 C<isl_polyhedron_minimize> computes the minimum of some linear
2074 or affine objective function over the integer points in a polyhedron.
2075 If an affine objective function
2076 is given, then the constant should appear in the last column.
2078 =head2 C<isl_polytope_scan>
2080 Given a polytope, C<isl_polytope_scan> prints
2081 all integer points in the polytope.
2083 =head1 C<isl-polylib>
2085 The C<isl-polylib> library provides the following functions for converting
2086 between C<isl> objects and C<PolyLib> objects.
2087 The library is distributed separately for licensing reasons.
2089 #include <isl_set_polylib.h>
2090 __isl_give isl_basic_set *isl_basic_set_new_from_polylib(
2091 Polyhedron *P, __isl_take isl_dim *dim);
2092 Polyhedron *isl_basic_set_to_polylib(
2093 __isl_keep isl_basic_set *bset);
2094 __isl_give isl_set *isl_set_new_from_polylib(Polyhedron *D,
2095 __isl_take isl_dim *dim);
2096 Polyhedron *isl_set_to_polylib(__isl_keep isl_set *set);
2098 #include <isl_map_polylib.h>
2099 __isl_give isl_basic_map *isl_basic_map_new_from_polylib(
2100 Polyhedron *P, __isl_take isl_dim *dim);
2101 __isl_give isl_map *isl_map_new_from_polylib(Polyhedron *D,
2102 __isl_take isl_dim *dim);
2103 Polyhedron *isl_basic_map_to_polylib(
2104 __isl_keep isl_basic_map *bmap);
2105 Polyhedron *isl_map_to_polylib(__isl_keep isl_map *map);