doc: remove description of how to get the piplib submodule
[platform/upstream/isl.git] / doc / user.pod
1 =head1 Introduction
2
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
8 using C<GMP>.
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.
12
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>.
22
23 =head2 Backward Incompatible Changes
24
25 =head3 Changes since isl-0.02
26
27 =over
28
29 =item * The old printing functions have been deprecated
30 and replaced by C<isl_printer> functions, see L<Input and Output>.
31
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>.
35
36 =back
37
38 =head1 Installation
39
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
44 the source.
45
46 =head2 Installation from the git repository
47
48 =over
49
50 =item 1 Clone or update the repository
51
52 The first time the source is obtained, you need to clone
53 the repository.
54
55         git clone git://repo.or.cz/isl.git
56
57 To obtain updates, you need to pull in the latest changes
58
59         git pull
60
61 =item 2 Generate C<configure>
62
63         ./autogen.sh
64
65 =back
66
67 After performing the above steps, continue
68 with the L<Common installation instructions>.
69
70 =head2 Common installation instructions
71
72 =over
73
74 =item 1 Obtain C<GMP>
75
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/>.
81
82 =item 2 Configure
83
84 C<isl> uses the standard C<autoconf> C<configure> script.
85 To run it, just type
86
87         ./configure
88
89 optionally followed by some configure options.
90 A complete list of options can be obtained by running
91
92         ./configure --help
93
94 Below we discuss some of the more common options.
95
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>
104 and C<piplib>.
105
106 =over
107
108 =item C<--prefix>
109
110 Installation prefix for C<isl>
111
112 =item C<--with-gmp-prefix>
113
114 Installation prefix for C<GMP> (architecture-independent files).
115
116 =item C<--with-gmp-exec-prefix>
117
118 Installation prefix for C<GMP> (architecture-dependent files).
119
120 =item C<--with-piplib>
121
122 Which copy of C<piplib> to use, either C<no> (default), C<system> or C<build>.
123
124 =item C<--with-piplib-prefix>
125
126 Installation prefix for C<system> C<piplib> (architecture-independent files).
127
128 =item C<--with-piplib-exec-prefix>
129
130 Installation prefix for C<system> C<piplib> (architecture-dependent files).
131
132 =item C<--with-piplib-builddir>
133
134 Location where C<build> C<piplib> was built.
135
136 =back
137
138 =item 3 Compile
139
140         make
141
142 =item 4 Install (optional)
143
144         make install
145
146 =back
147
148 =head1 Library
149
150 =head2 Initialization
151
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.
161
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.
166
167         isl_ctx *isl_ctx_alloc();
168         void isl_ctx_free(isl_ctx *ctx);
169
170 =head2 Integers
171
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>
185 after the last use.
186
187 =over
188
189 =item isl_int_init(i)
190
191 =item isl_int_clear(i)
192
193 =item isl_int_set(r,i)
194
195 =item isl_int_set_si(r,i)
196
197 =item isl_int_abs(r,i)
198
199 =item isl_int_neg(r,i)
200
201 =item isl_int_swap(i,j)
202
203 =item isl_int_swap_or_set(i,j)
204
205 =item isl_int_add_ui(r,i,j)
206
207 =item isl_int_sub_ui(r,i,j)
208
209 =item isl_int_add(r,i,j)
210
211 =item isl_int_sub(r,i,j)
212
213 =item isl_int_mul(r,i,j)
214
215 =item isl_int_mul_ui(r,i,j)
216
217 =item isl_int_addmul(r,i,j)
218
219 =item isl_int_submul(r,i,j)
220
221 =item isl_int_gcd(r,i,j)
222
223 =item isl_int_lcm(r,i,j)
224
225 =item isl_int_divexact(r,i,j)
226
227 =item isl_int_cdiv_q(r,i,j)
228
229 =item isl_int_fdiv_q(r,i,j)
230
231 =item isl_int_fdiv_r(r,i,j)
232
233 =item isl_int_fdiv_q_ui(r,i,j)
234
235 =item isl_int_read(r,s)
236
237 =item isl_int_print(out,i,width)
238
239 =item isl_int_sgn(i)
240
241 =item isl_int_cmp(i,j)
242
243 =item isl_int_cmp_si(i,si)
244
245 =item isl_int_eq(i,j)
246
247 =item isl_int_ne(i,j)
248
249 =item isl_int_lt(i,j)
250
251 =item isl_int_le(i,j)
252
253 =item isl_int_gt(i,j)
254
255 =item isl_int_ge(i,j)
256
257 =item isl_int_abs_eq(i,j)
258
259 =item isl_int_abs_ne(i,j)
260
261 =item isl_int_abs_lt(i,j)
262
263 =item isl_int_abs_gt(i,j)
264
265 =item isl_int_abs_ge(i,j)
266
267 =item isl_int_is_zero(i)
268
269 =item isl_int_is_one(i)
270
271 =item isl_int_is_negone(i)
272
273 =item isl_int_is_pos(i)
274
275 =item isl_int_is_neg(i)
276
277 =item isl_int_is_nonpos(i)
278
279 =item isl_int_is_nonneg(i)
280
281 =item isl_int_is_divisible_by(i,j)
282
283 =back
284
285 =head2 Sets and Relations
286
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.
302
303 =head2 Memory Management
304
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.
314
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
318 are used
319
320 =over
321
322 =item C<__isl_give>
323
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.
332
333 =item C<__isl_take>
334
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
344 are released.
345
346 =item C<__isl_keep>
347
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.
353
354 =back
355
356 =head2 Dimension Specifications
357
358 Whenever a new set or relation is created from scratch,
359 its dimension needs to be specified using an C<isl_dim>.
360
361         #include <isl_dim.h>
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);
370
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>.
381
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.
388
389         #include <isl_set.h>
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);
393
394         #include <isl_union_set.h>
395         __isl_give isl_dim *isl_union_set_get_dim(
396                 __isl_keep isl_union_set *uset);
397
398         #include <isl_map.h>
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);
402
403         #include <isl_union_map.h>
404         __isl_give isl_dim *isl_union_map_get_dim(
405                 __isl_keep isl_union_map *umap);
406
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);
416
417 The names of the individual dimensions may be set or read off
418 using the following functions.
419
420         #include <isl_dim.h>
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);
426
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.
434
435 The names of entire spaces may be set or read off
436 using the following functions.
437
438         #include <isl_dim.h>
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);
444
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
448 data structure.
449 Binary operations require the corresponding spaces of their arguments
450 to have the same name.
451
452 =head2 Input and Output
453
454 C<isl> supports its own input/output format, which is similar
455 to the C<Omega> format, but also supports the C<PolyLib> format
456 in some cases.
457
458 =head3 C<isl> format
459
460 The C<isl> format is similar to that of C<Omega>, but has a different
461 syntax for describing the parameters and allows for the definition
462 of an existentially quantified variable as the integer division
463 of an affine expression.
464 For example, the set of integers C<i> between C<0> and C<n>
465 such that C<i % 10 <= 6> can be described as
466
467         [n] -> { [i] : exists (a = [i/10] : 0 <= i and i <= n and
468                                 i - 10 a <= 6) }
469
470 A set or relation can have several disjuncts, separated
471 by the keyword C<or>.  Each disjunct is either a conjunction
472 of constraints or a projection (C<exists>) of a conjunction
473 of constraints.  The constraints are separated by the keyword
474 C<and>.
475
476 =head3 C<PolyLib> format
477
478 If the represented set is a union, then the first line
479 contains a single number representing the number of disjuncts.
480 Otherwise, a line containing the number C<1> is optional.
481
482 Each disjunct is represented by a matrix of constraints.
483 The first line contains two numbers representing
484 the number of rows and columns,
485 where the number of rows is equal to the number of constraints
486 and the number of columns is equal to two plus the number of variables.
487 The following lines contain the actual rows of the constraint matrix.
488 In each row, the first column indicates whether the constraint
489 is an equality (C<0>) or inequality (C<1>).  The final column
490 corresponds to the constant term.
491
492 If the set is parametric, then the coefficients of the parameters
493 appear in the last columns before the constant column.
494 The coefficients of any existentially quantified variables appear
495 between those of the set variables and those of the parameters.
496
497 =head3 Input
498
499         #include <isl_set.h>
500         __isl_give isl_basic_set *isl_basic_set_read_from_file(
501                 isl_ctx *ctx, FILE *input, int nparam);
502         __isl_give isl_basic_set *isl_basic_set_read_from_str(
503                 isl_ctx *ctx, const char *str, int nparam);
504         __isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx,
505                 FILE *input, int nparam);
506         __isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx,
507                 const char *str, int nparam);
508
509         #include <isl_map.h>
510         __isl_give isl_basic_map *isl_basic_map_read_from_file(
511                 isl_ctx *ctx, FILE *input, int nparam);
512         __isl_give isl_basic_map *isl_basic_map_read_from_str(
513                 isl_ctx *ctx, const char *str, int nparam);
514         __isl_give isl_map *isl_map_read_from_file(
515                 struct isl_ctx *ctx, FILE *input, int nparam);
516         __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx,
517                 const char *str, int nparam);
518
519 The input format is autodetected and may be either the C<PolyLib> format
520 or the C<isl> format.
521 C<nparam> specifies how many of the final columns in
522 the C<PolyLib> format correspond to parameters.
523 If input is given in the C<isl> format, then the number
524 of parameters needs to be equal to C<nparam>.
525 If C<nparam> is negative, then any number of parameters
526 is accepted in the C<isl> format and zero parameters
527 are assumed in the C<PolyLib> format.
528
529 =head3 Output
530
531 Before anything can be printed, an C<isl_printer> needs to
532 be created.
533
534         __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx,
535                 FILE *file);
536         __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx);
537         void isl_printer_free(__isl_take isl_printer *printer);
538         __isl_give char *isl_printer_get_str(
539                 __isl_keep isl_printer *printer);
540
541 The behavior of the printer can be modified in various ways
542
543         __isl_give isl_printer *isl_printer_set_output_format(
544                 __isl_take isl_printer *p, int output_format);
545         __isl_give isl_printer *isl_printer_set_indent(
546                 __isl_take isl_printer *p, int indent);
547         __isl_give isl_printer *isl_printer_set_prefix(
548                 __isl_take isl_printer *p, const char *prefix);
549         __isl_give isl_printer *isl_printer_set_suffix(
550                 __isl_take isl_printer *p, const char *suffix);
551
552 The C<output_format> may be either C<ISL_FORMAT_ISL>, C<ISL_FORMAT_OMEGA>
553 or C<ISL_FORMAT_POLYLIB> and defaults to C<ISL_FORMAT_ISL>.
554 Each line in the output is indented by C<indent> spaces
555 (default: 0), prefixed by C<prefix> and suffixed by C<suffix>.
556 In the C<PolyLib> format output,
557 the coefficients of the existentially quantified variables
558 appear between those of the set variables and those
559 of the parameters.
560
561 To actually print something, use
562
563         #include <isl_set.h>
564         __isl_give isl_printer *isl_printer_print_basic_set(
565                 __isl_take isl_printer *printer,
566                 __isl_keep isl_basic_set *bset);
567         __isl_give isl_printer *isl_printer_print_set(
568                 __isl_take isl_printer *printer,
569                 __isl_keep isl_set *set);
570
571         #include <isl_map.h>
572         __isl_give isl_printer *isl_printer_print_basic_map(
573                 __isl_take isl_printer *printer,
574                 __isl_keep isl_basic_map *bmap);
575         __isl_give isl_printer *isl_printer_print_map(
576                 __isl_take isl_printer *printer,
577                 __isl_keep isl_map *map);
578
579         #include <isl_union_set.h>
580         __isl_give isl_printer *isl_printer_print_union_set(
581                 __isl_take isl_printer *p,
582                 __isl_keep isl_union_set *uset);
583
584         #include <isl_union_map.h>
585         __isl_give isl_printer *isl_printer_print_union_map(
586                 __isl_take isl_printer *p,
587                 __isl_keep isl_union_map *umap);
588
589 When called on a file printer, the following function flushes
590 the file.  When called on a string printer, the buffer is cleared.
591
592         __isl_give isl_printer *isl_printer_flush(
593                 __isl_take isl_printer *p);
594
595 =head2 Creating New Sets and Relations
596
597 C<isl> has functions for creating some standard sets and relations.
598
599 =over
600
601 =item * Empty sets and relations
602
603         __isl_give isl_basic_set *isl_basic_set_empty(
604                 __isl_take isl_dim *dim);
605         __isl_give isl_basic_map *isl_basic_map_empty(
606                 __isl_take isl_dim *dim);
607         __isl_give isl_set *isl_set_empty(
608                 __isl_take isl_dim *dim);
609         __isl_give isl_map *isl_map_empty(
610                 __isl_take isl_dim *dim);
611         __isl_give isl_union_set *isl_union_set_empty(
612                 __isl_take isl_dim *dim);
613         __isl_give isl_union_map *isl_union_map_empty(
614                 __isl_take isl_dim *dim);
615
616 For C<isl_union_set>s and C<isl_union_map>s, the dimensions specification
617 is only used to specify the parameters.
618
619 =item * Universe sets and relations
620
621         __isl_give isl_basic_set *isl_basic_set_universe(
622                 __isl_take isl_dim *dim);
623         __isl_give isl_basic_map *isl_basic_map_universe(
624                 __isl_take isl_dim *dim);
625         __isl_give isl_set *isl_set_universe(
626                 __isl_take isl_dim *dim);
627         __isl_give isl_map *isl_map_universe(
628                 __isl_take isl_dim *dim);
629
630 =item * Identity relations
631
632         __isl_give isl_basic_map *isl_basic_map_identity(
633                 __isl_take isl_dim *set_dim);
634         __isl_give isl_map *isl_map_identity(
635                 __isl_take isl_dim *set_dim);
636
637 These functions take a dimension specification for a B<set>
638 and return an identity relation between two such sets.
639
640 =item * Lexicographic order
641
642         __isl_give isl_map *isl_map_lex_lt(
643                 __isl_take isl_dim *set_dim);
644         __isl_give isl_map *isl_map_lex_le(
645                 __isl_take isl_dim *set_dim);
646         __isl_give isl_map *isl_map_lex_gt(
647                 __isl_take isl_dim *set_dim);
648         __isl_give isl_map *isl_map_lex_ge(
649                 __isl_take isl_dim *set_dim);
650         __isl_give isl_map *isl_map_lex_lt_first(
651                 __isl_take isl_dim *dim, unsigned n);
652         __isl_give isl_map *isl_map_lex_le_first(
653                 __isl_take isl_dim *dim, unsigned n);
654         __isl_give isl_map *isl_map_lex_gt_first(
655                 __isl_take isl_dim *dim, unsigned n);
656         __isl_give isl_map *isl_map_lex_ge_first(
657                 __isl_take isl_dim *dim, unsigned n);
658
659 The first four functions take a dimension specification for a B<set>
660 and return relations that express that the elements in the domain
661 are lexicographically less
662 (C<isl_map_lex_lt>), less or equal (C<isl_map_lex_le>),
663 greater (C<isl_map_lex_gt>) or greater or equal (C<isl_map_lex_ge>)
664 than the elements in the range.
665 The last four functions take a dimension specification for a map
666 and return relations that express that the first C<n> dimensions
667 in the domain are lexicographically less
668 (C<isl_map_lex_lt_first>), less or equal (C<isl_map_lex_le_first>),
669 greater (C<isl_map_lex_gt_first>) or greater or equal (C<isl_map_lex_ge_first>)
670 than the first C<n> dimensions in the range.
671
672 =back
673
674 A basic set or relation can be converted to a set or relation
675 using the following functions.
676
677         __isl_give isl_set *isl_set_from_basic_set(
678                 __isl_take isl_basic_set *bset);
679         __isl_give isl_map *isl_map_from_basic_map(
680                 __isl_take isl_basic_map *bmap);
681
682 Sets and relations can be converted to union sets and relations
683 using the following functions.
684
685         __isl_give isl_union_map *isl_union_map_from_map(
686                 __isl_take isl_map *map);
687         __isl_give isl_union_set *isl_union_set_from_set(
688                 __isl_take isl_set *set);
689
690 Sets and relations can be copied and freed again using the following
691 functions.
692
693         __isl_give isl_basic_set *isl_basic_set_copy(
694                 __isl_keep isl_basic_set *bset);
695         __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set);
696         __isl_give isl_union_set *isl_union_set_copy(
697                 __isl_keep isl_union_set *uset);
698         __isl_give isl_basic_map *isl_basic_map_copy(
699                 __isl_keep isl_basic_map *bmap);
700         __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
701         __isl_give isl_union_map *isl_union_map_copy(
702                 __isl_keep isl_union_map *umap);
703         void isl_basic_set_free(__isl_take isl_basic_set *bset);
704         void isl_set_free(__isl_take isl_set *set);
705         void isl_union_set_free(__isl_take isl_union_set *uset);
706         void isl_basic_map_free(__isl_take isl_basic_map *bmap);
707         void isl_map_free(__isl_take isl_map *map);
708         void isl_union_map_free(__isl_take isl_union_map *umap);
709
710 Other sets and relations can be constructed by starting
711 from a universe set or relation, adding equality and/or
712 inequality constraints and then projecting out the
713 existentially quantified variables, if any.
714 Constraints can be constructed, manipulated and
715 added to basic sets and relations using the following functions.
716
717         #include <isl_constraint.h>
718         __isl_give isl_constraint *isl_equality_alloc(
719                 __isl_take isl_dim *dim);
720         __isl_give isl_constraint *isl_inequality_alloc(
721                 __isl_take isl_dim *dim);
722         void isl_constraint_set_constant(
723                 __isl_keep isl_constraint *constraint, isl_int v);
724         void isl_constraint_set_coefficient(
725                 __isl_keep isl_constraint *constraint,
726                 enum isl_dim_type type, int pos, isl_int v);
727         __isl_give isl_basic_map *isl_basic_map_add_constraint(
728                 __isl_take isl_basic_map *bmap,
729                 __isl_take isl_constraint *constraint);
730         __isl_give isl_basic_set *isl_basic_set_add_constraint(
731                 __isl_take isl_basic_set *bset,
732                 __isl_take isl_constraint *constraint);
733
734 For example, to create a set containing the even integers
735 between 10 and 42, you would use the following code.
736
737         isl_int v;
738         struct isl_dim *dim;
739         struct isl_constraint *c;
740         struct isl_basic_set *bset;
741
742         isl_int_init(v);
743         dim = isl_dim_set_alloc(ctx, 0, 2);
744         bset = isl_basic_set_universe(isl_dim_copy(dim));
745
746         c = isl_equality_alloc(isl_dim_copy(dim));
747         isl_int_set_si(v, -1);
748         isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
749         isl_int_set_si(v, 2);
750         isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
751         bset = isl_basic_set_add_constraint(bset, c);
752
753         c = isl_inequality_alloc(isl_dim_copy(dim));
754         isl_int_set_si(v, -10);
755         isl_constraint_set_constant(c, v);
756         isl_int_set_si(v, 1);
757         isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
758         bset = isl_basic_set_add_constraint(bset, c);
759
760         c = isl_inequality_alloc(dim);
761         isl_int_set_si(v, 42);
762         isl_constraint_set_constant(c, v);
763         isl_int_set_si(v, -1);
764         isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
765         bset = isl_basic_set_add_constraint(bset, c);
766
767         bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 1);
768
769         isl_int_clear(v);
770
771 Or, alternatively,
772
773         struct isl_basic_set *bset;
774         bset = isl_basic_set_read_from_str(ctx,
775                 "{[i] : exists (a : i = 2a and i >= 10 and i <= 42)}", -1);
776
777 =head2 Inspecting Sets and Relations
778
779 Usually, the user should not have to care about the actual constraints
780 of the sets and maps, but should instead apply the abstract operations
781 explained in the following sections.
782 Occasionally, however, it may be required to inspect the individual
783 coefficients of the constraints.  This section explains how to do so.
784 In these cases, it may also be useful to have C<isl> compute
785 an explicit representation of the existentially quantified variables.
786
787         __isl_give isl_set *isl_set_compute_divs(
788                 __isl_take isl_set *set);
789         __isl_give isl_map *isl_map_compute_divs(
790                 __isl_take isl_map *map);
791         __isl_give isl_union_set *isl_union_set_compute_divs(
792                 __isl_take isl_union_set *uset);
793         __isl_give isl_union_map *isl_union_map_compute_divs(
794                 __isl_take isl_union_map *umap);
795
796 This explicit representation defines the existentially quantified
797 variables as integer divisions of the other variables, possibly
798 including earlier existentially quantified variables.
799 An explicitly represented existentially quantified variable therefore
800 has a unique value when the values of the other variables are known.
801 If, furthermore, the same existentials, i.e., existentials
802 with the same explicit representations, should appear in the
803 same order in each of the disjuncts of a set or map, then the user should call
804 either of the following functions.
805
806         __isl_give isl_set *isl_set_align_divs(
807                 __isl_take isl_set *set);
808         __isl_give isl_map *isl_map_align_divs(
809                 __isl_take isl_map *map);
810
811 To iterate over all the sets or maps in a union set or map, use
812
813         int isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
814                 int (*fn)(__isl_take isl_set *set, void *user),
815                 void *user);
816         int isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
817                 int (*fn)(__isl_take isl_map *map, void *user),
818                 void *user);
819
820 To iterate over all the basic sets or maps in a set or map, use
821
822         int isl_set_foreach_basic_set(__isl_keep isl_set *set,
823                 int (*fn)(__isl_take isl_basic_set *bset, void *user),
824                 void *user);
825         int isl_map_foreach_basic_map(__isl_keep isl_map *map,
826                 int (*fn)(__isl_take isl_basic_map *bmap, void *user),
827                 void *user);
828
829 The callback function C<fn> should return 0 if successful and
830 -1 if an error occurs.  In the latter case, or if any other error
831 occurs, the above functions will return -1.
832
833 It should be noted that C<isl> does not guarantee that
834 the basic sets or maps passed to C<fn> are disjoint.
835 If this is required, then the user should call one of
836 the following functions first.
837
838         __isl_give isl_set *isl_set_make_disjoint(
839                 __isl_take isl_set *set);
840         __isl_give isl_map *isl_map_make_disjoint(
841                 __isl_take isl_map *map);
842
843 To iterate over the constraints of a basic set or map, use
844
845         #include <isl_constraint.h>
846
847         int isl_basic_map_foreach_constraint(
848                 __isl_keep isl_basic_map *bmap,
849                 int (*fn)(__isl_take isl_constraint *c, void *user),
850                 void *user);
851         void isl_constraint_free(struct isl_constraint *c);
852
853 Again, the callback function C<fn> should return 0 if successful and
854 -1 if an error occurs.  In the latter case, or if any other error
855 occurs, the above functions will return -1.
856 The constraint C<c> represents either an equality or an inequality.
857 Use the following function to find out whether a constraint
858 represents an equality.  If not, it represents an inequality.
859
860         int isl_constraint_is_equality(
861                 __isl_keep isl_constraint *constraint);
862
863 The coefficients of the constraints can be inspected using
864 the following functions.
865
866         void isl_constraint_get_constant(
867                 __isl_keep isl_constraint *constraint, isl_int *v);
868         void isl_constraint_get_coefficient(
869                 __isl_keep isl_constraint *constraint,
870                 enum isl_dim_type type, int pos, isl_int *v);
871
872 The explicit representations of the existentially quantified
873 variables can be inspected using the following functions.
874 Note that the user is only allowed to use these functions
875 if the inspected set or map is the result of a call
876 to C<isl_set_compute_divs> or C<isl_map_compute_divs>.
877
878         __isl_give isl_div *isl_constraint_div(
879                 __isl_keep isl_constraint *constraint, int pos);
880         void isl_div_get_constant(__isl_keep isl_div *div,
881                 isl_int *v);
882         void isl_div_get_denominator(__isl_keep isl_div *div,
883                 isl_int *v);
884         void isl_div_get_coefficient(__isl_keep isl_div *div,
885                 enum isl_dim_type type, int pos, isl_int *v);
886
887 =head2 Properties
888
889 =head3 Unary Properties
890
891 =over
892
893 =item * Emptiness
894
895 The following functions test whether the given set or relation
896 contains any integer points.  The ``fast'' variants do not perform
897 any computations, but simply check if the given set or relation
898 is already known to be empty.
899
900         int isl_basic_set_fast_is_empty(__isl_keep isl_basic_set *bset);
901         int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
902         int isl_set_is_empty(__isl_keep isl_set *set);
903         int isl_union_set_is_empty(__isl_keep isl_union_set *uset);
904         int isl_basic_map_fast_is_empty(__isl_keep isl_basic_map *bmap);
905         int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
906         int isl_map_fast_is_empty(__isl_keep isl_map *map);
907         int isl_map_is_empty(__isl_keep isl_map *map);
908         int isl_union_map_is_empty(__isl_keep isl_union_map *umap);
909
910 =item * Universality
911
912         int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
913         int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
914         int isl_set_fast_is_universe(__isl_keep isl_set *set);
915
916 =item * Single-valuedness
917
918         int isl_map_is_single_valued(__isl_keep isl_map *map);
919
920 =item * Bijectivity
921
922         int isl_map_is_bijective(__isl_keep isl_map *map);
923
924 =back
925
926 =head3 Binary Properties
927
928 =over
929
930 =item * Equality
931
932         int isl_set_fast_is_equal(__isl_keep isl_set *set1,
933                 __isl_keep isl_set *set2);
934         int isl_set_is_equal(__isl_keep isl_set *set1,
935                 __isl_keep isl_set *set2);
936         int isl_basic_map_is_equal(
937                 __isl_keep isl_basic_map *bmap1,
938                 __isl_keep isl_basic_map *bmap2);
939         int isl_map_is_equal(__isl_keep isl_map *map1,
940                 __isl_keep isl_map *map2);
941         int isl_map_fast_is_equal(__isl_keep isl_map *map1,
942                 __isl_keep isl_map *map2);
943         int isl_union_map_is_equal(
944                 __isl_keep isl_union_map *umap1,
945                 __isl_keep isl_union_map *umap2);
946
947 =item * Disjointness
948
949         int isl_set_fast_is_disjoint(__isl_keep isl_set *set1,
950                 __isl_keep isl_set *set2);
951
952 =item * Subset
953
954         int isl_set_is_subset(__isl_keep isl_set *set1,
955                 __isl_keep isl_set *set2);
956         int isl_set_is_strict_subset(
957                 __isl_keep isl_set *set1,
958                 __isl_keep isl_set *set2);
959         int isl_basic_map_is_subset(
960                 __isl_keep isl_basic_map *bmap1,
961                 __isl_keep isl_basic_map *bmap2);
962         int isl_basic_map_is_strict_subset(
963                 __isl_keep isl_basic_map *bmap1,
964                 __isl_keep isl_basic_map *bmap2);
965         int isl_map_is_subset(
966                 __isl_keep isl_map *map1,
967                 __isl_keep isl_map *map2);
968         int isl_map_is_strict_subset(
969                 __isl_keep isl_map *map1,
970                 __isl_keep isl_map *map2);
971         int isl_union_map_is_subset(
972                 __isl_keep isl_union_map *umap1,
973                 __isl_keep isl_union_map *umap2);
974         int isl_union_map_is_strict_subset(
975                 __isl_keep isl_union_map *umap1,
976                 __isl_keep isl_union_map *umap2);
977
978 =back
979
980 =head2 Unary Operations
981
982 =over
983
984 =item * Complement
985
986         __isl_give isl_set *isl_set_complement(
987                 __isl_take isl_set *set);
988
989 =item * Inverse map
990
991         __isl_give isl_basic_map *isl_basic_map_reverse(
992                 __isl_take isl_basic_map *bmap);
993         __isl_give isl_map *isl_map_reverse(
994                 __isl_take isl_map *map);
995         __isl_give isl_union_map *isl_union_map_reverse(
996                 __isl_take isl_union_map *umap);
997
998 =item * Projection
999
1000         __isl_give isl_basic_set *isl_basic_set_project_out(
1001                 __isl_take isl_basic_set *bset,
1002                 enum isl_dim_type type, unsigned first, unsigned n);
1003         __isl_give isl_basic_map *isl_basic_map_project_out(
1004                 __isl_take isl_basic_map *bmap,
1005                 enum isl_dim_type type, unsigned first, unsigned n);
1006         __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
1007                 enum isl_dim_type type, unsigned first, unsigned n);
1008         __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
1009                 enum isl_dim_type type, unsigned first, unsigned n);
1010         __isl_give isl_basic_set *isl_basic_map_domain(
1011                 __isl_take isl_basic_map *bmap);
1012         __isl_give isl_basic_set *isl_basic_map_range(
1013                 __isl_take isl_basic_map *bmap);
1014         __isl_give isl_set *isl_map_domain(
1015                 __isl_take isl_map *bmap);
1016         __isl_give isl_set *isl_map_range(
1017                 __isl_take isl_map *map);
1018         __isl_give isl_union_set *isl_union_map_domain(
1019                 __isl_take isl_union_map *umap);
1020         __isl_give isl_union_set *isl_union_map_range(
1021                 __isl_take isl_union_map *umap);
1022
1023 =item * Deltas
1024
1025         __isl_give isl_basic_set *isl_basic_map_deltas(
1026                 __isl_take isl_basic_map *bmap);
1027         __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
1028         __isl_give isl_union_set *isl_union_map_deltas(
1029                 __isl_take isl_union_map *umap);
1030
1031 These functions return a (basic) set containing the differences
1032 between image elements and corresponding domain elements in the input.
1033
1034 =item * Coalescing
1035
1036 Simplify the representation of a set or relation by trying
1037 to combine pairs of basic sets or relations into a single
1038 basic set or relation.
1039
1040         __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
1041         __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
1042         __isl_give isl_union_set *isl_union_set_coalesce(
1043                 __isl_take isl_union_set *uset);
1044         __isl_give isl_union_map *isl_union_map_coalesce(
1045                 __isl_take isl_union_map *umap);
1046
1047 =item * Convex hull
1048
1049         __isl_give isl_basic_set *isl_set_convex_hull(
1050                 __isl_take isl_set *set);
1051         __isl_give isl_basic_map *isl_map_convex_hull(
1052                 __isl_take isl_map *map);
1053
1054 If the input set or relation has any existentially quantified
1055 variables, then the result of these operations is currently undefined.
1056
1057 =item * Simple hull
1058
1059         __isl_give isl_basic_set *isl_set_simple_hull(
1060                 __isl_take isl_set *set);
1061         __isl_give isl_basic_map *isl_map_simple_hull(
1062                 __isl_take isl_map *map);
1063
1064 These functions compute a single basic set or relation
1065 that contains the whole input set or relation.
1066 In particular, the output is described by translates
1067 of the constraints describing the basic sets or relations in the input.
1068
1069 =begin latex
1070
1071 (See \autoref{s:simple hull}.)
1072
1073 =end latex
1074
1075 =item * Affine hull
1076
1077         __isl_give isl_basic_set *isl_basic_set_affine_hull(
1078                 __isl_take isl_basic_set *bset);
1079         __isl_give isl_basic_set *isl_set_affine_hull(
1080                 __isl_take isl_set *set);
1081         __isl_give isl_union_set *isl_union_set_affine_hull(
1082                 __isl_take isl_union_set *uset);
1083         __isl_give isl_basic_map *isl_basic_map_affine_hull(
1084                 __isl_take isl_basic_map *bmap);
1085         __isl_give isl_basic_map *isl_map_affine_hull(
1086                 __isl_take isl_map *map);
1087         __isl_give isl_union_map *isl_union_map_affine_hull(
1088                 __isl_take isl_union_map *umap);
1089
1090 In case of union sets and relations, the affine hull is computed
1091 per dimension.
1092
1093 =item * Power
1094
1095         __isl_give isl_map *isl_map_power(__isl_take isl_map *map,
1096                 unsigned param, int *exact);
1097
1098 Compute a parametric representation for all positive powers I<k> of C<map>.
1099 The power I<k> is equated to the parameter at position C<param>.
1100 The result may be an overapproximation.  If the result is exact,
1101 then C<*exact> is set to C<1>.
1102 The current implementation only produces exact results for particular
1103 cases of piecewise translations (i.e., piecewise uniform dependences).
1104
1105 =item * Transitive closure
1106
1107         __isl_give isl_map *isl_map_transitive_closure(
1108                 __isl_take isl_map *map, int *exact);
1109         __isl_give isl_union_map *isl_union_map_transitive_closure(
1110                 __isl_take isl_union_map *umap, int *exact);
1111
1112 Compute the transitive closure of C<map>.
1113 The result may be an overapproximation.  If the result is known to be exact,
1114 then C<*exact> is set to C<1>.
1115 The current implementation only produces exact results for particular
1116 cases of piecewise translations (i.e., piecewise uniform dependences).
1117
1118 =item * Reaching path lengths
1119
1120         __isl_give isl_map *isl_map_reaching_path_lengths(
1121                 __isl_take isl_map *map, int *exact);
1122
1123 Compute a relation that maps each element in the range of C<map>
1124 to the lengths of all paths composed of edges in C<map> that
1125 end up in the given element.
1126 The result may be an overapproximation.  If the result is known to be exact,
1127 then C<*exact> is set to C<1>.
1128 To compute the I<maximal> path length, the resulting relation
1129 should be postprocessed by C<isl_map_lexmax>.
1130 In particular, if the input relation is a dependence relation
1131 (mapping sources to sinks), then the maximal path length corresponds
1132 to the free schedule.
1133 Note, however, that C<isl_map_lexmax> expects the maximum to be
1134 finite, so if the path lengths are unbounded (possibly due to
1135 the overapproximation), then you will get an error message.
1136
1137 =back
1138
1139 =head2 Binary Operations
1140
1141 The two arguments of a binary operation not only need to live
1142 in the same C<isl_ctx>, they currently also need to have
1143 the same (number of) parameters.
1144
1145 =head3 Basic Operations
1146
1147 =over
1148
1149 =item * Intersection
1150
1151         __isl_give isl_basic_set *isl_basic_set_intersect(
1152                 __isl_take isl_basic_set *bset1,
1153                 __isl_take isl_basic_set *bset2);
1154         __isl_give isl_set *isl_set_intersect(
1155                 __isl_take isl_set *set1,
1156                 __isl_take isl_set *set2);
1157         __isl_give isl_union_set *isl_union_set_intersect(
1158                 __isl_take isl_union_set *uset1,
1159                 __isl_take isl_union_set *uset2);
1160         __isl_give isl_basic_map *isl_basic_map_intersect_domain(
1161                 __isl_take isl_basic_map *bmap,
1162                 __isl_take isl_basic_set *bset);
1163         __isl_give isl_basic_map *isl_basic_map_intersect_range(
1164                 __isl_take isl_basic_map *bmap,
1165                 __isl_take isl_basic_set *bset);
1166         __isl_give isl_basic_map *isl_basic_map_intersect(
1167                 __isl_take isl_basic_map *bmap1,
1168                 __isl_take isl_basic_map *bmap2);
1169         __isl_give isl_map *isl_map_intersect_domain(
1170                 __isl_take isl_map *map,
1171                 __isl_take isl_set *set);
1172         __isl_give isl_map *isl_map_intersect_range(
1173                 __isl_take isl_map *map,
1174                 __isl_take isl_set *set);
1175         __isl_give isl_map *isl_map_intersect(
1176                 __isl_take isl_map *map1,
1177                 __isl_take isl_map *map2);
1178         __isl_give isl_union_map *isl_union_map_intersect_domain(
1179                 __isl_take isl_union_map *umap,
1180                 __isl_take isl_union_set *uset);
1181         __isl_give isl_union_map *isl_union_map_intersect(
1182                 __isl_take isl_union_map *umap1,
1183                 __isl_take isl_union_map *umap2);
1184
1185 =item * Union
1186
1187         __isl_give isl_set *isl_basic_set_union(
1188                 __isl_take isl_basic_set *bset1,
1189                 __isl_take isl_basic_set *bset2);
1190         __isl_give isl_map *isl_basic_map_union(
1191                 __isl_take isl_basic_map *bmap1,
1192                 __isl_take isl_basic_map *bmap2);
1193         __isl_give isl_set *isl_set_union(
1194                 __isl_take isl_set *set1,
1195                 __isl_take isl_set *set2);
1196         __isl_give isl_map *isl_map_union(
1197                 __isl_take isl_map *map1,
1198                 __isl_take isl_map *map2);
1199         __isl_give isl_union_set *isl_union_set_union(
1200                 __isl_take isl_union_set *uset1,
1201                 __isl_take isl_union_set *uset2);
1202         __isl_give isl_union_map *isl_union_map_union(
1203                 __isl_take isl_union_map *umap1,
1204                 __isl_take isl_union_map *umap2);
1205
1206 =item * Set difference
1207
1208         __isl_give isl_set *isl_set_subtract(
1209                 __isl_take isl_set *set1,
1210                 __isl_take isl_set *set2);
1211         __isl_give isl_map *isl_map_subtract(
1212                 __isl_take isl_map *map1,
1213                 __isl_take isl_map *map2);
1214         __isl_give isl_union_set *isl_union_set_subtract(
1215                 __isl_take isl_union_set *uset1,
1216                 __isl_take isl_union_set *uset2);
1217         __isl_give isl_union_map *isl_union_map_subtract(
1218                 __isl_take isl_union_map *umap1,
1219                 __isl_take isl_union_map *umap2);
1220
1221 =item * Application
1222
1223         __isl_give isl_basic_set *isl_basic_set_apply(
1224                 __isl_take isl_basic_set *bset,
1225                 __isl_take isl_basic_map *bmap);
1226         __isl_give isl_set *isl_set_apply(
1227                 __isl_take isl_set *set,
1228                 __isl_take isl_map *map);
1229         __isl_give isl_union_set *isl_union_set_apply(
1230                 __isl_take isl_union_set *uset,
1231                 __isl_take isl_union_map *umap);
1232         __isl_give isl_basic_map *isl_basic_map_apply_domain(
1233                 __isl_take isl_basic_map *bmap1,
1234                 __isl_take isl_basic_map *bmap2);
1235         __isl_give isl_basic_map *isl_basic_map_apply_range(
1236                 __isl_take isl_basic_map *bmap1,
1237                 __isl_take isl_basic_map *bmap2);
1238         __isl_give isl_map *isl_map_apply_domain(
1239                 __isl_take isl_map *map1,
1240                 __isl_take isl_map *map2);
1241         __isl_give isl_map *isl_map_apply_range(
1242                 __isl_take isl_map *map1,
1243                 __isl_take isl_map *map2);
1244         __isl_give isl_union_map *isl_union_map_apply_range(
1245                 __isl_take isl_union_map *umap1,
1246                 __isl_take isl_union_map *umap2);
1247
1248 =item * Simplification
1249
1250         __isl_give isl_basic_set *isl_basic_set_gist(
1251                 __isl_take isl_basic_set *bset,
1252                 __isl_take isl_basic_set *context);
1253         __isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
1254                 __isl_take isl_set *context);
1255         __isl_give isl_union_set *isl_union_set_gist(
1256                 __isl_take isl_union_set *uset,
1257                 __isl_take isl_union_set *context);
1258         __isl_give isl_basic_map *isl_basic_map_gist(
1259                 __isl_take isl_basic_map *bmap,
1260                 __isl_take isl_basic_map *context);
1261         __isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
1262                 __isl_take isl_map *context);
1263         __isl_give isl_union_map *isl_union_map_gist(
1264                 __isl_take isl_union_map *umap,
1265                 __isl_take isl_union_map *context);
1266
1267 The gist operation returns a set or relation that has the
1268 same intersection with the context as the input set or relation.
1269 Any implicit equality in the intersection is made explicit in the result,
1270 while all inequalities that are redundant with respect to the intersection
1271 are removed.
1272 In case of union sets and relations, the gist operation is performed
1273 per dimension.
1274
1275 =back
1276
1277 =head3 Lexicographic Optimization
1278
1279 Given a (basic) set C<set> (or C<bset>) and a zero-dimensional domain C<dom>,
1280 the following functions
1281 compute a set that contains the lexicographic minimum or maximum
1282 of the elements in C<set> (or C<bset>) for those values of the parameters
1283 that satisfy C<dom>.
1284 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
1285 that contains the parameter values in C<dom> for which C<set> (or C<bset>)
1286 has no elements.
1287 In other words, the union of the parameter values
1288 for which the result is non-empty and of C<*empty>
1289 is equal to C<dom>.
1290
1291         __isl_give isl_set *isl_basic_set_partial_lexmin(
1292                 __isl_take isl_basic_set *bset,
1293                 __isl_take isl_basic_set *dom,
1294                 __isl_give isl_set **empty);
1295         __isl_give isl_set *isl_basic_set_partial_lexmax(
1296                 __isl_take isl_basic_set *bset,
1297                 __isl_take isl_basic_set *dom,
1298                 __isl_give isl_set **empty);
1299         __isl_give isl_set *isl_set_partial_lexmin(
1300                 __isl_take isl_set *set, __isl_take isl_set *dom,
1301                 __isl_give isl_set **empty);
1302         __isl_give isl_set *isl_set_partial_lexmax(
1303                 __isl_take isl_set *set, __isl_take isl_set *dom,
1304                 __isl_give isl_set **empty);
1305
1306 Given a (basic) set C<set> (or C<bset>), the following functions simply
1307 return a set containing the lexicographic minimum or maximum
1308 of the elements in C<set> (or C<bset>).
1309 In case of union sets, the optimum is computed per dimension.
1310
1311         __isl_give isl_set *isl_basic_set_lexmin(
1312                 __isl_take isl_basic_set *bset);
1313         __isl_give isl_set *isl_basic_set_lexmax(
1314                 __isl_take isl_basic_set *bset);
1315         __isl_give isl_set *isl_set_lexmin(
1316                 __isl_take isl_set *set);
1317         __isl_give isl_set *isl_set_lexmax(
1318                 __isl_take isl_set *set);
1319         __isl_give isl_union_set *isl_union_set_lexmin(
1320                 __isl_take isl_union_set *uset);
1321         __isl_give isl_union_set *isl_union_set_lexmax(
1322                 __isl_take isl_union_set *uset);
1323
1324 Given a (basic) relation C<map> (or C<bmap>) and a domain C<dom>,
1325 the following functions
1326 compute a relation that maps each element of C<dom>
1327 to the single lexicographic minimum or maximum
1328 of the elements that are associated to that same
1329 element in C<map> (or C<bmap>).
1330 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
1331 that contains the elements in C<dom> that do not map
1332 to any elements in C<map> (or C<bmap>).
1333 In other words, the union of the domain of the result and of C<*empty>
1334 is equal to C<dom>.
1335
1336         __isl_give isl_map *isl_basic_map_partial_lexmax(
1337                 __isl_take isl_basic_map *bmap,
1338                 __isl_take isl_basic_set *dom,
1339                 __isl_give isl_set **empty);
1340         __isl_give isl_map *isl_basic_map_partial_lexmin(
1341                 __isl_take isl_basic_map *bmap,
1342                 __isl_take isl_basic_set *dom,
1343                 __isl_give isl_set **empty);
1344         __isl_give isl_map *isl_map_partial_lexmax(
1345                 __isl_take isl_map *map, __isl_take isl_set *dom,
1346                 __isl_give isl_set **empty);
1347         __isl_give isl_map *isl_map_partial_lexmin(
1348                 __isl_take isl_map *map, __isl_take isl_set *dom,
1349                 __isl_give isl_set **empty);
1350
1351 Given a (basic) map C<map> (or C<bmap>), the following functions simply
1352 return a map mapping each element in the domain of
1353 C<map> (or C<bmap>) to the lexicographic minimum or maximum
1354 of all elements associated to that element.
1355 In case of union relations, the optimum is computed per dimension.
1356
1357         __isl_give isl_map *isl_basic_map_lexmin(
1358                 __isl_take isl_basic_map *bmap);
1359         __isl_give isl_map *isl_basic_map_lexmax(
1360                 __isl_take isl_basic_map *bmap);
1361         __isl_give isl_map *isl_map_lexmin(
1362                 __isl_take isl_map *map);
1363         __isl_give isl_map *isl_map_lexmax(
1364                 __isl_take isl_map *map);
1365         __isl_give isl_union_map *isl_union_map_lexmin(
1366                 __isl_take isl_union_map *umap);
1367         __isl_give isl_union_map *isl_union_map_lexmax(
1368                 __isl_take isl_union_map *umap);
1369
1370 =head2 Points
1371
1372 Points are elements of a set.  They can be used to construct
1373 simple sets (boxes) or they can be used to represent the
1374 individual elements of a set.
1375 The zero point (the origin) can be created using
1376
1377         __isl_give isl_point *isl_point_zero(__isl_take isl_dim *dim);
1378
1379 The coordinates of a point can be inspected, set and changed
1380 using
1381
1382         void isl_point_get_coordinate(__isl_keep isl_point *pnt,
1383                 enum isl_dim_type type, int pos, isl_int *v);
1384         __isl_give isl_point *isl_point_set_coordinate(
1385                 __isl_take isl_point *pnt,
1386                 enum isl_dim_type type, int pos, isl_int v);
1387
1388         __isl_give isl_point *isl_point_add_ui(
1389                 __isl_take isl_point *pnt,
1390                 enum isl_dim_type type, int pos, unsigned val);
1391         __isl_give isl_point *isl_point_sub_ui(
1392                 __isl_take isl_point *pnt,
1393                 enum isl_dim_type type, int pos, unsigned val);
1394
1395 Points can be copied or freed using
1396
1397         __isl_give isl_point *isl_point_copy(
1398                 __isl_keep isl_point *pnt);
1399         void isl_point_free(__isl_take isl_point *pnt);
1400
1401 A singleton set can be created from a point using
1402
1403         __isl_give isl_set *isl_set_from_point(
1404                 __isl_take isl_point *pnt);
1405
1406 and a box can be created from two opposite extremal points using
1407
1408         __isl_give isl_set *isl_set_box_from_points(
1409                 __isl_take isl_point *pnt1,
1410                 __isl_take isl_point *pnt2);
1411
1412 All elements of a B<bounded> (union) set can be enumerated using
1413 the following functions.
1414
1415         int isl_set_foreach_point(__isl_keep isl_set *set,
1416                 int (*fn)(__isl_take isl_point *pnt, void *user),
1417                 void *user);
1418         int isl_union_set_foreach_point(__isl_keep isl_union_set *uset,
1419                 int (*fn)(__isl_take isl_point *pnt, void *user),
1420                 void *user);
1421
1422 The function C<fn> is called for each integer point in
1423 C<set> with as second argument the last argument of
1424 the C<isl_set_foreach_point> call.  The function C<fn>
1425 should return C<0> on success and C<-1> on failure.
1426 In the latter case, C<isl_set_foreach_point> will stop
1427 enumerating and return C<-1> as well.
1428 If the enumeration is performed successfully and to completion,
1429 then C<isl_set_foreach_point> returns C<0>.
1430
1431 To obtain a single point of a set, use
1432
1433         __isl_give isl_point *isl_set_sample_point(
1434                 __isl_take isl_set *set);
1435
1436 If C<set> does not contain any (integer) points, then the
1437 resulting point will be ``void'', a property that can be
1438 tested using
1439
1440         int isl_point_is_void(__isl_keep isl_point *pnt);
1441
1442 =head2 Piecewise Quasipolynomials
1443
1444 A piecewise quasipolynomial is a particular kind of function that maps
1445 a parametric point to a rational value.
1446 More specifically, a quasipolynomial is a polynomial expression in greatest
1447 integer parts of affine expressions of parameters and variables.
1448 A piecewise quasipolynomial is a subdivision of a given parametric
1449 domain into disjoint cells with a quasipolynomial associated to
1450 each cell.  The value of the piecewise quasipolynomial at a given
1451 point is the value of the quasipolynomial associated to the cell
1452 that contains the point.  Outside of the union of cells,
1453 the value is assumed to be zero.
1454 For example, the piecewise quasipolynomial
1455
1456         [n] -> { [x] -> ((1 + n) - x) : x <= n and x >= 0 }
1457
1458 maps C<x> to C<1 + n - x> for values of C<x> between C<0> and C<n>.
1459 A given piecewise quasipolynomial has a fixed domain dimension.
1460 Union piecewise quasipolynomials are used to contain piecewise quasipolynomials
1461 defined over different domains.
1462 Piecewise quasipolynomials are mainly used by the C<barvinok>
1463 library for representing the number of elements in a parametric set or map.
1464 For example, the piecewise quasipolynomial above represents
1465 the number of points in the map
1466
1467         [n] -> { [x] -> [y] : x,y >= 0 and 0 <= x + y <= n }
1468
1469 =head3 Printing (Piecewise) Quasipolynomials
1470
1471 Quasipolynomials and piecewise quasipolynomials can be printed
1472 using the following functions.
1473
1474         __isl_give isl_printer *isl_printer_print_qpolynomial(
1475                 __isl_take isl_printer *p,
1476                 __isl_keep isl_qpolynomial *qp);
1477
1478         __isl_give isl_printer *isl_printer_print_pw_qpolynomial(
1479                 __isl_take isl_printer *p,
1480                 __isl_keep isl_pw_qpolynomial *pwqp);
1481
1482         __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial(
1483                 __isl_take isl_printer *p,
1484                 __isl_keep isl_union_pw_qpolynomial *upwqp);
1485
1486 The output format of the printer
1487 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
1488 For C<isl_printer_print_union_pw_qpolynomial>, only C<ISL_FORMAT_ISL>
1489 is supported.
1490
1491 =head3 Creating New (Piecewise) Quasipolynomials
1492
1493 Some simple quasipolynomials can be created using the following functions.
1494 More complicated quasipolynomials can be created by applying
1495 operations such as addition and multiplication
1496 on the resulting quasipolynomials
1497
1498         __isl_give isl_qpolynomial *isl_qpolynomial_zero(
1499                 __isl_take isl_dim *dim);
1500         __isl_give isl_qpolynomial *isl_qpolynomial_infty(
1501                 __isl_take isl_dim *dim);
1502         __isl_give isl_qpolynomial *isl_qpolynomial_neginfty(
1503                 __isl_take isl_dim *dim);
1504         __isl_give isl_qpolynomial *isl_qpolynomial_nan(
1505                 __isl_take isl_dim *dim);
1506         __isl_give isl_qpolynomial *isl_qpolynomial_rat_cst(
1507                 __isl_take isl_dim *dim,
1508                 const isl_int n, const isl_int d);
1509         __isl_give isl_qpolynomial *isl_qpolynomial_div(
1510                 __isl_take isl_div *div);
1511         __isl_give isl_qpolynomial *isl_qpolynomial_var(
1512                 __isl_take isl_dim *dim,
1513                 enum isl_dim_type type, unsigned pos);
1514
1515 The zero piecewise quasipolynomial or a piecewise quasipolynomial
1516 with a single cell can be created using the following functions.
1517 Multiple of these single cell piecewise quasipolynomials can
1518 be combined to create more complicated piecewise quasipolynomials.
1519
1520         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero(
1521                 __isl_take isl_dim *dim);
1522         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_alloc(
1523                 __isl_take isl_set *set,
1524                 __isl_take isl_qpolynomial *qp);
1525
1526         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_zero(
1527                 __isl_take isl_dim *dim);
1528         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_from_pw_qpolynomial(
1529                 __isl_take isl_pw_qpolynomial *pwqp);
1530         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add_pw_qpolynomial(
1531                 __isl_take isl_union_pw_qpolynomial *upwqp,
1532                 __isl_take isl_pw_qpolynomial *pwqp);
1533
1534 Quasipolynomials can be copied and freed again using the following
1535 functions.
1536
1537         __isl_give isl_qpolynomial *isl_qpolynomial_copy(
1538                 __isl_keep isl_qpolynomial *qp);
1539         void isl_qpolynomial_free(__isl_take isl_qpolynomial *qp);
1540
1541         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy(
1542                 __isl_keep isl_pw_qpolynomial *pwqp);
1543         void isl_pw_qpolynomial_free(
1544                 __isl_take isl_pw_qpolynomial *pwqp);
1545
1546         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_copy(
1547                 __isl_keep isl_union_pw_qpolynomial *upwqp);
1548         void isl_union_pw_qpolynomial_free(
1549                 __isl_take isl_union_pw_qpolynomial *upwqp);
1550
1551 =head3 Inspecting (Piecewise) Quasipolynomials
1552
1553 To iterate over all piecewise quasipolynomials in a union
1554 piecewise quasipolynomial, use the following function
1555
1556         int isl_union_pw_qpolynomial_foreach_pw_qpolynomial(
1557                 __isl_keep isl_union_pw_qpolynomial *upwqp,
1558                 int (*fn)(__isl_take isl_pw_qpolynomial *pwqp, void *user),
1559                 void *user);
1560
1561 To iterate over the cells in a piecewise quasipolynomial,
1562 use either of the following two functions
1563
1564         int isl_pw_qpolynomial_foreach_piece(
1565                 __isl_keep isl_pw_qpolynomial *pwqp,
1566                 int (*fn)(__isl_take isl_set *set,
1567                           __isl_take isl_qpolynomial *qp,
1568                           void *user), void *user);
1569         int isl_pw_qpolynomial_foreach_lifted_piece(
1570                 __isl_keep isl_pw_qpolynomial *pwqp,
1571                 int (*fn)(__isl_take isl_set *set,
1572                           __isl_take isl_qpolynomial *qp,
1573                           void *user), void *user);
1574
1575 As usual, the function C<fn> should return C<0> on success
1576 and C<-1> on failure.  The difference between
1577 C<isl_pw_qpolynomial_foreach_piece> and
1578 C<isl_pw_qpolynomial_foreach_lifted_piece> is that
1579 C<isl_pw_qpolynomial_foreach_lifted_piece> will first
1580 compute unique representations for all existentially quantified
1581 variables and then turn these existentially quantified variables
1582 into extra set variables, adapting the associated quasipolynomial
1583 accordingly.  This means that the C<set> passed to C<fn>
1584 will not have any existentially quantified variables, but that
1585 the dimensions of the sets may be different for different
1586 invocations of C<fn>.
1587
1588 To iterate over all terms in a quasipolynomial,
1589 use
1590
1591         int isl_qpolynomial_foreach_term(
1592                 __isl_keep isl_qpolynomial *qp,
1593                 int (*fn)(__isl_take isl_term *term,
1594                           void *user), void *user);
1595
1596 The terms themselves can be inspected and freed using
1597 these functions
1598
1599         unsigned isl_term_dim(__isl_keep isl_term *term,
1600                 enum isl_dim_type type);
1601         void isl_term_get_num(__isl_keep isl_term *term,
1602                 isl_int *n);
1603         void isl_term_get_den(__isl_keep isl_term *term,
1604                 isl_int *d);
1605         int isl_term_get_exp(__isl_keep isl_term *term,
1606                 enum isl_dim_type type, unsigned pos);
1607         __isl_give isl_div *isl_term_get_div(
1608                 __isl_keep isl_term *term, unsigned pos);
1609         void isl_term_free(__isl_take isl_term *term);
1610
1611 Each term is a product of parameters, set variables and
1612 integer divisions.  The function C<isl_term_get_exp>
1613 returns the exponent of a given dimensions in the given term.
1614 The C<isl_int>s in the arguments of C<isl_term_get_num>
1615 and C<isl_term_get_den> need to have been initialized
1616 using C<isl_int_init> before calling these functions.
1617
1618 =head3 Properties of (Piecewise) Quasipolynomials
1619
1620 To check whether a quasipolynomial is actually a constant,
1621 use the following function.
1622
1623         int isl_qpolynomial_is_cst(__isl_keep isl_qpolynomial *qp,
1624                 isl_int *n, isl_int *d);
1625
1626 If C<qp> is a constant and if C<n> and C<d> are not C<NULL>
1627 then the numerator and denominator of the constant
1628 are returned in C<*n> and C<*d>, respectively.
1629
1630 =head3 Operations on (Piecewise) Quasipolynomials
1631
1632         __isl_give isl_qpolynomial *isl_qpolynomial_neg(
1633                 __isl_take isl_qpolynomial *qp);
1634         __isl_give isl_qpolynomial *isl_qpolynomial_add(
1635                 __isl_take isl_qpolynomial *qp1,
1636                 __isl_take isl_qpolynomial *qp2);
1637         __isl_give isl_qpolynomial *isl_qpolynomial_sub(
1638                 __isl_take isl_qpolynomial *qp1,
1639                 __isl_take isl_qpolynomial *qp2);
1640         __isl_give isl_qpolynomial *isl_qpolynomial_mul(
1641                 __isl_take isl_qpolynomial *qp1,
1642                 __isl_take isl_qpolynomial *qp2);
1643
1644         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
1645                 __isl_take isl_pw_qpolynomial *pwqp1,
1646                 __isl_take isl_pw_qpolynomial *pwqp2);
1647         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub(
1648                 __isl_take isl_pw_qpolynomial *pwqp1,
1649                 __isl_take isl_pw_qpolynomial *pwqp2);
1650         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint(
1651                 __isl_take isl_pw_qpolynomial *pwqp1,
1652                 __isl_take isl_pw_qpolynomial *pwqp2);
1653         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg(
1654                 __isl_take isl_pw_qpolynomial *pwqp);
1655         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
1656                 __isl_take isl_pw_qpolynomial *pwqp1,
1657                 __isl_take isl_pw_qpolynomial *pwqp2);
1658
1659         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add(
1660                 __isl_take isl_union_pw_qpolynomial *upwqp1,
1661                 __isl_take isl_union_pw_qpolynomial *upwqp2);
1662         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
1663                 __isl_take isl_union_pw_qpolynomial *upwqp1,
1664                 __isl_take isl_union_pw_qpolynomial *upwqp2);
1665         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
1666                 __isl_take isl_union_pw_qpolynomial *upwqp1,
1667                 __isl_take isl_union_pw_qpolynomial *upwqp2);
1668
1669         __isl_give isl_qpolynomial *isl_pw_qpolynomial_eval(
1670                 __isl_take isl_pw_qpolynomial *pwqp,
1671                 __isl_take isl_point *pnt);
1672
1673         __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_eval(
1674                 __isl_take isl_union_pw_qpolynomial *upwqp,
1675                 __isl_take isl_point *pnt);
1676
1677         __isl_give isl_set *isl_pw_qpolynomial_domain(
1678                 __isl_take isl_pw_qpolynomial *pwqp);
1679         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_domain(
1680                 __isl_take isl_pw_qpolynomial *pwpq,
1681                 __isl_take isl_set *set);
1682
1683         __isl_give isl_union_set *isl_union_pw_qpolynomial_domain(
1684                 __isl_take isl_union_pw_qpolynomial *upwqp);
1685         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_intersect_domain(
1686                 __isl_take isl_union_pw_qpolynomial *upwpq,
1687                 __isl_take isl_union_set *uset);
1688
1689         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_coalesce(
1690                 __isl_take isl_union_pw_qpolynomial *upwqp);
1691
1692         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist(
1693                 __isl_take isl_pw_qpolynomial *pwqp,
1694                 __isl_take isl_set *context);
1695
1696         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist(
1697                 __isl_take isl_union_pw_qpolynomial *upwqp,
1698                 __isl_take isl_union_set *context);
1699
1700 The gist operation applies the gist operation to each of
1701 the cells in the domain of the input piecewise quasipolynomial.
1702 In future, the operation will also exploit the context
1703 to simplify the quasipolynomials associated to each cell.
1704
1705 =head2 Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions
1706
1707 A piecewise quasipolynomial reduction is a piecewise
1708 reduction (or fold) of quasipolynomials.
1709 In particular, the reduction can be maximum or a minimum.
1710 The objects are mainly used to represent the result of
1711 an upper or lower bound on a quasipolynomial over its domain,
1712 i.e., as the result of the following function.
1713
1714         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound(
1715                 __isl_take isl_pw_qpolynomial *pwqp,
1716                 enum isl_fold type, int *tight);
1717
1718         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_bound(
1719                 __isl_take isl_union_pw_qpolynomial *upwqp,
1720                 enum isl_fold type, int *tight);
1721
1722 The C<type> argument may be either C<isl_fold_min> or C<isl_fold_max>.
1723 If C<tight> is not C<NULL>, then C<*tight> is set to C<1>
1724 is the returned bound is known be tight, i.e., for each value
1725 of the parameters there is at least
1726 one element in the domain that reaches the bound.
1727
1728 A (piecewise) quasipolynomial reduction can be copied or freed using the
1729 following functions.
1730
1731         __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_copy(
1732                 __isl_keep isl_qpolynomial_fold *fold);
1733         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_copy(
1734                 __isl_keep isl_pw_qpolynomial_fold *pwf);
1735         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_copy(
1736                 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
1737         void isl_qpolynomial_fold_free(
1738                 __isl_take isl_qpolynomial_fold *fold);
1739         void isl_pw_qpolynomial_fold_free(
1740                 __isl_take isl_pw_qpolynomial_fold *pwf);
1741         void isl_union_pw_qpolynomial_fold_free(
1742                 __isl_take isl_union_pw_qpolynomial_fold *upwf);
1743
1744 =head3 Printing Piecewise Quasipolynomial Reductions
1745
1746 Piecewise quasipolynomial reductions can be printed
1747 using the following function.
1748
1749         __isl_give isl_printer *isl_printer_print_pw_qpolynomial_fold(
1750                 __isl_take isl_printer *p,
1751                 __isl_keep isl_pw_qpolynomial_fold *pwf);
1752         __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial_fold(
1753                 __isl_take isl_printer *p,
1754                 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
1755
1756 For C<isl_printer_print_pw_qpolynomial_fold>,
1757 output format of the printer
1758 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
1759 For C<isl_printer_print_union_pw_qpolynomial_fold>,
1760 output format of the printer
1761 needs to be set to either C<ISL_FORMAT_ISL>.
1762
1763 =head3 Inspecting (Piecewise) Quasipolynomial Reductions
1764
1765 To iterate over all piecewise quasipolynomial reductions in a union
1766 piecewise quasipolynomial reduction, use the following function
1767
1768         int isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(
1769                 __isl_keep isl_union_pw_qpolynomial_fold *upwf,
1770                 int (*fn)(__isl_take isl_pw_qpolynomial_fold *pwf,
1771                             void *user), void *user);
1772
1773 To iterate over the cells in a piecewise quasipolynomial reduction,
1774 use either of the following two functions
1775
1776         int isl_pw_qpolynomial_fold_foreach_piece(
1777                 __isl_keep isl_pw_qpolynomial_fold *pwf,
1778                 int (*fn)(__isl_take isl_set *set,
1779                           __isl_take isl_qpolynomial_fold *fold,
1780                           void *user), void *user);
1781         int isl_pw_qpolynomial_fold_foreach_lifted_piece(
1782                 __isl_keep isl_pw_qpolynomial_fold *pwf,
1783                 int (*fn)(__isl_take isl_set *set,
1784                           __isl_take isl_qpolynomial_fold *fold,
1785                           void *user), void *user);
1786
1787 See L<Inspecting (Piecewise) Quasipolynomials> for an explanation
1788 of the difference between these two functions.
1789
1790 To iterate over all quasipolynomials in a reduction, use
1791
1792         int isl_qpolynomial_fold_foreach_qpolynomial(
1793                 __isl_keep isl_qpolynomial_fold *fold,
1794                 int (*fn)(__isl_take isl_qpolynomial *qp,
1795                           void *user), void *user);
1796
1797 =head3 Operations on Piecewise Quasipolynomial Reductions
1798
1799         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
1800                 __isl_take isl_pw_qpolynomial_fold *pwf1,
1801                 __isl_take isl_pw_qpolynomial_fold *pwf2);
1802
1803         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_add(
1804                 __isl_take isl_union_pw_qpolynomial_fold *upwf1,
1805                 __isl_take isl_union_pw_qpolynomial_fold *upwf2);
1806
1807         __isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_eval(
1808                 __isl_take isl_pw_qpolynomial_fold *pwf,
1809                 __isl_take isl_point *pnt);
1810
1811         __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_fold_eval(
1812                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
1813                 __isl_take isl_point *pnt);
1814
1815         __isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain(
1816                 __isl_take isl_union_pw_qpolynomial_fold *upwf);
1817         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_intersect_domain(
1818                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
1819                 __isl_take isl_union_set *uset);
1820
1821         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_coalesce(
1822                 __isl_take isl_pw_qpolynomial_fold *pwf);
1823
1824         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_coalesce(
1825                 __isl_take isl_union_pw_qpolynomial_fold *upwf);
1826
1827         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist(
1828                 __isl_take isl_pw_qpolynomial_fold *pwf,
1829                 __isl_take isl_set *context);
1830
1831         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_gist(
1832                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
1833                 __isl_take isl_union_set *context);
1834
1835 The gist operation applies the gist operation to each of
1836 the cells in the domain of the input piecewise quasipolynomial reduction.
1837 In future, the operation will also exploit the context
1838 to simplify the quasipolynomial reductions associated to each cell.
1839
1840 =head2 Dependence Analysis
1841
1842 C<isl> contains specialized functionality for performing
1843 array dataflow analysis.  That is, given a I<sink> access relation
1844 and a collection of possible I<source> access relations,
1845 C<isl> can compute relations that describe
1846 for each iteration of the sink access, which iteration
1847 of which of the source access relations was the last
1848 to access the same data element before the given iteration
1849 of the sink access.
1850 To compute standard flow dependences, the sink should be
1851 a read, while the sources should be writes.
1852 If any of the source accesses are marked as being I<may>
1853 accesses, then there will be a dependence to the last
1854 I<must> access B<and> to any I<may> access that follows
1855 this last I<must> access.
1856 In particular, if I<all> sources are I<may> accesses,
1857 then memory based dependence analysis is performed.
1858 If, on the other hand, all sources are I<must> accesses,
1859 then value based dependence analysis is performed.
1860
1861         #include <isl_flow.h>
1862
1863         __isl_give isl_access_info *isl_access_info_alloc(
1864                 __isl_take isl_map *sink,
1865                 void *sink_user, isl_access_level_before fn,
1866                 int max_source);
1867         __isl_give isl_access_info *isl_access_info_add_source(
1868                 __isl_take isl_access_info *acc,
1869                 __isl_take isl_map *source, int must,
1870                 void *source_user);
1871
1872         __isl_give isl_flow *isl_access_info_compute_flow(
1873                 __isl_take isl_access_info *acc);
1874
1875         int isl_flow_foreach(__isl_keep isl_flow *deps,
1876                 int (*fn)(__isl_take isl_map *dep, int must,
1877                           void *dep_user, void *user),
1878                 void *user);
1879         __isl_give isl_set *isl_flow_get_no_source(
1880                 __isl_keep isl_flow *deps, int must);
1881         void isl_flow_free(__isl_take isl_flow *deps);
1882
1883 The function C<isl_access_info_compute_flow> performs the actual
1884 dependence analysis.  The other functions are used to construct
1885 the input for this function or to read off the output.
1886
1887 The input is collected in an C<isl_access_info>, which can
1888 be created through a call to C<isl_access_info_alloc>.
1889 The arguments to this functions are the sink access relation
1890 C<sink>, a token C<sink_user> used to identify the sink
1891 access to the user, a callback function for specifying the
1892 relative order of source and sink accesses, and the number
1893 of source access relations that will be added.
1894 The callback function has type C<int (*)(void *first, void *second)>.
1895 The function is called with two user supplied tokens identifying
1896 either a source or the sink and it should return the shared nesting
1897 level and the relative order of the two accesses.
1898 In particular, let I<n> be the number of loops shared by
1899 the two accesses.  If C<first> precedes C<second> textually,
1900 then the function should return I<2 * n + 1>; otherwise,
1901 it should return I<2 * n>.
1902 The sources can be added to the C<isl_access_info> by performing
1903 (at most) C<max_source> calls to C<isl_access_info_add_source>.
1904 C<must> indicates whether the source is a I<must> access
1905 or a I<may> access.  Note that a multi-valued access relation
1906 should only be marked I<must> if every iteration in the domain
1907 of the relation accesses I<all> elements in its image.
1908 The C<source_user> token is again used to identify
1909 the source access.  The range of the source access relation
1910 C<source> should have the same dimension as the range
1911 of the sink access relation.
1912
1913 The result of the dependence analysis is collected in an
1914 C<isl_flow>.  There may be elements in the domain of
1915 the sink access for which no preceding source access could be
1916 found or for which all preceding sources are I<may> accesses.
1917 The sets of these elements can be obtained through
1918 calls to C<isl_flow_get_no_source>, the first with C<must> set
1919 and the second with C<must> unset.
1920 In the case of standard flow dependence analysis,
1921 with the sink a read and the sources I<must> writes,
1922 the first set corresponds to the reads from uninitialized
1923 array elements and the second set is empty.
1924 The actual flow dependences can be extracted using
1925 C<isl_flow_foreach>.  This function will call the user-specified
1926 callback function C<fn> for each B<non-empty> dependence between
1927 a source and the sink.  The callback function is called
1928 with four arguments, the actual flow dependence relation
1929 mapping source iterations to sink iterations, a boolean that
1930 indicates whether it is a I<must> or I<may> dependence, a token
1931 identifying the source and an additional C<void *> with value
1932 equal to the third argument of the C<isl_flow_foreach> call.
1933 A dependence is marked I<must> if it originates from a I<must>
1934 source and if it is not followed by any I<may> sources.
1935
1936 After finishing with an C<isl_flow>, the user should call
1937 C<isl_flow_free> to free all associated memory.
1938
1939 =head2 Parametric Vertex Enumeration
1940
1941 The parametric vertex enumeration described in this section
1942 is mainly intended to be used internally and by the C<barvinok>
1943 library.
1944
1945         #include <isl_vertices.h>
1946         __isl_give isl_vertices *isl_basic_set_compute_vertices(
1947                 __isl_keep isl_basic_set *bset);
1948
1949 The function C<isl_basic_set_compute_vertices> performs the
1950 actual computation of the parametric vertices and the chamber
1951 decomposition and store the result in an C<isl_vertices> object.
1952 This information can be queried by either iterating over all
1953 the vertices or iterating over all the chambers or cells
1954 and then iterating over all vertices that are active on the chamber.
1955
1956         int isl_vertices_foreach_vertex(
1957                 __isl_keep isl_vertices *vertices,
1958                 int (*fn)(__isl_take isl_vertex *vertex, void *user),
1959                 void *user);
1960
1961         int isl_vertices_foreach_cell(
1962                 __isl_keep isl_vertices *vertices,
1963                 int (*fn)(__isl_take isl_cell *cell, void *user),
1964                 void *user);
1965         int isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
1966                 int (*fn)(__isl_take isl_vertex *vertex, void *user),
1967                 void *user);
1968
1969 Other operations that can be performed on an C<isl_vertices> object are
1970 the following.
1971
1972         isl_ctx *isl_vertices_get_ctx(
1973                 __isl_keep isl_vertices *vertices);
1974         int isl_vertices_get_n_vertices(
1975                 __isl_keep isl_vertices *vertices);
1976         void isl_vertices_free(__isl_take isl_vertices *vertices);
1977
1978 Vertices can be inspected and destroyed using the following functions.
1979
1980         isl_ctx *isl_vertex_get_ctx(__isl_keep isl_vertex *vertex);
1981         int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
1982         __isl_give isl_basic_set *isl_vertex_get_domain(
1983                 __isl_keep isl_vertex *vertex);
1984         __isl_give isl_basic_set *isl_vertex_get_expr(
1985                 __isl_keep isl_vertex *vertex);
1986         void isl_vertex_free(__isl_take isl_vertex *vertex);
1987
1988 C<isl_vertex_get_expr> returns a singleton parametric set describing
1989 the vertex, while C<isl_vertex_get_domain> returns the activity domain
1990 of the vertex.
1991 Note that C<isl_vertex_get_domain> and C<isl_vertex_get_expr> return
1992 B<rational> basic sets, so they should mainly be used for inspection
1993 and should not be mixed with integer sets.
1994
1995 Chambers can be inspected and destroyed using the following functions.
1996
1997         isl_ctx *isl_cell_get_ctx(__isl_keep isl_cell *cell);
1998         __isl_give isl_basic_set *isl_cell_get_domain(
1999                 __isl_keep isl_cell *cell);
2000         void isl_cell_free(__isl_take isl_cell *cell);
2001
2002 =head1 Applications
2003
2004 Although C<isl> is mainly meant to be used as a library,
2005 it also contains some basic applications that use some
2006 of the functionality of C<isl>.
2007 The input may be specified in either the L<isl format>
2008 or the L<PolyLib format>.
2009
2010 =head2 C<isl_polyhedron_sample>
2011
2012 C<isl_polyhedron_sample> takes a polyhedron as input and prints
2013 an integer element of the polyhedron, if there is any.
2014 The first column in the output is the denominator and is always
2015 equal to 1.  If the polyhedron contains no integer points,
2016 then a vector of length zero is printed.
2017
2018 =head2 C<isl_pip>
2019
2020 C<isl_pip> takes the same input as the C<example> program
2021 from the C<piplib> distribution, i.e., a set of constraints
2022 on the parameters, a line contains only -1 and finally a set
2023 of constraints on a parametric polyhedron.
2024 The coefficients of the parameters appear in the last columns
2025 (but before the final constant column).
2026 The output is the lexicographic minimum of the parametric polyhedron.
2027 As C<isl> currently does not have its own output format, the output
2028 is just a dump of the internal state.
2029
2030 =head2 C<isl_polyhedron_minimize>
2031
2032 C<isl_polyhedron_minimize> computes the minimum of some linear
2033 or affine objective function over the integer points in a polyhedron.
2034 If an affine objective function
2035 is given, then the constant should appear in the last column.
2036
2037 =head2 C<isl_polytope_scan>
2038
2039 Given a polytope, C<isl_polytope_scan> prints
2040 all integer points in the polytope.
2041
2042 =head1 C<isl-polylib>
2043
2044 The C<isl-polylib> library provides the following functions for converting
2045 between C<isl> objects and C<PolyLib> objects.
2046 The library is distributed separately for licensing reasons.
2047
2048         #include <isl_set_polylib.h>
2049         __isl_give isl_basic_set *isl_basic_set_new_from_polylib(
2050                 Polyhedron *P, __isl_take isl_dim *dim);
2051         Polyhedron *isl_basic_set_to_polylib(
2052                 __isl_keep isl_basic_set *bset);
2053         __isl_give isl_set *isl_set_new_from_polylib(Polyhedron *D,
2054                 __isl_take isl_dim *dim);
2055         Polyhedron *isl_set_to_polylib(__isl_keep isl_set *set);
2056
2057         #include <isl_map_polylib.h>
2058         __isl_give isl_basic_map *isl_basic_map_new_from_polylib(
2059                 Polyhedron *P, __isl_take isl_dim *dim);
2060         __isl_give isl_map *isl_map_new_from_polylib(Polyhedron *D,
2061                 __isl_take isl_dim *dim);
2062         Polyhedron *isl_basic_map_to_polylib(
2063                 __isl_keep isl_basic_map *bmap);
2064         Polyhedron *isl_map_to_polylib(__isl_keep isl_map *map);