doc: update example code to change in return type of isl_constraint_set_*
[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 =head3 Changes since isl-0.03
39
40 =over
41
42 =item * The function C<isl_pw_qpolynomial_fold_add> has been
43 renamed to C<isl_pw_qpolynomial_fold_fold>.
44 Similarly, C<isl_union_pw_qpolynomial_fold_add> has been
45 renamed to C<isl_union_pw_qpolynomial_fold_fold>.
46
47 =back
48
49 =head3 Changes since isl-0.04
50
51 =over
52
53 =item * All header files have been renamed from C<isl_header.h>
54 to C<isl/header.h>.
55
56 =back
57
58 =head3 Changes since isl-0.05
59
60 =over
61
62 =item * The functions C<isl_printer_print_basic_set> and
63 C<isl_printer_print_basic_map> no longer print a newline.
64
65 =item * The functions C<isl_flow_get_no_source>
66 and C<isl_union_map_compute_flow> now return
67 the accesses for which no source could be found instead of
68 the iterations where those accesses occur.
69
70 =item * The functions C<isl_basic_map_identity> and
71 C<isl_map_identity> now take a B<map> space as input.  An old call
72 C<isl_map_identity(space)> can be rewritten to
73 C<isl_map_identity(isl_space_map_from_set(space))>.
74
75 =item * The function C<isl_map_power> no longer takes
76 a parameter position as input.  Instead, the exponent
77 is now expressed as the domain of the resulting relation.
78
79 =back
80
81 =head3 Changes since isl-0.06
82
83 =over
84
85 =item * The format of C<isl_printer_print_qpolynomial>'s
86 C<ISL_FORMAT_ISL> output has changed.
87 Use C<ISL_FORMAT_C> to obtain the old output.
88
89 =item * The C<*_fast_*> functions have been renamed to C<*_plain_*>.
90 Some of the old names have been kept for backward compatibility,
91 but they will be removed in the future.
92
93 =back
94
95 =head3 Changes since isl-0.07
96
97 =over
98
99 =item * The function C<isl_pw_aff_max> has been renamed to
100 C<isl_pw_aff_union_max>.
101
102 =item * The C<isl_dim> type has been renamed to C<isl_space>
103 along with the associated functions.
104 Some of the old names have been kept for backward compatibility,
105 but they will be removed in the future.
106
107 =item * Spaces of maps, sets and parameter domains are now
108 treated differently.  The distinction between map spaces and set spaces
109 has always been made on a conceptual level, but proper use of such spaces
110 was never checked.  Furthermore, up until isl-0.07 there was no way
111 of explicitly creating a parameter space.  These can now be created
112 directly using C<isl_space_params_alloc> or from other spaces using
113 C<isl_space_params>.
114
115 =item * The space in which C<isl_aff>, C<isl_pw_aff>, C<isl_qpolynomial>,
116 C<isl_pw_qpolynomial>, C<isl_qpolynomial_fold> and C<isl_pw_qpolynomial_fold>
117 objects live is now a map space
118 instead of a set space.  This means, for example, that the dimensions
119 of the domain of an C<isl_aff> are now considered to be of type
120 C<isl_dim_in> instead of C<isl_dim_set>.  Extra functions have been
121 added to obtain the domain space.  Some of the constructors still
122 take a domain space and have therefore been renamed.
123
124 =back
125
126 =head1 Installation
127
128 The source of C<isl> can be obtained either as a tarball
129 or from the git repository.  Both are available from
130 L<http://freshmeat.net/projects/isl/>.
131 The installation process depends on how you obtained
132 the source.
133
134 =head2 Installation from the git repository
135
136 =over
137
138 =item 1 Clone or update the repository
139
140 The first time the source is obtained, you need to clone
141 the repository.
142
143         git clone git://repo.or.cz/isl.git
144
145 To obtain updates, you need to pull in the latest changes
146
147         git pull
148
149 =item 2 Generate C<configure>
150
151         ./autogen.sh
152
153 =back
154
155 After performing the above steps, continue
156 with the L<Common installation instructions>.
157
158 =head2 Common installation instructions
159
160 =over
161
162 =item 1 Obtain C<GMP>
163
164 Building C<isl> requires C<GMP>, including its headers files.
165 Your distribution may not provide these header files by default
166 and you may need to install a package called C<gmp-devel> or something
167 similar.  Alternatively, C<GMP> can be built from
168 source, available from L<http://gmplib.org/>.
169
170 =item 2 Configure
171
172 C<isl> uses the standard C<autoconf> C<configure> script.
173 To run it, just type
174
175         ./configure
176
177 optionally followed by some configure options.
178 A complete list of options can be obtained by running
179
180         ./configure --help
181
182 Below we discuss some of the more common options.
183
184 C<isl> can optionally use C<piplib>, but no
185 C<piplib> functionality is currently used by default.
186 The C<--with-piplib> option can
187 be used to specify which C<piplib>
188 library to use, either an installed version (C<system>),
189 an externally built version (C<build>)
190 or no version (C<no>).  The option C<build> is mostly useful
191 in C<configure> scripts of larger projects that bundle both C<isl>
192 and C<piplib>.
193
194 =over
195
196 =item C<--prefix>
197
198 Installation prefix for C<isl>
199
200 =item C<--with-gmp-prefix>
201
202 Installation prefix for C<GMP> (architecture-independent files).
203
204 =item C<--with-gmp-exec-prefix>
205
206 Installation prefix for C<GMP> (architecture-dependent files).
207
208 =item C<--with-piplib>
209
210 Which copy of C<piplib> to use, either C<no> (default), C<system> or C<build>.
211
212 =item C<--with-piplib-prefix>
213
214 Installation prefix for C<system> C<piplib> (architecture-independent files).
215
216 =item C<--with-piplib-exec-prefix>
217
218 Installation prefix for C<system> C<piplib> (architecture-dependent files).
219
220 =item C<--with-piplib-builddir>
221
222 Location where C<build> C<piplib> was built.
223
224 =back
225
226 =item 3 Compile
227
228         make
229
230 =item 4 Install (optional)
231
232         make install
233
234 =back
235
236 =head1 Library
237
238 =head2 Initialization
239
240 All manipulations of integer sets and relations occur within
241 the context of an C<isl_ctx>.
242 A given C<isl_ctx> can only be used within a single thread.
243 All arguments of a function are required to have been allocated
244 within the same context.
245 There are currently no functions available for moving an object
246 from one C<isl_ctx> to another C<isl_ctx>.  This means that
247 there is currently no way of safely moving an object from one
248 thread to another, unless the whole C<isl_ctx> is moved.
249
250 An C<isl_ctx> can be allocated using C<isl_ctx_alloc> and
251 freed using C<isl_ctx_free>.
252 All objects allocated within an C<isl_ctx> should be freed
253 before the C<isl_ctx> itself is freed.
254
255         isl_ctx *isl_ctx_alloc();
256         void isl_ctx_free(isl_ctx *ctx);
257
258 =head2 Integers
259
260 All operations on integers, mainly the coefficients
261 of the constraints describing the sets and relations,
262 are performed in exact integer arithmetic using C<GMP>.
263 However, to allow future versions of C<isl> to optionally
264 support fixed integer arithmetic, all calls to C<GMP>
265 are wrapped inside C<isl> specific macros.
266 The basic type is C<isl_int> and the operations below
267 are available on this type.
268 The meanings of these operations are essentially the same
269 as their C<GMP> C<mpz_> counterparts.
270 As always with C<GMP> types, C<isl_int>s need to be
271 initialized with C<isl_int_init> before they can be used
272 and they need to be released with C<isl_int_clear>
273 after the last use.
274 The user should not assume that an C<isl_int> is represented
275 as a C<mpz_t>, but should instead explicitly convert between
276 C<mpz_t>s and C<isl_int>s using C<isl_int_set_gmp> and
277 C<isl_int_get_gmp> whenever a C<mpz_t> is required.
278
279 =over
280
281 =item isl_int_init(i)
282
283 =item isl_int_clear(i)
284
285 =item isl_int_set(r,i)
286
287 =item isl_int_set_si(r,i)
288
289 =item isl_int_set_gmp(r,g)
290
291 =item isl_int_get_gmp(i,g)
292
293 =item isl_int_abs(r,i)
294
295 =item isl_int_neg(r,i)
296
297 =item isl_int_swap(i,j)
298
299 =item isl_int_swap_or_set(i,j)
300
301 =item isl_int_add_ui(r,i,j)
302
303 =item isl_int_sub_ui(r,i,j)
304
305 =item isl_int_add(r,i,j)
306
307 =item isl_int_sub(r,i,j)
308
309 =item isl_int_mul(r,i,j)
310
311 =item isl_int_mul_ui(r,i,j)
312
313 =item isl_int_addmul(r,i,j)
314
315 =item isl_int_submul(r,i,j)
316
317 =item isl_int_gcd(r,i,j)
318
319 =item isl_int_lcm(r,i,j)
320
321 =item isl_int_divexact(r,i,j)
322
323 =item isl_int_cdiv_q(r,i,j)
324
325 =item isl_int_fdiv_q(r,i,j)
326
327 =item isl_int_fdiv_r(r,i,j)
328
329 =item isl_int_fdiv_q_ui(r,i,j)
330
331 =item isl_int_read(r,s)
332
333 =item isl_int_print(out,i,width)
334
335 =item isl_int_sgn(i)
336
337 =item isl_int_cmp(i,j)
338
339 =item isl_int_cmp_si(i,si)
340
341 =item isl_int_eq(i,j)
342
343 =item isl_int_ne(i,j)
344
345 =item isl_int_lt(i,j)
346
347 =item isl_int_le(i,j)
348
349 =item isl_int_gt(i,j)
350
351 =item isl_int_ge(i,j)
352
353 =item isl_int_abs_eq(i,j)
354
355 =item isl_int_abs_ne(i,j)
356
357 =item isl_int_abs_lt(i,j)
358
359 =item isl_int_abs_gt(i,j)
360
361 =item isl_int_abs_ge(i,j)
362
363 =item isl_int_is_zero(i)
364
365 =item isl_int_is_one(i)
366
367 =item isl_int_is_negone(i)
368
369 =item isl_int_is_pos(i)
370
371 =item isl_int_is_neg(i)
372
373 =item isl_int_is_nonpos(i)
374
375 =item isl_int_is_nonneg(i)
376
377 =item isl_int_is_divisible_by(i,j)
378
379 =back
380
381 =head2 Sets and Relations
382
383 C<isl> uses six types of objects for representing sets and relations,
384 C<isl_basic_set>, C<isl_basic_map>, C<isl_set>, C<isl_map>,
385 C<isl_union_set> and C<isl_union_map>.
386 C<isl_basic_set> and C<isl_basic_map> represent sets and relations that
387 can be described as a conjunction of affine constraints, while
388 C<isl_set> and C<isl_map> represent unions of
389 C<isl_basic_set>s and C<isl_basic_map>s, respectively.
390 However, all C<isl_basic_set>s or C<isl_basic_map>s in the union need
391 to live in the same space.  C<isl_union_set>s and C<isl_union_map>s
392 represent unions of C<isl_set>s or C<isl_map>s in I<different> spaces,
393 where spaces are considered different if they have a different number
394 of dimensions and/or different names (see L<"Spaces">).
395 The difference between sets and relations (maps) is that sets have
396 one set of variables, while relations have two sets of variables,
397 input variables and output variables.
398
399 =head2 Memory Management
400
401 Since a high-level operation on sets and/or relations usually involves
402 several substeps and since the user is usually not interested in
403 the intermediate results, most functions that return a new object
404 will also release all the objects passed as arguments.
405 If the user still wants to use one or more of these arguments
406 after the function call, she should pass along a copy of the
407 object rather than the object itself.
408 The user is then responsible for making sure that the original
409 object gets used somewhere else or is explicitly freed.
410
411 The arguments and return values of all documented functions are
412 annotated to make clear which arguments are released and which
413 arguments are preserved.  In particular, the following annotations
414 are used
415
416 =over
417
418 =item C<__isl_give>
419
420 C<__isl_give> means that a new object is returned.
421 The user should make sure that the returned pointer is
422 used exactly once as a value for an C<__isl_take> argument.
423 In between, it can be used as a value for as many
424 C<__isl_keep> arguments as the user likes.
425 There is one exception, and that is the case where the
426 pointer returned is C<NULL>.  Is this case, the user
427 is free to use it as an C<__isl_take> argument or not.
428
429 =item C<__isl_take>
430
431 C<__isl_take> means that the object the argument points to
432 is taken over by the function and may no longer be used
433 by the user as an argument to any other function.
434 The pointer value must be one returned by a function
435 returning an C<__isl_give> pointer.
436 If the user passes in a C<NULL> value, then this will
437 be treated as an error in the sense that the function will
438 not perform its usual operation.  However, it will still
439 make sure that all the other C<__isl_take> arguments
440 are released.
441
442 =item C<__isl_keep>
443
444 C<__isl_keep> means that the function will only use the object
445 temporarily.  After the function has finished, the user
446 can still use it as an argument to other functions.
447 A C<NULL> value will be treated in the same way as
448 a C<NULL> value for an C<__isl_take> argument.
449
450 =back
451
452 =head2 Identifiers
453
454 Identifiers are used to identify both individual dimensions
455 and tuples of dimensions.  They consist of a name and an optional
456 pointer.  Identifiers with the same name but different pointer values
457 are considered to be distinct.
458 Identifiers can be constructed, copied, freed, inspected and printed
459 using the following functions.
460
461         #include <isl/id.h>
462         __isl_give isl_id *isl_id_alloc(isl_ctx *ctx,
463                 __isl_keep const char *name, void *user);
464         __isl_give isl_id *isl_id_copy(isl_id *id);
465         void *isl_id_free(__isl_take isl_id *id);
466
467         isl_ctx *isl_id_get_ctx(__isl_keep isl_id *id);
468         void *isl_id_get_user(__isl_keep isl_id *id);
469         __isl_keep const char *isl_id_get_name(__isl_keep isl_id *id);
470
471         __isl_give isl_printer *isl_printer_print_id(
472                 __isl_take isl_printer *p, __isl_keep isl_id *id);
473
474 Note that C<isl_id_get_name> returns a pointer to some internal
475 data structure, so the result can only be used while the
476 corresponding C<isl_id> is alive.
477
478 =head2 Spaces
479
480 Whenever a new set or relation is created from scratch,
481 the space in which it lives needs to be specified using an C<isl_space>.
482
483         #include <isl/space.h>
484         __isl_give isl_space *isl_space_alloc(isl_ctx *ctx,
485                 unsigned nparam, unsigned n_in, unsigned n_out);
486         __isl_give isl_space *isl_space_params_alloc(isl_ctx *ctx,
487                 unsigned nparam);
488         __isl_give isl_space *isl_space_set_alloc(isl_ctx *ctx,
489                 unsigned nparam, unsigned dim);
490         __isl_give isl_space *isl_space_copy(__isl_keep isl_space *space);
491         void isl_space_free(__isl_take isl_space *space);
492         unsigned isl_space_dim(__isl_keep isl_space *space,
493                 enum isl_dim_type type);
494
495 The space used for creating a parameter domain
496 needs to be created using C<isl_space_params_alloc>.
497 For other sets, the space
498 needs to be created using C<isl_space_set_alloc>, while
499 for a relation, the space
500 needs to be created using C<isl_space_alloc>.
501 C<isl_space_dim> can be used
502 to find out the number of dimensions of each type in
503 a space, where type may be
504 C<isl_dim_param>, C<isl_dim_in> (only for relations),
505 C<isl_dim_out> (only for relations), C<isl_dim_set>
506 (only for sets) or C<isl_dim_all>.
507
508 To check whether a given space is that of a set or a map
509 or whether it is a parameter space, use these functions:
510
511         #include <isl/space.h>
512         int isl_space_is_params(__isl_keep isl_space *space);
513         int isl_space_is_set(__isl_keep isl_space *space);
514
515 It is often useful to create objects that live in the
516 same space as some other object.  This can be accomplished
517 by creating the new objects
518 (see L<Creating New Sets and Relations> or
519 L<Creating New (Piecewise) Quasipolynomials>) based on the space
520 of the original object.
521
522         #include <isl/set.h>
523         __isl_give isl_space *isl_basic_set_get_space(
524                 __isl_keep isl_basic_set *bset);
525         __isl_give isl_space *isl_set_get_space(__isl_keep isl_set *set);
526
527         #include <isl/union_set.h>
528         __isl_give isl_space *isl_union_set_get_space(
529                 __isl_keep isl_union_set *uset);
530
531         #include <isl/map.h>
532         __isl_give isl_space *isl_basic_map_get_space(
533                 __isl_keep isl_basic_map *bmap);
534         __isl_give isl_space *isl_map_get_space(__isl_keep isl_map *map);
535
536         #include <isl/union_map.h>
537         __isl_give isl_space *isl_union_map_get_space(
538                 __isl_keep isl_union_map *umap);
539
540         #include <isl/constraint.h>
541         __isl_give isl_space *isl_constraint_get_space(
542                 __isl_keep isl_constraint *constraint);
543
544         #include <isl/polynomial.h>
545         __isl_give isl_space *isl_qpolynomial_get_domain_space(
546                 __isl_keep isl_qpolynomial *qp);
547         __isl_give isl_space *isl_qpolynomial_get_space(
548                 __isl_keep isl_qpolynomial *qp);
549         __isl_give isl_space *isl_qpolynomial_fold_get_space(
550                 __isl_keep isl_qpolynomial_fold *fold);
551         __isl_give isl_space *isl_pw_qpolynomial_get_domain_space(
552                 __isl_keep isl_pw_qpolynomial *pwqp);
553         __isl_give isl_space *isl_pw_qpolynomial_get_space(
554                 __isl_keep isl_pw_qpolynomial *pwqp);
555         __isl_give isl_space *isl_pw_qpolynomial_fold_get_domain_space(
556                 __isl_keep isl_pw_qpolynomial_fold *pwf);
557         __isl_give isl_space *isl_pw_qpolynomial_fold_get_space(
558                 __isl_keep isl_pw_qpolynomial_fold *pwf);
559         __isl_give isl_space *isl_union_pw_qpolynomial_get_space(
560                 __isl_keep isl_union_pw_qpolynomial *upwqp);
561         __isl_give isl_space *isl_union_pw_qpolynomial_fold_get_space(
562                 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
563
564         #include <isl/aff.h>
565         __isl_give isl_space *isl_aff_get_domain_space(
566                 __isl_keep isl_aff *aff);
567         __isl_give isl_space *isl_aff_get_space(
568                 __isl_keep isl_aff *aff);
569         __isl_give isl_space *isl_pw_aff_get_domain_space(
570                 __isl_keep isl_pw_aff *pwaff);
571         __isl_give isl_space *isl_pw_aff_get_space(
572                 __isl_keep isl_pw_aff *pwaff);
573
574         #include <isl/point.h>
575         __isl_give isl_space *isl_point_get_space(
576                 __isl_keep isl_point *pnt);
577
578 The identifiers or names of the individual dimensions may be set or read off
579 using the following functions.
580
581         #include <isl/space.h>
582         __isl_give isl_space *isl_space_set_dim_id(
583                 __isl_take isl_space *space,
584                 enum isl_dim_type type, unsigned pos,
585                 __isl_take isl_id *id);
586         int isl_space_has_dim_id(__isl_keep isl_space *space,
587                 enum isl_dim_type type, unsigned pos);
588         __isl_give isl_id *isl_space_get_dim_id(
589                 __isl_keep isl_space *space,
590                 enum isl_dim_type type, unsigned pos);
591         __isl_give isl_space *isl_space_set_dim_name(__isl_take isl_space *space,
592                                  enum isl_dim_type type, unsigned pos,
593                                  __isl_keep const char *name);
594         __isl_keep const char *isl_space_get_dim_name(__isl_keep isl_space *space,
595                                  enum isl_dim_type type, unsigned pos);
596
597 Note that C<isl_space_get_name> returns a pointer to some internal
598 data structure, so the result can only be used while the
599 corresponding C<isl_space> is alive.
600 Also note that every function that operates on two sets or relations
601 requires that both arguments have the same parameters.  This also
602 means that if one of the arguments has named parameters, then the
603 other needs to have named parameters too and the names need to match.
604 Pairs of C<isl_set>, C<isl_map>, C<isl_union_set> and/or C<isl_union_map>
605 arguments may have different parameters (as long as they are named),
606 in which case the result will have as parameters the union of the parameters of
607 the arguments.
608
609 Given the identifier of a dimension (typically a parameter),
610 its position can be obtained from the following function.
611
612         #include <isl/space.h>
613         int isl_space_find_dim_by_id(__isl_keep isl_space *space,
614                 enum isl_dim_type type, __isl_keep isl_id *id);
615
616 The identifiers or names of entire spaces may be set or read off
617 using the following functions.
618
619         #include <isl/space.h>
620         __isl_give isl_space *isl_space_set_tuple_id(
621                 __isl_take isl_space *space,
622                 enum isl_dim_type type, __isl_take isl_id *id);
623         __isl_give isl_space *isl_space_reset_tuple_id(
624                 __isl_take isl_space *space, enum isl_dim_type type);
625         int isl_space_has_tuple_id(__isl_keep isl_space *space,
626                 enum isl_dim_type type);
627         __isl_give isl_id *isl_space_get_tuple_id(
628                 __isl_keep isl_space *space, enum isl_dim_type type);
629         __isl_give isl_space *isl_space_set_tuple_name(
630                 __isl_take isl_space *space,
631                 enum isl_dim_type type, const char *s);
632         const char *isl_space_get_tuple_name(__isl_keep isl_space *space,
633                 enum isl_dim_type type);
634
635 The C<type> argument needs to be one of C<isl_dim_in>, C<isl_dim_out>
636 or C<isl_dim_set>.  As with C<isl_space_get_name>,
637 the C<isl_space_get_tuple_name> function returns a pointer to some internal
638 data structure.
639 Binary operations require the corresponding spaces of their arguments
640 to have the same name.
641
642 Spaces can be nested.  In particular, the domain of a set or
643 the domain or range of a relation can be a nested relation.
644 The following functions can be used to construct and deconstruct
645 such nested spaces.
646
647         #include <isl/space.h>
648         int isl_space_is_wrapping(__isl_keep isl_space *space);
649         __isl_give isl_space *isl_space_wrap(__isl_take isl_space *space);
650         __isl_give isl_space *isl_space_unwrap(__isl_take isl_space *space);
651
652 The input to C<isl_space_is_wrapping> and C<isl_space_unwrap> should
653 be the space of a set, while that of
654 C<isl_space_wrap> should be the space of a relation.
655 Conversely, the output of C<isl_space_unwrap> is the space
656 of a relation, while that of C<isl_space_wrap> is the space of a set.
657
658 Spaces can be created from other spaces
659 using the following functions.
660
661         __isl_give isl_space *isl_space_domain(__isl_take isl_space *space);
662         __isl_give isl_space *isl_space_from_domain(__isl_take isl_space *space);
663         __isl_give isl_space *isl_space_range(__isl_take isl_space *space);
664         __isl_give isl_space *isl_space_from_range(__isl_take isl_space *space);
665         __isl_give isl_space *isl_space_params(
666                 __isl_take isl_space *space);
667         __isl_give isl_space *isl_space_reverse(__isl_take isl_space *space);
668         __isl_give isl_space *isl_space_join(__isl_take isl_space *left,
669                 __isl_take isl_space *right);
670         __isl_give isl_space *isl_space_align_params(
671                 __isl_take isl_space *space1, __isl_take isl_space *space2)
672         __isl_give isl_space *isl_space_insert_dims(__isl_take isl_space *space,
673                 enum isl_dim_type type, unsigned pos, unsigned n);
674         __isl_give isl_space *isl_space_add_dims(__isl_take isl_space *space,
675                 enum isl_dim_type type, unsigned n);
676         __isl_give isl_space *isl_space_drop_dims(__isl_take isl_space *space,
677                 enum isl_dim_type type, unsigned first, unsigned n);
678         __isl_give isl_space *isl_space_move_dims(__isl_take isl_space *space,
679                 enum isl_dim_type dst_type, unsigned dst_pos,
680                 enum isl_dim_type src_type, unsigned src_pos,
681                 unsigned n);
682         __isl_give isl_space *isl_space_map_from_set(
683                 __isl_take isl_space *space);
684         __isl_give isl_space *isl_space_zip(__isl_take isl_space *space);
685
686 Note that if dimensions are added or removed from a space, then
687 the name and the internal structure are lost.
688
689 =head2 Local Spaces
690
691 A local space is essentially a space with
692 zero or more existentially quantified variables.
693 The local space of a basic set or relation can be obtained
694 using the following functions.
695
696         #include <isl/set.h>
697         __isl_give isl_local_space *isl_basic_set_get_local_space(
698                 __isl_keep isl_basic_set *bset);
699
700         #include <isl/map.h>
701         __isl_give isl_local_space *isl_basic_map_get_local_space(
702                 __isl_keep isl_basic_map *bmap);
703
704 A new local space can be created from a space using
705
706         #include <isl/local_space.h>
707         __isl_give isl_local_space *isl_local_space_from_space(
708                 __isl_take isl_space *space);
709
710 They can be inspected, copied and freed using the following functions.
711
712         #include <isl/local_space.h>
713         isl_ctx *isl_local_space_get_ctx(
714                 __isl_keep isl_local_space *ls);
715         int isl_local_space_is_set(__isl_keep isl_local_space *ls);
716         int isl_local_space_dim(__isl_keep isl_local_space *ls,
717                 enum isl_dim_type type);
718         const char *isl_local_space_get_dim_name(
719                 __isl_keep isl_local_space *ls,
720                 enum isl_dim_type type, unsigned pos);
721         __isl_give isl_local_space *isl_local_space_set_dim_name(
722                 __isl_take isl_local_space *ls,
723                 enum isl_dim_type type, unsigned pos, const char *s);
724         __isl_give isl_space *isl_local_space_get_space(
725                 __isl_keep isl_local_space *ls);
726         __isl_give isl_div *isl_local_space_get_div(
727                 __isl_keep isl_local_space *ls, int pos);
728         __isl_give isl_local_space *isl_local_space_copy(
729                 __isl_keep isl_local_space *ls);
730         void *isl_local_space_free(__isl_take isl_local_space *ls);
731
732 Two local spaces can be compared using
733
734         int isl_local_space_is_equal(__isl_keep isl_local_space *ls1,
735                 __isl_keep isl_local_space *ls2);
736
737 Local spaces can be created from other local spaces
738 using the following functions.
739
740         __isl_give isl_local_space *isl_local_space_domain(
741                 __isl_take isl_local_space *ls);
742         __isl_give isl_local_space *isl_local_space_from_domain(
743                 __isl_take isl_local_space *ls);
744         __isl_give isl_local_space *isl_local_space_add_dims(
745                 __isl_take isl_local_space *ls,
746                 enum isl_dim_type type, unsigned n);
747         __isl_give isl_local_space *isl_local_space_insert_dims(
748                 __isl_take isl_local_space *ls,
749                 enum isl_dim_type type, unsigned first, unsigned n);
750         __isl_give isl_local_space *isl_local_space_drop_dims(
751                 __isl_take isl_local_space *ls,
752                 enum isl_dim_type type, unsigned first, unsigned n);
753
754 =head2 Input and Output
755
756 C<isl> supports its own input/output format, which is similar
757 to the C<Omega> format, but also supports the C<PolyLib> format
758 in some cases.
759
760 =head3 C<isl> format
761
762 The C<isl> format is similar to that of C<Omega>, but has a different
763 syntax for describing the parameters and allows for the definition
764 of an existentially quantified variable as the integer division
765 of an affine expression.
766 For example, the set of integers C<i> between C<0> and C<n>
767 such that C<i % 10 <= 6> can be described as
768
769         [n] -> { [i] : exists (a = [i/10] : 0 <= i and i <= n and
770                                 i - 10 a <= 6) }
771
772 A set or relation can have several disjuncts, separated
773 by the keyword C<or>.  Each disjunct is either a conjunction
774 of constraints or a projection (C<exists>) of a conjunction
775 of constraints.  The constraints are separated by the keyword
776 C<and>.
777
778 =head3 C<PolyLib> format
779
780 If the represented set is a union, then the first line
781 contains a single number representing the number of disjuncts.
782 Otherwise, a line containing the number C<1> is optional.
783
784 Each disjunct is represented by a matrix of constraints.
785 The first line contains two numbers representing
786 the number of rows and columns,
787 where the number of rows is equal to the number of constraints
788 and the number of columns is equal to two plus the number of variables.
789 The following lines contain the actual rows of the constraint matrix.
790 In each row, the first column indicates whether the constraint
791 is an equality (C<0>) or inequality (C<1>).  The final column
792 corresponds to the constant term.
793
794 If the set is parametric, then the coefficients of the parameters
795 appear in the last columns before the constant column.
796 The coefficients of any existentially quantified variables appear
797 between those of the set variables and those of the parameters.
798
799 =head3 Extended C<PolyLib> format
800
801 The extended C<PolyLib> format is nearly identical to the
802 C<PolyLib> format.  The only difference is that the line
803 containing the number of rows and columns of a constraint matrix
804 also contains four additional numbers:
805 the number of output dimensions, the number of input dimensions,
806 the number of local dimensions (i.e., the number of existentially
807 quantified variables) and the number of parameters.
808 For sets, the number of ``output'' dimensions is equal
809 to the number of set dimensions, while the number of ``input''
810 dimensions is zero.
811
812 =head3 Input
813
814         #include <isl/set.h>
815         __isl_give isl_basic_set *isl_basic_set_read_from_file(
816                 isl_ctx *ctx, FILE *input, int nparam);
817         __isl_give isl_basic_set *isl_basic_set_read_from_str(
818                 isl_ctx *ctx, const char *str, int nparam);
819         __isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx,
820                 FILE *input, int nparam);
821         __isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx,
822                 const char *str, int nparam);
823
824         #include <isl/map.h>
825         __isl_give isl_basic_map *isl_basic_map_read_from_file(
826                 isl_ctx *ctx, FILE *input, int nparam);
827         __isl_give isl_basic_map *isl_basic_map_read_from_str(
828                 isl_ctx *ctx, const char *str, int nparam);
829         __isl_give isl_map *isl_map_read_from_file(
830                 isl_ctx *ctx, FILE *input, int nparam);
831         __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx,
832                 const char *str, int nparam);
833
834         #include <isl/union_set.h>
835         __isl_give isl_union_set *isl_union_set_read_from_file(
836                 isl_ctx *ctx, FILE *input);
837         __isl_give isl_union_set *isl_union_set_read_from_str(
838                 isl_ctx *ctx, const char *str);
839
840         #include <isl/union_map.h>
841         __isl_give isl_union_map *isl_union_map_read_from_file(
842                 isl_ctx *ctx, FILE *input);
843         __isl_give isl_union_map *isl_union_map_read_from_str(
844                 isl_ctx *ctx, const char *str);
845
846 The input format is autodetected and may be either the C<PolyLib> format
847 or the C<isl> format.
848 C<nparam> specifies how many of the final columns in
849 the C<PolyLib> format correspond to parameters.
850 If input is given in the C<isl> format, then the number
851 of parameters needs to be equal to C<nparam>.
852 If C<nparam> is negative, then any number of parameters
853 is accepted in the C<isl> format and zero parameters
854 are assumed in the C<PolyLib> format.
855
856 =head3 Output
857
858 Before anything can be printed, an C<isl_printer> needs to
859 be created.
860
861         __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx,
862                 FILE *file);
863         __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx);
864         void isl_printer_free(__isl_take isl_printer *printer);
865         __isl_give char *isl_printer_get_str(
866                 __isl_keep isl_printer *printer);
867
868 The behavior of the printer can be modified in various ways
869
870         __isl_give isl_printer *isl_printer_set_output_format(
871                 __isl_take isl_printer *p, int output_format);
872         __isl_give isl_printer *isl_printer_set_indent(
873                 __isl_take isl_printer *p, int indent);
874         __isl_give isl_printer *isl_printer_indent(
875                 __isl_take isl_printer *p, int indent);
876         __isl_give isl_printer *isl_printer_set_prefix(
877                 __isl_take isl_printer *p, const char *prefix);
878         __isl_give isl_printer *isl_printer_set_suffix(
879                 __isl_take isl_printer *p, const char *suffix);
880
881 The C<output_format> may be either C<ISL_FORMAT_ISL>, C<ISL_FORMAT_OMEGA>,
882 C<ISL_FORMAT_POLYLIB>, C<ISL_FORMAT_EXT_POLYLIB> or C<ISL_FORMAT_LATEX>
883 and defaults to C<ISL_FORMAT_ISL>.
884 Each line in the output is indented by C<indent> (set by
885 C<isl_printer_set_indent>) spaces
886 (default: 0), prefixed by C<prefix> and suffixed by C<suffix>.
887 In the C<PolyLib> format output,
888 the coefficients of the existentially quantified variables
889 appear between those of the set variables and those
890 of the parameters.
891 The function C<isl_printer_indent> increases the indentation
892 by the specified amount (which may be negative).
893
894 To actually print something, use
895
896         #include <isl/set.h>
897         __isl_give isl_printer *isl_printer_print_basic_set(
898                 __isl_take isl_printer *printer,
899                 __isl_keep isl_basic_set *bset);
900         __isl_give isl_printer *isl_printer_print_set(
901                 __isl_take isl_printer *printer,
902                 __isl_keep isl_set *set);
903
904         #include <isl/map.h>
905         __isl_give isl_printer *isl_printer_print_basic_map(
906                 __isl_take isl_printer *printer,
907                 __isl_keep isl_basic_map *bmap);
908         __isl_give isl_printer *isl_printer_print_map(
909                 __isl_take isl_printer *printer,
910                 __isl_keep isl_map *map);
911
912         #include <isl/union_set.h>
913         __isl_give isl_printer *isl_printer_print_union_set(
914                 __isl_take isl_printer *p,
915                 __isl_keep isl_union_set *uset);
916
917         #include <isl/union_map.h>
918         __isl_give isl_printer *isl_printer_print_union_map(
919                 __isl_take isl_printer *p,
920                 __isl_keep isl_union_map *umap);
921
922 When called on a file printer, the following function flushes
923 the file.  When called on a string printer, the buffer is cleared.
924
925         __isl_give isl_printer *isl_printer_flush(
926                 __isl_take isl_printer *p);
927
928 =head2 Creating New Sets and Relations
929
930 C<isl> has functions for creating some standard sets and relations.
931
932 =over
933
934 =item * Empty sets and relations
935
936         __isl_give isl_basic_set *isl_basic_set_empty(
937                 __isl_take isl_space *space);
938         __isl_give isl_basic_map *isl_basic_map_empty(
939                 __isl_take isl_space *space);
940         __isl_give isl_set *isl_set_empty(
941                 __isl_take isl_space *space);
942         __isl_give isl_map *isl_map_empty(
943                 __isl_take isl_space *space);
944         __isl_give isl_union_set *isl_union_set_empty(
945                 __isl_take isl_space *space);
946         __isl_give isl_union_map *isl_union_map_empty(
947                 __isl_take isl_space *space);
948
949 For C<isl_union_set>s and C<isl_union_map>s, the space
950 is only used to specify the parameters.
951
952 =item * Universe sets and relations
953
954         __isl_give isl_basic_set *isl_basic_set_universe(
955                 __isl_take isl_space *space);
956         __isl_give isl_basic_map *isl_basic_map_universe(
957                 __isl_take isl_space *space);
958         __isl_give isl_set *isl_set_universe(
959                 __isl_take isl_space *space);
960         __isl_give isl_map *isl_map_universe(
961                 __isl_take isl_space *space);
962         __isl_give isl_union_set *isl_union_set_universe(
963                 __isl_take isl_union_set *uset);
964         __isl_give isl_union_map *isl_union_map_universe(
965                 __isl_take isl_union_map *umap);
966
967 The sets and relations constructed by the functions above
968 contain all integer values, while those constructed by the
969 functions below only contain non-negative values.
970
971         __isl_give isl_basic_set *isl_basic_set_nat_universe(
972                 __isl_take isl_space *space);
973         __isl_give isl_basic_map *isl_basic_map_nat_universe(
974                 __isl_take isl_space *space);
975         __isl_give isl_set *isl_set_nat_universe(
976                 __isl_take isl_space *space);
977         __isl_give isl_map *isl_map_nat_universe(
978                 __isl_take isl_space *space);
979
980 =item * Identity relations
981
982         __isl_give isl_basic_map *isl_basic_map_identity(
983                 __isl_take isl_space *space);
984         __isl_give isl_map *isl_map_identity(
985                 __isl_take isl_space *space);
986
987 The number of input and output dimensions in C<space> needs
988 to be the same.
989
990 =item * Lexicographic order
991
992         __isl_give isl_map *isl_map_lex_lt(
993                 __isl_take isl_space *set_space);
994         __isl_give isl_map *isl_map_lex_le(
995                 __isl_take isl_space *set_space);
996         __isl_give isl_map *isl_map_lex_gt(
997                 __isl_take isl_space *set_space);
998         __isl_give isl_map *isl_map_lex_ge(
999                 __isl_take isl_space *set_space);
1000         __isl_give isl_map *isl_map_lex_lt_first(
1001                 __isl_take isl_space *space, unsigned n);
1002         __isl_give isl_map *isl_map_lex_le_first(
1003                 __isl_take isl_space *space, unsigned n);
1004         __isl_give isl_map *isl_map_lex_gt_first(
1005                 __isl_take isl_space *space, unsigned n);
1006         __isl_give isl_map *isl_map_lex_ge_first(
1007                 __isl_take isl_space *space, unsigned n);
1008
1009 The first four functions take a space for a B<set>
1010 and return relations that express that the elements in the domain
1011 are lexicographically less
1012 (C<isl_map_lex_lt>), less or equal (C<isl_map_lex_le>),
1013 greater (C<isl_map_lex_gt>) or greater or equal (C<isl_map_lex_ge>)
1014 than the elements in the range.
1015 The last four functions take a space for a map
1016 and return relations that express that the first C<n> dimensions
1017 in the domain are lexicographically less
1018 (C<isl_map_lex_lt_first>), less or equal (C<isl_map_lex_le_first>),
1019 greater (C<isl_map_lex_gt_first>) or greater or equal (C<isl_map_lex_ge_first>)
1020 than the first C<n> dimensions in the range.
1021
1022 =back
1023
1024 A basic set or relation can be converted to a set or relation
1025 using the following functions.
1026
1027         __isl_give isl_set *isl_set_from_basic_set(
1028                 __isl_take isl_basic_set *bset);
1029         __isl_give isl_map *isl_map_from_basic_map(
1030                 __isl_take isl_basic_map *bmap);
1031
1032 Sets and relations can be converted to union sets and relations
1033 using the following functions.
1034
1035         __isl_give isl_union_map *isl_union_map_from_map(
1036                 __isl_take isl_map *map);
1037         __isl_give isl_union_set *isl_union_set_from_set(
1038                 __isl_take isl_set *set);
1039
1040 The inverse conversions below can only be used if the input
1041 union set or relation is known to contain elements in exactly one
1042 space.
1043
1044         __isl_give isl_set *isl_set_from_union_set(
1045                 __isl_take isl_union_set *uset);
1046         __isl_give isl_map *isl_map_from_union_map(
1047                 __isl_take isl_union_map *umap);
1048
1049 Sets and relations can be copied and freed again using the following
1050 functions.
1051
1052         __isl_give isl_basic_set *isl_basic_set_copy(
1053                 __isl_keep isl_basic_set *bset);
1054         __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set);
1055         __isl_give isl_union_set *isl_union_set_copy(
1056                 __isl_keep isl_union_set *uset);
1057         __isl_give isl_basic_map *isl_basic_map_copy(
1058                 __isl_keep isl_basic_map *bmap);
1059         __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
1060         __isl_give isl_union_map *isl_union_map_copy(
1061                 __isl_keep isl_union_map *umap);
1062         void isl_basic_set_free(__isl_take isl_basic_set *bset);
1063         void isl_set_free(__isl_take isl_set *set);
1064         void *isl_union_set_free(__isl_take isl_union_set *uset);
1065         void isl_basic_map_free(__isl_take isl_basic_map *bmap);
1066         void isl_map_free(__isl_take isl_map *map);
1067         void *isl_union_map_free(__isl_take isl_union_map *umap);
1068
1069 Other sets and relations can be constructed by starting
1070 from a universe set or relation, adding equality and/or
1071 inequality constraints and then projecting out the
1072 existentially quantified variables, if any.
1073 Constraints can be constructed, manipulated and
1074 added to (or removed from) (basic) sets and relations
1075 using the following functions.
1076
1077         #include <isl/constraint.h>
1078         __isl_give isl_constraint *isl_equality_alloc(
1079                 __isl_take isl_space *space);
1080         __isl_give isl_constraint *isl_inequality_alloc(
1081                 __isl_take isl_space *space);
1082         __isl_give isl_constraint *isl_constraint_set_constant(
1083                 __isl_take isl_constraint *constraint, isl_int v);
1084         __isl_give isl_constraint *isl_constraint_set_constant_si(
1085                 __isl_take isl_constraint *constraint, int v);
1086         __isl_give isl_constraint *isl_constraint_set_coefficient(
1087                 __isl_take isl_constraint *constraint,
1088                 enum isl_dim_type type, int pos, isl_int v);
1089         __isl_give isl_constraint *isl_constraint_set_coefficient_si(
1090                 __isl_take isl_constraint *constraint,
1091                 enum isl_dim_type type, int pos, int v);
1092         __isl_give isl_basic_map *isl_basic_map_add_constraint(
1093                 __isl_take isl_basic_map *bmap,
1094                 __isl_take isl_constraint *constraint);
1095         __isl_give isl_basic_set *isl_basic_set_add_constraint(
1096                 __isl_take isl_basic_set *bset,
1097                 __isl_take isl_constraint *constraint);
1098         __isl_give isl_map *isl_map_add_constraint(
1099                 __isl_take isl_map *map,
1100                 __isl_take isl_constraint *constraint);
1101         __isl_give isl_set *isl_set_add_constraint(
1102                 __isl_take isl_set *set,
1103                 __isl_take isl_constraint *constraint);
1104         __isl_give isl_basic_set *isl_basic_set_drop_constraint(
1105                 __isl_take isl_basic_set *bset,
1106                 __isl_take isl_constraint *constraint);
1107
1108 For example, to create a set containing the even integers
1109 between 10 and 42, you would use the following code.
1110
1111         isl_space *space;
1112         isl_constraint *c;
1113         isl_basic_set *bset;
1114
1115         space = isl_space_set_alloc(ctx, 0, 2);
1116         bset = isl_basic_set_universe(isl_space_copy(space));
1117
1118         c = isl_equality_alloc(isl_space_copy(space));
1119         c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1120         c = isl_constraint_set_coefficient_si(c, isl_dim_set, 1, 2);
1121         bset = isl_basic_set_add_constraint(bset, c);
1122
1123         c = isl_inequality_alloc(isl_space_copy(space));
1124         c = isl_constraint_set_constant_si(c, -10);
1125         c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, 1);
1126         bset = isl_basic_set_add_constraint(bset, c);
1127
1128         c = isl_inequality_alloc(space);
1129         c = isl_constraint_set_constant_si(c, 42);
1130         c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1131         bset = isl_basic_set_add_constraint(bset, c);
1132
1133         bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 1);
1134
1135 Or, alternatively,
1136
1137         isl_basic_set *bset;
1138         bset = isl_basic_set_read_from_str(ctx,
1139                 "{[i] : exists (a : i = 2a and i >= 10 and i <= 42)}", -1);
1140
1141 A basic set or relation can also be constructed from two matrices
1142 describing the equalities and the inequalities.
1143
1144         __isl_give isl_basic_set *isl_basic_set_from_constraint_matrices(
1145                 __isl_take isl_space *space,
1146                 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1147                 enum isl_dim_type c1,
1148                 enum isl_dim_type c2, enum isl_dim_type c3,
1149                 enum isl_dim_type c4);
1150         __isl_give isl_basic_map *isl_basic_map_from_constraint_matrices(
1151                 __isl_take isl_space *space,
1152                 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1153                 enum isl_dim_type c1,
1154                 enum isl_dim_type c2, enum isl_dim_type c3,
1155                 enum isl_dim_type c4, enum isl_dim_type c5);
1156
1157 The C<isl_dim_type> arguments indicate the order in which
1158 different kinds of variables appear in the input matrices
1159 and should be a permutation of C<isl_dim_cst>, C<isl_dim_param>,
1160 C<isl_dim_set> and C<isl_dim_div> for sets and
1161 of C<isl_dim_cst>, C<isl_dim_param>,
1162 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div> for relations.
1163
1164 A (basic) set or relation can also be constructed from a (piecewise)
1165 affine expression
1166 or a list of affine expressions (See L<"Piecewise Quasi Affine Expressions">).
1167
1168         __isl_give isl_basic_map *isl_basic_map_from_aff(
1169                 __isl_take isl_aff *aff);
1170         __isl_give isl_set *isl_set_from_pw_aff(
1171                 __isl_take isl_pw_aff *pwaff);
1172         __isl_give isl_map *isl_map_from_pw_aff(
1173                 __isl_take isl_pw_aff *pwaff);
1174         __isl_give isl_basic_map *isl_basic_map_from_aff_list(
1175                 __isl_take isl_space *domain_space,
1176                 __isl_take isl_aff_list *list);
1177
1178 The C<domain_dim> argument describes the domain of the resulting
1179 basic relation.  It is required because the C<list> may consist
1180 of zero affine expressions.
1181
1182 =head2 Inspecting Sets and Relations
1183
1184 Usually, the user should not have to care about the actual constraints
1185 of the sets and maps, but should instead apply the abstract operations
1186 explained in the following sections.
1187 Occasionally, however, it may be required to inspect the individual
1188 coefficients of the constraints.  This section explains how to do so.
1189 In these cases, it may also be useful to have C<isl> compute
1190 an explicit representation of the existentially quantified variables.
1191
1192         __isl_give isl_set *isl_set_compute_divs(
1193                 __isl_take isl_set *set);
1194         __isl_give isl_map *isl_map_compute_divs(
1195                 __isl_take isl_map *map);
1196         __isl_give isl_union_set *isl_union_set_compute_divs(
1197                 __isl_take isl_union_set *uset);
1198         __isl_give isl_union_map *isl_union_map_compute_divs(
1199                 __isl_take isl_union_map *umap);
1200
1201 This explicit representation defines the existentially quantified
1202 variables as integer divisions of the other variables, possibly
1203 including earlier existentially quantified variables.
1204 An explicitly represented existentially quantified variable therefore
1205 has a unique value when the values of the other variables are known.
1206 If, furthermore, the same existentials, i.e., existentials
1207 with the same explicit representations, should appear in the
1208 same order in each of the disjuncts of a set or map, then the user should call
1209 either of the following functions.
1210
1211         __isl_give isl_set *isl_set_align_divs(
1212                 __isl_take isl_set *set);
1213         __isl_give isl_map *isl_map_align_divs(
1214                 __isl_take isl_map *map);
1215
1216 Alternatively, the existentially quantified variables can be removed
1217 using the following functions, which compute an overapproximation.
1218
1219         __isl_give isl_basic_set *isl_basic_set_remove_divs(
1220                 __isl_take isl_basic_set *bset);
1221         __isl_give isl_basic_map *isl_basic_map_remove_divs(
1222                 __isl_take isl_basic_map *bmap);
1223         __isl_give isl_set *isl_set_remove_divs(
1224                 __isl_take isl_set *set);
1225         __isl_give isl_map *isl_map_remove_divs(
1226                 __isl_take isl_map *map);
1227
1228 To iterate over all the sets or maps in a union set or map, use
1229
1230         int isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
1231                 int (*fn)(__isl_take isl_set *set, void *user),
1232                 void *user);
1233         int isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
1234                 int (*fn)(__isl_take isl_map *map, void *user),
1235                 void *user);
1236
1237 The number of sets or maps in a union set or map can be obtained
1238 from
1239
1240         int isl_union_set_n_set(__isl_keep isl_union_set *uset);
1241         int isl_union_map_n_map(__isl_keep isl_union_map *umap);
1242
1243 To extract the set or map in a given space from a union, use
1244
1245         __isl_give isl_set *isl_union_set_extract_set(
1246                 __isl_keep isl_union_set *uset,
1247                 __isl_take isl_space *space);
1248         __isl_give isl_map *isl_union_map_extract_map(
1249                 __isl_keep isl_union_map *umap,
1250                 __isl_take isl_space *space);
1251
1252 To iterate over all the basic sets or maps in a set or map, use
1253
1254         int isl_set_foreach_basic_set(__isl_keep isl_set *set,
1255                 int (*fn)(__isl_take isl_basic_set *bset, void *user),
1256                 void *user);
1257         int isl_map_foreach_basic_map(__isl_keep isl_map *map,
1258                 int (*fn)(__isl_take isl_basic_map *bmap, void *user),
1259                 void *user);
1260
1261 The callback function C<fn> should return 0 if successful and
1262 -1 if an error occurs.  In the latter case, or if any other error
1263 occurs, the above functions will return -1.
1264
1265 It should be noted that C<isl> does not guarantee that
1266 the basic sets or maps passed to C<fn> are disjoint.
1267 If this is required, then the user should call one of
1268 the following functions first.
1269
1270         __isl_give isl_set *isl_set_make_disjoint(
1271                 __isl_take isl_set *set);
1272         __isl_give isl_map *isl_map_make_disjoint(
1273                 __isl_take isl_map *map);
1274
1275 The number of basic sets in a set can be obtained
1276 from
1277
1278         int isl_set_n_basic_set(__isl_keep isl_set *set);
1279
1280 To iterate over the constraints of a basic set or map, use
1281
1282         #include <isl/constraint.h>
1283
1284         int isl_basic_map_foreach_constraint(
1285                 __isl_keep isl_basic_map *bmap,
1286                 int (*fn)(__isl_take isl_constraint *c, void *user),
1287                 void *user);
1288         void *isl_constraint_free(__isl_take isl_constraint *c);
1289
1290 Again, the callback function C<fn> should return 0 if successful and
1291 -1 if an error occurs.  In the latter case, or if any other error
1292 occurs, the above functions will return -1.
1293 The constraint C<c> represents either an equality or an inequality.
1294 Use the following function to find out whether a constraint
1295 represents an equality.  If not, it represents an inequality.
1296
1297         int isl_constraint_is_equality(
1298                 __isl_keep isl_constraint *constraint);
1299
1300 The coefficients of the constraints can be inspected using
1301 the following functions.
1302
1303         void isl_constraint_get_constant(
1304                 __isl_keep isl_constraint *constraint, isl_int *v);
1305         void isl_constraint_get_coefficient(
1306                 __isl_keep isl_constraint *constraint,
1307                 enum isl_dim_type type, int pos, isl_int *v);
1308         int isl_constraint_involves_dims(
1309                 __isl_keep isl_constraint *constraint,
1310                 enum isl_dim_type type, unsigned first, unsigned n);
1311
1312 The explicit representations of the existentially quantified
1313 variables can be inspected using the following functions.
1314 Note that the user is only allowed to use these functions
1315 if the inspected set or map is the result of a call
1316 to C<isl_set_compute_divs> or C<isl_map_compute_divs>.
1317
1318         __isl_give isl_div *isl_constraint_div(
1319                 __isl_keep isl_constraint *constraint, int pos);
1320         isl_ctx *isl_div_get_ctx(__isl_keep isl_div *div);
1321         void isl_div_get_constant(__isl_keep isl_div *div,
1322                 isl_int *v);
1323         void isl_div_get_denominator(__isl_keep isl_div *div,
1324                 isl_int *v);
1325         void isl_div_get_coefficient(__isl_keep isl_div *div,
1326                 enum isl_dim_type type, int pos, isl_int *v);
1327
1328 To obtain the constraints of a basic set or map in matrix
1329 form, use the following functions.
1330
1331         __isl_give isl_mat *isl_basic_set_equalities_matrix(
1332                 __isl_keep isl_basic_set *bset,
1333                 enum isl_dim_type c1, enum isl_dim_type c2,
1334                 enum isl_dim_type c3, enum isl_dim_type c4);
1335         __isl_give isl_mat *isl_basic_set_inequalities_matrix(
1336                 __isl_keep isl_basic_set *bset,
1337                 enum isl_dim_type c1, enum isl_dim_type c2,
1338                 enum isl_dim_type c3, enum isl_dim_type c4);
1339         __isl_give isl_mat *isl_basic_map_equalities_matrix(
1340                 __isl_keep isl_basic_map *bmap,
1341                 enum isl_dim_type c1,
1342                 enum isl_dim_type c2, enum isl_dim_type c3,
1343                 enum isl_dim_type c4, enum isl_dim_type c5);
1344         __isl_give isl_mat *isl_basic_map_inequalities_matrix(
1345                 __isl_keep isl_basic_map *bmap,
1346                 enum isl_dim_type c1,
1347                 enum isl_dim_type c2, enum isl_dim_type c3,
1348                 enum isl_dim_type c4, enum isl_dim_type c5);
1349
1350 The C<isl_dim_type> arguments dictate the order in which
1351 different kinds of variables appear in the resulting matrix
1352 and should be a permutation of C<isl_dim_cst>, C<isl_dim_param>,
1353 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div>.
1354
1355 The number of parameters, input, output or set dimensions can
1356 be obtained using the following functions.
1357
1358         unsigned isl_basic_set_dim(__isl_keep isl_basic_set *bset,
1359                 enum isl_dim_type type);
1360         unsigned isl_basic_map_dim(__isl_keep isl_basic_map *bmap,
1361                 enum isl_dim_type type);
1362         unsigned isl_set_dim(__isl_keep isl_set *set,
1363                 enum isl_dim_type type);
1364         unsigned isl_map_dim(__isl_keep isl_map *map,
1365                 enum isl_dim_type type);
1366
1367 To check whether the description of a set or relation depends
1368 on one or more given dimensions, it is not necessary to iterate over all
1369 constraints.  Instead the following functions can be used.
1370
1371         int isl_basic_set_involves_dims(
1372                 __isl_keep isl_basic_set *bset,
1373                 enum isl_dim_type type, unsigned first, unsigned n);
1374         int isl_set_involves_dims(__isl_keep isl_set *set,
1375                 enum isl_dim_type type, unsigned first, unsigned n);
1376         int isl_basic_map_involves_dims(
1377                 __isl_keep isl_basic_map *bmap,
1378                 enum isl_dim_type type, unsigned first, unsigned n);
1379         int isl_map_involves_dims(__isl_keep isl_map *map,
1380                 enum isl_dim_type type, unsigned first, unsigned n);
1381
1382 Similarly, the following functions can be used to check whether
1383 a given dimension is involved in any lower or upper bound.
1384
1385         int isl_set_dim_has_lower_bound(__isl_keep isl_set *set,
1386                 enum isl_dim_type type, unsigned pos);
1387         int isl_set_dim_has_upper_bound(__isl_keep isl_set *set,
1388                 enum isl_dim_type type, unsigned pos);
1389
1390 The identifiers or names of the domain and range spaces of a set
1391 or relation can be read off or set using the following functions.
1392
1393         __isl_give isl_set *isl_set_set_tuple_id(
1394                 __isl_take isl_set *set, __isl_take isl_id *id);
1395         __isl_give isl_set *isl_set_reset_tuple_id(
1396                 __isl_take isl_set *set);
1397         int isl_set_has_tuple_id(__isl_keep isl_set *set);
1398         __isl_give isl_id *isl_set_get_tuple_id(
1399                 __isl_keep isl_set *set);
1400         __isl_give isl_map *isl_map_set_tuple_id(
1401                 __isl_take isl_map *map, enum isl_dim_type type,
1402                 __isl_take isl_id *id);
1403         __isl_give isl_map *isl_map_reset_tuple_id(
1404                 __isl_take isl_map *map, enum isl_dim_type type);
1405         int isl_map_has_tuple_id(__isl_keep isl_map *map,
1406                 enum isl_dim_type type);
1407         __isl_give isl_id *isl_map_get_tuple_id(
1408                 __isl_keep isl_map *map, enum isl_dim_type type);
1409
1410         const char *isl_basic_set_get_tuple_name(
1411                 __isl_keep isl_basic_set *bset);
1412         __isl_give isl_basic_set *isl_basic_set_set_tuple_name(
1413                 __isl_take isl_basic_set *set, const char *s);
1414         const char *isl_set_get_tuple_name(
1415                 __isl_keep isl_set *set);
1416         const char *isl_basic_map_get_tuple_name(
1417                 __isl_keep isl_basic_map *bmap,
1418                 enum isl_dim_type type);
1419         const char *isl_map_get_tuple_name(
1420                 __isl_keep isl_map *map,
1421                 enum isl_dim_type type);
1422
1423 As with C<isl_space_get_tuple_name>, the value returned points to
1424 an internal data structure.
1425 The identifiers, positions or names of individual dimensions can be
1426 read off using the following functions.
1427
1428         __isl_give isl_set *isl_set_set_dim_id(
1429                 __isl_take isl_set *set, enum isl_dim_type type,
1430                 unsigned pos, __isl_take isl_id *id);
1431         int isl_set_has_dim_id(__isl_keep isl_set *set,
1432                 enum isl_dim_type type, unsigned pos);
1433         __isl_give isl_id *isl_set_get_dim_id(
1434                 __isl_keep isl_set *set, enum isl_dim_type type,
1435                 unsigned pos);
1436         __isl_give isl_map *isl_map_set_dim_id(
1437                 __isl_take isl_map *map, enum isl_dim_type type,
1438                 unsigned pos, __isl_take isl_id *id);
1439         int isl_map_has_dim_id(__isl_keep isl_map *map,
1440                 enum isl_dim_type type, unsigned pos);
1441         __isl_give isl_id *isl_map_get_dim_id(
1442                 __isl_keep isl_map *map, enum isl_dim_type type,
1443                 unsigned pos);
1444
1445         int isl_set_find_dim_by_id(__isl_keep isl_set *set,
1446                 enum isl_dim_type type, __isl_keep isl_id *id);
1447         int isl_map_find_dim_by_id(__isl_keep isl_map *map,
1448                 enum isl_dim_type type, __isl_keep isl_id *id);
1449
1450         const char *isl_constraint_get_dim_name(
1451                 __isl_keep isl_constraint *constraint,
1452                 enum isl_dim_type type, unsigned pos);
1453         const char *isl_basic_set_get_dim_name(
1454                 __isl_keep isl_basic_set *bset,
1455                 enum isl_dim_type type, unsigned pos);
1456         const char *isl_set_get_dim_name(
1457                 __isl_keep isl_set *set,
1458                 enum isl_dim_type type, unsigned pos);
1459         const char *isl_basic_map_get_dim_name(
1460                 __isl_keep isl_basic_map *bmap,
1461                 enum isl_dim_type type, unsigned pos);
1462         const char *isl_map_get_dim_name(
1463                 __isl_keep isl_map *map,
1464                 enum isl_dim_type type, unsigned pos);
1465
1466 These functions are mostly useful to obtain the identifiers, positions
1467 or names of the parameters.  Identifiers of individual dimensions are
1468 essentially only useful for printing.  They are ignored by all other
1469 operations and may not be preserved across those operations.
1470
1471 =head2 Properties
1472
1473 =head3 Unary Properties
1474
1475 =over
1476
1477 =item * Emptiness
1478
1479 The following functions test whether the given set or relation
1480 contains any integer points.  The ``plain'' variants do not perform
1481 any computations, but simply check if the given set or relation
1482 is already known to be empty.
1483
1484         int isl_basic_set_plain_is_empty(__isl_keep isl_basic_set *bset);
1485         int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
1486         int isl_set_plain_is_empty(__isl_keep isl_set *set);
1487         int isl_set_is_empty(__isl_keep isl_set *set);
1488         int isl_union_set_is_empty(__isl_keep isl_union_set *uset);
1489         int isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap);
1490         int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
1491         int isl_map_plain_is_empty(__isl_keep isl_map *map);
1492         int isl_map_is_empty(__isl_keep isl_map *map);
1493         int isl_union_map_is_empty(__isl_keep isl_union_map *umap);
1494
1495 =item * Universality
1496
1497         int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
1498         int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
1499         int isl_set_plain_is_universe(__isl_keep isl_set *set);
1500
1501 =item * Single-valuedness
1502
1503         int isl_map_is_single_valued(__isl_keep isl_map *map);
1504         int isl_union_map_is_single_valued(__isl_keep isl_union_map *umap);
1505
1506 =item * Injectivity
1507
1508         int isl_map_plain_is_injective(__isl_keep isl_map *map);
1509         int isl_map_is_injective(__isl_keep isl_map *map);
1510         int isl_union_map_plain_is_injective(
1511                 __isl_keep isl_union_map *umap);
1512         int isl_union_map_is_injective(
1513                 __isl_keep isl_union_map *umap);
1514
1515 =item * Bijectivity
1516
1517         int isl_map_is_bijective(__isl_keep isl_map *map);
1518         int isl_union_map_is_bijective(__isl_keep isl_union_map *umap);
1519
1520 =item * Position
1521
1522         int isl_basic_map_plain_is_fixed(
1523                 __isl_keep isl_basic_map *bmap,
1524                 enum isl_dim_type type, unsigned pos,
1525                 isl_int *val);
1526         int isl_map_plain_is_fixed(__isl_keep isl_map *map,
1527                 enum isl_dim_type type, unsigned pos,
1528                 isl_int *val);
1529
1530 Check if the relation obviously lies on a hyperplane where the given dimension
1531 has a fixed value and if so, return that value in C<*val>.
1532
1533 =item * Space
1534
1535 To check whether a set is a parameter domain, use this function:
1536
1537         int isl_set_is_params(__isl_keep isl_set *set);
1538
1539 =item * Wrapping
1540
1541 The following functions check whether the domain of the given
1542 (basic) set is a wrapped relation.
1543
1544         int isl_basic_set_is_wrapping(
1545                 __isl_keep isl_basic_set *bset);
1546         int isl_set_is_wrapping(__isl_keep isl_set *set);
1547
1548 =item * Internal Product
1549
1550         int isl_basic_map_can_zip(
1551                 __isl_keep isl_basic_map *bmap);
1552         int isl_map_can_zip(__isl_keep isl_map *map);
1553
1554 Check whether the product of domain and range of the given relation
1555 can be computed,
1556 i.e., whether both domain and range are nested relations.
1557
1558 =back
1559
1560 =head3 Binary Properties
1561
1562 =over
1563
1564 =item * Equality
1565
1566         int isl_set_plain_is_equal(__isl_keep isl_set *set1,
1567                 __isl_keep isl_set *set2);
1568         int isl_set_is_equal(__isl_keep isl_set *set1,
1569                 __isl_keep isl_set *set2);
1570         int isl_union_set_is_equal(
1571                 __isl_keep isl_union_set *uset1,
1572                 __isl_keep isl_union_set *uset2);
1573         int isl_basic_map_is_equal(
1574                 __isl_keep isl_basic_map *bmap1,
1575                 __isl_keep isl_basic_map *bmap2);
1576         int isl_map_is_equal(__isl_keep isl_map *map1,
1577                 __isl_keep isl_map *map2);
1578         int isl_map_plain_is_equal(__isl_keep isl_map *map1,
1579                 __isl_keep isl_map *map2);
1580         int isl_union_map_is_equal(
1581                 __isl_keep isl_union_map *umap1,
1582                 __isl_keep isl_union_map *umap2);
1583
1584 =item * Disjointness
1585
1586         int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
1587                 __isl_keep isl_set *set2);
1588
1589 =item * Subset
1590
1591         int isl_set_is_subset(__isl_keep isl_set *set1,
1592                 __isl_keep isl_set *set2);
1593         int isl_set_is_strict_subset(
1594                 __isl_keep isl_set *set1,
1595                 __isl_keep isl_set *set2);
1596         int isl_union_set_is_subset(
1597                 __isl_keep isl_union_set *uset1,
1598                 __isl_keep isl_union_set *uset2);
1599         int isl_union_set_is_strict_subset(
1600                 __isl_keep isl_union_set *uset1,
1601                 __isl_keep isl_union_set *uset2);
1602         int isl_basic_map_is_subset(
1603                 __isl_keep isl_basic_map *bmap1,
1604                 __isl_keep isl_basic_map *bmap2);
1605         int isl_basic_map_is_strict_subset(
1606                 __isl_keep isl_basic_map *bmap1,
1607                 __isl_keep isl_basic_map *bmap2);
1608         int isl_map_is_subset(
1609                 __isl_keep isl_map *map1,
1610                 __isl_keep isl_map *map2);
1611         int isl_map_is_strict_subset(
1612                 __isl_keep isl_map *map1,
1613                 __isl_keep isl_map *map2);
1614         int isl_union_map_is_subset(
1615                 __isl_keep isl_union_map *umap1,
1616                 __isl_keep isl_union_map *umap2);
1617         int isl_union_map_is_strict_subset(
1618                 __isl_keep isl_union_map *umap1,
1619                 __isl_keep isl_union_map *umap2);
1620
1621 =back
1622
1623 =head2 Unary Operations
1624
1625 =over
1626
1627 =item * Complement
1628
1629         __isl_give isl_set *isl_set_complement(
1630                 __isl_take isl_set *set);
1631
1632 =item * Inverse map
1633
1634         __isl_give isl_basic_map *isl_basic_map_reverse(
1635                 __isl_take isl_basic_map *bmap);
1636         __isl_give isl_map *isl_map_reverse(
1637                 __isl_take isl_map *map);
1638         __isl_give isl_union_map *isl_union_map_reverse(
1639                 __isl_take isl_union_map *umap);
1640
1641 =item * Projection
1642
1643         __isl_give isl_basic_set *isl_basic_set_project_out(
1644                 __isl_take isl_basic_set *bset,
1645                 enum isl_dim_type type, unsigned first, unsigned n);
1646         __isl_give isl_basic_map *isl_basic_map_project_out(
1647                 __isl_take isl_basic_map *bmap,
1648                 enum isl_dim_type type, unsigned first, unsigned n);
1649         __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
1650                 enum isl_dim_type type, unsigned first, unsigned n);
1651         __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
1652                 enum isl_dim_type type, unsigned first, unsigned n);
1653         __isl_give isl_basic_set *isl_basic_set_params(
1654                 __isl_take isl_basic_set *bset);
1655         __isl_give isl_basic_set *isl_basic_map_domain(
1656                 __isl_take isl_basic_map *bmap);
1657         __isl_give isl_basic_set *isl_basic_map_range(
1658                 __isl_take isl_basic_map *bmap);
1659         __isl_give isl_set *isl_set_params(__isl_take isl_set *set);
1660         __isl_give isl_set *isl_map_domain(
1661                 __isl_take isl_map *bmap);
1662         __isl_give isl_set *isl_map_range(
1663                 __isl_take isl_map *map);
1664         __isl_give isl_union_set *isl_union_map_domain(
1665                 __isl_take isl_union_map *umap);
1666         __isl_give isl_union_set *isl_union_map_range(
1667                 __isl_take isl_union_map *umap);
1668
1669         __isl_give isl_basic_map *isl_basic_map_domain_map(
1670                 __isl_take isl_basic_map *bmap);
1671         __isl_give isl_basic_map *isl_basic_map_range_map(
1672                 __isl_take isl_basic_map *bmap);
1673         __isl_give isl_map *isl_map_domain_map(__isl_take isl_map *map);
1674         __isl_give isl_map *isl_map_range_map(__isl_take isl_map *map);
1675         __isl_give isl_union_map *isl_union_map_domain_map(
1676                 __isl_take isl_union_map *umap);
1677         __isl_give isl_union_map *isl_union_map_range_map(
1678                 __isl_take isl_union_map *umap);
1679
1680 The functions above construct a (basic, regular or union) relation
1681 that maps (a wrapped version of) the input relation to its domain or range.
1682
1683 =item * Elimination
1684
1685         __isl_give isl_set *isl_set_eliminate(
1686                 __isl_take isl_set *set, enum isl_dim_type type,
1687                 unsigned first, unsigned n);
1688
1689 Eliminate the coefficients for the given dimensions from the constraints,
1690 without removing the dimensions.
1691
1692 =item * Slicing
1693
1694         __isl_give isl_basic_set *isl_basic_set_fix(
1695                 __isl_take isl_basic_set *bset,
1696                 enum isl_dim_type type, unsigned pos,
1697                 isl_int value);
1698         __isl_give isl_basic_set *isl_basic_set_fix_si(
1699                 __isl_take isl_basic_set *bset,
1700                 enum isl_dim_type type, unsigned pos, int value);
1701         __isl_give isl_set *isl_set_fix(__isl_take isl_set *set,
1702                 enum isl_dim_type type, unsigned pos,
1703                 isl_int value);
1704         __isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set,
1705                 enum isl_dim_type type, unsigned pos, int value);
1706         __isl_give isl_basic_map *isl_basic_map_fix_si(
1707                 __isl_take isl_basic_map *bmap,
1708                 enum isl_dim_type type, unsigned pos, int value);
1709         __isl_give isl_map *isl_map_fix_si(__isl_take isl_map *map,
1710                 enum isl_dim_type type, unsigned pos, int value);
1711
1712 Intersect the set or relation with the hyperplane where the given
1713 dimension has the fixed given value.
1714
1715         __isl_give isl_set *isl_set_equate(__isl_take isl_set *set,
1716                 enum isl_dim_type type1, int pos1,
1717                 enum isl_dim_type type2, int pos2);
1718         __isl_give isl_map *isl_map_equate(__isl_take isl_map *map,
1719                 enum isl_dim_type type1, int pos1,
1720                 enum isl_dim_type type2, int pos2);
1721
1722 Intersect the set or relation with the hyperplane where the given
1723 dimensions are equal to each other.
1724
1725         __isl_give isl_map *isl_map_oppose(__isl_take isl_map *map,
1726                 enum isl_dim_type type1, int pos1,
1727                 enum isl_dim_type type2, int pos2);
1728
1729 Intersect the relation with the hyperplane where the given
1730 dimensions have opposite values.
1731
1732 =item * Identity
1733
1734         __isl_give isl_map *isl_set_identity(
1735                 __isl_take isl_set *set);
1736         __isl_give isl_union_map *isl_union_set_identity(
1737                 __isl_take isl_union_set *uset);
1738
1739 Construct an identity relation on the given (union) set.
1740
1741 =item * Deltas
1742
1743         __isl_give isl_basic_set *isl_basic_map_deltas(
1744                 __isl_take isl_basic_map *bmap);
1745         __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
1746         __isl_give isl_union_set *isl_union_map_deltas(
1747                 __isl_take isl_union_map *umap);
1748
1749 These functions return a (basic) set containing the differences
1750 between image elements and corresponding domain elements in the input.
1751
1752         __isl_give isl_basic_map *isl_basic_map_deltas_map(
1753                 __isl_take isl_basic_map *bmap);
1754         __isl_give isl_map *isl_map_deltas_map(
1755                 __isl_take isl_map *map);
1756         __isl_give isl_union_map *isl_union_map_deltas_map(
1757                 __isl_take isl_union_map *umap);
1758
1759 The functions above construct a (basic, regular or union) relation
1760 that maps (a wrapped version of) the input relation to its delta set.
1761
1762 =item * Coalescing
1763
1764 Simplify the representation of a set or relation by trying
1765 to combine pairs of basic sets or relations into a single
1766 basic set or relation.
1767
1768         __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
1769         __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
1770         __isl_give isl_union_set *isl_union_set_coalesce(
1771                 __isl_take isl_union_set *uset);
1772         __isl_give isl_union_map *isl_union_map_coalesce(
1773                 __isl_take isl_union_map *umap);
1774
1775 =item * Detecting equalities
1776
1777         __isl_give isl_basic_set *isl_basic_set_detect_equalities(
1778                 __isl_take isl_basic_set *bset);
1779         __isl_give isl_basic_map *isl_basic_map_detect_equalities(
1780                 __isl_take isl_basic_map *bmap);
1781         __isl_give isl_set *isl_set_detect_equalities(
1782                 __isl_take isl_set *set);
1783         __isl_give isl_map *isl_map_detect_equalities(
1784                 __isl_take isl_map *map);
1785         __isl_give isl_union_set *isl_union_set_detect_equalities(
1786                 __isl_take isl_union_set *uset);
1787         __isl_give isl_union_map *isl_union_map_detect_equalities(
1788                 __isl_take isl_union_map *umap);
1789
1790 Simplify the representation of a set or relation by detecting implicit
1791 equalities.
1792
1793 =item * Removing redundant constraints
1794
1795         __isl_give isl_basic_set *isl_basic_set_remove_redundancies(
1796                 __isl_take isl_basic_set *bset);
1797         __isl_give isl_set *isl_set_remove_redundancies(
1798                 __isl_take isl_set *set);
1799         __isl_give isl_basic_map *isl_basic_map_remove_redundancies(
1800                 __isl_take isl_basic_map *bmap);
1801         __isl_give isl_map *isl_map_remove_redundancies(
1802                 __isl_take isl_map *map);
1803
1804 =item * Convex hull
1805
1806         __isl_give isl_basic_set *isl_set_convex_hull(
1807                 __isl_take isl_set *set);
1808         __isl_give isl_basic_map *isl_map_convex_hull(
1809                 __isl_take isl_map *map);
1810
1811 If the input set or relation has any existentially quantified
1812 variables, then the result of these operations is currently undefined.
1813
1814 =item * Simple hull
1815
1816         __isl_give isl_basic_set *isl_set_simple_hull(
1817                 __isl_take isl_set *set);
1818         __isl_give isl_basic_map *isl_map_simple_hull(
1819                 __isl_take isl_map *map);
1820         __isl_give isl_union_map *isl_union_map_simple_hull(
1821                 __isl_take isl_union_map *umap);
1822
1823 These functions compute a single basic set or relation
1824 that contains the whole input set or relation.
1825 In particular, the output is described by translates
1826 of the constraints describing the basic sets or relations in the input.
1827
1828 =begin latex
1829
1830 (See \autoref{s:simple hull}.)
1831
1832 =end latex
1833
1834 =item * Affine hull
1835
1836         __isl_give isl_basic_set *isl_basic_set_affine_hull(
1837                 __isl_take isl_basic_set *bset);
1838         __isl_give isl_basic_set *isl_set_affine_hull(
1839                 __isl_take isl_set *set);
1840         __isl_give isl_union_set *isl_union_set_affine_hull(
1841                 __isl_take isl_union_set *uset);
1842         __isl_give isl_basic_map *isl_basic_map_affine_hull(
1843                 __isl_take isl_basic_map *bmap);
1844         __isl_give isl_basic_map *isl_map_affine_hull(
1845                 __isl_take isl_map *map);
1846         __isl_give isl_union_map *isl_union_map_affine_hull(
1847                 __isl_take isl_union_map *umap);
1848
1849 In case of union sets and relations, the affine hull is computed
1850 per space.
1851
1852 =item * Polyhedral hull
1853
1854         __isl_give isl_basic_set *isl_set_polyhedral_hull(
1855                 __isl_take isl_set *set);
1856         __isl_give isl_basic_map *isl_map_polyhedral_hull(
1857                 __isl_take isl_map *map);
1858         __isl_give isl_union_set *isl_union_set_polyhedral_hull(
1859                 __isl_take isl_union_set *uset);
1860         __isl_give isl_union_map *isl_union_map_polyhedral_hull(
1861                 __isl_take isl_union_map *umap);
1862
1863 These functions compute a single basic set or relation
1864 not involving any existentially quantified variables
1865 that contains the whole input set or relation.
1866 In case of union sets and relations, the polyhedral hull is computed
1867 per space.
1868
1869 =item * Optimization
1870
1871         #include <isl/ilp.h>
1872         enum isl_lp_result isl_basic_set_max(
1873                 __isl_keep isl_basic_set *bset,
1874                 __isl_keep isl_aff *obj, isl_int *opt)
1875         enum isl_lp_result isl_set_min(__isl_keep isl_set *set,
1876                 __isl_keep isl_aff *obj, isl_int *opt);
1877         enum isl_lp_result isl_set_max(__isl_keep isl_set *set,
1878                 __isl_keep isl_aff *obj, isl_int *opt);
1879
1880 Compute the minimum or maximum of the integer affine expression C<obj>
1881 over the points in C<set>, returning the result in C<opt>.
1882 The return value may be one of C<isl_lp_error>,
1883 C<isl_lp_ok>, C<isl_lp_unbounded> or C<isl_lp_empty>.
1884
1885 =item * Parametric optimization
1886
1887         __isl_give isl_pw_aff *isl_set_dim_min(
1888                 __isl_take isl_set *set, int pos);
1889         __isl_give isl_pw_aff *isl_set_dim_max(
1890                 __isl_take isl_set *set, int pos);
1891
1892 Compute the minimum or maximum of the given set dimension as a function of the
1893 parameters, but independently of the other set dimensions.
1894 For lexicographic optimization, see L<"Lexicographic Optimization">.
1895
1896 =item * Dual
1897
1898 The following functions compute either the set of (rational) coefficient
1899 values of valid constraints for the given set or the set of (rational)
1900 values satisfying the constraints with coefficients from the given set.
1901 Internally, these two sets of functions perform essentially the
1902 same operations, except that the set of coefficients is assumed to
1903 be a cone, while the set of values may be any polyhedron.
1904 The current implementation is based on the Farkas lemma and
1905 Fourier-Motzkin elimination, but this may change or be made optional
1906 in future.  In particular, future implementations may use different
1907 dualization algorithms or skip the elimination step.
1908
1909         __isl_give isl_basic_set *isl_basic_set_coefficients(
1910                 __isl_take isl_basic_set *bset);
1911         __isl_give isl_basic_set *isl_set_coefficients(
1912                 __isl_take isl_set *set);
1913         __isl_give isl_union_set *isl_union_set_coefficients(
1914                 __isl_take isl_union_set *bset);
1915         __isl_give isl_basic_set *isl_basic_set_solutions(
1916                 __isl_take isl_basic_set *bset);
1917         __isl_give isl_basic_set *isl_set_solutions(
1918                 __isl_take isl_set *set);
1919         __isl_give isl_union_set *isl_union_set_solutions(
1920                 __isl_take isl_union_set *bset);
1921
1922 =item * Power
1923
1924         __isl_give isl_map *isl_map_power(__isl_take isl_map *map,
1925                 int *exact);
1926         __isl_give isl_union_map *isl_union_map_power(
1927                 __isl_take isl_union_map *umap, int *exact);
1928
1929 Compute a parametric representation for all positive powers I<k> of C<map>.
1930 The result maps I<k> to a nested relation corresponding to the
1931 I<k>th power of C<map>.
1932 The result may be an overapproximation.  If the result is known to be exact,
1933 then C<*exact> is set to C<1>.
1934
1935 =item * Transitive closure
1936
1937         __isl_give isl_map *isl_map_transitive_closure(
1938                 __isl_take isl_map *map, int *exact);
1939         __isl_give isl_union_map *isl_union_map_transitive_closure(
1940                 __isl_take isl_union_map *umap, int *exact);
1941
1942 Compute the transitive closure of C<map>.
1943 The result may be an overapproximation.  If the result is known to be exact,
1944 then C<*exact> is set to C<1>.
1945
1946 =item * Reaching path lengths
1947
1948         __isl_give isl_map *isl_map_reaching_path_lengths(
1949                 __isl_take isl_map *map, int *exact);
1950
1951 Compute a relation that maps each element in the range of C<map>
1952 to the lengths of all paths composed of edges in C<map> that
1953 end up in the given element.
1954 The result may be an overapproximation.  If the result is known to be exact,
1955 then C<*exact> is set to C<1>.
1956 To compute the I<maximal> path length, the resulting relation
1957 should be postprocessed by C<isl_map_lexmax>.
1958 In particular, if the input relation is a dependence relation
1959 (mapping sources to sinks), then the maximal path length corresponds
1960 to the free schedule.
1961 Note, however, that C<isl_map_lexmax> expects the maximum to be
1962 finite, so if the path lengths are unbounded (possibly due to
1963 the overapproximation), then you will get an error message.
1964
1965 =item * Wrapping
1966
1967         __isl_give isl_basic_set *isl_basic_map_wrap(
1968                 __isl_take isl_basic_map *bmap);
1969         __isl_give isl_set *isl_map_wrap(
1970                 __isl_take isl_map *map);
1971         __isl_give isl_union_set *isl_union_map_wrap(
1972                 __isl_take isl_union_map *umap);
1973         __isl_give isl_basic_map *isl_basic_set_unwrap(
1974                 __isl_take isl_basic_set *bset);
1975         __isl_give isl_map *isl_set_unwrap(
1976                 __isl_take isl_set *set);
1977         __isl_give isl_union_map *isl_union_set_unwrap(
1978                 __isl_take isl_union_set *uset);
1979
1980 =item * Flattening
1981
1982 Remove any internal structure of domain (and range) of the given
1983 set or relation.  If there is any such internal structure in the input,
1984 then the name of the space is also removed.
1985
1986         __isl_give isl_basic_set *isl_basic_set_flatten(
1987                 __isl_take isl_basic_set *bset);
1988         __isl_give isl_set *isl_set_flatten(
1989                 __isl_take isl_set *set);
1990         __isl_give isl_basic_map *isl_basic_map_flatten_domain(
1991                 __isl_take isl_basic_map *bmap);
1992         __isl_give isl_basic_map *isl_basic_map_flatten_range(
1993                 __isl_take isl_basic_map *bmap);
1994         __isl_give isl_map *isl_map_flatten_range(
1995                 __isl_take isl_map *map);
1996         __isl_give isl_map *isl_map_flatten_domain(
1997                 __isl_take isl_map *map);
1998         __isl_give isl_basic_map *isl_basic_map_flatten(
1999                 __isl_take isl_basic_map *bmap);
2000         __isl_give isl_map *isl_map_flatten(
2001                 __isl_take isl_map *map);
2002
2003         __isl_give isl_map *isl_set_flatten_map(
2004                 __isl_take isl_set *set);
2005
2006 The function above constructs a relation
2007 that maps the input set to a flattened version of the set.
2008
2009 =item * Lifting
2010
2011 Lift the input set to a space with extra dimensions corresponding
2012 to the existentially quantified variables in the input.
2013 In particular, the result lives in a wrapped map where the domain
2014 is the original space and the range corresponds to the original
2015 existentially quantified variables.
2016
2017         __isl_give isl_basic_set *isl_basic_set_lift(
2018                 __isl_take isl_basic_set *bset);
2019         __isl_give isl_set *isl_set_lift(
2020                 __isl_take isl_set *set);
2021         __isl_give isl_union_set *isl_union_set_lift(
2022                 __isl_take isl_union_set *uset);
2023
2024 =item * Internal Product
2025
2026         __isl_give isl_basic_map *isl_basic_map_zip(
2027                 __isl_take isl_basic_map *bmap);
2028         __isl_give isl_map *isl_map_zip(
2029                 __isl_take isl_map *map);
2030         __isl_give isl_union_map *isl_union_map_zip(
2031                 __isl_take isl_union_map *umap);
2032
2033 Given a relation with nested relations for domain and range,
2034 interchange the range of the domain with the domain of the range.
2035
2036 =item * Aligning parameters
2037
2038         __isl_give isl_set *isl_set_align_params(
2039                 __isl_take isl_set *set,
2040                 __isl_take isl_space *model);
2041         __isl_give isl_map *isl_map_align_params(
2042                 __isl_take isl_map *map,
2043                 __isl_take isl_space *model);
2044
2045 Change the order of the parameters of the given set or relation
2046 such that the first parameters match those of C<model>.
2047 This may involve the introduction of extra parameters.
2048 All parameters need to be named.
2049
2050 =item * Dimension manipulation
2051
2052         __isl_give isl_set *isl_set_add_dims(
2053                 __isl_take isl_set *set,
2054                 enum isl_dim_type type, unsigned n);
2055         __isl_give isl_map *isl_map_add_dims(
2056                 __isl_take isl_map *map,
2057                 enum isl_dim_type type, unsigned n);
2058         __isl_give isl_set *isl_set_insert_dims(
2059                 __isl_take isl_set *set,
2060                 enum isl_dim_type type, unsigned pos, unsigned n);
2061         __isl_give isl_map *isl_map_insert_dims(
2062                 __isl_take isl_map *map,
2063                 enum isl_dim_type type, unsigned pos, unsigned n);
2064
2065 It is usually not advisable to directly change the (input or output)
2066 space of a set or a relation as this removes the name and the internal
2067 structure of the space.  However, the above functions can be useful
2068 to add new parameters, assuming
2069 C<isl_set_align_params> and C<isl_map_align_params>
2070 are not sufficient.
2071
2072 =back
2073
2074 =head2 Binary Operations
2075
2076 The two arguments of a binary operation not only need to live
2077 in the same C<isl_ctx>, they currently also need to have
2078 the same (number of) parameters.
2079
2080 =head3 Basic Operations
2081
2082 =over
2083
2084 =item * Intersection
2085
2086         __isl_give isl_basic_set *isl_basic_set_intersect(
2087                 __isl_take isl_basic_set *bset1,
2088                 __isl_take isl_basic_set *bset2);
2089         __isl_give isl_set *isl_set_intersect_params(
2090                 __isl_take isl_set *set,
2091                 __isl_take isl_set *params);
2092         __isl_give isl_set *isl_set_intersect(
2093                 __isl_take isl_set *set1,
2094                 __isl_take isl_set *set2);
2095         __isl_give isl_union_set *isl_union_set_intersect(
2096                 __isl_take isl_union_set *uset1,
2097                 __isl_take isl_union_set *uset2);
2098         __isl_give isl_basic_map *isl_basic_map_intersect_domain(
2099                 __isl_take isl_basic_map *bmap,
2100                 __isl_take isl_basic_set *bset);
2101         __isl_give isl_basic_map *isl_basic_map_intersect_range(
2102                 __isl_take isl_basic_map *bmap,
2103                 __isl_take isl_basic_set *bset);
2104         __isl_give isl_basic_map *isl_basic_map_intersect(
2105                 __isl_take isl_basic_map *bmap1,
2106                 __isl_take isl_basic_map *bmap2);
2107         __isl_give isl_map *isl_map_intersect_params(
2108                 __isl_take isl_map *map,
2109                 __isl_take isl_set *params);
2110         __isl_give isl_map *isl_map_intersect_domain(
2111                 __isl_take isl_map *map,
2112                 __isl_take isl_set *set);
2113         __isl_give isl_map *isl_map_intersect_range(
2114                 __isl_take isl_map *map,
2115                 __isl_take isl_set *set);
2116         __isl_give isl_map *isl_map_intersect(
2117                 __isl_take isl_map *map1,
2118                 __isl_take isl_map *map2);
2119         __isl_give isl_union_map *isl_union_map_intersect_domain(
2120                 __isl_take isl_union_map *umap,
2121                 __isl_take isl_union_set *uset);
2122         __isl_give isl_union_map *isl_union_map_intersect_range(
2123                 __isl_take isl_union_map *umap,
2124                 __isl_take isl_union_set *uset);
2125         __isl_give isl_union_map *isl_union_map_intersect(
2126                 __isl_take isl_union_map *umap1,
2127                 __isl_take isl_union_map *umap2);
2128
2129 =item * Union
2130
2131         __isl_give isl_set *isl_basic_set_union(
2132                 __isl_take isl_basic_set *bset1,
2133                 __isl_take isl_basic_set *bset2);
2134         __isl_give isl_map *isl_basic_map_union(
2135                 __isl_take isl_basic_map *bmap1,
2136                 __isl_take isl_basic_map *bmap2);
2137         __isl_give isl_set *isl_set_union(
2138                 __isl_take isl_set *set1,
2139                 __isl_take isl_set *set2);
2140         __isl_give isl_map *isl_map_union(
2141                 __isl_take isl_map *map1,
2142                 __isl_take isl_map *map2);
2143         __isl_give isl_union_set *isl_union_set_union(
2144                 __isl_take isl_union_set *uset1,
2145                 __isl_take isl_union_set *uset2);
2146         __isl_give isl_union_map *isl_union_map_union(
2147                 __isl_take isl_union_map *umap1,
2148                 __isl_take isl_union_map *umap2);
2149
2150 =item * Set difference
2151
2152         __isl_give isl_set *isl_set_subtract(
2153                 __isl_take isl_set *set1,
2154                 __isl_take isl_set *set2);
2155         __isl_give isl_map *isl_map_subtract(
2156                 __isl_take isl_map *map1,
2157                 __isl_take isl_map *map2);
2158         __isl_give isl_union_set *isl_union_set_subtract(
2159                 __isl_take isl_union_set *uset1,
2160                 __isl_take isl_union_set *uset2);
2161         __isl_give isl_union_map *isl_union_map_subtract(
2162                 __isl_take isl_union_map *umap1,
2163                 __isl_take isl_union_map *umap2);
2164
2165 =item * Application
2166
2167         __isl_give isl_basic_set *isl_basic_set_apply(
2168                 __isl_take isl_basic_set *bset,
2169                 __isl_take isl_basic_map *bmap);
2170         __isl_give isl_set *isl_set_apply(
2171                 __isl_take isl_set *set,
2172                 __isl_take isl_map *map);
2173         __isl_give isl_union_set *isl_union_set_apply(
2174                 __isl_take isl_union_set *uset,
2175                 __isl_take isl_union_map *umap);
2176         __isl_give isl_basic_map *isl_basic_map_apply_domain(
2177                 __isl_take isl_basic_map *bmap1,
2178                 __isl_take isl_basic_map *bmap2);
2179         __isl_give isl_basic_map *isl_basic_map_apply_range(
2180                 __isl_take isl_basic_map *bmap1,
2181                 __isl_take isl_basic_map *bmap2);
2182         __isl_give isl_map *isl_map_apply_domain(
2183                 __isl_take isl_map *map1,
2184                 __isl_take isl_map *map2);
2185         __isl_give isl_union_map *isl_union_map_apply_domain(
2186                 __isl_take isl_union_map *umap1,
2187                 __isl_take isl_union_map *umap2);
2188         __isl_give isl_map *isl_map_apply_range(
2189                 __isl_take isl_map *map1,
2190                 __isl_take isl_map *map2);
2191         __isl_give isl_union_map *isl_union_map_apply_range(
2192                 __isl_take isl_union_map *umap1,
2193                 __isl_take isl_union_map *umap2);
2194
2195 =item * Cartesian Product
2196
2197         __isl_give isl_set *isl_set_product(
2198                 __isl_take isl_set *set1,
2199                 __isl_take isl_set *set2);
2200         __isl_give isl_union_set *isl_union_set_product(
2201                 __isl_take isl_union_set *uset1,
2202                 __isl_take isl_union_set *uset2);
2203         __isl_give isl_basic_map *isl_basic_map_domain_product(
2204                 __isl_take isl_basic_map *bmap1,
2205                 __isl_take isl_basic_map *bmap2);
2206         __isl_give isl_basic_map *isl_basic_map_range_product(
2207                 __isl_take isl_basic_map *bmap1,
2208                 __isl_take isl_basic_map *bmap2);
2209         __isl_give isl_map *isl_map_domain_product(
2210                 __isl_take isl_map *map1,
2211                 __isl_take isl_map *map2);
2212         __isl_give isl_map *isl_map_range_product(
2213                 __isl_take isl_map *map1,
2214                 __isl_take isl_map *map2);
2215         __isl_give isl_union_map *isl_union_map_range_product(
2216                 __isl_take isl_union_map *umap1,
2217                 __isl_take isl_union_map *umap2);
2218         __isl_give isl_map *isl_map_product(
2219                 __isl_take isl_map *map1,
2220                 __isl_take isl_map *map2);
2221         __isl_give isl_union_map *isl_union_map_product(
2222                 __isl_take isl_union_map *umap1,
2223                 __isl_take isl_union_map *umap2);
2224
2225 The above functions compute the cross product of the given
2226 sets or relations.  The domains and ranges of the results
2227 are wrapped maps between domains and ranges of the inputs.
2228 To obtain a ``flat'' product, use the following functions
2229 instead.
2230
2231         __isl_give isl_basic_set *isl_basic_set_flat_product(
2232                 __isl_take isl_basic_set *bset1,
2233                 __isl_take isl_basic_set *bset2);
2234         __isl_give isl_set *isl_set_flat_product(
2235                 __isl_take isl_set *set1,
2236                 __isl_take isl_set *set2);
2237         __isl_give isl_basic_map *isl_basic_map_flat_range_product(
2238                 __isl_take isl_basic_map *bmap1,
2239                 __isl_take isl_basic_map *bmap2);
2240         __isl_give isl_map *isl_map_flat_domain_product(
2241                 __isl_take isl_map *map1,
2242                 __isl_take isl_map *map2);
2243         __isl_give isl_map *isl_map_flat_range_product(
2244                 __isl_take isl_map *map1,
2245                 __isl_take isl_map *map2);
2246         __isl_give isl_union_map *isl_union_map_flat_range_product(
2247                 __isl_take isl_union_map *umap1,
2248                 __isl_take isl_union_map *umap2);
2249         __isl_give isl_basic_map *isl_basic_map_flat_product(
2250                 __isl_take isl_basic_map *bmap1,
2251                 __isl_take isl_basic_map *bmap2);
2252         __isl_give isl_map *isl_map_flat_product(
2253                 __isl_take isl_map *map1,
2254                 __isl_take isl_map *map2);
2255
2256 =item * Simplification
2257
2258         __isl_give isl_basic_set *isl_basic_set_gist(
2259                 __isl_take isl_basic_set *bset,
2260                 __isl_take isl_basic_set *context);
2261         __isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
2262                 __isl_take isl_set *context);
2263         __isl_give isl_set *isl_set_gist_params(
2264                 __isl_take isl_set *set,
2265                 __isl_take isl_set *context);
2266         __isl_give isl_union_set *isl_union_set_gist(
2267                 __isl_take isl_union_set *uset,
2268                 __isl_take isl_union_set *context);
2269         __isl_give isl_basic_map *isl_basic_map_gist(
2270                 __isl_take isl_basic_map *bmap,
2271                 __isl_take isl_basic_map *context);
2272         __isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
2273                 __isl_take isl_map *context);
2274         __isl_give isl_map *isl_map_gist_params(
2275                 __isl_take isl_map *map,
2276                 __isl_take isl_set *context);
2277         __isl_give isl_union_map *isl_union_map_gist(
2278                 __isl_take isl_union_map *umap,
2279                 __isl_take isl_union_map *context);
2280
2281 The gist operation returns a set or relation that has the
2282 same intersection with the context as the input set or relation.
2283 Any implicit equality in the intersection is made explicit in the result,
2284 while all inequalities that are redundant with respect to the intersection
2285 are removed.
2286 In case of union sets and relations, the gist operation is performed
2287 per space.
2288
2289 =back
2290
2291 =head3 Lexicographic Optimization
2292
2293 Given a (basic) set C<set> (or C<bset>) and a zero-dimensional domain C<dom>,
2294 the following functions
2295 compute a set that contains the lexicographic minimum or maximum
2296 of the elements in C<set> (or C<bset>) for those values of the parameters
2297 that satisfy C<dom>.
2298 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
2299 that contains the parameter values in C<dom> for which C<set> (or C<bset>)
2300 has no elements.
2301 In other words, the union of the parameter values
2302 for which the result is non-empty and of C<*empty>
2303 is equal to C<dom>.
2304
2305         __isl_give isl_set *isl_basic_set_partial_lexmin(
2306                 __isl_take isl_basic_set *bset,
2307                 __isl_take isl_basic_set *dom,
2308                 __isl_give isl_set **empty);
2309         __isl_give isl_set *isl_basic_set_partial_lexmax(
2310                 __isl_take isl_basic_set *bset,
2311                 __isl_take isl_basic_set *dom,
2312                 __isl_give isl_set **empty);
2313         __isl_give isl_set *isl_set_partial_lexmin(
2314                 __isl_take isl_set *set, __isl_take isl_set *dom,
2315                 __isl_give isl_set **empty);
2316         __isl_give isl_set *isl_set_partial_lexmax(
2317                 __isl_take isl_set *set, __isl_take isl_set *dom,
2318                 __isl_give isl_set **empty);
2319
2320 Given a (basic) set C<set> (or C<bset>), the following functions simply
2321 return a set containing the lexicographic minimum or maximum
2322 of the elements in C<set> (or C<bset>).
2323 In case of union sets, the optimum is computed per space.
2324
2325         __isl_give isl_set *isl_basic_set_lexmin(
2326                 __isl_take isl_basic_set *bset);
2327         __isl_give isl_set *isl_basic_set_lexmax(
2328                 __isl_take isl_basic_set *bset);
2329         __isl_give isl_set *isl_set_lexmin(
2330                 __isl_take isl_set *set);
2331         __isl_give isl_set *isl_set_lexmax(
2332                 __isl_take isl_set *set);
2333         __isl_give isl_union_set *isl_union_set_lexmin(
2334                 __isl_take isl_union_set *uset);
2335         __isl_give isl_union_set *isl_union_set_lexmax(
2336                 __isl_take isl_union_set *uset);
2337
2338 Given a (basic) relation C<map> (or C<bmap>) and a domain C<dom>,
2339 the following functions
2340 compute a relation that maps each element of C<dom>
2341 to the single lexicographic minimum or maximum
2342 of the elements that are associated to that same
2343 element in C<map> (or C<bmap>).
2344 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
2345 that contains the elements in C<dom> that do not map
2346 to any elements in C<map> (or C<bmap>).
2347 In other words, the union of the domain of the result and of C<*empty>
2348 is equal to C<dom>.
2349
2350         __isl_give isl_map *isl_basic_map_partial_lexmax(
2351                 __isl_take isl_basic_map *bmap,
2352                 __isl_take isl_basic_set *dom,
2353                 __isl_give isl_set **empty);
2354         __isl_give isl_map *isl_basic_map_partial_lexmin(
2355                 __isl_take isl_basic_map *bmap,
2356                 __isl_take isl_basic_set *dom,
2357                 __isl_give isl_set **empty);
2358         __isl_give isl_map *isl_map_partial_lexmax(
2359                 __isl_take isl_map *map, __isl_take isl_set *dom,
2360                 __isl_give isl_set **empty);
2361         __isl_give isl_map *isl_map_partial_lexmin(
2362                 __isl_take isl_map *map, __isl_take isl_set *dom,
2363                 __isl_give isl_set **empty);
2364
2365 Given a (basic) map C<map> (or C<bmap>), the following functions simply
2366 return a map mapping each element in the domain of
2367 C<map> (or C<bmap>) to the lexicographic minimum or maximum
2368 of all elements associated to that element.
2369 In case of union relations, the optimum is computed per space.
2370
2371         __isl_give isl_map *isl_basic_map_lexmin(
2372                 __isl_take isl_basic_map *bmap);
2373         __isl_give isl_map *isl_basic_map_lexmax(
2374                 __isl_take isl_basic_map *bmap);
2375         __isl_give isl_map *isl_map_lexmin(
2376                 __isl_take isl_map *map);
2377         __isl_give isl_map *isl_map_lexmax(
2378                 __isl_take isl_map *map);
2379         __isl_give isl_union_map *isl_union_map_lexmin(
2380                 __isl_take isl_union_map *umap);
2381         __isl_give isl_union_map *isl_union_map_lexmax(
2382                 __isl_take isl_union_map *umap);
2383
2384 =head2 Lists
2385
2386 Lists are defined over several element types, including
2387 C<isl_aff>, C<isl_pw_aff>, C<isl_basic_set> and C<isl_set>.
2388 Here we take lists of C<isl_set>s as an example.
2389 Lists can be created, copied and freed using the following functions.
2390
2391         #include <isl/list.h>
2392         __isl_give isl_set_list *isl_set_list_from_set(
2393                 __isl_take isl_set *el);
2394         __isl_give isl_set_list *isl_set_list_alloc(
2395                 isl_ctx *ctx, int n);
2396         __isl_give isl_set_list *isl_set_list_copy(
2397                 __isl_keep isl_set_list *list);
2398         __isl_give isl_set_list *isl_set_list_add(
2399                 __isl_take isl_set_list *list,
2400                 __isl_take isl_set *el);
2401         __isl_give isl_set_list *isl_set_list_concat(
2402                 __isl_take isl_set_list *list1,
2403                 __isl_take isl_set_list *list2);
2404         void *isl_set_list_free(__isl_take isl_set_list *list);
2405
2406 C<isl_set_list_alloc> creates an empty list with a capacity for
2407 C<n> elements.  C<isl_set_list_from_set> creates a list with a single
2408 element.
2409
2410 Lists can be inspected using the following functions.
2411
2412         #include <isl/list.h>
2413         isl_ctx *isl_set_list_get_ctx(__isl_keep isl_set_list *list);
2414         int isl_set_list_n_set(__isl_keep isl_set_list *list);
2415         __isl_give isl_set *isl_set_list_get_set(
2416                 __isl_keep isl_set_list *list, int index);
2417         int isl_set_list_foreach(__isl_keep isl_set_list *list,
2418                 int (*fn)(__isl_take isl_set *el, void *user),
2419                 void *user);
2420
2421 Lists can be printed using
2422
2423         #include <isl/list.h>
2424         __isl_give isl_printer *isl_printer_print_set_list(
2425                 __isl_take isl_printer *p,
2426                 __isl_keep isl_set_list *list);
2427
2428 =head2 Matrices
2429
2430 Matrices can be created, copied and freed using the following functions.
2431
2432         #include <isl/mat.h>
2433         __isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx,
2434                 unsigned n_row, unsigned n_col);
2435         __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat);
2436         void isl_mat_free(__isl_take isl_mat *mat);
2437
2438 Note that the elements of a newly created matrix may have arbitrary values.
2439 The elements can be changed and inspected using the following functions.
2440
2441         isl_ctx *isl_mat_get_ctx(__isl_keep isl_mat *mat);
2442         int isl_mat_rows(__isl_keep isl_mat *mat);
2443         int isl_mat_cols(__isl_keep isl_mat *mat);
2444         int isl_mat_get_element(__isl_keep isl_mat *mat,
2445                 int row, int col, isl_int *v);
2446         __isl_give isl_mat *isl_mat_set_element(__isl_take isl_mat *mat,
2447                 int row, int col, isl_int v);
2448         __isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat,
2449                 int row, int col, int v);
2450
2451 C<isl_mat_get_element> will return a negative value if anything went wrong.
2452 In that case, the value of C<*v> is undefined.
2453
2454 The following function can be used to compute the (right) inverse
2455 of a matrix, i.e., a matrix such that the product of the original
2456 and the inverse (in that order) is a multiple of the identity matrix.
2457 The input matrix is assumed to be of full row-rank.
2458
2459         __isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat);
2460
2461 The following function can be used to compute the (right) kernel
2462 (or null space) of a matrix, i.e., a matrix such that the product of
2463 the original and the kernel (in that order) is the zero matrix.
2464
2465         __isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat);
2466
2467 =head2 Piecewise Quasi Affine Expressions
2468
2469 The zero quasi affine expression on a given domain can be created using
2470
2471         __isl_give isl_aff *isl_aff_zero_on_domain(
2472                 __isl_take isl_local_space *ls);
2473
2474 Note that the space in which the resulting object lives is a map space
2475 with the given space as domain and a one-dimensional range.
2476
2477 A quasi affine expression can also be initialized from an C<isl_div>:
2478
2479         #include <isl/div.h>
2480         __isl_give isl_aff *isl_aff_from_div(__isl_take isl_div *div);
2481
2482 An empty piecewise quasi affine expression (one with no cells)
2483 or a piecewise quasi affine expression with a single cell can
2484 be created using the following functions.
2485
2486         #include <isl/aff.h>
2487         __isl_give isl_pw_aff *isl_pw_aff_empty(
2488                 __isl_take isl_space *space);
2489         __isl_give isl_pw_aff *isl_pw_aff_alloc(
2490                 __isl_take isl_set *set, __isl_take isl_aff *aff);
2491         __isl_give isl_pw_aff *isl_pw_aff_from_aff(
2492                 __isl_take isl_aff *aff);
2493
2494 Quasi affine expressions can be copied and freed using
2495
2496         #include <isl/aff.h>
2497         __isl_give isl_aff *isl_aff_copy(__isl_keep isl_aff *aff);
2498         void *isl_aff_free(__isl_take isl_aff *aff);
2499
2500         __isl_give isl_pw_aff *isl_pw_aff_copy(
2501                 __isl_keep isl_pw_aff *pwaff);
2502         void *isl_pw_aff_free(__isl_take isl_pw_aff *pwaff);
2503
2504 A (rational) bound on a dimension can be extracted from an C<isl_constraint>
2505 using the following function.  The constraint is required to have
2506 a non-zero coefficient for the specified dimension.
2507
2508         #include <isl/constraint.h>
2509         __isl_give isl_aff *isl_constraint_get_bound(
2510                 __isl_keep isl_constraint *constraint,
2511                 enum isl_dim_type type, int pos);
2512
2513 The entire affine expression of the constraint can also be extracted
2514 using the following function.
2515
2516         #include <isl/constraint.h>
2517         __isl_give isl_aff *isl_constraint_get_aff(
2518                 __isl_keep isl_constraint *constraint);
2519
2520 Conversely, an equality constraint equating
2521 the affine expression to zero or an inequality constraint enforcing
2522 the affine expression to be non-negative, can be constructed using
2523
2524         __isl_give isl_constraint *isl_equality_from_aff(
2525                 __isl_take isl_aff *aff);
2526         __isl_give isl_constraint *isl_inequality_from_aff(
2527                 __isl_take isl_aff *aff);
2528
2529 The expression can be inspected using
2530
2531         #include <isl/aff.h>
2532         isl_ctx *isl_aff_get_ctx(__isl_keep isl_aff *aff);
2533         int isl_aff_dim(__isl_keep isl_aff *aff,
2534                 enum isl_dim_type type);
2535         __isl_give isl_local_space *isl_aff_get_domain_local_space(
2536                 __isl_keep isl_aff *aff);
2537         __isl_give isl_local_space *isl_aff_get_local_space(
2538                 __isl_keep isl_aff *aff);
2539         const char *isl_aff_get_dim_name(__isl_keep isl_aff *aff,
2540                 enum isl_dim_type type, unsigned pos);
2541         int isl_aff_get_constant(__isl_keep isl_aff *aff,
2542                 isl_int *v);
2543         int isl_aff_get_coefficient(__isl_keep isl_aff *aff,
2544                 enum isl_dim_type type, int pos, isl_int *v);
2545         int isl_aff_get_denominator(__isl_keep isl_aff *aff,
2546                 isl_int *v);
2547         __isl_give isl_div *isl_aff_get_div(
2548                 __isl_keep isl_aff *aff, int pos);
2549
2550         int isl_pw_aff_foreach_piece(__isl_keep isl_pw_aff *pwaff,
2551                 int (*fn)(__isl_take isl_set *set,
2552                           __isl_take isl_aff *aff,
2553                           void *user), void *user);
2554
2555         int isl_aff_is_cst(__isl_keep isl_aff *aff);
2556         int isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff);
2557
2558         int isl_aff_involves_dims(__isl_keep isl_aff *aff,
2559                 enum isl_dim_type type, unsigned first, unsigned n);
2560         int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff,
2561                 enum isl_dim_type type, unsigned first, unsigned n);
2562
2563         isl_ctx *isl_pw_aff_get_ctx(__isl_keep isl_pw_aff *pwaff);
2564         unsigned isl_pw_aff_dim(__isl_keep isl_pw_aff *pwaff,
2565                 enum isl_dim_type type);
2566         int isl_pw_aff_is_empty(__isl_keep isl_pw_aff *pwaff);
2567
2568 It can be modified using
2569
2570         #include <isl/aff.h>
2571         __isl_give isl_pw_aff *isl_pw_aff_set_tuple_id(
2572                 __isl_take isl_pw_aff *pwaff,
2573                 __isl_take isl_id *id);
2574         __isl_give isl_aff *isl_aff_set_dim_name(
2575                 __isl_take isl_aff *aff, enum isl_dim_type type,
2576                 unsigned pos, const char *s);
2577         __isl_give isl_aff *isl_aff_set_constant(
2578                 __isl_take isl_aff *aff, isl_int v);
2579         __isl_give isl_aff *isl_aff_set_constant_si(
2580                 __isl_take isl_aff *aff, int v);
2581         __isl_give isl_aff *isl_aff_set_coefficient(
2582                 __isl_take isl_aff *aff,
2583                 enum isl_dim_type type, int pos, isl_int v);
2584         __isl_give isl_aff *isl_aff_set_coefficient_si(
2585                 __isl_take isl_aff *aff,
2586                 enum isl_dim_type type, int pos, int v);
2587         __isl_give isl_aff *isl_aff_set_denominator(
2588                 __isl_take isl_aff *aff, isl_int v);
2589
2590         __isl_give isl_aff *isl_aff_add_constant(
2591                 __isl_take isl_aff *aff, isl_int v);
2592         __isl_give isl_aff *isl_aff_add_constant_si(
2593                 __isl_take isl_aff *aff, int v);
2594         __isl_give isl_aff *isl_aff_add_coefficient(
2595                 __isl_take isl_aff *aff,
2596                 enum isl_dim_type type, int pos, isl_int v);
2597         __isl_give isl_aff *isl_aff_add_coefficient_si(
2598                 __isl_take isl_aff *aff,
2599                 enum isl_dim_type type, int pos, int v);
2600
2601         __isl_give isl_aff *isl_aff_insert_dims(
2602                 __isl_take isl_aff *aff,
2603                 enum isl_dim_type type, unsigned first, unsigned n);
2604         __isl_give isl_pw_aff *isl_pw_aff_insert_dims(
2605                 __isl_take isl_pw_aff *pwaff,
2606                 enum isl_dim_type type, unsigned first, unsigned n);
2607         __isl_give isl_aff *isl_aff_add_dims(
2608                 __isl_take isl_aff *aff,
2609                 enum isl_dim_type type, unsigned n);
2610         __isl_give isl_pw_aff *isl_pw_aff_add_dims(
2611                 __isl_take isl_pw_aff *pwaff,
2612                 enum isl_dim_type type, unsigned n);
2613         __isl_give isl_aff *isl_aff_drop_dims(
2614                 __isl_take isl_aff *aff,
2615                 enum isl_dim_type type, unsigned first, unsigned n);
2616         __isl_give isl_pw_aff *isl_pw_aff_drop_dims(
2617                 __isl_take isl_pw_aff *pwaff,
2618                 enum isl_dim_type type, unsigned first, unsigned n);
2619
2620 Note that the C<set_constant> and C<set_coefficient> functions
2621 set the I<numerator> of the constant or coefficient, while
2622 C<add_constant> and C<add_coefficient> add an integer value to
2623 the possibly rational constant or coefficient.
2624
2625 To check whether an affine expressions is obviously zero
2626 or obviously equal to some other affine expression, use
2627
2628         #include <isl/aff.h>
2629         int isl_aff_plain_is_zero(__isl_keep isl_aff *aff);
2630         int isl_aff_plain_is_equal(__isl_keep isl_aff *aff1,
2631                 __isl_keep isl_aff *aff2);
2632
2633 Operations include
2634
2635         #include <isl/aff.h>
2636         __isl_give isl_aff *isl_aff_add(__isl_take isl_aff *aff1,
2637                 __isl_take isl_aff *aff2);
2638         __isl_give isl_pw_aff *isl_pw_aff_add(
2639                 __isl_take isl_pw_aff *pwaff1,
2640                 __isl_take isl_pw_aff *pwaff2);
2641         __isl_give isl_pw_aff *isl_pw_aff_min(
2642                 __isl_take isl_pw_aff *pwaff1,
2643                 __isl_take isl_pw_aff *pwaff2);
2644         __isl_give isl_pw_aff *isl_pw_aff_max(
2645                 __isl_take isl_pw_aff *pwaff1,
2646                 __isl_take isl_pw_aff *pwaff2);
2647         __isl_give isl_aff *isl_aff_sub(__isl_take isl_aff *aff1,
2648                 __isl_take isl_aff *aff2);
2649         __isl_give isl_pw_aff *isl_pw_aff_sub(
2650                 __isl_take isl_pw_aff *pwaff1,
2651                 __isl_take isl_pw_aff *pwaff2);
2652         __isl_give isl_aff *isl_aff_neg(__isl_take isl_aff *aff);
2653         __isl_give isl_pw_aff *isl_pw_aff_neg(
2654                 __isl_take isl_pw_aff *pwaff);
2655         __isl_give isl_aff *isl_aff_ceil(__isl_take isl_aff *aff);
2656         __isl_give isl_pw_aff *isl_pw_aff_ceil(
2657                 __isl_take isl_pw_aff *pwaff);
2658         __isl_give isl_aff *isl_aff_floor(__isl_take isl_aff *aff);
2659         __isl_give isl_pw_aff *isl_pw_aff_floor(
2660                 __isl_take isl_pw_aff *pwaff);
2661         __isl_give isl_aff *isl_aff_mod(__isl_take isl_aff *aff,
2662                 isl_int mod);
2663         __isl_give isl_pw_aff *isl_pw_aff_mod(
2664                 __isl_take isl_pw_aff *pwaff, isl_int mod);
2665         __isl_give isl_aff *isl_aff_scale(__isl_take isl_aff *aff,
2666                 isl_int f);
2667         __isl_give isl_pw_aff *isl_pw_aff_scale(
2668                 __isl_take isl_pw_aff *pwaff, isl_int f);
2669         __isl_give isl_aff *isl_aff_scale_down(__isl_take isl_aff *aff,
2670                 isl_int f);
2671         __isl_give isl_aff *isl_aff_scale_down_ui(
2672                 __isl_take isl_aff *aff, unsigned f);
2673         __isl_give isl_pw_aff *isl_pw_aff_scale_down(
2674                 __isl_take isl_pw_aff *pwaff, isl_int f);
2675
2676         __isl_give isl_pw_aff *isl_pw_aff_list_min(
2677                 __isl_take isl_pw_aff_list *list);
2678         __isl_give isl_pw_aff *isl_pw_aff_list_max(
2679                 __isl_take isl_pw_aff_list *list);
2680
2681         __isl_give isl_pw_aff *isl_pw_aff_coalesce(
2682                 __isl_take isl_pw_aff *pwqp);
2683
2684         __isl_give isl_pw_aff *isl_pw_aff_align_params(
2685                 __isl_take isl_pw_aff *pwaff,
2686                 __isl_take isl_space *model);
2687
2688         __isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff,
2689                 __isl_take isl_set *context);
2690         __isl_give isl_pw_aff *isl_pw_aff_gist(
2691                 __isl_take isl_pw_aff *pwaff,
2692                 __isl_take isl_set *context);
2693
2694         __isl_give isl_set *isl_pw_aff_domain(
2695                 __isl_take isl_pw_aff *pwaff);
2696
2697         __isl_give isl_aff *isl_aff_mul(__isl_take isl_aff *aff1,
2698                 __isl_take isl_aff *aff2);
2699         __isl_give isl_pw_aff *isl_pw_aff_mul(
2700                 __isl_take isl_pw_aff *pwaff1,
2701                 __isl_take isl_pw_aff *pwaff2);
2702
2703 When multiplying two affine expressions, at least one of the two needs
2704 to be a constant.
2705
2706         #include <isl/aff.h>
2707         __isl_give isl_basic_set *isl_aff_le_basic_set(
2708                 __isl_take isl_aff *aff1, __isl_take isl_aff *aff2);
2709         __isl_give isl_basic_set *isl_aff_ge_basic_set(
2710                 __isl_take isl_aff *aff1, __isl_take isl_aff *aff2);
2711         __isl_give isl_set *isl_pw_aff_eq_set(
2712                 __isl_take isl_pw_aff *pwaff1,
2713                 __isl_take isl_pw_aff *pwaff2);
2714         __isl_give isl_set *isl_pw_aff_ne_set(
2715                 __isl_take isl_pw_aff *pwaff1,
2716                 __isl_take isl_pw_aff *pwaff2);
2717         __isl_give isl_set *isl_pw_aff_le_set(
2718                 __isl_take isl_pw_aff *pwaff1,
2719                 __isl_take isl_pw_aff *pwaff2);
2720         __isl_give isl_set *isl_pw_aff_lt_set(
2721                 __isl_take isl_pw_aff *pwaff1,
2722                 __isl_take isl_pw_aff *pwaff2);
2723         __isl_give isl_set *isl_pw_aff_ge_set(
2724                 __isl_take isl_pw_aff *pwaff1,
2725                 __isl_take isl_pw_aff *pwaff2);
2726         __isl_give isl_set *isl_pw_aff_gt_set(
2727                 __isl_take isl_pw_aff *pwaff1,
2728                 __isl_take isl_pw_aff *pwaff2);
2729
2730         __isl_give isl_set *isl_pw_aff_list_eq_set(
2731                 __isl_take isl_pw_aff_list *list1,
2732                 __isl_take isl_pw_aff_list *list2);
2733         __isl_give isl_set *isl_pw_aff_list_ne_set(
2734                 __isl_take isl_pw_aff_list *list1,
2735                 __isl_take isl_pw_aff_list *list2);
2736         __isl_give isl_set *isl_pw_aff_list_le_set(
2737                 __isl_take isl_pw_aff_list *list1,
2738                 __isl_take isl_pw_aff_list *list2);
2739         __isl_give isl_set *isl_pw_aff_list_lt_set(
2740                 __isl_take isl_pw_aff_list *list1,
2741                 __isl_take isl_pw_aff_list *list2);
2742         __isl_give isl_set *isl_pw_aff_list_ge_set(
2743                 __isl_take isl_pw_aff_list *list1,
2744                 __isl_take isl_pw_aff_list *list2);
2745         __isl_give isl_set *isl_pw_aff_list_gt_set(
2746                 __isl_take isl_pw_aff_list *list1,
2747                 __isl_take isl_pw_aff_list *list2);
2748
2749 The function C<isl_aff_ge_basic_set> returns a basic set
2750 containing those elements in the shared space
2751 of C<aff1> and C<aff2> where C<aff1> is greater than or equal to C<aff2>.
2752 The function C<isl_aff_ge_set> returns a set
2753 containing those elements in the shared domain
2754 of C<pwaff1> and C<pwaff2> where C<pwaff1> is greater than or equal to C<pwaff2>.
2755 The functions operating on C<isl_pw_aff_list> apply the corresponding
2756 C<isl_pw_aff> function to each pair of elements in the two lists.
2757
2758         #include <isl/aff.h>
2759         __isl_give isl_set *isl_pw_aff_nonneg_set(
2760                 __isl_take isl_pw_aff *pwaff);
2761         __isl_give isl_set *isl_pw_aff_zero_set(
2762                 __isl_take isl_pw_aff *pwaff);
2763         __isl_give isl_set *isl_pw_aff_non_zero_set(
2764                 __isl_take isl_pw_aff *pwaff);
2765
2766 The function C<isl_pw_aff_nonneg_set> returns a set
2767 containing those elements in the domain
2768 of C<pwaff> where C<pwaff> is non-negative.
2769
2770         #include <isl/aff.h>
2771         __isl_give isl_pw_aff *isl_pw_aff_cond(
2772                 __isl_take isl_set *cond,
2773                 __isl_take isl_pw_aff *pwaff_true,
2774                 __isl_take isl_pw_aff *pwaff_false);
2775
2776 The function C<isl_pw_aff_cond> performs a conditional operator
2777 and returns an expression that is equal to C<pwaff_true>
2778 for elements in C<cond> and equal to C<pwaff_false> for elements
2779 not in C<cond>.
2780
2781         #include <isl/aff.h>
2782         __isl_give isl_pw_aff *isl_pw_aff_union_min(
2783                 __isl_take isl_pw_aff *pwaff1,
2784                 __isl_take isl_pw_aff *pwaff2);
2785         __isl_give isl_pw_aff *isl_pw_aff_union_max(
2786                 __isl_take isl_pw_aff *pwaff1,
2787                 __isl_take isl_pw_aff *pwaff2);
2788
2789 The function C<isl_pw_aff_union_max> computes a piecewise quasi-affine
2790 expression with a domain that is the union of those of C<pwaff1> and
2791 C<pwaff2> and such that on each cell, the quasi-affine expression is
2792 the maximum of those of C<pwaff1> and C<pwaff2>.  If only one of
2793 C<pwaff1> or C<pwaff2> is defined on a given cell, then the
2794 associated expression is the defined one.
2795
2796 An expression can be printed using
2797
2798         #include <isl/aff.h>
2799         __isl_give isl_printer *isl_printer_print_aff(
2800                 __isl_take isl_printer *p, __isl_keep isl_aff *aff);
2801
2802         __isl_give isl_printer *isl_printer_print_pw_aff(
2803                 __isl_take isl_printer *p,
2804                 __isl_keep isl_pw_aff *pwaff);
2805
2806 =head2 Points
2807
2808 Points are elements of a set.  They can be used to construct
2809 simple sets (boxes) or they can be used to represent the
2810 individual elements of a set.
2811 The zero point (the origin) can be created using
2812
2813         __isl_give isl_point *isl_point_zero(__isl_take isl_space *space);
2814
2815 The coordinates of a point can be inspected, set and changed
2816 using
2817
2818         void isl_point_get_coordinate(__isl_keep isl_point *pnt,
2819                 enum isl_dim_type type, int pos, isl_int *v);
2820         __isl_give isl_point *isl_point_set_coordinate(
2821                 __isl_take isl_point *pnt,
2822                 enum isl_dim_type type, int pos, isl_int v);
2823
2824         __isl_give isl_point *isl_point_add_ui(
2825                 __isl_take isl_point *pnt,
2826                 enum isl_dim_type type, int pos, unsigned val);
2827         __isl_give isl_point *isl_point_sub_ui(
2828                 __isl_take isl_point *pnt,
2829                 enum isl_dim_type type, int pos, unsigned val);
2830
2831 Other properties can be obtained using
2832
2833         isl_ctx *isl_point_get_ctx(__isl_keep isl_point *pnt);
2834
2835 Points can be copied or freed using
2836
2837         __isl_give isl_point *isl_point_copy(
2838                 __isl_keep isl_point *pnt);
2839         void isl_point_free(__isl_take isl_point *pnt);
2840
2841 A singleton set can be created from a point using
2842
2843         __isl_give isl_basic_set *isl_basic_set_from_point(
2844                 __isl_take isl_point *pnt);
2845         __isl_give isl_set *isl_set_from_point(
2846                 __isl_take isl_point *pnt);
2847
2848 and a box can be created from two opposite extremal points using
2849
2850         __isl_give isl_basic_set *isl_basic_set_box_from_points(
2851                 __isl_take isl_point *pnt1,
2852                 __isl_take isl_point *pnt2);
2853         __isl_give isl_set *isl_set_box_from_points(
2854                 __isl_take isl_point *pnt1,
2855                 __isl_take isl_point *pnt2);
2856
2857 All elements of a B<bounded> (union) set can be enumerated using
2858 the following functions.
2859
2860         int isl_set_foreach_point(__isl_keep isl_set *set,
2861                 int (*fn)(__isl_take isl_point *pnt, void *user),
2862                 void *user);
2863         int isl_union_set_foreach_point(__isl_keep isl_union_set *uset,
2864                 int (*fn)(__isl_take isl_point *pnt, void *user),
2865                 void *user);
2866
2867 The function C<fn> is called for each integer point in
2868 C<set> with as second argument the last argument of
2869 the C<isl_set_foreach_point> call.  The function C<fn>
2870 should return C<0> on success and C<-1> on failure.
2871 In the latter case, C<isl_set_foreach_point> will stop
2872 enumerating and return C<-1> as well.
2873 If the enumeration is performed successfully and to completion,
2874 then C<isl_set_foreach_point> returns C<0>.
2875
2876 To obtain a single point of a (basic) set, use
2877
2878         __isl_give isl_point *isl_basic_set_sample_point(
2879                 __isl_take isl_basic_set *bset);
2880         __isl_give isl_point *isl_set_sample_point(
2881                 __isl_take isl_set *set);
2882
2883 If C<set> does not contain any (integer) points, then the
2884 resulting point will be ``void'', a property that can be
2885 tested using
2886
2887         int isl_point_is_void(__isl_keep isl_point *pnt);
2888
2889 =head2 Piecewise Quasipolynomials
2890
2891 A piecewise quasipolynomial is a particular kind of function that maps
2892 a parametric point to a rational value.
2893 More specifically, a quasipolynomial is a polynomial expression in greatest
2894 integer parts of affine expressions of parameters and variables.
2895 A piecewise quasipolynomial is a subdivision of a given parametric
2896 domain into disjoint cells with a quasipolynomial associated to
2897 each cell.  The value of the piecewise quasipolynomial at a given
2898 point is the value of the quasipolynomial associated to the cell
2899 that contains the point.  Outside of the union of cells,
2900 the value is assumed to be zero.
2901 For example, the piecewise quasipolynomial
2902
2903         [n] -> { [x] -> ((1 + n) - x) : x <= n and x >= 0 }
2904
2905 maps C<x> to C<1 + n - x> for values of C<x> between C<0> and C<n>.
2906 A given piecewise quasipolynomial has a fixed domain dimension.
2907 Union piecewise quasipolynomials are used to contain piecewise quasipolynomials
2908 defined over different domains.
2909 Piecewise quasipolynomials are mainly used by the C<barvinok>
2910 library for representing the number of elements in a parametric set or map.
2911 For example, the piecewise quasipolynomial above represents
2912 the number of points in the map
2913
2914         [n] -> { [x] -> [y] : x,y >= 0 and 0 <= x + y <= n }
2915
2916 =head3 Printing (Piecewise) Quasipolynomials
2917
2918 Quasipolynomials and piecewise quasipolynomials can be printed
2919 using the following functions.
2920
2921         __isl_give isl_printer *isl_printer_print_qpolynomial(
2922                 __isl_take isl_printer *p,
2923                 __isl_keep isl_qpolynomial *qp);
2924
2925         __isl_give isl_printer *isl_printer_print_pw_qpolynomial(
2926                 __isl_take isl_printer *p,
2927                 __isl_keep isl_pw_qpolynomial *pwqp);
2928
2929         __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial(
2930                 __isl_take isl_printer *p,
2931                 __isl_keep isl_union_pw_qpolynomial *upwqp);
2932
2933 The output format of the printer
2934 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
2935 For C<isl_printer_print_union_pw_qpolynomial>, only C<ISL_FORMAT_ISL>
2936 is supported.
2937 In case of printing in C<ISL_FORMAT_C>, the user may want
2938 to set the names of all dimensions
2939
2940         __isl_give isl_qpolynomial *isl_qpolynomial_set_dim_name(
2941                 __isl_take isl_qpolynomial *qp,
2942                 enum isl_dim_type type, unsigned pos,
2943                 const char *s);
2944         __isl_give isl_pw_qpolynomial *
2945         isl_pw_qpolynomial_set_dim_name(
2946                 __isl_take isl_pw_qpolynomial *pwqp,
2947                 enum isl_dim_type type, unsigned pos,
2948                 const char *s);
2949
2950 =head3 Creating New (Piecewise) Quasipolynomials
2951
2952 Some simple quasipolynomials can be created using the following functions.
2953 More complicated quasipolynomials can be created by applying
2954 operations such as addition and multiplication
2955 on the resulting quasipolynomials
2956
2957         __isl_give isl_qpolynomial *isl_qpolynomial_zero_on_domain(
2958                 __isl_take isl_space *domain);
2959         __isl_give isl_qpolynomial *isl_qpolynomial_one_on_domain(
2960                 __isl_take isl_space *domain);
2961         __isl_give isl_qpolynomial *isl_qpolynomial_infty_on_domain(
2962                 __isl_take isl_space *domain);
2963         __isl_give isl_qpolynomial *isl_qpolynomial_neginfty_on_domain(
2964                 __isl_take isl_space *domain);
2965         __isl_give isl_qpolynomial *isl_qpolynomial_nan_on_domain(
2966                 __isl_take isl_space *domain);
2967         __isl_give isl_qpolynomial *isl_qpolynomial_rat_cst_on_domain(
2968                 __isl_take isl_space *domain,
2969                 const isl_int n, const isl_int d);
2970         __isl_give isl_qpolynomial *isl_qpolynomial_div(
2971                 __isl_take isl_div *div);
2972         __isl_give isl_qpolynomial *isl_qpolynomial_var_on_domain(
2973                 __isl_take isl_space *domain,
2974                 enum isl_dim_type type, unsigned pos);
2975         __isl_give isl_qpolynomial *isl_qpolynomial_from_aff(
2976                 __isl_take isl_aff *aff);
2977
2978 Note that the space in which a quasipolynomial lives is a map space
2979 with a one-dimensional range.  The C<domain> argument in some of
2980 the functions above corresponds to the domain of this map space.
2981
2982 The zero piecewise quasipolynomial or a piecewise quasipolynomial
2983 with a single cell can be created using the following functions.
2984 Multiple of these single cell piecewise quasipolynomials can
2985 be combined to create more complicated piecewise quasipolynomials.
2986
2987         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero(
2988                 __isl_take isl_space *space);
2989         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_alloc(
2990                 __isl_take isl_set *set,
2991                 __isl_take isl_qpolynomial *qp);
2992         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial(
2993                 __isl_take isl_qpolynomial *qp);
2994         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_pw_aff(
2995                 __isl_take isl_pw_aff *pwaff);
2996
2997         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_zero(
2998                 __isl_take isl_space *space);
2999         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_from_pw_qpolynomial(
3000                 __isl_take isl_pw_qpolynomial *pwqp);
3001         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add_pw_qpolynomial(
3002                 __isl_take isl_union_pw_qpolynomial *upwqp,
3003                 __isl_take isl_pw_qpolynomial *pwqp);
3004
3005 Quasipolynomials can be copied and freed again using the following
3006 functions.
3007
3008         __isl_give isl_qpolynomial *isl_qpolynomial_copy(
3009                 __isl_keep isl_qpolynomial *qp);
3010         void *isl_qpolynomial_free(__isl_take isl_qpolynomial *qp);
3011
3012         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy(
3013                 __isl_keep isl_pw_qpolynomial *pwqp);
3014         void *isl_pw_qpolynomial_free(
3015                 __isl_take isl_pw_qpolynomial *pwqp);
3016
3017         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_copy(
3018                 __isl_keep isl_union_pw_qpolynomial *upwqp);
3019         void isl_union_pw_qpolynomial_free(
3020                 __isl_take isl_union_pw_qpolynomial *upwqp);
3021
3022 =head3 Inspecting (Piecewise) Quasipolynomials
3023
3024 To iterate over all piecewise quasipolynomials in a union
3025 piecewise quasipolynomial, use the following function
3026
3027         int isl_union_pw_qpolynomial_foreach_pw_qpolynomial(
3028                 __isl_keep isl_union_pw_qpolynomial *upwqp,
3029                 int (*fn)(__isl_take isl_pw_qpolynomial *pwqp, void *user),
3030                 void *user);
3031
3032 To extract the piecewise quasipolynomial in a given space from a union, use
3033
3034         __isl_give isl_pw_qpolynomial *
3035         isl_union_pw_qpolynomial_extract_pw_qpolynomial(
3036                 __isl_keep isl_union_pw_qpolynomial *upwqp,
3037                 __isl_take isl_space *space);
3038
3039 To iterate over the cells in a piecewise quasipolynomial,
3040 use either of the following two functions
3041
3042         int isl_pw_qpolynomial_foreach_piece(
3043                 __isl_keep isl_pw_qpolynomial *pwqp,
3044                 int (*fn)(__isl_take isl_set *set,
3045                           __isl_take isl_qpolynomial *qp,
3046                           void *user), void *user);
3047         int isl_pw_qpolynomial_foreach_lifted_piece(
3048                 __isl_keep isl_pw_qpolynomial *pwqp,
3049                 int (*fn)(__isl_take isl_set *set,
3050                           __isl_take isl_qpolynomial *qp,
3051                           void *user), void *user);
3052
3053 As usual, the function C<fn> should return C<0> on success
3054 and C<-1> on failure.  The difference between
3055 C<isl_pw_qpolynomial_foreach_piece> and
3056 C<isl_pw_qpolynomial_foreach_lifted_piece> is that
3057 C<isl_pw_qpolynomial_foreach_lifted_piece> will first
3058 compute unique representations for all existentially quantified
3059 variables and then turn these existentially quantified variables
3060 into extra set variables, adapting the associated quasipolynomial
3061 accordingly.  This means that the C<set> passed to C<fn>
3062 will not have any existentially quantified variables, but that
3063 the dimensions of the sets may be different for different
3064 invocations of C<fn>.
3065
3066 To iterate over all terms in a quasipolynomial,
3067 use
3068
3069         int isl_qpolynomial_foreach_term(
3070                 __isl_keep isl_qpolynomial *qp,
3071                 int (*fn)(__isl_take isl_term *term,
3072                           void *user), void *user);
3073
3074 The terms themselves can be inspected and freed using
3075 these functions
3076
3077         unsigned isl_term_dim(__isl_keep isl_term *term,
3078                 enum isl_dim_type type);
3079         void isl_term_get_num(__isl_keep isl_term *term,
3080                 isl_int *n);
3081         void isl_term_get_den(__isl_keep isl_term *term,
3082                 isl_int *d);
3083         int isl_term_get_exp(__isl_keep isl_term *term,
3084                 enum isl_dim_type type, unsigned pos);
3085         __isl_give isl_div *isl_term_get_div(
3086                 __isl_keep isl_term *term, unsigned pos);
3087         void isl_term_free(__isl_take isl_term *term);
3088
3089 Each term is a product of parameters, set variables and
3090 integer divisions.  The function C<isl_term_get_exp>
3091 returns the exponent of a given dimensions in the given term.
3092 The C<isl_int>s in the arguments of C<isl_term_get_num>
3093 and C<isl_term_get_den> need to have been initialized
3094 using C<isl_int_init> before calling these functions.
3095
3096 =head3 Properties of (Piecewise) Quasipolynomials
3097
3098 To check whether a quasipolynomial is actually a constant,
3099 use the following function.
3100
3101         int isl_qpolynomial_is_cst(__isl_keep isl_qpolynomial *qp,
3102                 isl_int *n, isl_int *d);
3103
3104 If C<qp> is a constant and if C<n> and C<d> are not C<NULL>
3105 then the numerator and denominator of the constant
3106 are returned in C<*n> and C<*d>, respectively.
3107
3108 =head3 Operations on (Piecewise) Quasipolynomials
3109
3110         __isl_give isl_qpolynomial *isl_qpolynomial_scale(
3111                 __isl_take isl_qpolynomial *qp, isl_int v);
3112         __isl_give isl_qpolynomial *isl_qpolynomial_neg(
3113                 __isl_take isl_qpolynomial *qp);
3114         __isl_give isl_qpolynomial *isl_qpolynomial_add(
3115                 __isl_take isl_qpolynomial *qp1,
3116                 __isl_take isl_qpolynomial *qp2);
3117         __isl_give isl_qpolynomial *isl_qpolynomial_sub(
3118                 __isl_take isl_qpolynomial *qp1,
3119                 __isl_take isl_qpolynomial *qp2);
3120         __isl_give isl_qpolynomial *isl_qpolynomial_mul(
3121                 __isl_take isl_qpolynomial *qp1,
3122                 __isl_take isl_qpolynomial *qp2);
3123         __isl_give isl_qpolynomial *isl_qpolynomial_pow(
3124                 __isl_take isl_qpolynomial *qp, unsigned exponent);
3125
3126         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
3127                 __isl_take isl_pw_qpolynomial *pwqp1,
3128                 __isl_take isl_pw_qpolynomial *pwqp2);
3129         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub(
3130                 __isl_take isl_pw_qpolynomial *pwqp1,
3131                 __isl_take isl_pw_qpolynomial *pwqp2);
3132         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint(
3133                 __isl_take isl_pw_qpolynomial *pwqp1,
3134                 __isl_take isl_pw_qpolynomial *pwqp2);
3135         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg(
3136                 __isl_take isl_pw_qpolynomial *pwqp);
3137         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
3138                 __isl_take isl_pw_qpolynomial *pwqp1,
3139                 __isl_take isl_pw_qpolynomial *pwqp2);
3140         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_pow(
3141                 __isl_take isl_pw_qpolynomial *pwqp, unsigned exponent);
3142
3143         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add(
3144                 __isl_take isl_union_pw_qpolynomial *upwqp1,
3145                 __isl_take isl_union_pw_qpolynomial *upwqp2);
3146         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
3147                 __isl_take isl_union_pw_qpolynomial *upwqp1,
3148                 __isl_take isl_union_pw_qpolynomial *upwqp2);
3149         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
3150                 __isl_take isl_union_pw_qpolynomial *upwqp1,
3151                 __isl_take isl_union_pw_qpolynomial *upwqp2);
3152
3153         __isl_give isl_qpolynomial *isl_pw_qpolynomial_eval(
3154                 __isl_take isl_pw_qpolynomial *pwqp,
3155                 __isl_take isl_point *pnt);
3156
3157         __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_eval(
3158                 __isl_take isl_union_pw_qpolynomial *upwqp,
3159                 __isl_take isl_point *pnt);
3160
3161         __isl_give isl_set *isl_pw_qpolynomial_domain(
3162                 __isl_take isl_pw_qpolynomial *pwqp);
3163         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_domain(
3164                 __isl_take isl_pw_qpolynomial *pwpq,
3165                 __isl_take isl_set *set);
3166
3167         __isl_give isl_union_set *isl_union_pw_qpolynomial_domain(
3168                 __isl_take isl_union_pw_qpolynomial *upwqp);
3169         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_intersect_domain(
3170                 __isl_take isl_union_pw_qpolynomial *upwpq,
3171                 __isl_take isl_union_set *uset);
3172
3173         __isl_give isl_qpolynomial *isl_qpolynomial_align_params(
3174                 __isl_take isl_qpolynomial *qp,
3175                 __isl_take isl_space *model);
3176
3177         __isl_give isl_qpolynomial *isl_qpolynomial_project_domain_on_params(
3178                 __isl_take isl_qpolynomial *qp);
3179         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_project_domain_on_params(
3180                 __isl_take isl_pw_qpolynomial *pwqp);
3181
3182         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_coalesce(
3183                 __isl_take isl_union_pw_qpolynomial *upwqp);
3184
3185         __isl_give isl_qpolynomial *isl_qpolynomial_gist(
3186                 __isl_take isl_qpolynomial *qp,
3187                 __isl_take isl_set *context);
3188
3189         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist(
3190                 __isl_take isl_pw_qpolynomial *pwqp,
3191                 __isl_take isl_set *context);
3192
3193         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist(
3194                 __isl_take isl_union_pw_qpolynomial *upwqp,
3195                 __isl_take isl_union_set *context);
3196
3197 The gist operation applies the gist operation to each of
3198 the cells in the domain of the input piecewise quasipolynomial.
3199 The context is also exploited
3200 to simplify the quasipolynomials associated to each cell.
3201
3202         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_to_polynomial(
3203                 __isl_take isl_pw_qpolynomial *pwqp, int sign);
3204         __isl_give isl_union_pw_qpolynomial *
3205         isl_union_pw_qpolynomial_to_polynomial(
3206                 __isl_take isl_union_pw_qpolynomial *upwqp, int sign);
3207
3208 Approximate each quasipolynomial by a polynomial.  If C<sign> is positive,
3209 the polynomial will be an overapproximation.  If C<sign> is negative,
3210 it will be an underapproximation.  If C<sign> is zero, the approximation
3211 will lie somewhere in between.
3212
3213 =head2 Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions
3214
3215 A piecewise quasipolynomial reduction is a piecewise
3216 reduction (or fold) of quasipolynomials.
3217 In particular, the reduction can be maximum or a minimum.
3218 The objects are mainly used to represent the result of
3219 an upper or lower bound on a quasipolynomial over its domain,
3220 i.e., as the result of the following function.
3221
3222         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound(
3223                 __isl_take isl_pw_qpolynomial *pwqp,
3224                 enum isl_fold type, int *tight);
3225
3226         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_bound(
3227                 __isl_take isl_union_pw_qpolynomial *upwqp,
3228                 enum isl_fold type, int *tight);
3229
3230 The C<type> argument may be either C<isl_fold_min> or C<isl_fold_max>.
3231 If C<tight> is not C<NULL>, then C<*tight> is set to C<1>
3232 is the returned bound is known be tight, i.e., for each value
3233 of the parameters there is at least
3234 one element in the domain that reaches the bound.
3235 If the domain of C<pwqp> is not wrapping, then the bound is computed
3236 over all elements in that domain and the result has a purely parametric
3237 domain.  If the domain of C<pwqp> is wrapping, then the bound is
3238 computed over the range of the wrapped relation.  The domain of the
3239 wrapped relation becomes the domain of the result.
3240
3241 A (piecewise) quasipolynomial reduction can be copied or freed using the
3242 following functions.
3243
3244         __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_copy(
3245                 __isl_keep isl_qpolynomial_fold *fold);
3246         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_copy(
3247                 __isl_keep isl_pw_qpolynomial_fold *pwf);
3248         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_copy(
3249                 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
3250         void isl_qpolynomial_fold_free(
3251                 __isl_take isl_qpolynomial_fold *fold);
3252         void *isl_pw_qpolynomial_fold_free(
3253                 __isl_take isl_pw_qpolynomial_fold *pwf);
3254         void isl_union_pw_qpolynomial_fold_free(
3255                 __isl_take isl_union_pw_qpolynomial_fold *upwf);
3256
3257 =head3 Printing Piecewise Quasipolynomial Reductions
3258
3259 Piecewise quasipolynomial reductions can be printed
3260 using the following function.
3261
3262         __isl_give isl_printer *isl_printer_print_pw_qpolynomial_fold(
3263                 __isl_take isl_printer *p,
3264                 __isl_keep isl_pw_qpolynomial_fold *pwf);
3265         __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial_fold(
3266                 __isl_take isl_printer *p,
3267                 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
3268
3269 For C<isl_printer_print_pw_qpolynomial_fold>,
3270 output format of the printer
3271 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
3272 For C<isl_printer_print_union_pw_qpolynomial_fold>,
3273 output format of the printer
3274 needs to be set to C<ISL_FORMAT_ISL>.
3275 In case of printing in C<ISL_FORMAT_C>, the user may want
3276 to set the names of all dimensions
3277
3278         __isl_give isl_pw_qpolynomial_fold *
3279         isl_pw_qpolynomial_fold_set_dim_name(
3280                 __isl_take isl_pw_qpolynomial_fold *pwf,
3281                 enum isl_dim_type type, unsigned pos,
3282                 const char *s);
3283
3284 =head3 Inspecting (Piecewise) Quasipolynomial Reductions
3285
3286 To iterate over all piecewise quasipolynomial reductions in a union
3287 piecewise quasipolynomial reduction, use the following function
3288
3289         int isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(
3290                 __isl_keep isl_union_pw_qpolynomial_fold *upwf,
3291                 int (*fn)(__isl_take isl_pw_qpolynomial_fold *pwf,
3292                             void *user), void *user);
3293
3294 To iterate over the cells in a piecewise quasipolynomial reduction,
3295 use either of the following two functions
3296
3297         int isl_pw_qpolynomial_fold_foreach_piece(
3298                 __isl_keep isl_pw_qpolynomial_fold *pwf,
3299                 int (*fn)(__isl_take isl_set *set,
3300                           __isl_take isl_qpolynomial_fold *fold,
3301                           void *user), void *user);
3302         int isl_pw_qpolynomial_fold_foreach_lifted_piece(
3303                 __isl_keep isl_pw_qpolynomial_fold *pwf,
3304                 int (*fn)(__isl_take isl_set *set,
3305                           __isl_take isl_qpolynomial_fold *fold,
3306                           void *user), void *user);
3307
3308 See L<Inspecting (Piecewise) Quasipolynomials> for an explanation
3309 of the difference between these two functions.
3310
3311 To iterate over all quasipolynomials in a reduction, use
3312
3313         int isl_qpolynomial_fold_foreach_qpolynomial(
3314                 __isl_keep isl_qpolynomial_fold *fold,
3315                 int (*fn)(__isl_take isl_qpolynomial *qp,
3316                           void *user), void *user);
3317
3318 =head3 Operations on Piecewise Quasipolynomial Reductions
3319
3320         __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_scale(
3321                 __isl_take isl_qpolynomial_fold *fold, isl_int v);
3322
3323         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
3324                 __isl_take isl_pw_qpolynomial_fold *pwf1,
3325                 __isl_take isl_pw_qpolynomial_fold *pwf2);
3326
3327         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_fold(
3328                 __isl_take isl_pw_qpolynomial_fold *pwf1,
3329                 __isl_take isl_pw_qpolynomial_fold *pwf2);
3330
3331         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_fold(
3332                 __isl_take isl_union_pw_qpolynomial_fold *upwf1,
3333                 __isl_take isl_union_pw_qpolynomial_fold *upwf2);
3334
3335         __isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_eval(
3336                 __isl_take isl_pw_qpolynomial_fold *pwf,
3337                 __isl_take isl_point *pnt);
3338
3339         __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_fold_eval(
3340                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
3341                 __isl_take isl_point *pnt);
3342
3343         __isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain(
3344                 __isl_take isl_union_pw_qpolynomial_fold *upwf);
3345         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_intersect_domain(
3346                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
3347                 __isl_take isl_union_set *uset);
3348
3349         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_project_domain_on_params(
3350                 __isl_take isl_pw_qpolynomial_fold *pwf);
3351
3352         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_coalesce(
3353                 __isl_take isl_pw_qpolynomial_fold *pwf);
3354
3355         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_coalesce(
3356                 __isl_take isl_union_pw_qpolynomial_fold *upwf);
3357
3358         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist(
3359                 __isl_take isl_pw_qpolynomial_fold *pwf,
3360                 __isl_take isl_set *context);
3361
3362         __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_gist(
3363                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
3364                 __isl_take isl_union_set *context);
3365
3366 The gist operation applies the gist operation to each of
3367 the cells in the domain of the input piecewise quasipolynomial reduction.
3368 In future, the operation will also exploit the context
3369 to simplify the quasipolynomial reductions associated to each cell.
3370
3371         __isl_give isl_pw_qpolynomial_fold *
3372         isl_set_apply_pw_qpolynomial_fold(
3373                 __isl_take isl_set *set,
3374                 __isl_take isl_pw_qpolynomial_fold *pwf,
3375                 int *tight);
3376         __isl_give isl_pw_qpolynomial_fold *
3377         isl_map_apply_pw_qpolynomial_fold(
3378                 __isl_take isl_map *map,
3379                 __isl_take isl_pw_qpolynomial_fold *pwf,
3380                 int *tight);
3381         __isl_give isl_union_pw_qpolynomial_fold *
3382         isl_union_set_apply_union_pw_qpolynomial_fold(
3383                 __isl_take isl_union_set *uset,
3384                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
3385                 int *tight);
3386         __isl_give isl_union_pw_qpolynomial_fold *
3387         isl_union_map_apply_union_pw_qpolynomial_fold(
3388                 __isl_take isl_union_map *umap,
3389                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
3390                 int *tight);
3391
3392 The functions taking a map
3393 compose the given map with the given piecewise quasipolynomial reduction.
3394 That is, compute a bound (of the same type as C<pwf> or C<upwf> itself)
3395 over all elements in the intersection of the range of the map
3396 and the domain of the piecewise quasipolynomial reduction
3397 as a function of an element in the domain of the map.
3398 The functions taking a set compute a bound over all elements in the
3399 intersection of the set and the domain of the
3400 piecewise quasipolynomial reduction.
3401
3402 =head2 Dependence Analysis
3403
3404 C<isl> contains specialized functionality for performing
3405 array dataflow analysis.  That is, given a I<sink> access relation
3406 and a collection of possible I<source> access relations,
3407 C<isl> can compute relations that describe
3408 for each iteration of the sink access, which iteration
3409 of which of the source access relations was the last
3410 to access the same data element before the given iteration
3411 of the sink access.
3412 To compute standard flow dependences, the sink should be
3413 a read, while the sources should be writes.
3414 If any of the source accesses are marked as being I<may>
3415 accesses, then there will be a dependence to the last
3416 I<must> access B<and> to any I<may> access that follows
3417 this last I<must> access.
3418 In particular, if I<all> sources are I<may> accesses,
3419 then memory based dependence analysis is performed.
3420 If, on the other hand, all sources are I<must> accesses,
3421 then value based dependence analysis is performed.
3422
3423         #include <isl/flow.h>
3424
3425         typedef int (*isl_access_level_before)(void *first, void *second);
3426
3427         __isl_give isl_access_info *isl_access_info_alloc(
3428                 __isl_take isl_map *sink,
3429                 void *sink_user, isl_access_level_before fn,
3430                 int max_source);
3431         __isl_give isl_access_info *isl_access_info_add_source(
3432                 __isl_take isl_access_info *acc,
3433                 __isl_take isl_map *source, int must,
3434                 void *source_user);
3435         void isl_access_info_free(__isl_take isl_access_info *acc);
3436
3437         __isl_give isl_flow *isl_access_info_compute_flow(
3438                 __isl_take isl_access_info *acc);
3439
3440         int isl_flow_foreach(__isl_keep isl_flow *deps,
3441                 int (*fn)(__isl_take isl_map *dep, int must,
3442                           void *dep_user, void *user),
3443                 void *user);
3444         __isl_give isl_map *isl_flow_get_no_source(
3445                 __isl_keep isl_flow *deps, int must);
3446         void isl_flow_free(__isl_take isl_flow *deps);
3447
3448 The function C<isl_access_info_compute_flow> performs the actual
3449 dependence analysis.  The other functions are used to construct
3450 the input for this function or to read off the output.
3451
3452 The input is collected in an C<isl_access_info>, which can
3453 be created through a call to C<isl_access_info_alloc>.
3454 The arguments to this functions are the sink access relation
3455 C<sink>, a token C<sink_user> used to identify the sink
3456 access to the user, a callback function for specifying the
3457 relative order of source and sink accesses, and the number
3458 of source access relations that will be added.
3459 The callback function has type C<int (*)(void *first, void *second)>.
3460 The function is called with two user supplied tokens identifying
3461 either a source or the sink and it should return the shared nesting
3462 level and the relative order of the two accesses.
3463 In particular, let I<n> be the number of loops shared by
3464 the two accesses.  If C<first> precedes C<second> textually,
3465 then the function should return I<2 * n + 1>; otherwise,
3466 it should return I<2 * n>.
3467 The sources can be added to the C<isl_access_info> by performing
3468 (at most) C<max_source> calls to C<isl_access_info_add_source>.
3469 C<must> indicates whether the source is a I<must> access
3470 or a I<may> access.  Note that a multi-valued access relation
3471 should only be marked I<must> if every iteration in the domain
3472 of the relation accesses I<all> elements in its image.
3473 The C<source_user> token is again used to identify
3474 the source access.  The range of the source access relation
3475 C<source> should have the same dimension as the range
3476 of the sink access relation.
3477 The C<isl_access_info_free> function should usually not be
3478 called explicitly, because it is called implicitly by
3479 C<isl_access_info_compute_flow>.
3480
3481 The result of the dependence analysis is collected in an
3482 C<isl_flow>.  There may be elements of
3483 the sink access for which no preceding source access could be
3484 found or for which all preceding sources are I<may> accesses.
3485 The relations containing these elements can be obtained through
3486 calls to C<isl_flow_get_no_source>, the first with C<must> set
3487 and the second with C<must> unset.
3488 In the case of standard flow dependence analysis,
3489 with the sink a read and the sources I<must> writes,
3490 the first relation corresponds to the reads from uninitialized
3491 array elements and the second relation is empty.
3492 The actual flow dependences can be extracted using
3493 C<isl_flow_foreach>.  This function will call the user-specified
3494 callback function C<fn> for each B<non-empty> dependence between
3495 a source and the sink.  The callback function is called
3496 with four arguments, the actual flow dependence relation
3497 mapping source iterations to sink iterations, a boolean that
3498 indicates whether it is a I<must> or I<may> dependence, a token
3499 identifying the source and an additional C<void *> with value
3500 equal to the third argument of the C<isl_flow_foreach> call.
3501 A dependence is marked I<must> if it originates from a I<must>
3502 source and if it is not followed by any I<may> sources.
3503
3504 After finishing with an C<isl_flow>, the user should call
3505 C<isl_flow_free> to free all associated memory.
3506
3507 A higher-level interface to dependence analysis is provided
3508 by the following function.
3509
3510         #include <isl/flow.h>
3511
3512         int isl_union_map_compute_flow(__isl_take isl_union_map *sink,
3513                 __isl_take isl_union_map *must_source,
3514                 __isl_take isl_union_map *may_source,
3515                 __isl_take isl_union_map *schedule,
3516                 __isl_give isl_union_map **must_dep,
3517                 __isl_give isl_union_map **may_dep,
3518                 __isl_give isl_union_map **must_no_source,
3519                 __isl_give isl_union_map **may_no_source);
3520
3521 The arrays are identified by the tuple names of the ranges
3522 of the accesses.  The iteration domains by the tuple names
3523 of the domains of the accesses and of the schedule.
3524 The relative order of the iteration domains is given by the
3525 schedule.  The relations returned through C<must_no_source>
3526 and C<may_no_source> are subsets of C<sink>.
3527 Any of C<must_dep>, C<may_dep>, C<must_no_source>
3528 or C<may_no_source> may be C<NULL>, but a C<NULL> value for
3529 any of the other arguments is treated as an error.
3530
3531 =head2 Scheduling
3532
3533 B<The functionality described in this section is fairly new
3534 and may be subject to change.>
3535
3536 The following function can be used to compute a schedule
3537 for a union of domains.  The generated schedule respects
3538 all C<validity> dependences.  That is, all dependence distances
3539 over these dependences in the scheduled space are lexicographically
3540 positive.  The generated schedule schedule also tries to minimize
3541 the dependence distances over C<proximity> dependences.
3542 Moreover, it tries to obtain sequences (bands) of schedule dimensions
3543 for groups of domains where the dependence distances have only
3544 non-negative values.
3545 The algorithm used to construct the schedule is similar to that
3546 of C<Pluto>.
3547
3548         #include <isl/schedule.h>
3549         __isl_give isl_schedule *isl_union_set_compute_schedule(
3550                 __isl_take isl_union_set *domain,
3551                 __isl_take isl_union_map *validity,
3552                 __isl_take isl_union_map *proximity);
3553         void *isl_schedule_free(__isl_take isl_schedule *sched);
3554
3555 A mapping from the domains to the scheduled space can be obtained
3556 from an C<isl_schedule> using the following function.
3557
3558         __isl_give isl_union_map *isl_schedule_get_map(
3559                 __isl_keep isl_schedule *sched);
3560
3561 A representation of the schedule can be printed using
3562          
3563         __isl_give isl_printer *isl_printer_print_schedule(
3564                 __isl_take isl_printer *p,
3565                 __isl_keep isl_schedule *schedule);
3566
3567 A representation of the schedule as a forest of bands can be obtained
3568 using the following function.
3569
3570         __isl_give isl_band_list *isl_schedule_get_band_forest(
3571                 __isl_keep isl_schedule *schedule);
3572
3573 The list can be manipulated as explained in L<"Lists">.
3574 The bands inside the list can be copied and freed using the following
3575 functions.
3576
3577         #include <isl/band.h>
3578         __isl_give isl_band *isl_band_copy(
3579                 __isl_keep isl_band *band);
3580         void *isl_band_free(__isl_take isl_band *band);
3581
3582 Each band contains zero or more scheduling dimensions.
3583 These are referred to as the members of the band.
3584 The section of the schedule that corresponds to the band is
3585 referred to as the partial schedule of the band.
3586 For those nodes that participate in a band, the outer scheduling
3587 dimensions form the prefix schedule, while the inner scheduling
3588 dimensions form the suffix schedule.
3589 That is, if we take a cut of the band forest, then the union of
3590 the concatenations of the prefix, partial and suffix schedules of
3591 each band in the cut is equal to the entire schedule (modulo
3592 some possible padding at the end with zero scheduling dimensions).
3593 The properties of a band can be inspected using the following functions.
3594
3595         #include <isl/band.h>
3596         isl_ctx *isl_band_get_ctx(__isl_keep isl_band *band);
3597
3598         int isl_band_has_children(__isl_keep isl_band *band);
3599         __isl_give isl_band_list *isl_band_get_children(
3600                 __isl_keep isl_band *band);
3601
3602         __isl_give isl_union_map *isl_band_get_prefix_schedule(
3603                 __isl_keep isl_band *band);
3604         __isl_give isl_union_map *isl_band_get_partial_schedule(
3605                 __isl_keep isl_band *band);
3606         __isl_give isl_union_map *isl_band_get_suffix_schedule(
3607                 __isl_keep isl_band *band);
3608
3609         int isl_band_n_member(__isl_keep isl_band *band);
3610         int isl_band_member_is_zero_distance(
3611                 __isl_keep isl_band *band, int pos);
3612
3613 Note that a scheduling dimension is considered to be ``zero
3614 distance'' if it does not carry any proximity dependences
3615 within its band.
3616 That is, if the dependence distances of the proximity
3617 dependences are all zero in that direction (for fixed
3618 iterations of outer bands).
3619
3620 A representation of the band can be printed using
3621
3622         #include <isl/band.h>
3623         __isl_give isl_printer *isl_printer_print_band(
3624                 __isl_take isl_printer *p,
3625                 __isl_keep isl_band *band);
3626
3627 =head2 Parametric Vertex Enumeration
3628
3629 The parametric vertex enumeration described in this section
3630 is mainly intended to be used internally and by the C<barvinok>
3631 library.
3632
3633         #include <isl/vertices.h>
3634         __isl_give isl_vertices *isl_basic_set_compute_vertices(
3635                 __isl_keep isl_basic_set *bset);
3636
3637 The function C<isl_basic_set_compute_vertices> performs the
3638 actual computation of the parametric vertices and the chamber
3639 decomposition and store the result in an C<isl_vertices> object.
3640 This information can be queried by either iterating over all
3641 the vertices or iterating over all the chambers or cells
3642 and then iterating over all vertices that are active on the chamber.
3643
3644         int isl_vertices_foreach_vertex(
3645                 __isl_keep isl_vertices *vertices,
3646                 int (*fn)(__isl_take isl_vertex *vertex, void *user),
3647                 void *user);
3648
3649         int isl_vertices_foreach_cell(
3650                 __isl_keep isl_vertices *vertices,
3651                 int (*fn)(__isl_take isl_cell *cell, void *user),
3652                 void *user);
3653         int isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
3654                 int (*fn)(__isl_take isl_vertex *vertex, void *user),
3655                 void *user);
3656
3657 Other operations that can be performed on an C<isl_vertices> object are
3658 the following.
3659
3660         isl_ctx *isl_vertices_get_ctx(
3661                 __isl_keep isl_vertices *vertices);
3662         int isl_vertices_get_n_vertices(
3663                 __isl_keep isl_vertices *vertices);
3664         void isl_vertices_free(__isl_take isl_vertices *vertices);
3665
3666 Vertices can be inspected and destroyed using the following functions.
3667
3668         isl_ctx *isl_vertex_get_ctx(__isl_keep isl_vertex *vertex);
3669         int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
3670         __isl_give isl_basic_set *isl_vertex_get_domain(
3671                 __isl_keep isl_vertex *vertex);
3672         __isl_give isl_basic_set *isl_vertex_get_expr(
3673                 __isl_keep isl_vertex *vertex);
3674         void isl_vertex_free(__isl_take isl_vertex *vertex);
3675
3676 C<isl_vertex_get_expr> returns a singleton parametric set describing
3677 the vertex, while C<isl_vertex_get_domain> returns the activity domain
3678 of the vertex.
3679 Note that C<isl_vertex_get_domain> and C<isl_vertex_get_expr> return
3680 B<rational> basic sets, so they should mainly be used for inspection
3681 and should not be mixed with integer sets.
3682
3683 Chambers can be inspected and destroyed using the following functions.
3684
3685         isl_ctx *isl_cell_get_ctx(__isl_keep isl_cell *cell);
3686         __isl_give isl_basic_set *isl_cell_get_domain(
3687                 __isl_keep isl_cell *cell);
3688         void isl_cell_free(__isl_take isl_cell *cell);
3689
3690 =head1 Applications
3691
3692 Although C<isl> is mainly meant to be used as a library,
3693 it also contains some basic applications that use some
3694 of the functionality of C<isl>.
3695 The input may be specified in either the L<isl format>
3696 or the L<PolyLib format>.
3697
3698 =head2 C<isl_polyhedron_sample>
3699
3700 C<isl_polyhedron_sample> takes a polyhedron as input and prints
3701 an integer element of the polyhedron, if there is any.
3702 The first column in the output is the denominator and is always
3703 equal to 1.  If the polyhedron contains no integer points,
3704 then a vector of length zero is printed.
3705
3706 =head2 C<isl_pip>
3707
3708 C<isl_pip> takes the same input as the C<example> program
3709 from the C<piplib> distribution, i.e., a set of constraints
3710 on the parameters, a line containing only -1 and finally a set
3711 of constraints on a parametric polyhedron.
3712 The coefficients of the parameters appear in the last columns
3713 (but before the final constant column).
3714 The output is the lexicographic minimum of the parametric polyhedron.
3715 As C<isl> currently does not have its own output format, the output
3716 is just a dump of the internal state.
3717
3718 =head2 C<isl_polyhedron_minimize>
3719
3720 C<isl_polyhedron_minimize> computes the minimum of some linear
3721 or affine objective function over the integer points in a polyhedron.
3722 If an affine objective function
3723 is given, then the constant should appear in the last column.
3724
3725 =head2 C<isl_polytope_scan>
3726
3727 Given a polytope, C<isl_polytope_scan> prints
3728 all integer points in the polytope.