add isl_val_inv
[isl.git] / doc / user.pod
blob8f50f46a00b8350d46219e80e2e7c7c60a4dfb01
1 =head1 Introduction
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> or C<imath>.
9 The C<isl> library offers functionality that is similar
10 to that offered by the C<Omega> and C<Omega+> libraries,
11 but the underlying algorithms are in most cases completely different.
13 The library is by no means complete and some fairly basic
14 functionality is still missing.
15 Still, even in its current form, the library has been successfully
16 used as a backend polyhedral library for the polyhedral
17 scanner C<CLooG> and as part of an equivalence checker of
18 static affine programs.
19 For bug reports, feature requests and questions,
20 visit the discussion group at
21 L<http://groups.google.com/group/isl-development>.
23 =head2 Backward Incompatible Changes
25 =head3 Changes since isl-0.02
27 =over
29 =item * The old printing functions have been deprecated
30 and replaced by C<isl_printer> functions, see L<Input and Output>.
32 =item * Most functions related to dependence analysis have acquired
33 an extra C<must> argument.  To obtain the old behavior, this argument
34 should be given the value 1.  See L<Dependence Analysis>.
36 =back
38 =head3 Changes since isl-0.03
40 =over
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>.
47 =back
49 =head3 Changes since isl-0.04
51 =over
53 =item * All header files have been renamed from C<isl_header.h>
54 to C<isl/header.h>.
56 =back
58 =head3 Changes since isl-0.05
60 =over
62 =item * The functions C<isl_printer_print_basic_set> and
63 C<isl_printer_print_basic_map> no longer print a newline.
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.
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))>.
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.
79 =back
81 =head3 Changes since isl-0.06
83 =over
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.
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.
93 =back
95 =head3 Changes since isl-0.07
97 =over
99 =item * The function C<isl_pw_aff_max> has been renamed to
100 C<isl_pw_aff_union_max>.
101 Similarly, the function C<isl_pw_aff_add> has been renamed to
102 C<isl_pw_aff_union_add>.
104 =item * The C<isl_dim> type has been renamed to C<isl_space>
105 along with the associated functions.
106 Some of the old names have been kept for backward compatibility,
107 but they will be removed in the future.
109 =item * Spaces of maps, sets and parameter domains are now
110 treated differently.  The distinction between map spaces and set spaces
111 has always been made on a conceptual level, but proper use of such spaces
112 was never checked.  Furthermore, up until isl-0.07 there was no way
113 of explicitly creating a parameter space.  These can now be created
114 directly using C<isl_space_params_alloc> or from other spaces using
115 C<isl_space_params>.
117 =item * The space in which C<isl_aff>, C<isl_pw_aff>, C<isl_qpolynomial>,
118 C<isl_pw_qpolynomial>, C<isl_qpolynomial_fold> and C<isl_pw_qpolynomial_fold>
119 objects live is now a map space
120 instead of a set space.  This means, for example, that the dimensions
121 of the domain of an C<isl_aff> are now considered to be of type
122 C<isl_dim_in> instead of C<isl_dim_set>.  Extra functions have been
123 added to obtain the domain space.  Some of the constructors still
124 take a domain space and have therefore been renamed.
126 =item * The functions C<isl_equality_alloc> and C<isl_inequality_alloc>
127 now take an C<isl_local_space> instead of an C<isl_space>.
128 An C<isl_local_space> can be created from an C<isl_space>
129 using C<isl_local_space_from_space>.
131 =item * The C<isl_div> type has been removed.  Functions that used
132 to return an C<isl_div> now return an C<isl_aff>.
133 Note that the space of an C<isl_aff> is that of relation.
134 When replacing a call to C<isl_div_get_coefficient> by a call to
135 C<isl_aff_get_coefficient> any C<isl_dim_set> argument needs
136 to be replaced by C<isl_dim_in>.
137 A call to C<isl_aff_from_div> can be replaced by a call
138 to C<isl_aff_floor>.
139 A call to C<isl_qpolynomial_div(div)> call be replaced by
140 the nested call
142         isl_qpolynomial_from_aff(isl_aff_floor(div))
144 The function C<isl_constraint_div> has also been renamed
145 to C<isl_constraint_get_div>.
147 =item * The C<nparam> argument has been removed from
148 C<isl_map_read_from_str> and similar functions.
149 When reading input in the original PolyLib format,
150 the result will have no parameters.
151 If parameters are expected, the caller may want to perform
152 dimension manipulation on the result.
154 =back
156 =head3 Changes since isl-0.09
158 =over
160 =item * The C<schedule_split_parallel> option has been replaced
161 by the C<schedule_split_scaled> option.
163 =item * The first argument of C<isl_pw_aff_cond> is now
164 an C<isl_pw_aff> instead of an C<isl_set>.
165 A call C<isl_pw_aff_cond(a, b, c)> can be replaced by
167         isl_pw_aff_cond(isl_set_indicator_function(a), b, c)
169 =back
171 =head3 Changes since isl-0.10
173 =over
175 =item * The functions C<isl_set_dim_has_lower_bound> and
176 C<isl_set_dim_has_upper_bound> have been renamed to
177 C<isl_set_dim_has_any_lower_bound> and
178 C<isl_set_dim_has_any_upper_bound>.
179 The new C<isl_set_dim_has_lower_bound> and
180 C<isl_set_dim_has_upper_bound> have slightly different meanings.
182 =back
184 =head3 Changes since isl-0.12
186 =over
188 =item * C<isl_int> has been replaced by C<isl_val>.
189 Some of the old functions are still available in C<isl/deprecated/*.h>
190 but they will be removed in the future.
192 =item * The functions C<isl_pw_qpolynomial_eval>,
193 C<isl_union_pw_qpolynomial_eval>, C<isl_pw_qpolynomial_fold_eval>
194 and C<isl_union_pw_qpolynomial_fold_eval> have been changed to return
195 an C<isl_val> instead of an C<isl_qpolynomial>.
197 =item * The function C<isl_band_member_is_zero_distance>
198 has been removed.  Essentially the same functionality is available
199 through C<isl_band_member_is_coincident>, except that is requires
200 setting up coincidence constraints.
201 The option C<schedule_outer_zero_distance> has accordingly been
202 replaced by the option C<schedule_outer_coincidence>.
204 =item * The function C<isl_vertex_get_expr> has been changed
205 to return an C<isl_multi_aff> instead of a rational C<isl_basic_set>.
206 The function C<isl_vertex_get_domain> has been changed to return
207 a regular basic set, rather than a rational basic set.
209 =back
211 =head3 Changes since isl-0.14
213 =over
215 =item * Objects of type C<isl_union_pw_multi_aff> can no longer contain
216 two or more C<isl_pw_multi_aff> objects with the same domain space.
218 =item * The function C<isl_union_pw_multi_aff_add> now consistently
219 computes the sum on the shared definition domain.
220 The function C<isl_union_pw_multi_aff_union_add> has been added
221 to compute the sum on the union of definition domains.
222 The original behavior of C<isl_union_pw_multi_aff_add> was
223 confused and is no longer available.
225 =back
227 =head1 License
229 C<isl> is released under the MIT license.
231 =over
233 Permission is hereby granted, free of charge, to any person obtaining a copy of
234 this software and associated documentation files (the "Software"), to deal in
235 the Software without restriction, including without limitation the rights to
236 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
237 of the Software, and to permit persons to whom the Software is furnished to do
238 so, subject to the following conditions:
240 The above copyright notice and this permission notice shall be included in all
241 copies or substantial portions of the Software.
243 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
244 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
245 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
246 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
247 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
248 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
249 SOFTWARE.
251 =back
253 Note that by default C<isl> requires C<GMP>, which is released
254 under the GNU Lesser General Public License (LGPL).  This means
255 that code linked against C<isl> is also linked against LGPL code.
257 When configuring with C<--with-int=imath>, C<isl> will link against C<imath>, a
258 library for exact integer arithmetic released under the MIT license.
260 =head1 Installation
262 The source of C<isl> can be obtained either as a tarball
263 or from the git repository.  Both are available from
264 L<http://freshmeat.net/projects/isl/>.
265 The installation process depends on how you obtained
266 the source.
268 =head2 Installation from the git repository
270 =over
272 =item 1 Clone or update the repository
274 The first time the source is obtained, you need to clone
275 the repository.
277         git clone git://repo.or.cz/isl.git
279 To obtain updates, you need to pull in the latest changes
281         git pull
283 =item 2 Optionally get C<imath> submodule
285 To build C<isl> with C<imath>, you need to obtain the C<imath>
286 submodule by running in the git source tree of C<isl>
288        git submodule init
289        git submodule update
291 This will fetch the required version of C<imath> in a subdirectory of C<isl>.
293 =item 2 Generate C<configure>
295         ./autogen.sh
297 =back
299 After performing the above steps, continue
300 with the L<Common installation instructions>.
302 =head2 Common installation instructions
304 =over
306 =item 1 Obtain C<GMP>
308 By default, building C<isl> requires C<GMP>, including its headers files.
309 Your distribution may not provide these header files by default
310 and you may need to install a package called C<gmp-devel> or something
311 similar.  Alternatively, C<GMP> can be built from
312 source, available from L<http://gmplib.org/>.
313 C<GMP> is not needed if you build C<isl> with C<imath>.
315 =item 2 Configure
317 C<isl> uses the standard C<autoconf> C<configure> script.
318 To run it, just type
320         ./configure
322 optionally followed by some configure options.
323 A complete list of options can be obtained by running
325         ./configure --help
327 Below we discuss some of the more common options.
329 =over
331 =item C<--prefix>
333 Installation prefix for C<isl>
335 =item C<--with-int=[gmp|imath]>
337 Select the integer library to be used by C<isl>, the default is C<gmp>.
338 Note that C<isl> may run significantly slower if you use C<imath>.
340 =item C<--with-gmp-prefix>
342 Installation prefix for C<GMP> (architecture-independent files).
344 =item C<--with-gmp-exec-prefix>
346 Installation prefix for C<GMP> (architecture-dependent files).
348 =back
350 =item 3 Compile
352         make
354 =item 4 Install (optional)
356         make install
358 =back
360 =head1 Integer Set Library
362 =head2 Memory Management
364 Since a high-level operation on isl objects usually involves
365 several substeps and since the user is usually not interested in
366 the intermediate results, most functions that return a new object
367 will also release all the objects passed as arguments.
368 If the user still wants to use one or more of these arguments
369 after the function call, she should pass along a copy of the
370 object rather than the object itself.
371 The user is then responsible for making sure that the original
372 object gets used somewhere else or is explicitly freed.
374 The arguments and return values of all documented functions are
375 annotated to make clear which arguments are released and which
376 arguments are preserved.  In particular, the following annotations
377 are used
379 =over
381 =item C<__isl_give>
383 C<__isl_give> means that a new object is returned.
384 The user should make sure that the returned pointer is
385 used exactly once as a value for an C<__isl_take> argument.
386 In between, it can be used as a value for as many
387 C<__isl_keep> arguments as the user likes.
388 There is one exception, and that is the case where the
389 pointer returned is C<NULL>.  Is this case, the user
390 is free to use it as an C<__isl_take> argument or not.
391 When applied to a C<char *>, the returned pointer needs to be
392 freed using C<free>.
394 =item C<__isl_null>
396 C<__isl_null> means that a C<NULL> value is returned.
398 =item C<__isl_take>
400 C<__isl_take> means that the object the argument points to
401 is taken over by the function and may no longer be used
402 by the user as an argument to any other function.
403 The pointer value must be one returned by a function
404 returning an C<__isl_give> pointer.
405 If the user passes in a C<NULL> value, then this will
406 be treated as an error in the sense that the function will
407 not perform its usual operation.  However, it will still
408 make sure that all the other C<__isl_take> arguments
409 are released.
411 =item C<__isl_keep>
413 C<__isl_keep> means that the function will only use the object
414 temporarily.  After the function has finished, the user
415 can still use it as an argument to other functions.
416 A C<NULL> value will be treated in the same way as
417 a C<NULL> value for an C<__isl_take> argument.
418 This annotation may also be used on return values of
419 type C<const char *>, in which case the returned pointer should
420 not be freed by the user and is only valid until the object
421 from which it was derived is updated or freed.
423 =back
425 =head2 Initialization
427 All manipulations of integer sets and relations occur within
428 the context of an C<isl_ctx>.
429 A given C<isl_ctx> can only be used within a single thread.
430 All arguments of a function are required to have been allocated
431 within the same context.
432 There are currently no functions available for moving an object
433 from one C<isl_ctx> to another C<isl_ctx>.  This means that
434 there is currently no way of safely moving an object from one
435 thread to another, unless the whole C<isl_ctx> is moved.
437 An C<isl_ctx> can be allocated using C<isl_ctx_alloc> and
438 freed using C<isl_ctx_free>.
439 All objects allocated within an C<isl_ctx> should be freed
440 before the C<isl_ctx> itself is freed.
442         isl_ctx *isl_ctx_alloc();
443         void isl_ctx_free(isl_ctx *ctx);
445 The user can impose a bound on the number of low-level I<operations>
446 that can be performed by an C<isl_ctx>.  This bound can be set and
447 retrieved using the following functions.  A bound of zero means that
448 no bound is imposed.  The number of operations performed can be
449 reset using C<isl_ctx_reset_operations>.  Note that the number
450 of low-level operations needed to perform a high-level computation
451 may differ significantly across different versions
452 of C<isl>, but it should be the same across different platforms
453 for the same version of C<isl>.
455 Warning: This feature is experimental.  C<isl> has good support to abort and
456 bail out during the computation, but this feature may exercise error code paths
457 that are normally not used that much. Consequently, it is not unlikely that
458 hidden bugs will be exposed.
460         void isl_ctx_set_max_operations(isl_ctx *ctx,
461                 unsigned long max_operations);
462         unsigned long isl_ctx_get_max_operations(isl_ctx *ctx);
463         void isl_ctx_reset_operations(isl_ctx *ctx);
465 In order to be able to create an object in the same context
466 as another object, most object types (described later in
467 this document) provide a function to obtain the context
468 in which the object was created.
470         #include <isl/val.h>
471         isl_ctx *isl_val_get_ctx(__isl_keep isl_val *val);
472         isl_ctx *isl_multi_val_get_ctx(
473                 __isl_keep isl_multi_val *mv);
475         #include <isl/id.h>
476         isl_ctx *isl_id_get_ctx(__isl_keep isl_id *id);
478         #include <isl/local_space.h>
479         isl_ctx *isl_local_space_get_ctx(
480                 __isl_keep isl_local_space *ls);
482         #include <isl/set.h>
483         isl_ctx *isl_set_list_get_ctx(
484                 __isl_keep isl_set_list *list);
486         #include <isl/aff.h>
487         isl_ctx *isl_aff_get_ctx(__isl_keep isl_aff *aff);
488         isl_ctx *isl_multi_aff_get_ctx(
489                 __isl_keep isl_multi_aff *maff);
490         isl_ctx *isl_pw_aff_get_ctx(__isl_keep isl_pw_aff *pa);
491         isl_ctx *isl_pw_multi_aff_get_ctx(
492                 __isl_keep isl_pw_multi_aff *pma);
493         isl_ctx *isl_multi_pw_aff_get_ctx(
494                 __isl_keep isl_multi_pw_aff *mpa);
495         isl_ctx *isl_union_pw_multi_aff_get_ctx(
496                 __isl_keep isl_union_pw_multi_aff *upma);
498         #include <isl/id_to_ast_expr.h>
499         isl_ctx *isl_id_to_ast_expr_get_ctx(
500                 __isl_keep id_to_ast_expr *id2expr);
502         #include <isl/point.h>
503         isl_ctx *isl_point_get_ctx(__isl_keep isl_point *pnt);
505         #include <isl/vec.h>
506         isl_ctx *isl_vec_get_ctx(__isl_keep isl_vec *vec);
508         #include <isl/mat.h>
509         isl_ctx *isl_mat_get_ctx(__isl_keep isl_mat *mat);
511         #include <isl/vertices.h>
512         isl_ctx *isl_vertices_get_ctx(
513                 __isl_keep isl_vertices *vertices);
514         isl_ctx *isl_vertex_get_ctx(__isl_keep isl_vertex *vertex);
515         isl_ctx *isl_cell_get_ctx(__isl_keep isl_cell *cell);
517         #include <isl/flow.h>
518         isl_ctx *isl_restriction_get_ctx(
519                 __isl_keep isl_restriction *restr);
521         #include <isl/schedule.h>
522         isl_ctx *isl_schedule_constraints_get_ctx(
523                 __isl_keep isl_schedule_constraints *sc);
525         #include <isl/band.h>
526         isl_ctx *isl_band_get_ctx(__isl_keep isl_band *band);
528         #include <isl/ast_build.h>
529         isl_ctx *isl_ast_build_get_ctx(
530                 __isl_keep isl_ast_build *build);
532         #include <isl/ast.h>
533         isl_ctx *isl_ast_expr_get_ctx(
534                 __isl_keep isl_ast_expr *expr);
535         isl_ctx *isl_ast_node_get_ctx(
536                 __isl_keep isl_ast_node *node);
538 =head2 Values
540 An C<isl_val> represents an integer value, a rational value
541 or one of three special values, infinity, negative infinity and NaN.
542 Some predefined values can be created using the following functions.
544         #include <isl/val.h>
545         __isl_give isl_val *isl_val_zero(isl_ctx *ctx);
546         __isl_give isl_val *isl_val_one(isl_ctx *ctx);
547         __isl_give isl_val *isl_val_negone(isl_ctx *ctx);
548         __isl_give isl_val *isl_val_nan(isl_ctx *ctx);
549         __isl_give isl_val *isl_val_infty(isl_ctx *ctx);
550         __isl_give isl_val *isl_val_neginfty(isl_ctx *ctx);
552 Specific integer values can be created using the following functions.
554         #include <isl/val.h>
555         __isl_give isl_val *isl_val_int_from_si(isl_ctx *ctx,
556                 long i);
557         __isl_give isl_val *isl_val_int_from_ui(isl_ctx *ctx,
558                 unsigned long u);
559         __isl_give isl_val *isl_val_int_from_chunks(isl_ctx *ctx,
560                 size_t n, size_t size, const void *chunks);
562 The function C<isl_val_int_from_chunks> constructs an C<isl_val>
563 from the C<n> I<digits>, each consisting of C<size> bytes, stored at C<chunks>.
564 The least significant digit is assumed to be stored first.
566 Value objects can be copied and freed using the following functions.
568         #include <isl/val.h>
569         __isl_give isl_val *isl_val_copy(__isl_keep isl_val *v);
570         __isl_null isl_val *isl_val_free(__isl_take isl_val *v);
572 They can be inspected using the following functions.
574         #include <isl/val.h>
575         long isl_val_get_num_si(__isl_keep isl_val *v);
576         long isl_val_get_den_si(__isl_keep isl_val *v);
577         double isl_val_get_d(__isl_keep isl_val *v);
578         size_t isl_val_n_abs_num_chunks(__isl_keep isl_val *v,
579                 size_t size);
580         int isl_val_get_abs_num_chunks(__isl_keep isl_val *v,
581                 size_t size, void *chunks);
583 C<isl_val_n_abs_num_chunks> returns the number of I<digits>
584 of C<size> bytes needed to store the absolute value of the
585 numerator of C<v>.
586 C<isl_val_get_abs_num_chunks> stores these digits at C<chunks>,
587 which is assumed to have been preallocated by the caller.
588 The least significant digit is stored first.
589 Note that C<isl_val_get_num_si>, C<isl_val_get_den_si>,
590 C<isl_val_get_d>, C<isl_val_n_abs_num_chunks>
591 and C<isl_val_get_abs_num_chunks> can only be applied to rational values.
593 An C<isl_val> can be modified using the following function.
595         #include <isl/val.h>
596         __isl_give isl_val *isl_val_set_si(__isl_take isl_val *v,
597                 long i);
599 The following unary properties are defined on C<isl_val>s.
601         #include <isl/val.h>
602         int isl_val_sgn(__isl_keep isl_val *v);
603         int isl_val_is_zero(__isl_keep isl_val *v);
604         int isl_val_is_one(__isl_keep isl_val *v);
605         int isl_val_is_negone(__isl_keep isl_val *v);
606         int isl_val_is_nonneg(__isl_keep isl_val *v);
607         int isl_val_is_nonpos(__isl_keep isl_val *v);
608         int isl_val_is_pos(__isl_keep isl_val *v);
609         int isl_val_is_neg(__isl_keep isl_val *v);
610         int isl_val_is_int(__isl_keep isl_val *v);
611         int isl_val_is_rat(__isl_keep isl_val *v);
612         int isl_val_is_nan(__isl_keep isl_val *v);
613         int isl_val_is_infty(__isl_keep isl_val *v);
614         int isl_val_is_neginfty(__isl_keep isl_val *v);
616 Note that the sign of NaN is undefined.
618 The following binary properties are defined on pairs of C<isl_val>s.
620         #include <isl/val.h>
621         int isl_val_lt(__isl_keep isl_val *v1,
622                 __isl_keep isl_val *v2);
623         int isl_val_le(__isl_keep isl_val *v1,
624                 __isl_keep isl_val *v2);
625         int isl_val_gt(__isl_keep isl_val *v1,
626                 __isl_keep isl_val *v2);
627         int isl_val_ge(__isl_keep isl_val *v1,
628                 __isl_keep isl_val *v2);
629         int isl_val_eq(__isl_keep isl_val *v1,
630                 __isl_keep isl_val *v2);
631         int isl_val_ne(__isl_keep isl_val *v1,
632                 __isl_keep isl_val *v2);
633         int isl_val_abs_eq(__isl_keep isl_val *v1,
634                 __isl_keep isl_val *v2);
636 The function C<isl_val_abs_eq> checks whether its two arguments
637 are equal in absolute value.
639 For integer C<isl_val>s we additionally have the following binary property.
641         #include <isl/val.h>
642         int isl_val_is_divisible_by(__isl_keep isl_val *v1,
643                 __isl_keep isl_val *v2);
645 An C<isl_val> can also be compared to an integer using the following
646 function.  The result is undefined for NaN.
648         #include <isl/val.h>
649         int isl_val_cmp_si(__isl_keep isl_val *v, long i);
651 The following unary operations are available on C<isl_val>s.
653         #include <isl/val.h>
654         __isl_give isl_val *isl_val_abs(__isl_take isl_val *v);
655         __isl_give isl_val *isl_val_neg(__isl_take isl_val *v);
656         __isl_give isl_val *isl_val_floor(__isl_take isl_val *v);
657         __isl_give isl_val *isl_val_ceil(__isl_take isl_val *v);
658         __isl_give isl_val *isl_val_trunc(__isl_take isl_val *v);
659         __isl_give isl_val *isl_val_inv(__isl_take isl_val *v);
660         __isl_give isl_val *isl_val_2exp(__isl_take isl_val *v);
662 The following binary operations are available on C<isl_val>s.
664         #include <isl/val.h>
665         __isl_give isl_val *isl_val_min(__isl_take isl_val *v1,
666                 __isl_take isl_val *v2);
667         __isl_give isl_val *isl_val_max(__isl_take isl_val *v1,
668                 __isl_take isl_val *v2);
669         __isl_give isl_val *isl_val_add(__isl_take isl_val *v1,
670                 __isl_take isl_val *v2);
671         __isl_give isl_val *isl_val_add_ui(__isl_take isl_val *v1,
672                 unsigned long v2);
673         __isl_give isl_val *isl_val_sub(__isl_take isl_val *v1,
674                 __isl_take isl_val *v2);
675         __isl_give isl_val *isl_val_sub_ui(__isl_take isl_val *v1,
676                 unsigned long v2);
677         __isl_give isl_val *isl_val_mul(__isl_take isl_val *v1,
678                 __isl_take isl_val *v2);
679         __isl_give isl_val *isl_val_mul_ui(__isl_take isl_val *v1,
680                 unsigned long v2);
681         __isl_give isl_val *isl_val_div(__isl_take isl_val *v1,
682                 __isl_take isl_val *v2);
684 On integer values, we additionally have the following operations.
686         #include <isl/val.h>
687         __isl_give isl_val *isl_val_2exp(__isl_take isl_val *v);
688         __isl_give isl_val *isl_val_mod(__isl_take isl_val *v1,
689                 __isl_take isl_val *v2);
690         __isl_give isl_val *isl_val_gcd(__isl_take isl_val *v1,
691                 __isl_take isl_val *v2);
692         __isl_give isl_val *isl_val_gcdext(__isl_take isl_val *v1,
693                 __isl_take isl_val *v2, __isl_give isl_val **x,
694                 __isl_give isl_val **y);
696 The function C<isl_val_gcdext> returns the greatest common divisor g
697 of C<v1> and C<v2> as well as two integers C<*x> and C<*y> such
698 that C<*x> * C<v1> + C<*y> * C<v2> = g.
700 =head3 GMP specific functions
702 These functions are only available if C<isl> has been compiled with C<GMP>
703 support.
705 Specific integer and rational values can be created from C<GMP> values using
706 the following functions.
708         #include <isl/val_gmp.h>
709         __isl_give isl_val *isl_val_int_from_gmp(isl_ctx *ctx,
710                 mpz_t z);
711         __isl_give isl_val *isl_val_from_gmp(isl_ctx *ctx,
712                 const mpz_t n, const mpz_t d);
714 The numerator and denominator of a rational value can be extracted as
715 C<GMP> values using the following functions.
717         #include <isl/val_gmp.h>
718         int isl_val_get_num_gmp(__isl_keep isl_val *v, mpz_t z);
719         int isl_val_get_den_gmp(__isl_keep isl_val *v, mpz_t z);
721 =head2 Sets and Relations
723 C<isl> uses six types of objects for representing sets and relations,
724 C<isl_basic_set>, C<isl_basic_map>, C<isl_set>, C<isl_map>,
725 C<isl_union_set> and C<isl_union_map>.
726 C<isl_basic_set> and C<isl_basic_map> represent sets and relations that
727 can be described as a conjunction of affine constraints, while
728 C<isl_set> and C<isl_map> represent unions of
729 C<isl_basic_set>s and C<isl_basic_map>s, respectively.
730 However, all C<isl_basic_set>s or C<isl_basic_map>s in the union need
731 to live in the same space.  C<isl_union_set>s and C<isl_union_map>s
732 represent unions of C<isl_set>s or C<isl_map>s in I<different> spaces,
733 where spaces are considered different if they have a different number
734 of dimensions and/or different names (see L<"Spaces">).
735 The difference between sets and relations (maps) is that sets have
736 one set of variables, while relations have two sets of variables,
737 input variables and output variables.
739 =head2 Error Handling
741 C<isl> supports different ways to react in case a runtime error is triggered.
742 Runtime errors arise, e.g., if a function such as C<isl_map_intersect> is called
743 with two maps that have incompatible spaces. There are three possible ways
744 to react on error: to warn, to continue or to abort.
746 The default behavior is to warn. In this mode, C<isl> prints a warning, stores
747 the last error in the corresponding C<isl_ctx> and the function in which the
748 error was triggered returns C<NULL>. An error does not corrupt internal state,
749 such that isl can continue to be used. C<isl> also provides functions to
750 read the last error and to reset the memory that stores the last error. The
751 last error is only stored for information purposes. Its presence does not
752 change the behavior of C<isl>. Hence, resetting an error is not required to
753 continue to use isl, but only to observe new errors.
755         #include <isl/ctx.h>
756         enum isl_error isl_ctx_last_error(isl_ctx *ctx);
757         void isl_ctx_reset_error(isl_ctx *ctx);
759 Another option is to continue on error. This is similar to warn on error mode,
760 except that C<isl> does not print any warning. This allows a program to
761 implement its own error reporting.
763 The last option is to directly abort the execution of the program from within
764 the isl library. This makes it obviously impossible to recover from an error,
765 but it allows to directly spot the error location. By aborting on error,
766 debuggers break at the location the error occurred and can provide a stack
767 trace. Other tools that automatically provide stack traces on abort or that do
768 not want to continue execution after an error was triggered may also prefer to
769 abort on error.
771 The on error behavior of isl can be specified by calling
772 C<isl_options_set_on_error> or by setting the command line option
773 C<--isl-on-error>. Valid arguments for the function call are
774 C<ISL_ON_ERROR_WARN>, C<ISL_ON_ERROR_CONTINUE> and C<ISL_ON_ERROR_ABORT>. The
775 choices for the command line option are C<warn>, C<continue> and C<abort>.
776 It is also possible to query the current error mode.
778         #include <isl/options.h>
779         int isl_options_set_on_error(isl_ctx *ctx, int val);
780         int isl_options_get_on_error(isl_ctx *ctx);
782 =head2 Identifiers
784 Identifiers are used to identify both individual dimensions
785 and tuples of dimensions.  They consist of an optional name and an optional
786 user pointer.  The name and the user pointer cannot both be C<NULL>, however.
787 Identifiers with the same name but different pointer values
788 are considered to be distinct.
789 Similarly, identifiers with different names but the same pointer value
790 are also considered to be distinct.
791 Equal identifiers are represented using the same object.
792 Pairs of identifiers can therefore be tested for equality using the
793 C<==> operator.
794 Identifiers can be constructed, copied, freed, inspected and printed
795 using the following functions.
797         #include <isl/id.h>
798         __isl_give isl_id *isl_id_alloc(isl_ctx *ctx,
799                 __isl_keep const char *name, void *user);
800         __isl_give isl_id *isl_id_set_free_user(
801                 __isl_take isl_id *id,
802                 __isl_give void (*free_user)(void *user));
803         __isl_give isl_id *isl_id_copy(isl_id *id);
804         __isl_null isl_id *isl_id_free(__isl_take isl_id *id);
806         void *isl_id_get_user(__isl_keep isl_id *id);
807         __isl_keep const char *isl_id_get_name(__isl_keep isl_id *id);
809         __isl_give isl_printer *isl_printer_print_id(
810                 __isl_take isl_printer *p, __isl_keep isl_id *id);
812 The callback set by C<isl_id_set_free_user> is called on the user
813 pointer when the last reference to the C<isl_id> is freed.
814 Note that C<isl_id_get_name> returns a pointer to some internal
815 data structure, so the result can only be used while the
816 corresponding C<isl_id> is alive.
818 =head2 Spaces
820 Whenever a new set, relation or similar object is created from scratch,
821 the space in which it lives needs to be specified using an C<isl_space>.
822 Each space involves zero or more parameters and zero, one or two
823 tuples of set or input/output dimensions.  The parameters and dimensions
824 are identified by an C<isl_dim_type> and a position.
825 The type C<isl_dim_param> refers to parameters,
826 the type C<isl_dim_set> refers to set dimensions (for spaces
827 with a single tuple of dimensions) and the types C<isl_dim_in>
828 and C<isl_dim_out> refer to input and output dimensions
829 (for spaces with two tuples of dimensions).
830 Local spaces (see L</"Local Spaces">) also contain dimensions
831 of type C<isl_dim_div>.
832 Note that parameters are only identified by their position within
833 a given object.  Across different objects, parameters are (usually)
834 identified by their names or identifiers.  Only unnamed parameters
835 are identified by their positions across objects.  The use of unnamed
836 parameters is discouraged.
838         #include <isl/space.h>
839         __isl_give isl_space *isl_space_alloc(isl_ctx *ctx,
840                 unsigned nparam, unsigned n_in, unsigned n_out);
841         __isl_give isl_space *isl_space_params_alloc(isl_ctx *ctx,
842                 unsigned nparam);
843         __isl_give isl_space *isl_space_set_alloc(isl_ctx *ctx,
844                 unsigned nparam, unsigned dim);
845         __isl_give isl_space *isl_space_copy(__isl_keep isl_space *space);
846         __isl_null isl_space *isl_space_free(__isl_take isl_space *space);
848 The space used for creating a parameter domain
849 needs to be created using C<isl_space_params_alloc>.
850 For other sets, the space
851 needs to be created using C<isl_space_set_alloc>, while
852 for a relation, the space
853 needs to be created using C<isl_space_alloc>.
855 To check whether a given space is that of a set or a map
856 or whether it is a parameter space, use these functions:
858         #include <isl/space.h>
859         int isl_space_is_params(__isl_keep isl_space *space);
860         int isl_space_is_set(__isl_keep isl_space *space);
861         int isl_space_is_map(__isl_keep isl_space *space);
863 Spaces can be compared using the following functions:
865         #include <isl/space.h>
866         int isl_space_is_equal(__isl_keep isl_space *space1,
867                 __isl_keep isl_space *space2);
868         int isl_space_is_domain(__isl_keep isl_space *space1,
869                 __isl_keep isl_space *space2);
870         int isl_space_is_range(__isl_keep isl_space *space1,
871                 __isl_keep isl_space *space2);
872         int isl_space_tuple_is_equal(
873                 __isl_keep isl_space *space1,
874                 enum isl_dim_type type1,
875                 __isl_keep isl_space *space2,
876                 enum isl_dim_type type2);
878 C<isl_space_is_domain> checks whether the first argument is equal
879 to the domain of the second argument.  This requires in particular that
880 the first argument is a set space and that the second argument
881 is a map space.  C<isl_space_tuple_is_equal> checks whether the given
882 tuples (C<isl_dim_in>, C<isl_dim_out> or C<isl_dim_set>) of the given
883 spaces are the same.  That is, it checks if they have the same
884 identifier (if any), the same dimension and the same internal structure
885 (if any).
887 It is often useful to create objects that live in the
888 same space as some other object.  This can be accomplished
889 by creating the new objects
890 (see L</"Creating New Sets and Relations"> or
891 L</"Functions">) based on the space
892 of the original object.
894         #include <isl/set.h>
895         __isl_give isl_space *isl_basic_set_get_space(
896                 __isl_keep isl_basic_set *bset);
897         __isl_give isl_space *isl_set_get_space(__isl_keep isl_set *set);
899         #include <isl/union_set.h>
900         __isl_give isl_space *isl_union_set_get_space(
901                 __isl_keep isl_union_set *uset);
903         #include <isl/map.h>
904         __isl_give isl_space *isl_basic_map_get_space(
905                 __isl_keep isl_basic_map *bmap);
906         __isl_give isl_space *isl_map_get_space(__isl_keep isl_map *map);
908         #include <isl/union_map.h>
909         __isl_give isl_space *isl_union_map_get_space(
910                 __isl_keep isl_union_map *umap);
912         #include <isl/constraint.h>
913         __isl_give isl_space *isl_constraint_get_space(
914                 __isl_keep isl_constraint *constraint);
916         #include <isl/polynomial.h>
917         __isl_give isl_space *isl_qpolynomial_get_domain_space(
918                 __isl_keep isl_qpolynomial *qp);
919         __isl_give isl_space *isl_qpolynomial_get_space(
920                 __isl_keep isl_qpolynomial *qp);
921         __isl_give isl_space *isl_qpolynomial_fold_get_space(
922                 __isl_keep isl_qpolynomial_fold *fold);
923         __isl_give isl_space *isl_pw_qpolynomial_get_domain_space(
924                 __isl_keep isl_pw_qpolynomial *pwqp);
925         __isl_give isl_space *isl_pw_qpolynomial_get_space(
926                 __isl_keep isl_pw_qpolynomial *pwqp);
927         __isl_give isl_space *isl_pw_qpolynomial_fold_get_domain_space(
928                 __isl_keep isl_pw_qpolynomial_fold *pwf);
929         __isl_give isl_space *isl_pw_qpolynomial_fold_get_space(
930                 __isl_keep isl_pw_qpolynomial_fold *pwf);
931         __isl_give isl_space *isl_union_pw_qpolynomial_get_space(
932                 __isl_keep isl_union_pw_qpolynomial *upwqp);
933         __isl_give isl_space *isl_union_pw_qpolynomial_fold_get_space(
934                 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
936         #include <isl/val.h>
937         __isl_give isl_space *isl_multi_val_get_space(
938                 __isl_keep isl_multi_val *mv);
940         #include <isl/aff.h>
941         __isl_give isl_space *isl_aff_get_domain_space(
942                 __isl_keep isl_aff *aff);
943         __isl_give isl_space *isl_aff_get_space(
944                 __isl_keep isl_aff *aff);
945         __isl_give isl_space *isl_pw_aff_get_domain_space(
946                 __isl_keep isl_pw_aff *pwaff);
947         __isl_give isl_space *isl_pw_aff_get_space(
948                 __isl_keep isl_pw_aff *pwaff);
949         __isl_give isl_space *isl_multi_aff_get_domain_space(
950                 __isl_keep isl_multi_aff *maff);
951         __isl_give isl_space *isl_multi_aff_get_space(
952                 __isl_keep isl_multi_aff *maff);
953         __isl_give isl_space *isl_pw_multi_aff_get_domain_space(
954                 __isl_keep isl_pw_multi_aff *pma);
955         __isl_give isl_space *isl_pw_multi_aff_get_space(
956                 __isl_keep isl_pw_multi_aff *pma);
957         __isl_give isl_space *isl_union_pw_multi_aff_get_space(
958                 __isl_keep isl_union_pw_multi_aff *upma);
959         __isl_give isl_space *isl_multi_pw_aff_get_domain_space(
960                 __isl_keep isl_multi_pw_aff *mpa);
961         __isl_give isl_space *isl_multi_pw_aff_get_space(
962                 __isl_keep isl_multi_pw_aff *mpa);
964         #include <isl/point.h>
965         __isl_give isl_space *isl_point_get_space(
966                 __isl_keep isl_point *pnt);
968 The number of dimensions of a given type of space
969 may be read off from a space or an object that lives
970 in a space using the following functions.
971 In case of C<isl_space_dim>, type may be
972 C<isl_dim_param>, C<isl_dim_in> (only for relations),
973 C<isl_dim_out> (only for relations), C<isl_dim_set>
974 (only for sets) or C<isl_dim_all>.
976         #include <isl/space.h>
977         unsigned isl_space_dim(__isl_keep isl_space *space,
978                 enum isl_dim_type type);
980         #include <isl/local_space.h>
981         int isl_local_space_dim(__isl_keep isl_local_space *ls,
982                 enum isl_dim_type type);
984         #include <isl/set.h>
985         unsigned isl_basic_set_dim(__isl_keep isl_basic_set *bset,
986                 enum isl_dim_type type);
987         unsigned isl_set_dim(__isl_keep isl_set *set,
988                 enum isl_dim_type type);
990         #include <isl/map.h>
991         unsigned isl_basic_map_dim(__isl_keep isl_basic_map *bmap,
992                 enum isl_dim_type type);
993         unsigned isl_map_dim(__isl_keep isl_map *map,
994                 enum isl_dim_type type);
996         #include <isl/union_map.h>
997         unsigned isl_union_map_dim(__isl_keep isl_union_map *umap,
998                 enum isl_dim_type type);
1000         #include <isl/val.h>
1001         unsigned isl_multi_val_dim(__isl_keep isl_multi_val *mv,
1002                 enum isl_dim_type type);
1004         #include <isl/aff.h>
1005         int isl_aff_dim(__isl_keep isl_aff *aff,
1006                 enum isl_dim_type type);
1007         unsigned isl_multi_aff_dim(__isl_keep isl_multi_aff *maff,
1008                 enum isl_dim_type type);
1009         unsigned isl_pw_aff_dim(__isl_keep isl_pw_aff *pwaff,
1010                 enum isl_dim_type type);
1011         unsigned isl_pw_multi_aff_dim(
1012                 __isl_keep isl_pw_multi_aff *pma,
1013                 enum isl_dim_type type);
1014         unsigned isl_multi_pw_aff_dim(
1015                 __isl_keep isl_multi_pw_aff *mpa,
1016                 enum isl_dim_type type);
1018 Note that an C<isl_union_map> only has parameters.
1020 The identifiers or names of the individual dimensions of spaces
1021 may be set or read off using the following functions on spaces
1022 or objects that live in spaces.
1023 These functions are mostly useful to obtain the identifiers, positions
1024 or names of the parameters.  Identifiers of individual dimensions are
1025 essentially only useful for printing.  They are ignored by all other
1026 operations and may not be preserved across those operations.
1028         #include <isl/space.h>
1029         __isl_give isl_space *isl_space_set_dim_id(
1030                 __isl_take isl_space *space,
1031                 enum isl_dim_type type, unsigned pos,
1032                 __isl_take isl_id *id);
1033         int isl_space_has_dim_id(__isl_keep isl_space *space,
1034                 enum isl_dim_type type, unsigned pos);
1035         __isl_give isl_id *isl_space_get_dim_id(
1036                 __isl_keep isl_space *space,
1037                 enum isl_dim_type type, unsigned pos);
1038         __isl_give isl_space *isl_space_set_dim_name(
1039                 __isl_take isl_space *space,
1040                  enum isl_dim_type type, unsigned pos,
1041                  __isl_keep const char *name);
1042         int isl_space_has_dim_name(__isl_keep isl_space *space,
1043                 enum isl_dim_type type, unsigned pos);
1044         __isl_keep const char *isl_space_get_dim_name(
1045                 __isl_keep isl_space *space,
1046                 enum isl_dim_type type, unsigned pos);
1048         #include <isl/local_space.h>
1049         __isl_give isl_local_space *isl_local_space_set_dim_id(
1050                 __isl_take isl_local_space *ls,
1051                 enum isl_dim_type type, unsigned pos,
1052                 __isl_take isl_id *id);
1053         int isl_local_space_has_dim_id(
1054                 __isl_keep isl_local_space *ls,
1055                 enum isl_dim_type type, unsigned pos);
1056         __isl_give isl_id *isl_local_space_get_dim_id(
1057                 __isl_keep isl_local_space *ls,
1058                 enum isl_dim_type type, unsigned pos);
1059         __isl_give isl_local_space *isl_local_space_set_dim_name(
1060                 __isl_take isl_local_space *ls,
1061                 enum isl_dim_type type, unsigned pos, const char *s);
1062         int isl_local_space_has_dim_name(
1063                 __isl_keep isl_local_space *ls,
1064                 enum isl_dim_type type, unsigned pos)
1065         const char *isl_local_space_get_dim_name(
1066                 __isl_keep isl_local_space *ls,
1067                 enum isl_dim_type type, unsigned pos);
1069         #include <isl/constraint.h>
1070         const char *isl_constraint_get_dim_name(
1071                 __isl_keep isl_constraint *constraint,
1072                 enum isl_dim_type type, unsigned pos);
1074         #include <isl/set.h>
1075         __isl_give isl_id *isl_basic_set_get_dim_id(
1076                 __isl_keep isl_basic_set *bset,
1077                 enum isl_dim_type type, unsigned pos);
1078         __isl_give isl_set *isl_set_set_dim_id(
1079                 __isl_take isl_set *set, enum isl_dim_type type,
1080                 unsigned pos, __isl_take isl_id *id);
1081         int isl_set_has_dim_id(__isl_keep isl_set *set,
1082                 enum isl_dim_type type, unsigned pos);
1083         __isl_give isl_id *isl_set_get_dim_id(
1084                 __isl_keep isl_set *set, enum isl_dim_type type,
1085                 unsigned pos);
1086         const char *isl_basic_set_get_dim_name(
1087                 __isl_keep isl_basic_set *bset,
1088                 enum isl_dim_type type, unsigned pos);
1089         int isl_set_has_dim_name(__isl_keep isl_set *set,
1090                 enum isl_dim_type type, unsigned pos);
1091         const char *isl_set_get_dim_name(
1092                 __isl_keep isl_set *set,
1093                 enum isl_dim_type type, unsigned pos);
1095         #include <isl/map.h>
1096         __isl_give isl_map *isl_map_set_dim_id(
1097                 __isl_take isl_map *map, enum isl_dim_type type,
1098                 unsigned pos, __isl_take isl_id *id);
1099         int isl_basic_map_has_dim_id(
1100                 __isl_keep isl_basic_map *bmap,
1101                 enum isl_dim_type type, unsigned pos);
1102         int isl_map_has_dim_id(__isl_keep isl_map *map,
1103                 enum isl_dim_type type, unsigned pos);
1104         __isl_give isl_id *isl_map_get_dim_id(
1105                 __isl_keep isl_map *map, enum isl_dim_type type,
1106                 unsigned pos);
1107         __isl_give isl_id *isl_union_map_get_dim_id(
1108                 __isl_keep isl_union_map *umap,
1109                 enum isl_dim_type type, unsigned pos);
1110         const char *isl_basic_map_get_dim_name(
1111                 __isl_keep isl_basic_map *bmap,
1112                 enum isl_dim_type type, unsigned pos);
1113         int isl_map_has_dim_name(__isl_keep isl_map *map,
1114                 enum isl_dim_type type, unsigned pos);
1115         const char *isl_map_get_dim_name(
1116                 __isl_keep isl_map *map,
1117                 enum isl_dim_type type, unsigned pos);
1119         #include <isl/val.h>
1120         __isl_give isl_multi_val *isl_multi_val_set_dim_id(
1121                 __isl_take isl_multi_val *mv,
1122                 enum isl_dim_type type, unsigned pos,
1123                 __isl_take isl_id *id);
1124         __isl_give isl_id *isl_multi_val_get_dim_id(
1125                 __isl_keep isl_multi_val *mv,
1126                 enum isl_dim_type type, unsigned pos);
1127         __isl_give isl_multi_val *isl_multi_val_set_dim_name(
1128                 __isl_take isl_multi_val *mv,
1129                 enum isl_dim_type type, unsigned pos, const char *s);
1131         #include <isl/aff.h>
1132         __isl_give isl_aff *isl_aff_set_dim_id(
1133                 __isl_take isl_aff *aff, enum isl_dim_type type,
1134                 unsigned pos, __isl_take isl_id *id);
1135         __isl_give isl_multi_aff *isl_multi_aff_set_dim_id(
1136                 __isl_take isl_multi_aff *maff,
1137                 enum isl_dim_type type, unsigned pos,
1138                 __isl_take isl_id *id);
1139         __isl_give isl_pw_aff *isl_pw_aff_set_dim_id(
1140                 __isl_take isl_pw_aff *pma,
1141                 enum isl_dim_type type, unsigned pos,
1142                 __isl_take isl_id *id);
1143         __isl_give isl_multi_pw_aff *
1144         isl_multi_pw_aff_set_dim_id(
1145                 __isl_take isl_multi_pw_aff *mpa,
1146                 enum isl_dim_type type, unsigned pos,
1147                 __isl_take isl_id *id);
1148         __isl_give isl_id *isl_multi_aff_get_dim_id(
1149                 __isl_keep isl_multi_aff *ma,
1150                 enum isl_dim_type type, unsigned pos);
1151         int isl_pw_aff_has_dim_id(__isl_keep isl_pw_aff *pa,
1152                 enum isl_dim_type type, unsigned pos);
1153         __isl_give isl_id *isl_pw_aff_get_dim_id(
1154                 __isl_keep isl_pw_aff *pa,
1155                 enum isl_dim_type type, unsigned pos);
1156         __isl_give isl_id *isl_pw_multi_aff_get_dim_id(
1157                 __isl_keep isl_pw_multi_aff *pma,
1158                 enum isl_dim_type type, unsigned pos);
1159         __isl_give isl_id *isl_multi_pw_aff_get_dim_id(
1160                 __isl_keep isl_multi_pw_aff *mpa,
1161                 enum isl_dim_type type, unsigned pos);
1162         __isl_give isl_aff *isl_aff_set_dim_name(
1163                 __isl_take isl_aff *aff, enum isl_dim_type type,
1164                 unsigned pos, const char *s);
1165         __isl_give isl_multi_aff *isl_multi_aff_set_dim_name(
1166                 __isl_take isl_multi_aff *maff,
1167                 enum isl_dim_type type, unsigned pos, const char *s);
1168         __isl_give isl_multi_pw_aff *
1169         isl_multi_pw_aff_set_dim_name(
1170                 __isl_take isl_multi_pw_aff *mpa,
1171                 enum isl_dim_type type, unsigned pos, const char *s);
1172         const char *isl_aff_get_dim_name(__isl_keep isl_aff *aff,
1173                 enum isl_dim_type type, unsigned pos);
1174         const char *isl_pw_aff_get_dim_name(
1175                 __isl_keep isl_pw_aff *pa,
1176                 enum isl_dim_type type, unsigned pos);
1177         const char *isl_pw_multi_aff_get_dim_name(
1178                 __isl_keep isl_pw_multi_aff *pma,
1179                 enum isl_dim_type type, unsigned pos);
1181         #include <isl/polynomial.h>
1182         __isl_give isl_qpolynomial *isl_qpolynomial_set_dim_name(
1183                 __isl_take isl_qpolynomial *qp,
1184                 enum isl_dim_type type, unsigned pos,
1185                 const char *s);
1186         __isl_give isl_pw_qpolynomial *
1187         isl_pw_qpolynomial_set_dim_name(
1188                 __isl_take isl_pw_qpolynomial *pwqp,
1189                 enum isl_dim_type type, unsigned pos,
1190                 const char *s);
1191         __isl_give isl_pw_qpolynomial_fold *
1192         isl_pw_qpolynomial_fold_set_dim_name(
1193                 __isl_take isl_pw_qpolynomial_fold *pwf,
1194                 enum isl_dim_type type, unsigned pos,
1195                 const char *s);
1197 Note that C<isl_space_get_name> returns a pointer to some internal
1198 data structure, so the result can only be used while the
1199 corresponding C<isl_space> is alive.
1200 Also note that every function that operates on two sets or relations
1201 requires that both arguments have the same parameters.  This also
1202 means that if one of the arguments has named parameters, then the
1203 other needs to have named parameters too and the names need to match.
1204 Pairs of C<isl_set>, C<isl_map>, C<isl_union_set> and/or C<isl_union_map>
1205 arguments may have different parameters (as long as they are named),
1206 in which case the result will have as parameters the union of the parameters of
1207 the arguments.
1209 Given the identifier or name of a dimension (typically a parameter),
1210 its position can be obtained from the following functions.
1212         #include <isl/space.h>
1213         int isl_space_find_dim_by_id(__isl_keep isl_space *space,
1214                 enum isl_dim_type type, __isl_keep isl_id *id);
1215         int isl_space_find_dim_by_name(__isl_keep isl_space *space,
1216                 enum isl_dim_type type, const char *name);
1218         #include <isl/val.h>
1219         int isl_multi_val_find_dim_by_id(
1220                 __isl_keep isl_multi_val *mv,
1221                 enum isl_dim_type type, __isl_keep isl_id *id);
1223         #include <isl/set.h>
1224         int isl_set_find_dim_by_id(__isl_keep isl_set *set,
1225                 enum isl_dim_type type, __isl_keep isl_id *id);
1226         int isl_set_find_dim_by_name(__isl_keep isl_set *set,
1227                 enum isl_dim_type type, const char *name);
1229         #include <isl/map.h>
1230         int isl_map_find_dim_by_id(__isl_keep isl_map *map,
1231                 enum isl_dim_type type, __isl_keep isl_id *id);
1232         int isl_map_find_dim_by_name(__isl_keep isl_map *map,
1233                 enum isl_dim_type type, const char *name);
1235         #include <isl/aff.h>
1236         int isl_multi_aff_find_dim_by_id(
1237                 __isl_keep isl_multi_aff *ma,
1238                 enum isl_dim_type type, __isl_keep isl_id *id);
1239         int isl_multi_pw_aff_find_dim_by_id(
1240                 __isl_keep isl_multi_pw_aff *mpa,
1241                 enum isl_dim_type type, __isl_keep isl_id *id);
1243 The identifiers or names of entire spaces may be set or read off
1244 using the following functions.
1246         #include <isl/space.h>
1247         __isl_give isl_space *isl_space_set_tuple_id(
1248                 __isl_take isl_space *space,
1249                 enum isl_dim_type type, __isl_take isl_id *id);
1250         __isl_give isl_space *isl_space_reset_tuple_id(
1251                 __isl_take isl_space *space, enum isl_dim_type type);
1252         int isl_space_has_tuple_id(__isl_keep isl_space *space,
1253                 enum isl_dim_type type);
1254         __isl_give isl_id *isl_space_get_tuple_id(
1255                 __isl_keep isl_space *space, enum isl_dim_type type);
1256         __isl_give isl_space *isl_space_set_tuple_name(
1257                 __isl_take isl_space *space,
1258                 enum isl_dim_type type, const char *s);
1259         int isl_space_has_tuple_name(__isl_keep isl_space *space,
1260                 enum isl_dim_type type);
1261         const char *isl_space_get_tuple_name(__isl_keep isl_space *space,
1262                 enum isl_dim_type type);
1264         #include <isl/local_space.h>
1265         __isl_give isl_local_space *isl_local_space_set_tuple_id(
1266                 __isl_take isl_local_space *ls,
1267                 enum isl_dim_type type, __isl_take isl_id *id);
1269         #include <isl/set.h>
1270         __isl_give isl_basic_set *isl_basic_set_set_tuple_id(
1271                 __isl_take isl_basic_set *bset,
1272                 __isl_take isl_id *id);
1273         __isl_give isl_set *isl_set_set_tuple_id(
1274                 __isl_take isl_set *set, __isl_take isl_id *id);
1275         __isl_give isl_set *isl_set_reset_tuple_id(
1276                 __isl_take isl_set *set);
1277         int isl_set_has_tuple_id(__isl_keep isl_set *set);
1278         __isl_give isl_id *isl_set_get_tuple_id(
1279                 __isl_keep isl_set *set);
1280         __isl_give isl_basic_set *isl_basic_set_set_tuple_name(
1281                 __isl_take isl_basic_set *set, const char *s);
1282         __isl_give isl_set *isl_set_set_tuple_name(
1283                 __isl_take isl_set *set, const char *s);
1284         const char *isl_basic_set_get_tuple_name(
1285                 __isl_keep isl_basic_set *bset);
1286         int isl_set_has_tuple_name(__isl_keep isl_set *set);
1287         const char *isl_set_get_tuple_name(
1288                 __isl_keep isl_set *set);
1290         #include <isl/map.h>
1291         __isl_give isl_basic_map *isl_basic_map_set_tuple_id(
1292                 __isl_take isl_basic_map *bmap,
1293                 enum isl_dim_type type, __isl_take isl_id *id);
1294         __isl_give isl_map *isl_map_set_tuple_id(
1295                 __isl_take isl_map *map, enum isl_dim_type type,
1296                 __isl_take isl_id *id);
1297         __isl_give isl_map *isl_map_reset_tuple_id(
1298                 __isl_take isl_map *map, enum isl_dim_type type);
1299         int isl_map_has_tuple_id(__isl_keep isl_map *map,
1300                 enum isl_dim_type type);
1301         __isl_give isl_id *isl_map_get_tuple_id(
1302                 __isl_keep isl_map *map, enum isl_dim_type type);
1303         __isl_give isl_map *isl_map_set_tuple_name(
1304                 __isl_take isl_map *map,
1305                 enum isl_dim_type type, const char *s);
1306         const char *isl_basic_map_get_tuple_name(
1307                 __isl_keep isl_basic_map *bmap,
1308                 enum isl_dim_type type);
1309         __isl_give isl_basic_map *isl_basic_map_set_tuple_name(
1310                 __isl_take isl_basic_map *bmap,
1311                 enum isl_dim_type type, const char *s);
1312         int isl_map_has_tuple_name(__isl_keep isl_map *map,
1313                 enum isl_dim_type type);
1314         const char *isl_map_get_tuple_name(
1315                 __isl_keep isl_map *map,
1316                 enum isl_dim_type type);
1318         #include <isl/val.h>
1319         __isl_give isl_multi_val *isl_multi_val_set_tuple_id(
1320                 __isl_take isl_multi_val *mv,
1321                 enum isl_dim_type type, __isl_take isl_id *id);
1322         __isl_give isl_multi_val *isl_multi_val_reset_tuple_id(
1323                 __isl_take isl_multi_val *mv,
1324                 enum isl_dim_type type);
1325         int isl_multi_val_has_tuple_id(__isl_keep isl_multi_val *mv,
1326                 enum isl_dim_type type);
1327         __isl_give isl_id *isl_multi_val_get_tuple_id(
1328                 __isl_keep isl_multi_val *mv,
1329                 enum isl_dim_type type);
1330         __isl_give isl_multi_val *isl_multi_val_set_tuple_name(
1331                 __isl_take isl_multi_val *mv,
1332                 enum isl_dim_type type, const char *s);
1333         const char *isl_multi_val_get_tuple_name(
1334                 __isl_keep isl_multi_val *mv,
1335                 enum isl_dim_type type);
1337         #include <isl/aff.h>
1338         __isl_give isl_aff *isl_aff_set_tuple_id(
1339                 __isl_take isl_aff *aff,
1340                 enum isl_dim_type type, __isl_take isl_id *id);
1341         __isl_give isl_multi_aff *isl_multi_aff_set_tuple_id(
1342                 __isl_take isl_multi_aff *maff,
1343                 enum isl_dim_type type, __isl_take isl_id *id);
1344         __isl_give isl_pw_aff *isl_pw_aff_set_tuple_id(
1345                 __isl_take isl_pw_aff *pwaff,
1346                 enum isl_dim_type type, __isl_take isl_id *id);
1347         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_tuple_id(
1348                 __isl_take isl_pw_multi_aff *pma,
1349                 enum isl_dim_type type, __isl_take isl_id *id);
1350         __isl_give isl_multi_aff *isl_multi_aff_reset_tuple_id(
1351                 __isl_take isl_multi_aff *ma,
1352                 enum isl_dim_type type);
1353         __isl_give isl_pw_aff *isl_pw_aff_reset_tuple_id(
1354                 __isl_take isl_pw_aff *pa,
1355                 enum isl_dim_type type);
1356         __isl_give isl_multi_pw_aff *
1357         isl_multi_pw_aff_reset_tuple_id(
1358                 __isl_take isl_multi_pw_aff *mpa,
1359                 enum isl_dim_type type);
1360         __isl_give isl_pw_multi_aff *
1361         isl_pw_multi_aff_reset_tuple_id(
1362                 __isl_take isl_pw_multi_aff *pma,
1363                 enum isl_dim_type type);
1364         int isl_multi_aff_has_tuple_id(__isl_keep isl_multi_aff *ma,
1365                 enum isl_dim_type type);
1366         __isl_give isl_id *isl_multi_aff_get_tuple_id(
1367                 __isl_keep isl_multi_aff *ma,
1368                 enum isl_dim_type type);
1369         int isl_pw_aff_has_tuple_id(__isl_keep isl_pw_aff *pa,
1370                 enum isl_dim_type type);
1371         __isl_give isl_id *isl_pw_aff_get_tuple_id(
1372                 __isl_keep isl_pw_aff *pa,
1373                 enum isl_dim_type type);
1374         int isl_pw_multi_aff_has_tuple_id(
1375                 __isl_keep isl_pw_multi_aff *pma,
1376                 enum isl_dim_type type);
1377         __isl_give isl_id *isl_pw_multi_aff_get_tuple_id(
1378                 __isl_keep isl_pw_multi_aff *pma,
1379                 enum isl_dim_type type);
1380         int isl_multi_pw_aff_has_tuple_id(
1381                 __isl_keep isl_multi_pw_aff *mpa,
1382                 enum isl_dim_type type);
1383         __isl_give isl_id *isl_multi_pw_aff_get_tuple_id(
1384                 __isl_keep isl_multi_pw_aff *mpa,
1385                 enum isl_dim_type type);
1386         __isl_give isl_multi_aff *isl_multi_aff_set_tuple_name(
1387                 __isl_take isl_multi_aff *maff,
1388                 enum isl_dim_type type, const char *s);
1389         __isl_give isl_multi_pw_aff *
1390         isl_multi_pw_aff_set_tuple_name(
1391                 __isl_take isl_multi_pw_aff *mpa,
1392                 enum isl_dim_type type, const char *s);
1393         const char *isl_multi_aff_get_tuple_name(
1394                 __isl_keep isl_multi_aff *multi,
1395                 enum isl_dim_type type);
1396         int isl_pw_multi_aff_has_tuple_name(
1397                 __isl_keep isl_pw_multi_aff *pma,
1398                 enum isl_dim_type type);
1399         const char *isl_pw_multi_aff_get_tuple_name(
1400                 __isl_keep isl_pw_multi_aff *pma,
1401                 enum isl_dim_type type);
1403 The C<type> argument needs to be one of C<isl_dim_in>, C<isl_dim_out>
1404 or C<isl_dim_set>.  As with C<isl_space_get_name>,
1405 the C<isl_space_get_tuple_name> function returns a pointer to some internal
1406 data structure.
1407 Binary operations require the corresponding spaces of their arguments
1408 to have the same name.
1410 To keep the names of all parameters and tuples, but reset the user pointers
1411 of all the corresponding identifiers, use the following function.
1413         #include <isl/space.h>
1414         __isl_give isl_space *isl_space_reset_user(
1415                 __isl_take isl_space *space);
1417         #include <isl/set.h>
1418         __isl_give isl_set *isl_set_reset_user(
1419                 __isl_take isl_set *set);
1421         #include <isl/map.h>
1422         __isl_give isl_map *isl_map_reset_user(
1423                 __isl_take isl_map *map);
1425         #include <isl/union_set.h>
1426         __isl_give isl_union_set *isl_union_set_reset_user(
1427                 __isl_take isl_union_set *uset);
1429         #include <isl/union_map.h>
1430         __isl_give isl_union_map *isl_union_map_reset_user(
1431                 __isl_take isl_union_map *umap);
1433         #include <isl/val.h>
1434         __isl_give isl_multi_val *isl_multi_val_reset_user(
1435                 __isl_take isl_multi_val *mv);
1437         #include <isl/aff.h>
1438         __isl_give isl_multi_aff *isl_multi_aff_reset_user(
1439                 __isl_take isl_multi_aff *ma);
1440         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_reset_user(
1441                 __isl_take isl_multi_pw_aff *mpa);
1443 Spaces can be nested.  In particular, the domain of a set or
1444 the domain or range of a relation can be a nested relation.
1445 This process is also called I<wrapping>.
1446 The functions for detecting, constructing and deconstructing
1447 such nested spaces can be found in the wrapping properties
1448 of L</"Unary Properties">, the wrapping operations
1449 of L</"Unary Operations"> and the Cartesian product operations
1450 of L</"Basic Operations">.
1452 Spaces can be created from other spaces
1453 using the functions described in L</"Unary Operations">
1454 and L</"Binary Operations">.
1456 =head2 Local Spaces
1458 A local space is essentially a space with
1459 zero or more existentially quantified variables.
1460 The local space of various objects can be obtained
1461 using the following functions.
1463         #include <isl/constraint.h>
1464         __isl_give isl_local_space *isl_constraint_get_local_space(
1465                 __isl_keep isl_constraint *constraint);
1467         #include <isl/set.h>
1468         __isl_give isl_local_space *isl_basic_set_get_local_space(
1469                 __isl_keep isl_basic_set *bset);
1471         #include <isl/map.h>
1472         __isl_give isl_local_space *isl_basic_map_get_local_space(
1473                 __isl_keep isl_basic_map *bmap);
1475         #include <isl/aff.h>
1476         __isl_give isl_local_space *isl_aff_get_domain_local_space(
1477                 __isl_keep isl_aff *aff);
1478         __isl_give isl_local_space *isl_aff_get_local_space(
1479                 __isl_keep isl_aff *aff);
1481 A new local space can be created from a space using
1483         #include <isl/local_space.h>
1484         __isl_give isl_local_space *isl_local_space_from_space(
1485                 __isl_take isl_space *space);
1487 They can be inspected, modified, copied and freed using the following functions.
1489         #include <isl/local_space.h>
1490         int isl_local_space_is_params(
1491                 __isl_keep isl_local_space *ls);
1492         int isl_local_space_is_set(__isl_keep isl_local_space *ls);
1493         __isl_give isl_space *isl_local_space_get_space(
1494                 __isl_keep isl_local_space *ls);
1495         __isl_give isl_aff *isl_local_space_get_div(
1496                 __isl_keep isl_local_space *ls, int pos);
1497         __isl_give isl_local_space *isl_local_space_copy(
1498                 __isl_keep isl_local_space *ls);
1499         __isl_null isl_local_space *isl_local_space_free(
1500                 __isl_take isl_local_space *ls);
1502 Note that C<isl_local_space_get_div> can only be used on local spaces
1503 of sets.
1505 Two local spaces can be compared using
1507         int isl_local_space_is_equal(__isl_keep isl_local_space *ls1,
1508                 __isl_keep isl_local_space *ls2);
1510 Local spaces can be created from other local spaces
1511 using the functions described in L</"Unary Operations">
1512 and L</"Binary Operations">.
1514 =head2 Creating New Sets and Relations
1516 C<isl> has functions for creating some standard sets and relations.
1518 =over
1520 =item * Empty sets and relations
1522         __isl_give isl_basic_set *isl_basic_set_empty(
1523                 __isl_take isl_space *space);
1524         __isl_give isl_basic_map *isl_basic_map_empty(
1525                 __isl_take isl_space *space);
1526         __isl_give isl_set *isl_set_empty(
1527                 __isl_take isl_space *space);
1528         __isl_give isl_map *isl_map_empty(
1529                 __isl_take isl_space *space);
1530         __isl_give isl_union_set *isl_union_set_empty(
1531                 __isl_take isl_space *space);
1532         __isl_give isl_union_map *isl_union_map_empty(
1533                 __isl_take isl_space *space);
1535 For C<isl_union_set>s and C<isl_union_map>s, the space
1536 is only used to specify the parameters.
1538 =item * Universe sets and relations
1540         __isl_give isl_basic_set *isl_basic_set_universe(
1541                 __isl_take isl_space *space);
1542         __isl_give isl_basic_map *isl_basic_map_universe(
1543                 __isl_take isl_space *space);
1544         __isl_give isl_set *isl_set_universe(
1545                 __isl_take isl_space *space);
1546         __isl_give isl_map *isl_map_universe(
1547                 __isl_take isl_space *space);
1548         __isl_give isl_union_set *isl_union_set_universe(
1549                 __isl_take isl_union_set *uset);
1550         __isl_give isl_union_map *isl_union_map_universe(
1551                 __isl_take isl_union_map *umap);
1553 The sets and relations constructed by the functions above
1554 contain all integer values, while those constructed by the
1555 functions below only contain non-negative values.
1557         __isl_give isl_basic_set *isl_basic_set_nat_universe(
1558                 __isl_take isl_space *space);
1559         __isl_give isl_basic_map *isl_basic_map_nat_universe(
1560                 __isl_take isl_space *space);
1561         __isl_give isl_set *isl_set_nat_universe(
1562                 __isl_take isl_space *space);
1563         __isl_give isl_map *isl_map_nat_universe(
1564                 __isl_take isl_space *space);
1566 =item * Identity relations
1568         __isl_give isl_basic_map *isl_basic_map_identity(
1569                 __isl_take isl_space *space);
1570         __isl_give isl_map *isl_map_identity(
1571                 __isl_take isl_space *space);
1573 The number of input and output dimensions in C<space> needs
1574 to be the same.
1576 =item * Lexicographic order
1578         __isl_give isl_map *isl_map_lex_lt(
1579                 __isl_take isl_space *set_space);
1580         __isl_give isl_map *isl_map_lex_le(
1581                 __isl_take isl_space *set_space);
1582         __isl_give isl_map *isl_map_lex_gt(
1583                 __isl_take isl_space *set_space);
1584         __isl_give isl_map *isl_map_lex_ge(
1585                 __isl_take isl_space *set_space);
1586         __isl_give isl_map *isl_map_lex_lt_first(
1587                 __isl_take isl_space *space, unsigned n);
1588         __isl_give isl_map *isl_map_lex_le_first(
1589                 __isl_take isl_space *space, unsigned n);
1590         __isl_give isl_map *isl_map_lex_gt_first(
1591                 __isl_take isl_space *space, unsigned n);
1592         __isl_give isl_map *isl_map_lex_ge_first(
1593                 __isl_take isl_space *space, unsigned n);
1595 The first four functions take a space for a B<set>
1596 and return relations that express that the elements in the domain
1597 are lexicographically less
1598 (C<isl_map_lex_lt>), less or equal (C<isl_map_lex_le>),
1599 greater (C<isl_map_lex_gt>) or greater or equal (C<isl_map_lex_ge>)
1600 than the elements in the range.
1601 The last four functions take a space for a map
1602 and return relations that express that the first C<n> dimensions
1603 in the domain are lexicographically less
1604 (C<isl_map_lex_lt_first>), less or equal (C<isl_map_lex_le_first>),
1605 greater (C<isl_map_lex_gt_first>) or greater or equal (C<isl_map_lex_ge_first>)
1606 than the first C<n> dimensions in the range.
1608 =back
1610 A basic set or relation can be converted to a set or relation
1611 using the following functions.
1613         __isl_give isl_set *isl_set_from_basic_set(
1614                 __isl_take isl_basic_set *bset);
1615         __isl_give isl_map *isl_map_from_basic_map(
1616                 __isl_take isl_basic_map *bmap);
1618 Sets and relations can be converted to union sets and relations
1619 using the following functions.
1621         __isl_give isl_union_set *isl_union_set_from_basic_set(
1622                 __isl_take isl_basic_set *bset);
1623         __isl_give isl_union_map *isl_union_map_from_basic_map(
1624                 __isl_take isl_basic_map *bmap);
1625         __isl_give isl_union_set *isl_union_set_from_set(
1626                 __isl_take isl_set *set);
1627         __isl_give isl_union_map *isl_union_map_from_map(
1628                 __isl_take isl_map *map);
1630 The inverse conversions below can only be used if the input
1631 union set or relation is known to contain elements in exactly one
1632 space.
1634         __isl_give isl_set *isl_set_from_union_set(
1635                 __isl_take isl_union_set *uset);
1636         __isl_give isl_map *isl_map_from_union_map(
1637                 __isl_take isl_union_map *umap);
1639 Sets and relations can be copied and freed again using the following
1640 functions.
1642         __isl_give isl_basic_set *isl_basic_set_copy(
1643                 __isl_keep isl_basic_set *bset);
1644         __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set);
1645         __isl_give isl_union_set *isl_union_set_copy(
1646                 __isl_keep isl_union_set *uset);
1647         __isl_give isl_basic_map *isl_basic_map_copy(
1648                 __isl_keep isl_basic_map *bmap);
1649         __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
1650         __isl_give isl_union_map *isl_union_map_copy(
1651                 __isl_keep isl_union_map *umap);
1652         __isl_null isl_basic_set *isl_basic_set_free(
1653                 __isl_take isl_basic_set *bset);
1654         __isl_null isl_set *isl_set_free(__isl_take isl_set *set);
1655         __isl_null isl_union_set *isl_union_set_free(
1656                 __isl_take isl_union_set *uset);
1657         __isl_null isl_basic_map *isl_basic_map_free(
1658                 __isl_take isl_basic_map *bmap);
1659         __isl_null isl_map *isl_map_free(__isl_take isl_map *map);
1660         __isl_null isl_union_map *isl_union_map_free(
1661                 __isl_take isl_union_map *umap);
1663 Other sets and relations can be constructed by starting
1664 from a universe set or relation, adding equality and/or
1665 inequality constraints and then projecting out the
1666 existentially quantified variables, if any.
1667 Constraints can be constructed, manipulated and
1668 added to (or removed from) (basic) sets and relations
1669 using the following functions.
1671         #include <isl/constraint.h>
1672         __isl_give isl_constraint *isl_equality_alloc(
1673                 __isl_take isl_local_space *ls);
1674         __isl_give isl_constraint *isl_inequality_alloc(
1675                 __isl_take isl_local_space *ls);
1676         __isl_give isl_constraint *isl_constraint_set_constant_si(
1677                 __isl_take isl_constraint *constraint, int v);
1678         __isl_give isl_constraint *isl_constraint_set_constant_val(
1679                 __isl_take isl_constraint *constraint,
1680                 __isl_take isl_val *v);
1681         __isl_give isl_constraint *isl_constraint_set_coefficient_si(
1682                 __isl_take isl_constraint *constraint,
1683                 enum isl_dim_type type, int pos, int v);
1684         __isl_give isl_constraint *
1685         isl_constraint_set_coefficient_val(
1686                 __isl_take isl_constraint *constraint,
1687                 enum isl_dim_type type, int pos,
1688                 __isl_take isl_val *v);
1689         __isl_give isl_basic_map *isl_basic_map_add_constraint(
1690                 __isl_take isl_basic_map *bmap,
1691                 __isl_take isl_constraint *constraint);
1692         __isl_give isl_basic_set *isl_basic_set_add_constraint(
1693                 __isl_take isl_basic_set *bset,
1694                 __isl_take isl_constraint *constraint);
1695         __isl_give isl_map *isl_map_add_constraint(
1696                 __isl_take isl_map *map,
1697                 __isl_take isl_constraint *constraint);
1698         __isl_give isl_set *isl_set_add_constraint(
1699                 __isl_take isl_set *set,
1700                 __isl_take isl_constraint *constraint);
1701         __isl_give isl_basic_set *isl_basic_set_drop_constraint(
1702                 __isl_take isl_basic_set *bset,
1703                 __isl_take isl_constraint *constraint);
1705 For example, to create a set containing the even integers
1706 between 10 and 42, you would use the following code.
1708         isl_space *space;
1709         isl_local_space *ls;
1710         isl_constraint *c;
1711         isl_basic_set *bset;
1713         space = isl_space_set_alloc(ctx, 0, 2);
1714         bset = isl_basic_set_universe(isl_space_copy(space));
1715         ls = isl_local_space_from_space(space);
1717         c = isl_equality_alloc(isl_local_space_copy(ls));
1718         c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1719         c = isl_constraint_set_coefficient_si(c, isl_dim_set, 1, 2);
1720         bset = isl_basic_set_add_constraint(bset, c);
1722         c = isl_inequality_alloc(isl_local_space_copy(ls));
1723         c = isl_constraint_set_constant_si(c, -10);
1724         c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, 1);
1725         bset = isl_basic_set_add_constraint(bset, c);
1727         c = isl_inequality_alloc(ls);
1728         c = isl_constraint_set_constant_si(c, 42);
1729         c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1730         bset = isl_basic_set_add_constraint(bset, c);
1732         bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 1);
1734 Or, alternatively,
1736         isl_basic_set *bset;
1737         bset = isl_basic_set_read_from_str(ctx,
1738                 "{[i] : exists (a : i = 2a and i >= 10 and i <= 42)}");
1740 A basic set or relation can also be constructed from two matrices
1741 describing the equalities and the inequalities.
1743         __isl_give isl_basic_set *isl_basic_set_from_constraint_matrices(
1744                 __isl_take isl_space *space,
1745                 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1746                 enum isl_dim_type c1,
1747                 enum isl_dim_type c2, enum isl_dim_type c3,
1748                 enum isl_dim_type c4);
1749         __isl_give isl_basic_map *isl_basic_map_from_constraint_matrices(
1750                 __isl_take isl_space *space,
1751                 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1752                 enum isl_dim_type c1,
1753                 enum isl_dim_type c2, enum isl_dim_type c3,
1754                 enum isl_dim_type c4, enum isl_dim_type c5);
1756 The C<isl_dim_type> arguments indicate the order in which
1757 different kinds of variables appear in the input matrices
1758 and should be a permutation of C<isl_dim_cst>, C<isl_dim_param>,
1759 C<isl_dim_set> and C<isl_dim_div> for sets and
1760 of C<isl_dim_cst>, C<isl_dim_param>,
1761 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div> for relations.
1763 A (basic or union) set or relation can also be constructed from a
1764 (union) (piecewise) (multiple) affine expression
1765 or a list of affine expressions
1766 (See L</"Functions">).
1768         __isl_give isl_basic_map *isl_basic_map_from_aff(
1769                 __isl_take isl_aff *aff);
1770         __isl_give isl_map *isl_map_from_aff(
1771                 __isl_take isl_aff *aff);
1772         __isl_give isl_set *isl_set_from_pw_aff(
1773                 __isl_take isl_pw_aff *pwaff);
1774         __isl_give isl_map *isl_map_from_pw_aff(
1775                 __isl_take isl_pw_aff *pwaff);
1776         __isl_give isl_basic_map *isl_basic_map_from_aff_list(
1777                 __isl_take isl_space *domain_space,
1778                 __isl_take isl_aff_list *list);
1779         __isl_give isl_basic_map *isl_basic_map_from_multi_aff(
1780                 __isl_take isl_multi_aff *maff)
1781         __isl_give isl_map *isl_map_from_multi_aff(
1782                 __isl_take isl_multi_aff *maff)
1783         __isl_give isl_set *isl_set_from_pw_multi_aff(
1784                 __isl_take isl_pw_multi_aff *pma);
1785         __isl_give isl_map *isl_map_from_pw_multi_aff(
1786                 __isl_take isl_pw_multi_aff *pma);
1787         __isl_give isl_set *isl_set_from_multi_pw_aff(
1788                 __isl_take isl_multi_pw_aff *mpa);
1789         __isl_give isl_map *isl_map_from_multi_pw_aff(
1790                 __isl_take isl_multi_pw_aff *mpa);
1791         __isl_give isl_union_map *
1792         isl_union_map_from_union_pw_multi_aff(
1793                 __isl_take isl_union_pw_multi_aff *upma);
1795 The C<domain_space> argument describes the domain of the resulting
1796 basic relation.  It is required because the C<list> may consist
1797 of zero affine expressions.
1799 =head2 Inspecting Sets and Relations
1801 Usually, the user should not have to care about the actual constraints
1802 of the sets and maps, but should instead apply the abstract operations
1803 explained in the following sections.
1804 Occasionally, however, it may be required to inspect the individual
1805 coefficients of the constraints.  This section explains how to do so.
1806 In these cases, it may also be useful to have C<isl> compute
1807 an explicit representation of the existentially quantified variables.
1809         __isl_give isl_set *isl_set_compute_divs(
1810                 __isl_take isl_set *set);
1811         __isl_give isl_map *isl_map_compute_divs(
1812                 __isl_take isl_map *map);
1813         __isl_give isl_union_set *isl_union_set_compute_divs(
1814                 __isl_take isl_union_set *uset);
1815         __isl_give isl_union_map *isl_union_map_compute_divs(
1816                 __isl_take isl_union_map *umap);
1818 This explicit representation defines the existentially quantified
1819 variables as integer divisions of the other variables, possibly
1820 including earlier existentially quantified variables.
1821 An explicitly represented existentially quantified variable therefore
1822 has a unique value when the values of the other variables are known.
1823 If, furthermore, the same existentials, i.e., existentials
1824 with the same explicit representations, should appear in the
1825 same order in each of the disjuncts of a set or map, then the user should call
1826 either of the following functions.
1828         __isl_give isl_set *isl_set_align_divs(
1829                 __isl_take isl_set *set);
1830         __isl_give isl_map *isl_map_align_divs(
1831                 __isl_take isl_map *map);
1833 Alternatively, the existentially quantified variables can be removed
1834 using the following functions, which compute an overapproximation.
1836         __isl_give isl_basic_set *isl_basic_set_remove_divs(
1837                 __isl_take isl_basic_set *bset);
1838         __isl_give isl_basic_map *isl_basic_map_remove_divs(
1839                 __isl_take isl_basic_map *bmap);
1840         __isl_give isl_set *isl_set_remove_divs(
1841                 __isl_take isl_set *set);
1842         __isl_give isl_map *isl_map_remove_divs(
1843                 __isl_take isl_map *map);
1845 It is also possible to only remove those divs that are defined
1846 in terms of a given range of dimensions or only those for which
1847 no explicit representation is known.
1849         __isl_give isl_basic_set *
1850         isl_basic_set_remove_divs_involving_dims(
1851                 __isl_take isl_basic_set *bset,
1852                 enum isl_dim_type type,
1853                 unsigned first, unsigned n);
1854         __isl_give isl_basic_map *
1855         isl_basic_map_remove_divs_involving_dims(
1856                 __isl_take isl_basic_map *bmap,
1857                 enum isl_dim_type type,
1858                 unsigned first, unsigned n);
1859         __isl_give isl_set *isl_set_remove_divs_involving_dims(
1860                 __isl_take isl_set *set, enum isl_dim_type type,
1861                 unsigned first, unsigned n);
1862         __isl_give isl_map *isl_map_remove_divs_involving_dims(
1863                 __isl_take isl_map *map, enum isl_dim_type type,
1864                 unsigned first, unsigned n);
1866         __isl_give isl_basic_set *
1867         isl_basic_set_remove_unknown_divs(
1868                 __isl_take isl_basic_set *bset);
1869         __isl_give isl_set *isl_set_remove_unknown_divs(
1870                 __isl_take isl_set *set);
1871         __isl_give isl_map *isl_map_remove_unknown_divs(
1872                 __isl_take isl_map *map);
1874 To iterate over all the sets or maps in a union set or map, use
1876         int isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
1877                 int (*fn)(__isl_take isl_set *set, void *user),
1878                 void *user);
1879         int isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
1880                 int (*fn)(__isl_take isl_map *map, void *user),
1881                 void *user);
1883 The number of sets or maps in a union set or map can be obtained
1884 from
1886         int isl_union_set_n_set(__isl_keep isl_union_set *uset);
1887         int isl_union_map_n_map(__isl_keep isl_union_map *umap);
1889 To extract the set or map in a given space from a union, use
1891         __isl_give isl_set *isl_union_set_extract_set(
1892                 __isl_keep isl_union_set *uset,
1893                 __isl_take isl_space *space);
1894         __isl_give isl_map *isl_union_map_extract_map(
1895                 __isl_keep isl_union_map *umap,
1896                 __isl_take isl_space *space);
1898 To iterate over all the basic sets or maps in a set or map, use
1900         int isl_set_foreach_basic_set(__isl_keep isl_set *set,
1901                 int (*fn)(__isl_take isl_basic_set *bset, void *user),
1902                 void *user);
1903         int isl_map_foreach_basic_map(__isl_keep isl_map *map,
1904                 int (*fn)(__isl_take isl_basic_map *bmap, void *user),
1905                 void *user);
1907 The callback function C<fn> should return 0 if successful and
1908 -1 if an error occurs.  In the latter case, or if any other error
1909 occurs, the above functions will return -1.
1911 It should be noted that C<isl> does not guarantee that
1912 the basic sets or maps passed to C<fn> are disjoint.
1913 If this is required, then the user should call one of
1914 the following functions first.
1916         __isl_give isl_set *isl_set_make_disjoint(
1917                 __isl_take isl_set *set);
1918         __isl_give isl_map *isl_map_make_disjoint(
1919                 __isl_take isl_map *map);
1921 The number of basic sets in a set can be obtained
1922 or the number of basic maps in a map can be obtained
1923 from
1925         #include <isl/set.h>
1926         int isl_set_n_basic_set(__isl_keep isl_set *set);
1928         #include <isl/map.h>
1929         int isl_map_n_basic_map(__isl_keep isl_map *map);
1931 To iterate over the constraints of a basic set or map, use
1933         #include <isl/constraint.h>
1935         int isl_basic_set_n_constraint(
1936                 __isl_keep isl_basic_set *bset);
1937         int isl_basic_set_foreach_constraint(
1938                 __isl_keep isl_basic_set *bset,
1939                 int (*fn)(__isl_take isl_constraint *c, void *user),
1940                 void *user);
1941         int isl_basic_map_n_constraint(
1942                 __isl_keep isl_basic_map *bmap);
1943         int isl_basic_map_foreach_constraint(
1944                 __isl_keep isl_basic_map *bmap,
1945                 int (*fn)(__isl_take isl_constraint *c, void *user),
1946                 void *user);
1947         __isl_null isl_constraint *isl_constraint_free(
1948                 __isl_take isl_constraint *c);
1950 Again, the callback function C<fn> should return 0 if successful and
1951 -1 if an error occurs.  In the latter case, or if any other error
1952 occurs, the above functions will return -1.
1953 The constraint C<c> represents either an equality or an inequality.
1954 Use the following function to find out whether a constraint
1955 represents an equality.  If not, it represents an inequality.
1957         int isl_constraint_is_equality(
1958                 __isl_keep isl_constraint *constraint);
1960 It is also possible to obtain a list of constraints from a basic
1961 map or set
1963         #include <isl/constraint.h>
1964         __isl_give isl_constraint_list *
1965         isl_basic_map_get_constraint_list(
1966                 __isl_keep isl_basic_map *bmap);
1967         __isl_give isl_constraint_list *
1968         isl_basic_set_get_constraint_list(
1969                 __isl_keep isl_basic_set *bset);
1971 These functions require that all existentially quantified variables
1972 have an explicit representation.
1973 The returned list can be manipulated using the functions in L<"Lists">.
1975 The coefficients of the constraints can be inspected using
1976 the following functions.
1978         int isl_constraint_is_lower_bound(
1979                 __isl_keep isl_constraint *constraint,
1980                 enum isl_dim_type type, unsigned pos);
1981         int isl_constraint_is_upper_bound(
1982                 __isl_keep isl_constraint *constraint,
1983                 enum isl_dim_type type, unsigned pos);
1984         __isl_give isl_val *isl_constraint_get_constant_val(
1985                 __isl_keep isl_constraint *constraint);
1986         __isl_give isl_val *isl_constraint_get_coefficient_val(
1987                 __isl_keep isl_constraint *constraint,
1988                 enum isl_dim_type type, int pos);
1990 The explicit representations of the existentially quantified
1991 variables can be inspected using the following function.
1992 Note that the user is only allowed to use this function
1993 if the inspected set or map is the result of a call
1994 to C<isl_set_compute_divs> or C<isl_map_compute_divs>.
1995 The existentially quantified variable is equal to the floor
1996 of the returned affine expression.  The affine expression
1997 itself can be inspected using the functions in
1998 L</"Functions">.
2000         __isl_give isl_aff *isl_constraint_get_div(
2001                 __isl_keep isl_constraint *constraint, int pos);
2003 To obtain the constraints of a basic set or map in matrix
2004 form, use the following functions.
2006         __isl_give isl_mat *isl_basic_set_equalities_matrix(
2007                 __isl_keep isl_basic_set *bset,
2008                 enum isl_dim_type c1, enum isl_dim_type c2,
2009                 enum isl_dim_type c3, enum isl_dim_type c4);
2010         __isl_give isl_mat *isl_basic_set_inequalities_matrix(
2011                 __isl_keep isl_basic_set *bset,
2012                 enum isl_dim_type c1, enum isl_dim_type c2,
2013                 enum isl_dim_type c3, enum isl_dim_type c4);
2014         __isl_give isl_mat *isl_basic_map_equalities_matrix(
2015                 __isl_keep isl_basic_map *bmap,
2016                 enum isl_dim_type c1,
2017                 enum isl_dim_type c2, enum isl_dim_type c3,
2018                 enum isl_dim_type c4, enum isl_dim_type c5);
2019         __isl_give isl_mat *isl_basic_map_inequalities_matrix(
2020                 __isl_keep isl_basic_map *bmap,
2021                 enum isl_dim_type c1,
2022                 enum isl_dim_type c2, enum isl_dim_type c3,
2023                 enum isl_dim_type c4, enum isl_dim_type c5);
2025 The C<isl_dim_type> arguments dictate the order in which
2026 different kinds of variables appear in the resulting matrix.
2027 For set inputs, they should be a permutation of
2028 C<isl_dim_cst>, C<isl_dim_param>, C<isl_dim_set> and C<isl_dim_div>.
2029 For map inputs, they should be a permutation of
2030 C<isl_dim_cst>, C<isl_dim_param>,
2031 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div>.
2033 =head2 Points
2035 Points are elements of a set.  They can be used to construct
2036 simple sets (boxes) or they can be used to represent the
2037 individual elements of a set.
2038 The zero point (the origin) can be created using
2040         __isl_give isl_point *isl_point_zero(__isl_take isl_space *space);
2042 The coordinates of a point can be inspected, set and changed
2043 using
2045         __isl_give isl_val *isl_point_get_coordinate_val(
2046                 __isl_keep isl_point *pnt,
2047                 enum isl_dim_type type, int pos);
2048         __isl_give isl_point *isl_point_set_coordinate_val(
2049                 __isl_take isl_point *pnt,
2050                 enum isl_dim_type type, int pos,
2051                 __isl_take isl_val *v);
2053         __isl_give isl_point *isl_point_add_ui(
2054                 __isl_take isl_point *pnt,
2055                 enum isl_dim_type type, int pos, unsigned val);
2056         __isl_give isl_point *isl_point_sub_ui(
2057                 __isl_take isl_point *pnt,
2058                 enum isl_dim_type type, int pos, unsigned val);
2060 Points can be copied or freed using
2062         __isl_give isl_point *isl_point_copy(
2063                 __isl_keep isl_point *pnt);
2064         void isl_point_free(__isl_take isl_point *pnt);
2066 A singleton set can be created from a point using
2068         __isl_give isl_basic_set *isl_basic_set_from_point(
2069                 __isl_take isl_point *pnt);
2070         __isl_give isl_set *isl_set_from_point(
2071                 __isl_take isl_point *pnt);
2073 and a box can be created from two opposite extremal points using
2075         __isl_give isl_basic_set *isl_basic_set_box_from_points(
2076                 __isl_take isl_point *pnt1,
2077                 __isl_take isl_point *pnt2);
2078         __isl_give isl_set *isl_set_box_from_points(
2079                 __isl_take isl_point *pnt1,
2080                 __isl_take isl_point *pnt2);
2082 All elements of a B<bounded> (union) set can be enumerated using
2083 the following functions.
2085         int isl_set_foreach_point(__isl_keep isl_set *set,
2086                 int (*fn)(__isl_take isl_point *pnt, void *user),
2087                 void *user);
2088         int isl_union_set_foreach_point(__isl_keep isl_union_set *uset,
2089                 int (*fn)(__isl_take isl_point *pnt, void *user),
2090                 void *user);
2092 The function C<fn> is called for each integer point in
2093 C<set> with as second argument the last argument of
2094 the C<isl_set_foreach_point> call.  The function C<fn>
2095 should return C<0> on success and C<-1> on failure.
2096 In the latter case, C<isl_set_foreach_point> will stop
2097 enumerating and return C<-1> as well.
2098 If the enumeration is performed successfully and to completion,
2099 then C<isl_set_foreach_point> returns C<0>.
2101 To obtain a single point of a (basic) set, use
2103         __isl_give isl_point *isl_basic_set_sample_point(
2104                 __isl_take isl_basic_set *bset);
2105         __isl_give isl_point *isl_set_sample_point(
2106                 __isl_take isl_set *set);
2108 If C<set> does not contain any (integer) points, then the
2109 resulting point will be ``void'', a property that can be
2110 tested using
2112         int isl_point_is_void(__isl_keep isl_point *pnt);
2114 =head2 Functions
2116 Besides sets and relation, C<isl> also supports various types of functions.
2117 Each of these types is derived from the value type (see L</"Values">)
2118 or from one of two primitive function types
2119 through the application of zero or more type constructors.
2120 We first describe the primitive type and then we describe
2121 the types derived from these primitive types.
2123 =head3 Primitive Functions
2125 C<isl> support two primitive function types, quasi-affine
2126 expressions and quasipolynomials.
2127 A quasi-affine expression is defined either over a parameter
2128 space or over a set and is composed of integer constants,
2129 parameters and set variables, addition, subtraction and
2130 integer division by an integer constant.
2131 For example, the quasi-affine expression
2133         [n] -> { [x] -> [2*floor((4 n + x)/9] }
2135 maps C<x> to C<2*floor((4 n + x)/9>.
2136 A quasipolynomial is a polynomial expression in quasi-affine
2137 expression.  That is, it additionally allows for multiplication.
2138 Note, though, that it is not allowed to construct an integer
2139 division of an expression involving multiplications.
2140 Here is an example of a quasipolynomial that is not
2141 quasi-affine expression
2143         [n] -> { [x] -> (n*floor((4 n + x)/9) }
2145 Note that the external representations of quasi-affine expressions
2146 and quasipolynomials are different.  Quasi-affine expressions
2147 use a notation with square brackets just like binary relations,
2148 while quasipolynomials do not.  This might change at some point.
2150 If a primitive function is defined over a parameter space,
2151 then the space of the function itself is that of a set.
2152 If it is defined over a set, then the space of the function
2153 is that of a relation.  In both cases, the set space (or
2154 the output space) is single-dimensional, anonymous and unstructured.
2155 To create functions with multiple dimensions or with other kinds
2156 of set or output spaces, use multiple expressions
2157 (see L</"Multiple Expressions">).
2159 =over
2161 =item * Quasi-affine Expressions
2163 Besides the expressions described above, a quasi-affine
2164 expression can also be set to NaN.  Such expressions
2165 typically represent a failure to represent a result
2166 as a quasi-affine expression.
2168 The zero quasi affine expression or the quasi affine expression
2169 that is equal to a given value or
2170 a specified dimension on a given domain can be created using
2172         #include <isl/aff.h>
2173         __isl_give isl_aff *isl_aff_zero_on_domain(
2174                 __isl_take isl_local_space *ls);
2175         __isl_give isl_aff *isl_aff_val_on_domain(
2176                 __isl_take isl_local_space *ls,
2177                 __isl_take isl_val *val);
2178         __isl_give isl_aff *isl_aff_var_on_domain(
2179                 __isl_take isl_local_space *ls,
2180                 enum isl_dim_type type, unsigned pos);
2181         __isl_give isl_aff *isl_aff_nan_on_domain(
2182                 __isl_take isl_local_space *ls);
2184 Quasi affine expressions can be copied and freed using
2186         #include <isl/aff.h>
2187         __isl_give isl_aff *isl_aff_copy(
2188                 __isl_keep isl_aff *aff);
2189         __isl_null isl_aff *isl_aff_free(
2190                 __isl_take isl_aff *aff);
2192 A (rational) bound on a dimension can be extracted from an C<isl_constraint>
2193 using the following function.  The constraint is required to have
2194 a non-zero coefficient for the specified dimension.
2196         #include <isl/constraint.h>
2197         __isl_give isl_aff *isl_constraint_get_bound(
2198                 __isl_keep isl_constraint *constraint,
2199                 enum isl_dim_type type, int pos);
2201 The entire affine expression of the constraint can also be extracted
2202 using the following function.
2204         #include <isl/constraint.h>
2205         __isl_give isl_aff *isl_constraint_get_aff(
2206                 __isl_keep isl_constraint *constraint);
2208 Conversely, an equality constraint equating
2209 the affine expression to zero or an inequality constraint enforcing
2210 the affine expression to be non-negative, can be constructed using
2212         __isl_give isl_constraint *isl_equality_from_aff(
2213                 __isl_take isl_aff *aff);
2214         __isl_give isl_constraint *isl_inequality_from_aff(
2215                 __isl_take isl_aff *aff);
2217 The coefficients and the integer divisions of an affine expression
2218 can be inspected using the following functions.
2220         #include <isl/aff.h>
2221         __isl_give isl_val *isl_aff_get_constant_val(
2222                 __isl_keep isl_aff *aff);
2223         __isl_give isl_val *isl_aff_get_coefficient_val(
2224                 __isl_keep isl_aff *aff,
2225                 enum isl_dim_type type, int pos);
2226         int isl_aff_coefficient_sgn(__isl_keep isl_aff *aff,
2227                 enum isl_dim_type type, int pos);
2228         __isl_give isl_val *isl_aff_get_denominator_val(
2229                 __isl_keep isl_aff *aff);
2230         __isl_give isl_aff *isl_aff_get_div(
2231                 __isl_keep isl_aff *aff, int pos);
2233 They can be modified using the following functions.
2235         #include <isl/aff.h>
2236         __isl_give isl_aff *isl_aff_set_constant_si(
2237                 __isl_take isl_aff *aff, int v);
2238         __isl_give isl_aff *isl_aff_set_constant_val(
2239                 __isl_take isl_aff *aff, __isl_take isl_val *v);
2240         __isl_give isl_aff *isl_aff_set_coefficient_si(
2241                 __isl_take isl_aff *aff,
2242                 enum isl_dim_type type, int pos, int v);
2243         __isl_give isl_aff *isl_aff_set_coefficient_val(
2244                 __isl_take isl_aff *aff,
2245                 enum isl_dim_type type, int pos,
2246                 __isl_take isl_val *v);
2248         __isl_give isl_aff *isl_aff_add_constant_si(
2249                 __isl_take isl_aff *aff, int v);
2250         __isl_give isl_aff *isl_aff_add_constant_val(
2251                 __isl_take isl_aff *aff, __isl_take isl_val *v);
2252         __isl_give isl_aff *isl_aff_add_constant_num_si(
2253                 __isl_take isl_aff *aff, int v);
2254         __isl_give isl_aff *isl_aff_add_coefficient_si(
2255                 __isl_take isl_aff *aff,
2256                 enum isl_dim_type type, int pos, int v);
2257         __isl_give isl_aff *isl_aff_add_coefficient_val(
2258                 __isl_take isl_aff *aff,
2259                 enum isl_dim_type type, int pos,
2260                 __isl_take isl_val *v);
2262 Note that C<isl_aff_set_constant_si> and C<isl_aff_set_coefficient_si>
2263 set the I<numerator> of the constant or coefficient, while
2264 C<isl_aff_set_constant_val> and C<isl_aff_set_coefficient_val> set
2265 the constant or coefficient as a whole.
2266 The C<add_constant> and C<add_coefficient> functions add an integer
2267 or rational value to
2268 the possibly rational constant or coefficient.
2269 The C<add_constant_num> functions add an integer value to
2270 the numerator.
2272 =item * Quasipolynomials
2274 Some simple quasipolynomials can be created using the following functions.
2276         #include <isl/polynomial.h>
2277         __isl_give isl_qpolynomial *isl_qpolynomial_zero_on_domain(
2278                 __isl_take isl_space *domain);
2279         __isl_give isl_qpolynomial *isl_qpolynomial_one_on_domain(
2280                 __isl_take isl_space *domain);
2281         __isl_give isl_qpolynomial *isl_qpolynomial_infty_on_domain(
2282                 __isl_take isl_space *domain);
2283         __isl_give isl_qpolynomial *isl_qpolynomial_neginfty_on_domain(
2284                 __isl_take isl_space *domain);
2285         __isl_give isl_qpolynomial *isl_qpolynomial_nan_on_domain(
2286                 __isl_take isl_space *domain);
2287         __isl_give isl_qpolynomial *isl_qpolynomial_val_on_domain(
2288                 __isl_take isl_space *domain,
2289                 __isl_take isl_val *val);
2290         __isl_give isl_qpolynomial *isl_qpolynomial_var_on_domain(
2291                 __isl_take isl_space *domain,
2292                 enum isl_dim_type type, unsigned pos);
2293         __isl_give isl_qpolynomial *isl_qpolynomial_from_aff(
2294                 __isl_take isl_aff *aff);
2296 Recall that the space in which a quasipolynomial lives is a map space
2297 with a one-dimensional range.  The C<domain> argument in some of
2298 the functions above corresponds to the domain of this map space.
2300 Quasipolynomials can be copied and freed again using the following
2301 functions.
2303         #include <isl/polynomial.h>
2304         __isl_give isl_qpolynomial *isl_qpolynomial_copy(
2305                 __isl_keep isl_qpolynomial *qp);
2306         __isl_null isl_qpolynomial *isl_qpolynomial_free(
2307                 __isl_take isl_qpolynomial *qp);
2309 The constant term of a quasipolynomial can be extracted using
2311         __isl_give isl_val *isl_qpolynomial_get_constant_val(
2312                 __isl_keep isl_qpolynomial *qp);
2314 To iterate over all terms in a quasipolynomial,
2317         int isl_qpolynomial_foreach_term(
2318                 __isl_keep isl_qpolynomial *qp,
2319                 int (*fn)(__isl_take isl_term *term,
2320                           void *user), void *user);
2322 The terms themselves can be inspected and freed using
2323 these functions
2325         unsigned isl_term_dim(__isl_keep isl_term *term,
2326                 enum isl_dim_type type);
2327         __isl_give isl_val *isl_term_get_coefficient_val(
2328                 __isl_keep isl_term *term);
2329         int isl_term_get_exp(__isl_keep isl_term *term,
2330                 enum isl_dim_type type, unsigned pos);
2331         __isl_give isl_aff *isl_term_get_div(
2332                 __isl_keep isl_term *term, unsigned pos);
2333         void isl_term_free(__isl_take isl_term *term);
2335 Each term is a product of parameters, set variables and
2336 integer divisions.  The function C<isl_term_get_exp>
2337 returns the exponent of a given dimensions in the given term.
2339 =back
2341 =head3 Reductions
2343 A reduction represents a maximum or a minimum of its
2344 base expressions.
2345 The only reduction type defined by C<isl> is
2346 C<isl_qpolynomial_fold>.
2348 There are currently no functions to directly create such
2349 objects, but they do appear in the piecewise quasipolynomial
2350 reductions returned by the C<isl_pw_qpolynomial_bound> function.
2352 L</"Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions">.
2354 Reductions can be copied and freed using
2355 the following functions.
2357         #include <isl/polynomial.h>
2358         __isl_give isl_qpolynomial_fold *
2359         isl_qpolynomial_fold_copy(
2360                 __isl_keep isl_qpolynomial_fold *fold);
2361         void isl_qpolynomial_fold_free(
2362                 __isl_take isl_qpolynomial_fold *fold);
2364 To iterate over all quasipolynomials in a reduction, use
2366         int isl_qpolynomial_fold_foreach_qpolynomial(
2367                 __isl_keep isl_qpolynomial_fold *fold,
2368                 int (*fn)(__isl_take isl_qpolynomial *qp,
2369                           void *user), void *user);
2371 =head3 Multiple Expressions
2373 A multiple expression represents a sequence of zero or
2374 more base expressions, all defined on the same domain space.
2375 The domain space of the multiple expression is the same
2376 as that of the base expressions, but the range space
2377 can be any space.  In case the base expressions have
2378 a set space, the corresponding multiple expression
2379 also has a set space.
2380 Objects of the value type do not have an associated space.
2381 The space of a multiple value is therefore always a set space.
2383 The multiple expression types defined by C<isl>
2384 are C<isl_multi_val>, C<isl_multi_aff> and C<isl_multi_pw_aff>.
2386 A multiple expression with the value zero for
2387 each output (or set) dimension can be created
2388 using the following functions.
2390         #include <isl/val.h>
2391         __isl_give isl_multi_val *isl_multi_val_zero(
2392                 __isl_take isl_space *space);
2394         #include <isl/aff.h>
2395         __isl_give isl_multi_aff *isl_multi_aff_zero(
2396                 __isl_take isl_space *space);
2397         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_zero(
2398                 __isl_take isl_space *space);
2400 An identity function can be created using the following
2401 functions.  The space needs to be that of a relation
2402 with the same number of input and output dimensions.
2404         #include <isl/aff.h>
2405         __isl_give isl_multi_aff *isl_multi_aff_identity(
2406                 __isl_take isl_space *space);
2407         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_identity(
2408                 __isl_take isl_space *space);
2410 A function that performs a projection on a universe
2411 relation or set can be created using the following functions.
2412 See also the corresponding
2413 projection operations in L</"Unary Operations">.
2415         #include <isl/aff.h>
2416         __isl_give isl_multi_aff *isl_multi_aff_domain_map(
2417                 __isl_take isl_space *space);
2418         __isl_give isl_multi_aff *isl_multi_aff_range_map(
2419                 __isl_take isl_space *space);
2420         __isl_give isl_multi_aff *isl_multi_aff_project_out_map(
2421                 __isl_take isl_space *space,
2422                 enum isl_dim_type type,
2423                 unsigned first, unsigned n);
2425 A multiple expression can be created from a single
2426 base expression using the following functions.
2427 The space of the created multiple expression is the same
2428 as that of the base expression.
2430         #include <isl/aff.h>
2431         __isl_give isl_multi_aff *isl_multi_aff_from_aff(
2432                 __isl_take isl_aff *aff);
2433         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_aff(
2434                 __isl_take isl_pw_aff *pa);
2436 A multiple expression can be created from a list
2437 of base expression in a specified space.
2438 The domain of this space needs to be the same
2439 as the domains of the base expressions in the list.
2440 If the base expressions have a set space (or no associated space),
2441 then this space also needs to be a set space.
2443         #include <isl/val.h>
2444         __isl_give isl_multi_val *isl_multi_val_from_val_list(
2445                 __isl_take isl_space *space,
2446                 __isl_take isl_val_list *list);
2448         #include <isl/aff.h>
2449         __isl_give isl_multi_aff *isl_multi_aff_from_aff_list(
2450                 __isl_take isl_space *space,
2451                 __isl_take isl_aff_list *list);
2453 As a convenience, a multiple piecewise expression can
2454 also be created from a multiple expression.
2455 Each piecewise expression in the result has a single
2456 universe cell.
2458         #include <isl/aff.h>
2459         __isl_give isl_multi_pw_aff *
2460         isl_multi_pw_aff_from_multi_aff(
2461                 __isl_take isl_multi_aff *ma);
2463 Multiple expressions can be copied and freed using
2464 the following functions.
2466         #include <isl/val.h>
2467         __isl_give isl_multi_val *isl_multi_val_copy(
2468                 __isl_keep isl_multi_val *mv);
2469         __isl_null isl_multi_val *isl_multi_val_free(
2470                 __isl_take isl_multi_val *mv);
2472         #include <isl/aff.h>
2473         __isl_give isl_multi_aff *isl_multi_aff_copy(
2474                 __isl_keep isl_multi_aff *maff);
2475         __isl_null isl_multi_aff *isl_multi_aff_free(
2476                 __isl_take isl_multi_aff *maff);
2477         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_copy(
2478                 __isl_keep isl_multi_pw_aff *mpa);
2479         __isl_null isl_multi_pw_aff *isl_multi_pw_aff_free(
2480                 __isl_take isl_multi_pw_aff *mpa);
2482 The base expression at a given position of a multiple
2483 expression can be extracted using the following functions.
2485         #include <isl/val.h>
2486         __isl_give isl_val *isl_multi_val_get_val(
2487                 __isl_keep isl_multi_val *mv, int pos);
2489         #include <isl/aff.h>
2490         __isl_give isl_aff *isl_multi_aff_get_aff(
2491                 __isl_keep isl_multi_aff *multi, int pos);
2492         __isl_give isl_pw_aff *isl_multi_pw_aff_get_pw_aff(
2493                 __isl_keep isl_multi_pw_aff *mpa, int pos);
2495 It can be replaced using the following functions.
2497         #include <isl/val.h>
2498         __isl_give isl_multi_val *isl_multi_val_set_val(
2499                 __isl_take isl_multi_val *mv, int pos,
2500                 __isl_take isl_val *val);
2502         #include <isl/aff.h>
2503         __isl_give isl_multi_aff *isl_multi_aff_set_aff(
2504                 __isl_take isl_multi_aff *multi, int pos,
2505                 __isl_take isl_aff *aff);
2507 =head3 Piecewise Expressions
2509 A piecewise expression is an expression that is described
2510 using zero or more base expression defined over the same
2511 number of cells in the domain space of the base expressions.
2512 All base expressions are defined over the same
2513 domain space and the cells are disjoint.
2514 The space of a piecewise expression is the same as
2515 that of the base expressions.
2516 If the union of the cells is a strict subset of the domain
2517 space, then the value of the piecewise expression outside
2518 this union is different for types derived from quasi-affine
2519 expressions and those derived from quasipolynomials.
2520 Piecewise expressions derived from quasi-affine expressions
2521 are considered to be undefined outside the union of their cells.
2522 Piecewise expressions derived from quasipolynomials
2523 are considered to be zero outside the union of their cells.
2525 Piecewise quasipolynomials are mainly used by the C<barvinok>
2526 library for representing the number of elements in a parametric set or map.
2527 For example, the piecewise quasipolynomial
2529         [n] -> { [x] -> ((1 + n) - x) : x <= n and x >= 0 }
2531 represents the number of points in the map
2533         [n] -> { [x] -> [y] : x,y >= 0 and 0 <= x + y <= n }
2535 The piecewise expression types defined by C<isl>
2536 are C<isl_pw_aff>, C<isl_pw_multi_aff>,
2537 C<isl_pw_qpolynomial> and C<isl_pw_qpolynomial_fold>.
2539 A piecewise expression with no cells can be created using
2540 the following functions.
2542         #include <isl/aff.h>
2543         __isl_give isl_pw_aff *isl_pw_aff_empty(
2544                 __isl_take isl_space *space);
2545         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_empty(
2546                 __isl_take isl_space *space);
2548 A piecewise expression with a single universe cell can be
2549 created using the following functions.
2551         #include <isl/aff.h>
2552         __isl_give isl_pw_aff *isl_pw_aff_from_aff(
2553                 __isl_take isl_aff *aff);
2554         __isl_give isl_pw_multi_aff *
2555         isl_pw_multi_aff_from_multi_aff(
2556                 __isl_take isl_multi_aff *ma);
2558         #include <isl/polynomial.h>
2559         __isl_give isl_pw_qpolynomial *
2560         isl_pw_qpolynomial_from_qpolynomial(
2561                 __isl_take isl_qpolynomial *qp);
2563 A piecewise expression with a single specified cell can be
2564 created using the following functions.
2566         #include <isl/aff.h>
2567         __isl_give isl_pw_aff *isl_pw_aff_alloc(
2568                 __isl_take isl_set *set, __isl_take isl_aff *aff);
2569         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_alloc(
2570                 __isl_take isl_set *set,
2571                 __isl_take isl_multi_aff *maff);
2573         #include <isl/polynomial.h>
2574         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_alloc(
2575                 __isl_take isl_set *set,
2576                 __isl_take isl_qpolynomial *qp);
2578 The following convenience functions first create a base expression and
2579 then create a piecewise expression over a universe domain.
2581         #include <isl/aff.h>
2582         __isl_give isl_pw_aff *isl_pw_aff_zero_on_domain(
2583                 __isl_take isl_local_space *ls);
2584         __isl_give isl_pw_aff *isl_pw_aff_var_on_domain(
2585                 __isl_take isl_local_space *ls,
2586                 enum isl_dim_type type, unsigned pos);
2587         __isl_give isl_pw_aff *isl_pw_aff_nan_on_domain(
2588                 __isl_take isl_local_space *ls);
2589         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_zero(
2590                 __isl_take isl_space *space);
2591         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_identity(
2592                 __isl_take isl_space *space);
2593         __isl_give isl_pw_multi_aff *
2594         isl_pw_multi_aff_project_out_map(
2595                 __isl_take isl_space *space,
2596                 enum isl_dim_type type,
2597                 unsigned first, unsigned n);
2599         #include <isl/polynomial.h>
2600         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero(
2601                 __isl_take isl_space *space);
2603 As a convenience, a piecewise multiple expression can
2604 also be created from a piecewise expression.
2605 Each multiple expression in the result is derived
2606 from the corresponding base expression.
2608         #include <isl/aff.h>
2609         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_pw_aff(
2610                 __isl_take isl_pw_aff *pa);
2612 Similarly, a piecewise quasipolynomial can be
2613 created from a piecewise quasi-affine expression using
2614 the following function.
2616         #include <isl/polynomial.h>
2617         __isl_give isl_pw_qpolynomial *
2618         isl_pw_qpolynomial_from_pw_aff(
2619                 __isl_take isl_pw_aff *pwaff);
2621 Piecewise expressions can be copied and freed using the following functions.
2623         #include <isl/aff.h>
2624         __isl_give isl_pw_aff *isl_pw_aff_copy(
2625                 __isl_keep isl_pw_aff *pwaff);
2626         __isl_null isl_pw_aff *isl_pw_aff_free(
2627                 __isl_take isl_pw_aff *pwaff);
2628         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_copy(
2629                 __isl_keep isl_pw_multi_aff *pma);
2630         __isl_null isl_pw_multi_aff *isl_pw_multi_aff_free(
2631                 __isl_take isl_pw_multi_aff *pma);
2633         #include <isl/polynomial.h>
2634         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy(
2635                 __isl_keep isl_pw_qpolynomial *pwqp);
2636         __isl_null isl_pw_qpolynomial *isl_pw_qpolynomial_free(
2637                 __isl_take isl_pw_qpolynomial *pwqp);
2638         __isl_give isl_pw_qpolynomial_fold *
2639         isl_pw_qpolynomial_fold_copy(
2640                 __isl_keep isl_pw_qpolynomial_fold *pwf);
2641         __isl_null isl_pw_qpolynomial_fold *
2642         isl_pw_qpolynomial_fold_free(
2643                 __isl_take isl_pw_qpolynomial_fold *pwf);
2645 To iterate over the different cells of a piecewise expression,
2646 use the following functions.
2648         #include <isl/aff.h>
2649         int isl_pw_aff_is_empty(__isl_keep isl_pw_aff *pwaff);
2650         int isl_pw_aff_n_piece(__isl_keep isl_pw_aff *pwaff);
2651         int isl_pw_aff_foreach_piece(__isl_keep isl_pw_aff *pwaff,
2652                 int (*fn)(__isl_take isl_set *set,
2653                           __isl_take isl_aff *aff,
2654                           void *user), void *user);
2655         int isl_pw_multi_aff_foreach_piece(
2656                 __isl_keep isl_pw_multi_aff *pma,
2657                 int (*fn)(__isl_take isl_set *set,
2658                             __isl_take isl_multi_aff *maff,
2659                             void *user), void *user);
2661         #include <isl/polynomial.h>
2662         int isl_pw_qpolynomial_foreach_piece(
2663                 __isl_keep isl_pw_qpolynomial *pwqp,
2664                 int (*fn)(__isl_take isl_set *set,
2665                           __isl_take isl_qpolynomial *qp,
2666                           void *user), void *user);
2667         int isl_pw_qpolynomial_foreach_lifted_piece(
2668                 __isl_keep isl_pw_qpolynomial *pwqp,
2669                 int (*fn)(__isl_take isl_set *set,
2670                           __isl_take isl_qpolynomial *qp,
2671                           void *user), void *user);
2672         int isl_pw_qpolynomial_fold_foreach_piece(
2673                 __isl_keep isl_pw_qpolynomial_fold *pwf,
2674                 int (*fn)(__isl_take isl_set *set,
2675                           __isl_take isl_qpolynomial_fold *fold,
2676                           void *user), void *user);
2677         int isl_pw_qpolynomial_fold_foreach_lifted_piece(
2678                 __isl_keep isl_pw_qpolynomial_fold *pwf,
2679                 int (*fn)(__isl_take isl_set *set,
2680                           __isl_take isl_qpolynomial_fold *fold,
2681                           void *user), void *user);
2683 As usual, the function C<fn> should return C<0> on success
2684 and C<-1> on failure.  The difference between
2685 C<isl_pw_qpolynomial_foreach_piece> and
2686 C<isl_pw_qpolynomial_foreach_lifted_piece> is that
2687 C<isl_pw_qpolynomial_foreach_lifted_piece> will first
2688 compute unique representations for all existentially quantified
2689 variables and then turn these existentially quantified variables
2690 into extra set variables, adapting the associated quasipolynomial
2691 accordingly.  This means that the C<set> passed to C<fn>
2692 will not have any existentially quantified variables, but that
2693 the dimensions of the sets may be different for different
2694 invocations of C<fn>.
2695 Similarly for C<isl_pw_qpolynomial_fold_foreach_piece>
2696 and C<isl_pw_qpolynomial_fold_foreach_lifted_piece>.
2698 A piecewise expression consisting of the expressions at a given
2699 position of a piecewise multiple expression can be extracted
2700 using the following function.
2702         #include <isl/aff.h>
2703         __isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff(
2704                 __isl_keep isl_pw_multi_aff *pma, int pos);
2706 These expressions can be replaced using the following function.
2708         #include <isl/aff.h>
2709         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_pw_aff(
2710                 __isl_take isl_pw_multi_aff *pma, unsigned pos,
2711                 __isl_take isl_pw_aff *pa);
2713 Note that there is a difference between C<isl_multi_pw_aff> and
2714 C<isl_pw_multi_aff> objects.  The first is a sequence of piecewise
2715 affine expressions, while the second is a piecewise sequence
2716 of affine expressions.  In particular, each of the piecewise
2717 affine expressions in an C<isl_multi_pw_aff> may have a different
2718 domain, while all multiple expressions associated to a cell
2719 in an C<isl_pw_multi_aff> have the same domain.
2720 It is possible to convert between the two, but when converting
2721 an C<isl_multi_pw_aff> to an C<isl_pw_multi_aff>, the domain
2722 of the result is the intersection of the domains of the input.
2723 The reverse conversion is exact.
2725         #include <isl/aff.h>
2726         __isl_give isl_pw_multi_aff *
2727         isl_pw_multi_aff_from_multi_pw_aff(
2728                 __isl_take isl_multi_pw_aff *mpa);
2729         __isl_give isl_multi_pw_aff *
2730         isl_multi_pw_aff_from_pw_multi_aff(
2731                 __isl_take isl_pw_multi_aff *pma);
2733 =head3 Union Expressions
2735 A union expression collects base expressions defined
2736 over different domains.  The space of a union expression
2737 is that of the shared parameter space.
2739 The union expression types defined by C<isl>
2740 are C<isl_union_pw_multi_aff>, C<isl_union_pw_qpolynomial> and
2741 C<isl_union_pw_qpolynomial_fold>.
2743 An empty union expression can be created using the following functions.
2745         #include <isl/aff.h>
2746         __isl_give isl_union_pw_multi_aff *
2747         isl_union_pw_multi_aff_empty(
2748                 __isl_take isl_space *space);
2750         #include <isl/polynomial.h>
2751         __isl_give isl_union_pw_qpolynomial *
2752         isl_union_pw_qpolynomial_zero(
2753                 __isl_take isl_space *space);
2755 A union expression containing a single base expression
2756 can be created using the following functions.
2758         #include <isl/aff.h>
2759         __isl_give isl_union_pw_multi_aff *
2760         isl_union_pw_multi_aff_from_pw_multi_aff(
2761                 __isl_take isl_pw_multi_aff *pma);
2763         #include <isl/polynomial.h>
2764         __isl_give isl_union_pw_qpolynomial *
2765         isl_union_pw_qpolynomial_from_pw_qpolynomial(
2766                 __isl_take isl_pw_qpolynomial *pwqp);
2768 A base expression can be added to a union expression using
2769 the following functions.
2771         #include <isl/aff.h>
2772         __isl_give isl_union_pw_multi_aff *
2773         isl_union_pw_multi_aff_add_pw_multi_aff(
2774                 __isl_take isl_union_pw_multi_aff *upma,
2775                 __isl_take isl_pw_multi_aff *pma);
2777         #include <isl/polynomial.h>
2778         __isl_give isl_union_pw_qpolynomial *
2779         isl_union_pw_qpolynomial_add_pw_qpolynomial(
2780                 __isl_take isl_union_pw_qpolynomial *upwqp,
2781                 __isl_take isl_pw_qpolynomial *pwqp);
2783 Union expressions can be copied and freed using
2784 the following functions.
2786         #include <isl/aff.h>
2787         __isl_give isl_union_pw_multi_aff *
2788         isl_union_pw_multi_aff_copy(
2789                 __isl_keep isl_union_pw_multi_aff *upma);
2790         __isl_null isl_union_pw_multi_aff *
2791         isl_union_pw_multi_aff_free(
2792                 __isl_take isl_union_pw_multi_aff *upma);
2794         #include <isl/polynomial.h>
2795         __isl_give isl_union_pw_qpolynomial *
2796         isl_union_pw_qpolynomial_copy(
2797                 __isl_keep isl_union_pw_qpolynomial *upwqp);
2798         __isl_null isl_union_pw_qpolynomial *
2799         isl_union_pw_qpolynomial_free(
2800                 __isl_take isl_union_pw_qpolynomial *upwqp);
2801         __isl_give isl_union_pw_qpolynomial_fold *
2802         isl_union_pw_qpolynomial_fold_copy(
2803                 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
2804         __isl_null isl_union_pw_qpolynomial_fold *
2805         isl_union_pw_qpolynomial_fold_free(
2806                 __isl_take isl_union_pw_qpolynomial_fold *upwf);
2808 To iterate over the base expressions in a union expression,
2809 use the following functions.
2811         #include <isl/aff.h>
2812         int isl_union_pw_multi_aff_foreach_pw_multi_aff(
2813                 __isl_keep isl_union_pw_multi_aff *upma,
2814                 int (*fn)(__isl_take isl_pw_multi_aff *pma,
2815                             void *user), void *user);
2817         #include <isl/polynomial.h>
2818         int isl_union_pw_qpolynomial_foreach_pw_qpolynomial(
2819                 __isl_keep isl_union_pw_qpolynomial *upwqp,
2820                 int (*fn)(__isl_take isl_pw_qpolynomial *pwqp,
2821                             void *user), void *user);
2822         int isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(
2823                 __isl_keep isl_union_pw_qpolynomial_fold *upwf,
2824                 int (*fn)(__isl_take isl_pw_qpolynomial_fold *pwf,
2825                             void *user), void *user);
2827 To extract the base expression in a given space from a union, use
2828 the following functions.
2830         #include <isl/aff.h>
2831         __isl_give isl_pw_multi_aff *
2832         isl_union_pw_multi_aff_extract_pw_multi_aff(
2833                 __isl_keep isl_union_pw_multi_aff *upma,
2834                 __isl_take isl_space *space);
2836         #include <isl/polynomial.h>
2837         __isl_give isl_pw_qpolynomial *
2838         isl_union_pw_qpolynomial_extract_pw_qpolynomial(
2839                 __isl_keep isl_union_pw_qpolynomial *upwqp,
2840                 __isl_take isl_space *space);
2842 =head2 Input and Output
2844 For set and relation,
2845 C<isl> supports its own input/output format, which is similar
2846 to the C<Omega> format, but also supports the C<PolyLib> format
2847 in some cases.
2848 For other object types, typically only an C<isl> format is supported.
2850 =head3 C<isl> format
2852 The C<isl> format is similar to that of C<Omega>, but has a different
2853 syntax for describing the parameters and allows for the definition
2854 of an existentially quantified variable as the integer division
2855 of an affine expression.
2856 For example, the set of integers C<i> between C<0> and C<n>
2857 such that C<i % 10 <= 6> can be described as
2859         [n] -> { [i] : exists (a = [i/10] : 0 <= i and i <= n and
2860                                 i - 10 a <= 6) }
2862 A set or relation can have several disjuncts, separated
2863 by the keyword C<or>.  Each disjunct is either a conjunction
2864 of constraints or a projection (C<exists>) of a conjunction
2865 of constraints.  The constraints are separated by the keyword
2866 C<and>.
2868 =head3 C<PolyLib> format
2870 If the represented set is a union, then the first line
2871 contains a single number representing the number of disjuncts.
2872 Otherwise, a line containing the number C<1> is optional.
2874 Each disjunct is represented by a matrix of constraints.
2875 The first line contains two numbers representing
2876 the number of rows and columns,
2877 where the number of rows is equal to the number of constraints
2878 and the number of columns is equal to two plus the number of variables.
2879 The following lines contain the actual rows of the constraint matrix.
2880 In each row, the first column indicates whether the constraint
2881 is an equality (C<0>) or inequality (C<1>).  The final column
2882 corresponds to the constant term.
2884 If the set is parametric, then the coefficients of the parameters
2885 appear in the last columns before the constant column.
2886 The coefficients of any existentially quantified variables appear
2887 between those of the set variables and those of the parameters.
2889 =head3 Extended C<PolyLib> format
2891 The extended C<PolyLib> format is nearly identical to the
2892 C<PolyLib> format.  The only difference is that the line
2893 containing the number of rows and columns of a constraint matrix
2894 also contains four additional numbers:
2895 the number of output dimensions, the number of input dimensions,
2896 the number of local dimensions (i.e., the number of existentially
2897 quantified variables) and the number of parameters.
2898 For sets, the number of ``output'' dimensions is equal
2899 to the number of set dimensions, while the number of ``input''
2900 dimensions is zero.
2902 =head3 Input
2904 Objects can be read from input using the following functions.
2906         #include <isl/val.h>
2907         __isl_give isl_val *isl_val_read_from_str(isl_ctx *ctx,
2908                 const char *str);
2910         #include <isl/set.h>
2911         __isl_give isl_basic_set *isl_basic_set_read_from_file(
2912                 isl_ctx *ctx, FILE *input);
2913         __isl_give isl_basic_set *isl_basic_set_read_from_str(
2914                 isl_ctx *ctx, const char *str);
2915         __isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx,
2916                 FILE *input);
2917         __isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx,
2918                 const char *str);
2920         #include <isl/map.h>
2921         __isl_give isl_basic_map *isl_basic_map_read_from_file(
2922                 isl_ctx *ctx, FILE *input);
2923         __isl_give isl_basic_map *isl_basic_map_read_from_str(
2924                 isl_ctx *ctx, const char *str);
2925         __isl_give isl_map *isl_map_read_from_file(
2926                 isl_ctx *ctx, FILE *input);
2927         __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx,
2928                 const char *str);
2930         #include <isl/union_set.h>
2931         __isl_give isl_union_set *isl_union_set_read_from_file(
2932                 isl_ctx *ctx, FILE *input);
2933         __isl_give isl_union_set *isl_union_set_read_from_str(
2934                 isl_ctx *ctx, const char *str);
2936         #include <isl/union_map.h>
2937         __isl_give isl_union_map *isl_union_map_read_from_file(
2938                 isl_ctx *ctx, FILE *input);
2939         __isl_give isl_union_map *isl_union_map_read_from_str(
2940                 isl_ctx *ctx, const char *str);
2942         #include <isl/aff.h>
2943         __isl_give isl_aff *isl_aff_read_from_str(
2944                 isl_ctx *ctx, const char *str);
2945         __isl_give isl_multi_aff *isl_multi_aff_read_from_str(
2946                 isl_ctx *ctx, const char *str);
2947         __isl_give isl_pw_aff *isl_pw_aff_read_from_str(
2948                 isl_ctx *ctx, const char *str);
2949         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str(
2950                 isl_ctx *ctx, const char *str);
2951         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_read_from_str(
2952                 isl_ctx *ctx, const char *str);
2953         __isl_give isl_union_pw_multi_aff *
2954         isl_union_pw_multi_aff_read_from_str(
2955                 isl_ctx *ctx, const char *str);
2957         #include <isl/polynomial.h>
2958         __isl_give isl_union_pw_qpolynomial *
2959         isl_union_pw_qpolynomial_read_from_str(
2960                 isl_ctx *ctx, const char *str);
2962 For sets and relations,
2963 the input format is autodetected and may be either the C<PolyLib> format
2964 or the C<isl> format.
2966 =head3 Output
2968 Before anything can be printed, an C<isl_printer> needs to
2969 be created.
2971         __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx,
2972                 FILE *file);
2973         __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx);
2974         __isl_null isl_printer *isl_printer_free(
2975                 __isl_take isl_printer *printer);
2976         __isl_give char *isl_printer_get_str(
2977                 __isl_keep isl_printer *printer);
2979 The printer can be inspected using the following functions.
2981         FILE *isl_printer_get_file(
2982                 __isl_keep isl_printer *printer);
2983         int isl_printer_get_output_format(
2984                 __isl_keep isl_printer *p);
2986 The behavior of the printer can be modified in various ways
2988         __isl_give isl_printer *isl_printer_set_output_format(
2989                 __isl_take isl_printer *p, int output_format);
2990         __isl_give isl_printer *isl_printer_set_indent(
2991                 __isl_take isl_printer *p, int indent);
2992         __isl_give isl_printer *isl_printer_set_indent_prefix(
2993                 __isl_take isl_printer *p, const char *prefix);
2994         __isl_give isl_printer *isl_printer_indent(
2995                 __isl_take isl_printer *p, int indent);
2996         __isl_give isl_printer *isl_printer_set_prefix(
2997                 __isl_take isl_printer *p, const char *prefix);
2998         __isl_give isl_printer *isl_printer_set_suffix(
2999                 __isl_take isl_printer *p, const char *suffix);
3001 The C<output_format> may be either C<ISL_FORMAT_ISL>, C<ISL_FORMAT_OMEGA>,
3002 C<ISL_FORMAT_POLYLIB>, C<ISL_FORMAT_EXT_POLYLIB> or C<ISL_FORMAT_LATEX>
3003 and defaults to C<ISL_FORMAT_ISL>.
3004 Each line in the output is prefixed by C<indent_prefix>,
3005 indented by C<indent> (set by C<isl_printer_set_indent>) spaces
3006 (default: 0), prefixed by C<prefix> and suffixed by C<suffix>.
3007 In the C<PolyLib> format output,
3008 the coefficients of the existentially quantified variables
3009 appear between those of the set variables and those
3010 of the parameters.
3011 The function C<isl_printer_indent> increases the indentation
3012 by the specified amount (which may be negative).
3014 To actually print something, use
3016         #include <isl/printer.h>
3017         __isl_give isl_printer *isl_printer_print_double(
3018                 __isl_take isl_printer *p, double d);
3020         #include <isl/val.h>
3021         __isl_give isl_printer *isl_printer_print_val(
3022                 __isl_take isl_printer *p, __isl_keep isl_val *v);
3024         #include <isl/set.h>
3025         __isl_give isl_printer *isl_printer_print_basic_set(
3026                 __isl_take isl_printer *printer,
3027                 __isl_keep isl_basic_set *bset);
3028         __isl_give isl_printer *isl_printer_print_set(
3029                 __isl_take isl_printer *printer,
3030                 __isl_keep isl_set *set);
3032         #include <isl/map.h>
3033         __isl_give isl_printer *isl_printer_print_basic_map(
3034                 __isl_take isl_printer *printer,
3035                 __isl_keep isl_basic_map *bmap);
3036         __isl_give isl_printer *isl_printer_print_map(
3037                 __isl_take isl_printer *printer,
3038                 __isl_keep isl_map *map);
3040         #include <isl/union_set.h>
3041         __isl_give isl_printer *isl_printer_print_union_set(
3042                 __isl_take isl_printer *p,
3043                 __isl_keep isl_union_set *uset);
3045         #include <isl/union_map.h>
3046         __isl_give isl_printer *isl_printer_print_union_map(
3047                 __isl_take isl_printer *p,
3048                 __isl_keep isl_union_map *umap);
3050         #include <isl/val.h>
3051         __isl_give isl_printer *isl_printer_print_multi_val(
3052                 __isl_take isl_printer *p,
3053                 __isl_keep isl_multi_val *mv);
3055         #include <isl/aff.h>
3056         __isl_give isl_printer *isl_printer_print_aff(
3057                 __isl_take isl_printer *p, __isl_keep isl_aff *aff);
3058         __isl_give isl_printer *isl_printer_print_multi_aff(
3059                 __isl_take isl_printer *p,
3060                 __isl_keep isl_multi_aff *maff);
3061         __isl_give isl_printer *isl_printer_print_pw_aff(
3062                 __isl_take isl_printer *p,
3063                 __isl_keep isl_pw_aff *pwaff);
3064         __isl_give isl_printer *isl_printer_print_pw_multi_aff(
3065                 __isl_take isl_printer *p,
3066                 __isl_keep isl_pw_multi_aff *pma);
3067         __isl_give isl_printer *isl_printer_print_multi_pw_aff(
3068                 __isl_take isl_printer *p,
3069                 __isl_keep isl_multi_pw_aff *mpa);
3070         __isl_give isl_printer *isl_printer_print_union_pw_multi_aff(
3071                 __isl_take isl_printer *p,
3072                 __isl_keep isl_union_pw_multi_aff *upma);
3074         #include <isl/polynomial.h>
3075         __isl_give isl_printer *isl_printer_print_qpolynomial(
3076                 __isl_take isl_printer *p,
3077                 __isl_keep isl_qpolynomial *qp);
3078         __isl_give isl_printer *isl_printer_print_pw_qpolynomial(
3079                 __isl_take isl_printer *p,
3080                 __isl_keep isl_pw_qpolynomial *pwqp);
3081         __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial(
3082                 __isl_take isl_printer *p,
3083                 __isl_keep isl_union_pw_qpolynomial *upwqp);
3085         __isl_give isl_printer *
3086         isl_printer_print_pw_qpolynomial_fold(
3087                 __isl_take isl_printer *p,
3088                 __isl_keep isl_pw_qpolynomial_fold *pwf);
3089         __isl_give isl_printer *
3090         isl_printer_print_union_pw_qpolynomial_fold(
3091                 __isl_take isl_printer *p,
3092                 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
3094 For C<isl_printer_print_qpolynomial>,
3095 C<isl_printer_print_pw_qpolynomial> and
3096 C<isl_printer_print_pw_qpolynomial_fold>,
3097 the output format of the printer
3098 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
3099 For C<isl_printer_print_union_pw_qpolynomial> and
3100 C<isl_printer_print_union_pw_qpolynomial_fold>, only C<ISL_FORMAT_ISL>
3101 is supported.
3102 In case of printing in C<ISL_FORMAT_C>, the user may want
3103 to set the names of all dimensions first.
3105 When called on a file printer, the following function flushes
3106 the file.  When called on a string printer, the buffer is cleared.
3108         __isl_give isl_printer *isl_printer_flush(
3109                 __isl_take isl_printer *p);
3111 Alternatively, a string representation can be obtained
3112 directly using the following functions, which always print
3113 in isl format.
3115         #include <isl/space.h>
3116         __isl_give char *isl_space_to_str(
3117                 __isl_keep isl_space *space);
3119         #include <isl/val.h>
3120         __isl_give char *isl_val_to_str(__isl_keep isl_val *v);
3121         __isl_give char *isl_multi_val_to_str(
3122                 __isl_keep isl_multi_val *mv);
3124         #include <isl/set.h>
3125         __isl_give char *isl_set_to_str(
3126                 __isl_keep isl_set *set);
3128         #include <isl/union_set.h>
3129         __isl_give char *isl_union_set_to_str(
3130                 __isl_keep isl_union_set *uset);
3132         #include <isl/map.h>
3133         __isl_give char *isl_map_to_str(
3134                 __isl_keep isl_map *map);
3136         #include <isl/union_map.h>
3137         __isl_give char *isl_union_map_to_str(
3138                 __isl_keep isl_union_map *umap);
3140         #include <isl/aff.h>
3141         __isl_give char *isl_multi_aff_to_str(
3142                 __isl_keep isl_multi_aff *aff);
3143         __isl_give char *isl_union_pw_multi_aff_to_str(
3144                 __isl_keep isl_union_pw_multi_aff *upma);
3146 =head2 Properties
3148 =head3 Unary Properties
3150 =over
3152 =item * Emptiness
3154 The following functions test whether the given set or relation
3155 contains any integer points.  The ``plain'' variants do not perform
3156 any computations, but simply check if the given set or relation
3157 is already known to be empty.
3159         int isl_basic_set_plain_is_empty(__isl_keep isl_basic_set *bset);
3160         int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
3161         int isl_set_plain_is_empty(__isl_keep isl_set *set);
3162         int isl_set_is_empty(__isl_keep isl_set *set);
3163         int isl_union_set_is_empty(__isl_keep isl_union_set *uset);
3164         int isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap);
3165         int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
3166         int isl_map_plain_is_empty(__isl_keep isl_map *map);
3167         int isl_map_is_empty(__isl_keep isl_map *map);
3168         int isl_union_map_is_empty(__isl_keep isl_union_map *umap);
3170 =item * Universality
3172         int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
3173         int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
3174         int isl_set_plain_is_universe(__isl_keep isl_set *set);
3176 =item * Single-valuedness
3178         #include <isl/set.h>
3179         int isl_set_is_singleton(__isl_keep isl_set *set);
3181         #include <isl/map.h>
3182         int isl_basic_map_is_single_valued(
3183                 __isl_keep isl_basic_map *bmap);
3184         int isl_map_plain_is_single_valued(
3185                 __isl_keep isl_map *map);
3186         int isl_map_is_single_valued(__isl_keep isl_map *map);
3188         #include <isl/union_map.h>
3189         int isl_union_map_is_single_valued(__isl_keep isl_union_map *umap);
3191 =item * Injectivity
3193         int isl_map_plain_is_injective(__isl_keep isl_map *map);
3194         int isl_map_is_injective(__isl_keep isl_map *map);
3195         int isl_union_map_plain_is_injective(
3196                 __isl_keep isl_union_map *umap);
3197         int isl_union_map_is_injective(
3198                 __isl_keep isl_union_map *umap);
3200 =item * Bijectivity
3202         int isl_map_is_bijective(__isl_keep isl_map *map);
3203         int isl_union_map_is_bijective(__isl_keep isl_union_map *umap);
3205 =item * Position
3207         __isl_give isl_val *
3208         isl_basic_map_plain_get_val_if_fixed(
3209                 __isl_keep isl_basic_map *bmap,
3210                 enum isl_dim_type type, unsigned pos);
3211         __isl_give isl_val *isl_set_plain_get_val_if_fixed(
3212                 __isl_keep isl_set *set,
3213                 enum isl_dim_type type, unsigned pos);
3214         __isl_give isl_val *isl_map_plain_get_val_if_fixed(
3215                 __isl_keep isl_map *map,
3216                 enum isl_dim_type type, unsigned pos);
3218 If the set or relation obviously lies on a hyperplane where the given dimension
3219 has a fixed value, then return that value.
3220 Otherwise return NaN.
3222 =item * Stride
3224         int isl_set_dim_residue_class_val(
3225                 __isl_keep isl_set *set,
3226                 int pos, __isl_give isl_val **modulo,
3227                 __isl_give isl_val **residue);
3229 Check if the values of the given set dimension are equal to a fixed
3230 value modulo some integer value.  If so, assign the modulo to C<*modulo>
3231 and the fixed value to C<*residue>.  If the given dimension attains only
3232 a single value, then assign C<0> to C<*modulo> and the fixed value to
3233 C<*residue>.
3234 If the dimension does not attain only a single value and if no modulo
3235 can be found then assign C<1> to C<*modulo> and C<1> to C<*residue>.
3237 =item * Dependence
3239 To check whether the description of a set, relation or function depends
3240 on one or more given dimensions,
3241 the following functions can be used.
3243         #include <isl/constraint.h>
3244         int isl_constraint_involves_dims(
3245                 __isl_keep isl_constraint *constraint,
3246                 enum isl_dim_type type, unsigned first, unsigned n);
3248         #include <isl/set.h>
3249         int isl_basic_set_involves_dims(
3250                 __isl_keep isl_basic_set *bset,
3251                 enum isl_dim_type type, unsigned first, unsigned n);
3252         int isl_set_involves_dims(__isl_keep isl_set *set,
3253                 enum isl_dim_type type, unsigned first, unsigned n);
3255         #include <isl/map.h>
3256         int isl_basic_map_involves_dims(
3257                 __isl_keep isl_basic_map *bmap,
3258                 enum isl_dim_type type, unsigned first, unsigned n);
3259         int isl_map_involves_dims(__isl_keep isl_map *map,
3260                 enum isl_dim_type type, unsigned first, unsigned n);
3262         #include <isl/aff.h>
3263         int isl_aff_involves_dims(__isl_keep isl_aff *aff,
3264                 enum isl_dim_type type, unsigned first, unsigned n);
3265         int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff,
3266                 enum isl_dim_type type, unsigned first, unsigned n);
3267         int isl_multi_aff_involves_dims(
3268                 __isl_keep isl_multi_aff *ma,
3269                 enum isl_dim_type type, unsigned first, unsigned n);
3270         int isl_multi_pw_aff_involves_dims(
3271                 __isl_keep isl_multi_pw_aff *mpa,
3272                 enum isl_dim_type type, unsigned first, unsigned n);
3274 Similarly, the following functions can be used to check whether
3275 a given dimension is involved in any lower or upper bound.
3277         #include <isl/set.h>
3278         int isl_set_dim_has_any_lower_bound(__isl_keep isl_set *set,
3279                 enum isl_dim_type type, unsigned pos);
3280         int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set,
3281                 enum isl_dim_type type, unsigned pos);
3283 Note that these functions return true even if there is a bound on
3284 the dimension on only some of the basic sets of C<set>.
3285 To check if they have a bound for all of the basic sets in C<set>,
3286 use the following functions instead.
3288         #include <isl/set.h>
3289         int isl_set_dim_has_lower_bound(__isl_keep isl_set *set,
3290                 enum isl_dim_type type, unsigned pos);
3291         int isl_set_dim_has_upper_bound(__isl_keep isl_set *set,
3292                 enum isl_dim_type type, unsigned pos);
3294 =item * Space
3296 To check whether a set is a parameter domain, use this function:
3298         int isl_set_is_params(__isl_keep isl_set *set);
3299         int isl_union_set_is_params(
3300                 __isl_keep isl_union_set *uset);
3302 =item * Wrapping
3304 The following functions check whether the space of the given
3305 (basic) set or relation range is a wrapped relation.
3307         #include <isl/space.h>
3308         int isl_space_is_wrapping(
3309                 __isl_keep isl_space *space);
3310         int isl_space_domain_is_wrapping(
3311                 __isl_keep isl_space *space);
3312         int isl_space_range_is_wrapping(
3313                 __isl_keep isl_space *space);
3315         #include <isl/set.h>
3316         int isl_basic_set_is_wrapping(
3317                 __isl_keep isl_basic_set *bset);
3318         int isl_set_is_wrapping(__isl_keep isl_set *set);
3320         #include <isl/map.h>
3321         int isl_map_domain_is_wrapping(
3322                 __isl_keep isl_map *map);
3323         int isl_map_range_is_wrapping(
3324                 __isl_keep isl_map *map);
3326         #include <isl/val.h>
3327         int isl_multi_val_range_is_wrapping(
3328                 __isl_keep isl_multi_val *mv);
3330         #include <isl/aff.h>
3331         int isl_multi_aff_range_is_wrapping(
3332                 __isl_keep isl_multi_aff *ma);
3333         int isl_multi_pw_aff_range_is_wrapping(
3334                 __isl_keep isl_multi_pw_aff *mpa);
3336 The input to C<isl_space_is_wrapping> should
3337 be the space of a set, while that of
3338 C<isl_space_domain_is_wrapping> and
3339 C<isl_space_range_is_wrapping> should be the space of a relation.
3341 =item * Internal Product
3343         int isl_basic_map_can_zip(
3344                 __isl_keep isl_basic_map *bmap);
3345         int isl_map_can_zip(__isl_keep isl_map *map);
3347 Check whether the product of domain and range of the given relation
3348 can be computed,
3349 i.e., whether both domain and range are nested relations.
3351 =item * Currying
3353         int isl_basic_map_can_curry(
3354                 __isl_keep isl_basic_map *bmap);
3355         int isl_map_can_curry(__isl_keep isl_map *map);
3357 Check whether the domain of the (basic) relation is a wrapped relation.
3359         int isl_basic_map_can_uncurry(
3360                 __isl_keep isl_basic_map *bmap);
3361         int isl_map_can_uncurry(__isl_keep isl_map *map);
3363 Check whether the range of the (basic) relation is a wrapped relation.
3365 =item * Special Values
3367         #include <isl/aff.h>
3368         int isl_aff_is_cst(__isl_keep isl_aff *aff);
3369         int isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff);
3371 Check whether the given expression is a constant.
3373         #include <isl/aff.h>
3374         int isl_aff_is_nan(__isl_keep isl_aff *aff);
3375         int isl_pw_aff_involves_nan(__isl_keep isl_pw_aff *pa);
3377 Check whether the given expression is equal to or involves NaN.
3379         #include <isl/aff.h>
3380         int isl_aff_plain_is_zero(__isl_keep isl_aff *aff);
3382 Check whether the affine expression is obviously zero.
3384 =back
3386 =head3 Binary Properties
3388 =over
3390 =item * Equality
3392 The following functions check whether two objects
3393 represent the same set, relation or function.
3394 The C<plain> variants only return true if the objects
3395 are obviously the same.  That is, they may return false
3396 even if the objects are the same, but they will never
3397 return true if the objects are not the same.
3399         #include <isl/set.h>
3400         int isl_basic_set_plain_is_equal(
3401                 __isl_keep isl_basic_set *bset1,
3402                 __isl_keep isl_basic_set *bset2);
3403         int isl_set_plain_is_equal(__isl_keep isl_set *set1,
3404                 __isl_keep isl_set *set2);
3405         int isl_set_is_equal(__isl_keep isl_set *set1,
3406                 __isl_keep isl_set *set2);
3408         #include <isl/map.h>
3409         int isl_basic_map_is_equal(
3410                 __isl_keep isl_basic_map *bmap1,
3411                 __isl_keep isl_basic_map *bmap2);
3412         int isl_map_is_equal(__isl_keep isl_map *map1,
3413                 __isl_keep isl_map *map2);
3414         int isl_map_plain_is_equal(__isl_keep isl_map *map1,
3415                 __isl_keep isl_map *map2);
3417         #include <isl/union_set.h>
3418         int isl_union_set_is_equal(
3419                 __isl_keep isl_union_set *uset1,
3420                 __isl_keep isl_union_set *uset2);
3422         #include <isl/union_map.h>
3423         int isl_union_map_is_equal(
3424                 __isl_keep isl_union_map *umap1,
3425                 __isl_keep isl_union_map *umap2);
3427         #include <isl/aff.h>
3428         int isl_aff_plain_is_equal(__isl_keep isl_aff *aff1,
3429                 __isl_keep isl_aff *aff2);
3430         int isl_multi_aff_plain_is_equal(
3431                 __isl_keep isl_multi_aff *maff1,
3432                 __isl_keep isl_multi_aff *maff2);
3433         int isl_pw_aff_plain_is_equal(
3434                 __isl_keep isl_pw_aff *pwaff1,
3435                 __isl_keep isl_pw_aff *pwaff2);
3436         int isl_pw_multi_aff_plain_is_equal(
3437                 __isl_keep isl_pw_multi_aff *pma1,
3438                 __isl_keep isl_pw_multi_aff *pma2);
3439         int isl_multi_pw_aff_plain_is_equal(
3440                 __isl_keep isl_multi_pw_aff *mpa1,
3441                 __isl_keep isl_multi_pw_aff *mpa2);
3442         int isl_multi_pw_aff_is_equal(
3443                 __isl_keep isl_multi_pw_aff *mpa1,
3444                 __isl_keep isl_multi_pw_aff *mpa2);
3445         int isl_union_pw_multi_aff_plain_is_equal(
3446                 __isl_keep isl_union_pw_multi_aff *upma1,
3447                 __isl_keep isl_union_pw_multi_aff *upma2);
3449         #include <isl/polynomial.h>
3450         int isl_union_pw_qpolynomial_plain_is_equal(
3451                 __isl_keep isl_union_pw_qpolynomial *upwqp1,
3452                 __isl_keep isl_union_pw_qpolynomial *upwqp2);
3453         int isl_union_pw_qpolynomial_fold_plain_is_equal(
3454                 __isl_keep isl_union_pw_qpolynomial_fold *upwf1,
3455                 __isl_keep isl_union_pw_qpolynomial_fold *upwf2);
3457 =item * Disjointness
3459         int isl_basic_set_is_disjoint(
3460                 __isl_keep isl_basic_set *bset1,
3461                 __isl_keep isl_basic_set *bset2);
3462         int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
3463                 __isl_keep isl_set *set2);
3464         int isl_set_is_disjoint(__isl_keep isl_set *set1,
3465                 __isl_keep isl_set *set2);
3466         int isl_basic_map_is_disjoint(
3467                 __isl_keep isl_basic_map *bmap1,
3468                 __isl_keep isl_basic_map *bmap2);
3469         int isl_map_is_disjoint(__isl_keep isl_map *map1,
3470                 __isl_keep isl_map *map2);
3472 =item * Subset
3474         int isl_basic_set_is_subset(
3475                 __isl_keep isl_basic_set *bset1,
3476                 __isl_keep isl_basic_set *bset2);
3477         int isl_set_is_subset(__isl_keep isl_set *set1,
3478                 __isl_keep isl_set *set2);
3479         int isl_set_is_strict_subset(
3480                 __isl_keep isl_set *set1,
3481                 __isl_keep isl_set *set2);
3482         int isl_union_set_is_subset(
3483                 __isl_keep isl_union_set *uset1,
3484                 __isl_keep isl_union_set *uset2);
3485         int isl_union_set_is_strict_subset(
3486                 __isl_keep isl_union_set *uset1,
3487                 __isl_keep isl_union_set *uset2);
3488         int isl_basic_map_is_subset(
3489                 __isl_keep isl_basic_map *bmap1,
3490                 __isl_keep isl_basic_map *bmap2);
3491         int isl_basic_map_is_strict_subset(
3492                 __isl_keep isl_basic_map *bmap1,
3493                 __isl_keep isl_basic_map *bmap2);
3494         int isl_map_is_subset(
3495                 __isl_keep isl_map *map1,
3496                 __isl_keep isl_map *map2);
3497         int isl_map_is_strict_subset(
3498                 __isl_keep isl_map *map1,
3499                 __isl_keep isl_map *map2);
3500         int isl_union_map_is_subset(
3501                 __isl_keep isl_union_map *umap1,
3502                 __isl_keep isl_union_map *umap2);
3503         int isl_union_map_is_strict_subset(
3504                 __isl_keep isl_union_map *umap1,
3505                 __isl_keep isl_union_map *umap2);
3507 Check whether the first argument is a (strict) subset of the
3508 second argument.
3510 =item * Order
3512 Every comparison function returns a negative value if the first
3513 argument is considered smaller than the second, a positive value
3514 if the first argument is considered greater and zero if the two
3515 constraints are considered the same by the comparison criterion.
3517         #include <isl/constraint.h>
3518         int isl_constraint_plain_cmp(
3519                 __isl_keep isl_constraint *c1,
3520                 __isl_keep isl_constraint *c2);
3522 This function is useful for sorting C<isl_constraint>s.
3523 The order depends on the internal representation of the inputs.
3524 The order is fixed over different calls to the function (assuming
3525 the internal representation of the inputs has not changed), but may
3526 change over different versions of C<isl>.
3528         #include <isl/constraint.h>
3529         int isl_constraint_cmp_last_non_zero(
3530                 __isl_keep isl_constraint *c1,
3531                 __isl_keep isl_constraint *c2);
3533 This function can be used to sort constraints that live in the same
3534 local space.  Constraints that involve ``earlier'' dimensions or
3535 that have a smaller coefficient for the shared latest dimension
3536 are considered smaller than other constraints.
3537 This function only defines a B<partial> order.
3539         #include <isl/set.h>
3540         int isl_set_plain_cmp(__isl_keep isl_set *set1,
3541                 __isl_keep isl_set *set2);
3543 This function is useful for sorting C<isl_set>s.
3544 The order depends on the internal representation of the inputs.
3545 The order is fixed over different calls to the function (assuming
3546 the internal representation of the inputs has not changed), but may
3547 change over different versions of C<isl>.
3549         #include <isl/aff.h>
3550         int isl_pw_aff_plain_cmp(__isl_keep isl_pw_aff *pa1,
3551                 __isl_keep isl_pw_aff *pa2);
3553 The function C<isl_pw_aff_plain_cmp> can be used to sort
3554 C<isl_pw_aff>s.  The order is not strictly defined.
3555 The current order sorts expressions that only involve
3556 earlier dimensions before those that involve later dimensions.
3558 =back
3560 =head2 Unary Operations
3562 =over
3564 =item * Complement
3566         __isl_give isl_set *isl_set_complement(
3567                 __isl_take isl_set *set);
3568         __isl_give isl_map *isl_map_complement(
3569                 __isl_take isl_map *map);
3571 =item * Inverse map
3573         #include <isl/space.h>
3574         __isl_give isl_space *isl_space_reverse(
3575                 __isl_take isl_space *space);
3577         #include <isl/map.h>
3578         __isl_give isl_basic_map *isl_basic_map_reverse(
3579                 __isl_take isl_basic_map *bmap);
3580         __isl_give isl_map *isl_map_reverse(
3581                 __isl_take isl_map *map);
3583         #include <isl/union_map.h>
3584         __isl_give isl_union_map *isl_union_map_reverse(
3585                 __isl_take isl_union_map *umap);
3587 =item * Projection
3589         #include <isl/space.h>
3590         __isl_give isl_space *isl_space_domain(
3591                 __isl_take isl_space *space);
3592         __isl_give isl_space *isl_space_range(
3593                 __isl_take isl_space *space);
3594         __isl_give isl_space *isl_space_params(
3595                 __isl_take isl_space *space);
3597         #include <isl/local_space.h>
3598         __isl_give isl_local_space *isl_local_space_domain(
3599                 __isl_take isl_local_space *ls);
3600         __isl_give isl_local_space *isl_local_space_range(
3601                 __isl_take isl_local_space *ls);
3603         #include <isl/set.h>
3604         __isl_give isl_basic_set *isl_basic_set_project_out(
3605                 __isl_take isl_basic_set *bset,
3606                 enum isl_dim_type type, unsigned first, unsigned n);
3607         __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
3608                 enum isl_dim_type type, unsigned first, unsigned n);
3609         __isl_give isl_basic_set *isl_basic_set_params(
3610                 __isl_take isl_basic_set *bset);
3611         __isl_give isl_set *isl_set_params(__isl_take isl_set *set);
3613         #include <isl/map.h>
3614         __isl_give isl_basic_map *isl_basic_map_project_out(
3615                 __isl_take isl_basic_map *bmap,
3616                 enum isl_dim_type type, unsigned first, unsigned n);
3617         __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
3618                 enum isl_dim_type type, unsigned first, unsigned n);
3619         __isl_give isl_basic_set *isl_basic_map_domain(
3620                 __isl_take isl_basic_map *bmap);
3621         __isl_give isl_basic_set *isl_basic_map_range(
3622                 __isl_take isl_basic_map *bmap);
3623         __isl_give isl_set *isl_map_params(__isl_take isl_map *map);
3624         __isl_give isl_set *isl_map_domain(
3625                 __isl_take isl_map *bmap);
3626         __isl_give isl_set *isl_map_range(
3627                 __isl_take isl_map *map);
3629         #include <isl/union_set.h>
3630         __isl_give isl_set *isl_union_set_params(
3631                 __isl_take isl_union_set *uset);
3633         #include <isl/union_map.h>
3634         __isl_give isl_union_map *isl_union_map_project_out(
3635                 __isl_take isl_union_map *umap,
3636                 enum isl_dim_type type, unsigned first, unsigned n);
3637         __isl_give isl_set *isl_union_map_params(
3638                 __isl_take isl_union_map *umap);
3639         __isl_give isl_union_set *isl_union_map_domain(
3640                 __isl_take isl_union_map *umap);
3641         __isl_give isl_union_set *isl_union_map_range(
3642                 __isl_take isl_union_map *umap);
3644 The function C<isl_union_map_project_out> can only project out
3645 parameters.
3647         #include <isl/aff.h>
3648         __isl_give isl_aff *isl_aff_project_domain_on_params(
3649                 __isl_take isl_aff *aff);
3650         __isl_give isl_pw_multi_aff *
3651         isl_pw_multi_aff_project_domain_on_params(
3652                 __isl_take isl_pw_multi_aff *pma);
3653         __isl_give isl_set *isl_pw_aff_domain(
3654                 __isl_take isl_pw_aff *pwaff);
3655         __isl_give isl_set *isl_pw_multi_aff_domain(
3656                 __isl_take isl_pw_multi_aff *pma);
3657         __isl_give isl_set *isl_multi_pw_aff_domain(
3658                 __isl_take isl_multi_pw_aff *mpa);
3659         __isl_give isl_union_set *isl_union_pw_multi_aff_domain(
3660                 __isl_take isl_union_pw_multi_aff *upma);
3661         __isl_give isl_set *isl_pw_aff_params(
3662                 __isl_take isl_pw_aff *pwa);
3664         #include <isl/polynomial.h>
3665         __isl_give isl_qpolynomial *
3666         isl_qpolynomial_project_domain_on_params(
3667                 __isl_take isl_qpolynomial *qp);
3668         __isl_give isl_pw_qpolynomial *
3669         isl_pw_qpolynomial_project_domain_on_params(
3670                 __isl_take isl_pw_qpolynomial *pwqp);
3671         __isl_give isl_pw_qpolynomial_fold *
3672         isl_pw_qpolynomial_fold_project_domain_on_params(
3673                 __isl_take isl_pw_qpolynomial_fold *pwf);
3674         __isl_give isl_set *isl_pw_qpolynomial_domain(
3675                 __isl_take isl_pw_qpolynomial *pwqp);
3676         __isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain(
3677                 __isl_take isl_union_pw_qpolynomial_fold *upwf);
3678         __isl_give isl_union_set *isl_union_pw_qpolynomial_domain(
3679                 __isl_take isl_union_pw_qpolynomial *upwqp);
3681         #include <isl/space.h>
3682         __isl_give isl_space *isl_space_domain_map(
3683                 __isl_take isl_space *space);
3684         __isl_give isl_space *isl_space_range_map(
3685                 __isl_take isl_space *space);
3687         #include <isl/map.h>
3688         __isl_give isl_basic_map *isl_basic_map_domain_map(
3689                 __isl_take isl_basic_map *bmap);
3690         __isl_give isl_basic_map *isl_basic_map_range_map(
3691                 __isl_take isl_basic_map *bmap);
3692         __isl_give isl_map *isl_map_domain_map(__isl_take isl_map *map);
3693         __isl_give isl_map *isl_map_range_map(__isl_take isl_map *map);
3695         #include <isl/union_map.h>
3696         __isl_give isl_union_map *isl_union_map_domain_map(
3697                 __isl_take isl_union_map *umap);
3698         __isl_give isl_union_map *isl_union_map_range_map(
3699                 __isl_take isl_union_map *umap);
3701 The functions above construct a (basic, regular or union) relation
3702 that maps (a wrapped version of) the input relation to its domain or range.
3704 =item * Elimination
3706         __isl_give isl_basic_set *isl_basic_set_eliminate(
3707                 __isl_take isl_basic_set *bset,
3708                 enum isl_dim_type type,
3709                 unsigned first, unsigned n);
3710         __isl_give isl_set *isl_set_eliminate(
3711                 __isl_take isl_set *set, enum isl_dim_type type,
3712                 unsigned first, unsigned n);
3713         __isl_give isl_basic_map *isl_basic_map_eliminate(
3714                 __isl_take isl_basic_map *bmap,
3715                 enum isl_dim_type type,
3716                 unsigned first, unsigned n);
3717         __isl_give isl_map *isl_map_eliminate(
3718                 __isl_take isl_map *map, enum isl_dim_type type,
3719                 unsigned first, unsigned n);
3721 Eliminate the coefficients for the given dimensions from the constraints,
3722 without removing the dimensions.
3724 =item * Constructing a set from a parameter domain
3726 A zero-dimensional space or (basic) set can be constructed
3727 on a given parameter domain using the following functions.
3729         #include <isl/space.h>
3730         __isl_give isl_space *isl_space_set_from_params(
3731                 __isl_take isl_space *space);
3733         #include <isl/set.h>
3734         __isl_give isl_basic_set *isl_basic_set_from_params(
3735                 __isl_take isl_basic_set *bset);
3736         __isl_give isl_set *isl_set_from_params(
3737                 __isl_take isl_set *set);
3739 =item * Constructing a relation from a set
3741 Create a relation with the given set as domain or range.
3742 The range or domain of the created relation is a zero-dimensional
3743 flat anonymous space.
3745         #include <isl/space.h>
3746         __isl_give isl_space *isl_space_from_domain(
3747                 __isl_take isl_space *space);
3748         __isl_give isl_space *isl_space_from_range(
3749                 __isl_take isl_space *space);
3750         __isl_give isl_space *isl_space_map_from_set(
3751                 __isl_take isl_space *space);
3752         __isl_give isl_space *isl_space_map_from_domain_and_range(
3753                 __isl_take isl_space *domain,
3754                 __isl_take isl_space *range);
3756         #include <isl/local_space.h>
3757         __isl_give isl_local_space *isl_local_space_from_domain(
3758                 __isl_take isl_local_space *ls);
3760         #include <isl/map.h>
3761         __isl_give isl_map *isl_map_from_domain(
3762                 __isl_take isl_set *set);
3763         __isl_give isl_map *isl_map_from_range(
3764                 __isl_take isl_set *set);
3766         #include <isl/val.h>
3767         __isl_give isl_multi_val *isl_multi_val_from_range(
3768                 __isl_take isl_multi_val *mv);
3770         #include <isl/aff.h>
3771         __isl_give isl_multi_aff *isl_multi_aff_from_range(
3772                 __isl_take isl_multi_aff *ma);
3773         __isl_give isl_pw_aff *isl_pw_aff_from_range(
3774                 __isl_take isl_pw_aff *pwa);
3775         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_range(
3776                 __isl_take isl_multi_pw_aff *mpa);
3777         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_domain(
3778                 __isl_take isl_set *set);
3779         __isl_give isl_union_pw_multi_aff *
3780         isl_union_pw_multi_aff_from_domain(
3781                 __isl_take isl_union_set *uset);
3783 =item * Slicing
3785         #include <isl/set.h>
3786         __isl_give isl_basic_set *isl_basic_set_fix_si(
3787                 __isl_take isl_basic_set *bset,
3788                 enum isl_dim_type type, unsigned pos, int value);
3789         __isl_give isl_basic_set *isl_basic_set_fix_val(
3790                 __isl_take isl_basic_set *bset,
3791                 enum isl_dim_type type, unsigned pos,
3792                 __isl_take isl_val *v);
3793         __isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set,
3794                 enum isl_dim_type type, unsigned pos, int value);
3795         __isl_give isl_set *isl_set_fix_val(
3796                 __isl_take isl_set *set,
3797                 enum isl_dim_type type, unsigned pos,
3798                 __isl_take isl_val *v);
3800         #include <isl/map.h>
3801         __isl_give isl_basic_map *isl_basic_map_fix_si(
3802                 __isl_take isl_basic_map *bmap,
3803                 enum isl_dim_type type, unsigned pos, int value);
3804         __isl_give isl_basic_map *isl_basic_map_fix_val(
3805                 __isl_take isl_basic_map *bmap,
3806                 enum isl_dim_type type, unsigned pos,
3807                 __isl_take isl_val *v);
3808         __isl_give isl_map *isl_map_fix_si(__isl_take isl_map *map,
3809                 enum isl_dim_type type, unsigned pos, int value);
3810         __isl_give isl_map *isl_map_fix_val(
3811                 __isl_take isl_map *map,
3812                 enum isl_dim_type type, unsigned pos,
3813                 __isl_take isl_val *v);
3815         #include <isl/aff.h>
3816         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_fix_si(
3817                 __isl_take isl_pw_multi_aff *pma,
3818                 enum isl_dim_type type, unsigned pos, int value);
3820         #include <isl/polynomial.h>
3821         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_fix_val(
3822                 __isl_take isl_pw_qpolynomial *pwqp,
3823                 enum isl_dim_type type, unsigned n,
3824                 __isl_take isl_val *v);
3826 Intersect the set, relation or function domain
3827 with the hyperplane where the given
3828 dimension has the fixed given value.
3830         __isl_give isl_basic_map *isl_basic_map_lower_bound_si(
3831                 __isl_take isl_basic_map *bmap,
3832                 enum isl_dim_type type, unsigned pos, int value);
3833         __isl_give isl_basic_map *isl_basic_map_upper_bound_si(
3834                 __isl_take isl_basic_map *bmap,
3835                 enum isl_dim_type type, unsigned pos, int value);
3836         __isl_give isl_set *isl_set_lower_bound_si(
3837                 __isl_take isl_set *set,
3838                 enum isl_dim_type type, unsigned pos, int value);
3839         __isl_give isl_set *isl_set_lower_bound_val(
3840                 __isl_take isl_set *set,
3841                 enum isl_dim_type type, unsigned pos,
3842                 __isl_take isl_val *value);
3843         __isl_give isl_map *isl_map_lower_bound_si(
3844                 __isl_take isl_map *map,
3845                 enum isl_dim_type type, unsigned pos, int value);
3846         __isl_give isl_set *isl_set_upper_bound_si(
3847                 __isl_take isl_set *set,
3848                 enum isl_dim_type type, unsigned pos, int value);
3849         __isl_give isl_set *isl_set_upper_bound_val(
3850                 __isl_take isl_set *set,
3851                 enum isl_dim_type type, unsigned pos,
3852                 __isl_take isl_val *value);
3853         __isl_give isl_map *isl_map_upper_bound_si(
3854                 __isl_take isl_map *map,
3855                 enum isl_dim_type type, unsigned pos, int value);
3857 Intersect the set or relation with the half-space where the given
3858 dimension has a value bounded by the fixed given integer value.
3860         __isl_give isl_set *isl_set_equate(__isl_take isl_set *set,
3861                 enum isl_dim_type type1, int pos1,
3862                 enum isl_dim_type type2, int pos2);
3863         __isl_give isl_basic_map *isl_basic_map_equate(
3864                 __isl_take isl_basic_map *bmap,
3865                 enum isl_dim_type type1, int pos1,
3866                 enum isl_dim_type type2, int pos2);
3867         __isl_give isl_map *isl_map_equate(__isl_take isl_map *map,
3868                 enum isl_dim_type type1, int pos1,
3869                 enum isl_dim_type type2, int pos2);
3871 Intersect the set or relation with the hyperplane where the given
3872 dimensions are equal to each other.
3874         __isl_give isl_map *isl_map_oppose(__isl_take isl_map *map,
3875                 enum isl_dim_type type1, int pos1,
3876                 enum isl_dim_type type2, int pos2);
3878 Intersect the relation with the hyperplane where the given
3879 dimensions have opposite values.
3881         __isl_give isl_map *isl_map_order_le(
3882                 __isl_take isl_map *map,
3883                 enum isl_dim_type type1, int pos1,
3884                 enum isl_dim_type type2, int pos2);
3885         __isl_give isl_basic_map *isl_basic_map_order_ge(
3886                 __isl_take isl_basic_map *bmap,
3887                 enum isl_dim_type type1, int pos1,
3888                 enum isl_dim_type type2, int pos2);
3889         __isl_give isl_map *isl_map_order_ge(
3890                 __isl_take isl_map *map,
3891                 enum isl_dim_type type1, int pos1,
3892                 enum isl_dim_type type2, int pos2);
3893         __isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map,
3894                 enum isl_dim_type type1, int pos1,
3895                 enum isl_dim_type type2, int pos2);
3896         __isl_give isl_basic_map *isl_basic_map_order_gt(
3897                 __isl_take isl_basic_map *bmap,
3898                 enum isl_dim_type type1, int pos1,
3899                 enum isl_dim_type type2, int pos2);
3900         __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
3901                 enum isl_dim_type type1, int pos1,
3902                 enum isl_dim_type type2, int pos2);
3904 Intersect the relation with the half-space where the given
3905 dimensions satisfy the given ordering.
3907 =item * Locus
3909         #include <isl/aff.h>
3910         __isl_give isl_basic_set *isl_aff_zero_basic_set(
3911                 __isl_take isl_aff *aff);
3912         __isl_give isl_basic_set *isl_aff_neg_basic_set(
3913                 __isl_take isl_aff *aff);
3914         __isl_give isl_set *isl_pw_aff_nonneg_set(
3915                 __isl_take isl_pw_aff *pwaff);
3916         __isl_give isl_set *isl_pw_aff_zero_set(
3917                 __isl_take isl_pw_aff *pwaff);
3918         __isl_give isl_set *isl_pw_aff_non_zero_set(
3919                 __isl_take isl_pw_aff *pwaff);
3921 The function C<isl_aff_neg_basic_set> returns a basic set
3922 containing those elements in the domain space
3923 of C<aff> where C<aff> is negative.
3924 The function C<isl_pw_aff_nonneg_set> returns a set
3925 containing those elements in the domain
3926 of C<pwaff> where C<pwaff> is non-negative.
3928 =item * Identity
3930         __isl_give isl_map *isl_set_identity(
3931                 __isl_take isl_set *set);
3932         __isl_give isl_union_map *isl_union_set_identity(
3933                 __isl_take isl_union_set *uset);
3935 Construct an identity relation on the given (union) set.
3937 =item * Function Extraction
3939 A piecewise quasi affine expression that is equal to 1 on a set
3940 and 0 outside the set can be created using the following function.
3942         #include <isl/aff.h>
3943         __isl_give isl_pw_aff *isl_set_indicator_function(
3944                 __isl_take isl_set *set);
3946 A piecewise multiple quasi affine expression can be extracted
3947 from an C<isl_set> or C<isl_map>, provided the C<isl_set> is a singleton
3948 and the C<isl_map> is single-valued.
3949 In case of a conversion from an C<isl_union_map>
3950 to an C<isl_union_pw_multi_aff>, these properties need to hold
3951 in each domain space.
3953         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_set(
3954                 __isl_take isl_set *set);
3955         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_map(
3956                 __isl_take isl_map *map);
3958         __isl_give isl_union_pw_multi_aff *
3959         isl_union_pw_multi_aff_from_union_set(
3960                 __isl_take isl_union_set *uset);
3961         __isl_give isl_union_pw_multi_aff *
3962         isl_union_pw_multi_aff_from_union_map(
3963                 __isl_take isl_union_map *umap);
3965 =item * Deltas
3967         __isl_give isl_basic_set *isl_basic_map_deltas(
3968                 __isl_take isl_basic_map *bmap);
3969         __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
3970         __isl_give isl_union_set *isl_union_map_deltas(
3971                 __isl_take isl_union_map *umap);
3973 These functions return a (basic) set containing the differences
3974 between image elements and corresponding domain elements in the input.
3976         __isl_give isl_basic_map *isl_basic_map_deltas_map(
3977                 __isl_take isl_basic_map *bmap);
3978         __isl_give isl_map *isl_map_deltas_map(
3979                 __isl_take isl_map *map);
3980         __isl_give isl_union_map *isl_union_map_deltas_map(
3981                 __isl_take isl_union_map *umap);
3983 The functions above construct a (basic, regular or union) relation
3984 that maps (a wrapped version of) the input relation to its delta set.
3986 =item * Coalescing
3988 Simplify the representation of a set, relation or functions by trying
3989 to combine pairs of basic sets or relations into a single
3990 basic set or relation.
3992         #include <isl/set.h>
3993         __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
3995         #include <isl/map.h>
3996         __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
3998         #include <isl/union_set.h>
3999         __isl_give isl_union_set *isl_union_set_coalesce(
4000                 __isl_take isl_union_set *uset);
4002         #include <isl/union_map.h>
4003         __isl_give isl_union_map *isl_union_map_coalesce(
4004                 __isl_take isl_union_map *umap);
4006         #include <isl/aff.h>
4007         __isl_give isl_pw_aff *isl_pw_aff_coalesce(
4008                 __isl_take isl_pw_aff *pwqp);
4009         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_coalesce(
4010                 __isl_take isl_pw_multi_aff *pma);
4011         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_coalesce(
4012                 __isl_take isl_multi_pw_aff *mpa);
4013         __isl_give isl_union_pw_multi_aff *
4014         isl_union_pw_multi_aff_coalesce(
4015                 __isl_take isl_union_pw_multi_aff *upma);
4017         #include <isl/polynomial.h>
4018         __isl_give isl_pw_qpolynomial_fold *
4019         isl_pw_qpolynomial_fold_coalesce(
4020                 __isl_take isl_pw_qpolynomial_fold *pwf);
4021         __isl_give isl_union_pw_qpolynomial *
4022         isl_union_pw_qpolynomial_coalesce(
4023                 __isl_take isl_union_pw_qpolynomial *upwqp);
4024         __isl_give isl_union_pw_qpolynomial_fold *
4025         isl_union_pw_qpolynomial_fold_coalesce(
4026                 __isl_take isl_union_pw_qpolynomial_fold *upwf);
4028 One of the methods for combining pairs of basic sets or relations
4029 can result in coefficients that are much larger than those that appear
4030 in the constraints of the input.  By default, the coefficients are
4031 not allowed to grow larger, but this can be changed by unsetting
4032 the following option.
4034         int isl_options_set_coalesce_bounded_wrapping(
4035                 isl_ctx *ctx, int val);
4036         int isl_options_get_coalesce_bounded_wrapping(
4037                 isl_ctx *ctx);
4039 =item * Detecting equalities
4041         __isl_give isl_basic_set *isl_basic_set_detect_equalities(
4042                 __isl_take isl_basic_set *bset);
4043         __isl_give isl_basic_map *isl_basic_map_detect_equalities(
4044                 __isl_take isl_basic_map *bmap);
4045         __isl_give isl_set *isl_set_detect_equalities(
4046                 __isl_take isl_set *set);
4047         __isl_give isl_map *isl_map_detect_equalities(
4048                 __isl_take isl_map *map);
4049         __isl_give isl_union_set *isl_union_set_detect_equalities(
4050                 __isl_take isl_union_set *uset);
4051         __isl_give isl_union_map *isl_union_map_detect_equalities(
4052                 __isl_take isl_union_map *umap);
4054 Simplify the representation of a set or relation by detecting implicit
4055 equalities.
4057 =item * Removing redundant constraints
4059         __isl_give isl_basic_set *isl_basic_set_remove_redundancies(
4060                 __isl_take isl_basic_set *bset);
4061         __isl_give isl_set *isl_set_remove_redundancies(
4062                 __isl_take isl_set *set);
4063         __isl_give isl_basic_map *isl_basic_map_remove_redundancies(
4064                 __isl_take isl_basic_map *bmap);
4065         __isl_give isl_map *isl_map_remove_redundancies(
4066                 __isl_take isl_map *map);
4068 =item * Convex hull
4070         __isl_give isl_basic_set *isl_set_convex_hull(
4071                 __isl_take isl_set *set);
4072         __isl_give isl_basic_map *isl_map_convex_hull(
4073                 __isl_take isl_map *map);
4075 If the input set or relation has any existentially quantified
4076 variables, then the result of these operations is currently undefined.
4078 =item * Simple hull
4080         #include <isl/set.h>
4081         __isl_give isl_basic_set *
4082         isl_set_unshifted_simple_hull(
4083                 __isl_take isl_set *set);
4084         __isl_give isl_basic_set *isl_set_simple_hull(
4085                 __isl_take isl_set *set);
4086         __isl_give isl_basic_set *
4087         isl_set_unshifted_simple_hull_from_set_list(
4088                 __isl_take isl_set *set,
4089                 __isl_take isl_set_list *list);
4091         #include <isl/map.h>
4092         __isl_give isl_basic_map *
4093         isl_map_unshifted_simple_hull(
4094                 __isl_take isl_map *map);
4095         __isl_give isl_basic_map *isl_map_simple_hull(
4096                 __isl_take isl_map *map);
4098         #include <isl/union_map.h>
4099         __isl_give isl_union_map *isl_union_map_simple_hull(
4100                 __isl_take isl_union_map *umap);
4102 These functions compute a single basic set or relation
4103 that contains the whole input set or relation.
4104 In particular, the output is described by translates
4105 of the constraints describing the basic sets or relations in the input.
4106 In case of C<isl_set_unshifted_simple_hull>, only the original
4107 constraints are used, without any translation.
4108 In case of C<isl_set_unshifted_simple_hull_from_set_list>, the
4109 constraints are taken from the elements of the second argument.
4111 =begin latex
4113 (See \autoref{s:simple hull}.)
4115 =end latex
4117 =item * Affine hull
4119         __isl_give isl_basic_set *isl_basic_set_affine_hull(
4120                 __isl_take isl_basic_set *bset);
4121         __isl_give isl_basic_set *isl_set_affine_hull(
4122                 __isl_take isl_set *set);
4123         __isl_give isl_union_set *isl_union_set_affine_hull(
4124                 __isl_take isl_union_set *uset);
4125         __isl_give isl_basic_map *isl_basic_map_affine_hull(
4126                 __isl_take isl_basic_map *bmap);
4127         __isl_give isl_basic_map *isl_map_affine_hull(
4128                 __isl_take isl_map *map);
4129         __isl_give isl_union_map *isl_union_map_affine_hull(
4130                 __isl_take isl_union_map *umap);
4132 In case of union sets and relations, the affine hull is computed
4133 per space.
4135 =item * Polyhedral hull
4137         __isl_give isl_basic_set *isl_set_polyhedral_hull(
4138                 __isl_take isl_set *set);
4139         __isl_give isl_basic_map *isl_map_polyhedral_hull(
4140                 __isl_take isl_map *map);
4141         __isl_give isl_union_set *isl_union_set_polyhedral_hull(
4142                 __isl_take isl_union_set *uset);
4143         __isl_give isl_union_map *isl_union_map_polyhedral_hull(
4144                 __isl_take isl_union_map *umap);
4146 These functions compute a single basic set or relation
4147 not involving any existentially quantified variables
4148 that contains the whole input set or relation.
4149 In case of union sets and relations, the polyhedral hull is computed
4150 per space.
4152 =item * Other approximations
4154         #include <isl/set.h>
4155         __isl_give isl_basic_set *
4156         isl_basic_set_drop_constraints_involving_dims(
4157                 __isl_take isl_basic_set *bset,
4158                 enum isl_dim_type type,
4159                 unsigned first, unsigned n);
4160         __isl_give isl_basic_set *
4161         isl_basic_set_drop_constraints_not_involving_dims(
4162                 __isl_take isl_basic_set *bset,
4163                 enum isl_dim_type type,
4164                 unsigned first, unsigned n);
4165         __isl_give isl_set *
4166         isl_set_drop_constraints_involving_dims(
4167                 __isl_take isl_set *set,
4168                 enum isl_dim_type type,
4169                 unsigned first, unsigned n);
4171         #include <isl/map.h>
4172         __isl_give isl_basic_map *
4173         isl_basic_map_drop_constraints_involving_dims(
4174                 __isl_take isl_basic_map *bmap,
4175                 enum isl_dim_type type,
4176                 unsigned first, unsigned n);
4177         __isl_give isl_map *
4178         isl_map_drop_constraints_involving_dims(
4179                 __isl_take isl_map *map,
4180                 enum isl_dim_type type,
4181                 unsigned first, unsigned n);
4183 These functions drop any constraints (not) involving the specified dimensions.
4184 Note that the result depends on the representation of the input.
4186         #include <isl/polynomial.h>
4187         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_to_polynomial(
4188                 __isl_take isl_pw_qpolynomial *pwqp, int sign);
4189         __isl_give isl_union_pw_qpolynomial *
4190         isl_union_pw_qpolynomial_to_polynomial(
4191                 __isl_take isl_union_pw_qpolynomial *upwqp, int sign);
4193 Approximate each quasipolynomial by a polynomial.  If C<sign> is positive,
4194 the polynomial will be an overapproximation.  If C<sign> is negative,
4195 it will be an underapproximation.  If C<sign> is zero, the approximation
4196 will lie somewhere in between.
4198 =item * Feasibility
4200         __isl_give isl_basic_set *isl_basic_set_sample(
4201                 __isl_take isl_basic_set *bset);
4202         __isl_give isl_basic_set *isl_set_sample(
4203                 __isl_take isl_set *set);
4204         __isl_give isl_basic_map *isl_basic_map_sample(
4205                 __isl_take isl_basic_map *bmap);
4206         __isl_give isl_basic_map *isl_map_sample(
4207                 __isl_take isl_map *map);
4209 If the input (basic) set or relation is non-empty, then return
4210 a singleton subset of the input.  Otherwise, return an empty set.
4212 =item * Optimization
4214         #include <isl/ilp.h>
4215         __isl_give isl_val *isl_basic_set_max_val(
4216                 __isl_keep isl_basic_set *bset,
4217                 __isl_keep isl_aff *obj);
4218         __isl_give isl_val *isl_set_min_val(
4219                 __isl_keep isl_set *set,
4220                 __isl_keep isl_aff *obj);
4221         __isl_give isl_val *isl_set_max_val(
4222                 __isl_keep isl_set *set,
4223                 __isl_keep isl_aff *obj);
4225 Compute the minimum or maximum of the integer affine expression C<obj>
4226 over the points in C<set>, returning the result in C<opt>.
4227 The result is C<NULL> in case of an error, the optimal value in case
4228 there is one, negative infinity or infinity if the problem is unbounded and
4229 NaN if the problem is empty.
4231 =item * Parametric optimization
4233         __isl_give isl_pw_aff *isl_set_dim_min(
4234                 __isl_take isl_set *set, int pos);
4235         __isl_give isl_pw_aff *isl_set_dim_max(
4236                 __isl_take isl_set *set, int pos);
4237         __isl_give isl_pw_aff *isl_map_dim_max(
4238                 __isl_take isl_map *map, int pos);
4240 Compute the minimum or maximum of the given set or output dimension
4241 as a function of the parameters (and input dimensions), but independently
4242 of the other set or output dimensions.
4243 For lexicographic optimization, see L<"Lexicographic Optimization">.
4245 =item * Dual
4247 The following functions compute either the set of (rational) coefficient
4248 values of valid constraints for the given set or the set of (rational)
4249 values satisfying the constraints with coefficients from the given set.
4250 Internally, these two sets of functions perform essentially the
4251 same operations, except that the set of coefficients is assumed to
4252 be a cone, while the set of values may be any polyhedron.
4253 The current implementation is based on the Farkas lemma and
4254 Fourier-Motzkin elimination, but this may change or be made optional
4255 in future.  In particular, future implementations may use different
4256 dualization algorithms or skip the elimination step.
4258         __isl_give isl_basic_set *isl_basic_set_coefficients(
4259                 __isl_take isl_basic_set *bset);
4260         __isl_give isl_basic_set *isl_set_coefficients(
4261                 __isl_take isl_set *set);
4262         __isl_give isl_union_set *isl_union_set_coefficients(
4263                 __isl_take isl_union_set *bset);
4264         __isl_give isl_basic_set *isl_basic_set_solutions(
4265                 __isl_take isl_basic_set *bset);
4266         __isl_give isl_basic_set *isl_set_solutions(
4267                 __isl_take isl_set *set);
4268         __isl_give isl_union_set *isl_union_set_solutions(
4269                 __isl_take isl_union_set *bset);
4271 =item * Power
4273         __isl_give isl_map *isl_map_fixed_power_val(
4274                 __isl_take isl_map *map,
4275                 __isl_take isl_val *exp);
4276         __isl_give isl_union_map *
4277         isl_union_map_fixed_power_val(
4278                 __isl_take isl_union_map *umap,
4279                 __isl_take isl_val *exp);
4281 Compute the given power of C<map>, where C<exp> is assumed to be non-zero.
4282 If the exponent C<exp> is negative, then the -C<exp> th power of the inverse
4283 of C<map> is computed.
4285         __isl_give isl_map *isl_map_power(__isl_take isl_map *map,
4286                 int *exact);
4287         __isl_give isl_union_map *isl_union_map_power(
4288                 __isl_take isl_union_map *umap, int *exact);
4290 Compute a parametric representation for all positive powers I<k> of C<map>.
4291 The result maps I<k> to a nested relation corresponding to the
4292 I<k>th power of C<map>.
4293 The result may be an overapproximation.  If the result is known to be exact,
4294 then C<*exact> is set to C<1>.
4296 =item * Transitive closure
4298         __isl_give isl_map *isl_map_transitive_closure(
4299                 __isl_take isl_map *map, int *exact);
4300         __isl_give isl_union_map *isl_union_map_transitive_closure(
4301                 __isl_take isl_union_map *umap, int *exact);
4303 Compute the transitive closure of C<map>.
4304 The result may be an overapproximation.  If the result is known to be exact,
4305 then C<*exact> is set to C<1>.
4307 =item * Reaching path lengths
4309         __isl_give isl_map *isl_map_reaching_path_lengths(
4310                 __isl_take isl_map *map, int *exact);
4312 Compute a relation that maps each element in the range of C<map>
4313 to the lengths of all paths composed of edges in C<map> that
4314 end up in the given element.
4315 The result may be an overapproximation.  If the result is known to be exact,
4316 then C<*exact> is set to C<1>.
4317 To compute the I<maximal> path length, the resulting relation
4318 should be postprocessed by C<isl_map_lexmax>.
4319 In particular, if the input relation is a dependence relation
4320 (mapping sources to sinks), then the maximal path length corresponds
4321 to the free schedule.
4322 Note, however, that C<isl_map_lexmax> expects the maximum to be
4323 finite, so if the path lengths are unbounded (possibly due to
4324 the overapproximation), then you will get an error message.
4326 =item * Wrapping
4328         #include <isl/space.h>
4329         __isl_give isl_space *isl_space_wrap(
4330                 __isl_take isl_space *space);
4331         __isl_give isl_space *isl_space_unwrap(
4332                 __isl_take isl_space *space);
4334         #include <isl/set.h>
4335         __isl_give isl_basic_map *isl_basic_set_unwrap(
4336                 __isl_take isl_basic_set *bset);
4337         __isl_give isl_map *isl_set_unwrap(
4338                 __isl_take isl_set *set);
4340         #include <isl/map.h>
4341         __isl_give isl_basic_set *isl_basic_map_wrap(
4342                 __isl_take isl_basic_map *bmap);
4343         __isl_give isl_set *isl_map_wrap(
4344                 __isl_take isl_map *map);
4346         #include <isl/union_set.h>
4347         __isl_give isl_union_map *isl_union_set_unwrap(
4348                 __isl_take isl_union_set *uset);
4350         #include <isl/union_map.h>
4351         __isl_give isl_union_set *isl_union_map_wrap(
4352                 __isl_take isl_union_map *umap);
4354 The input to C<isl_space_unwrap> should
4355 be the space of a set, while that of
4356 C<isl_space_wrap> should be the space of a relation.
4357 Conversely, the output of C<isl_space_unwrap> is the space
4358 of a relation, while that of C<isl_space_wrap> is the space of a set.
4360 =item * Flattening
4362 Remove any internal structure of domain (and range) of the given
4363 set or relation.  If there is any such internal structure in the input,
4364 then the name of the space is also removed.
4366         #include <isl/local_space.h>
4367         __isl_give isl_local_space *
4368         isl_local_space_flatten_domain(
4369                 __isl_take isl_local_space *ls);
4370         __isl_give isl_local_space *
4371         isl_local_space_flatten_range(
4372                 __isl_take isl_local_space *ls);
4374         #include <isl/set.h>
4375         __isl_give isl_basic_set *isl_basic_set_flatten(
4376                 __isl_take isl_basic_set *bset);
4377         __isl_give isl_set *isl_set_flatten(
4378                 __isl_take isl_set *set);
4380         #include <isl/map.h>
4381         __isl_give isl_basic_map *isl_basic_map_flatten_domain(
4382                 __isl_take isl_basic_map *bmap);
4383         __isl_give isl_basic_map *isl_basic_map_flatten_range(
4384                 __isl_take isl_basic_map *bmap);
4385         __isl_give isl_map *isl_map_flatten_range(
4386                 __isl_take isl_map *map);
4387         __isl_give isl_map *isl_map_flatten_domain(
4388                 __isl_take isl_map *map);
4389         __isl_give isl_basic_map *isl_basic_map_flatten(
4390                 __isl_take isl_basic_map *bmap);
4391         __isl_give isl_map *isl_map_flatten(
4392                 __isl_take isl_map *map);
4394         #include <isl/val.h>
4395         __isl_give isl_multi_val *isl_multi_val_flatten_range(
4396                 __isl_take isl_multi_val *mv);
4398         #include <isl/aff.h>
4399         __isl_give isl_multi_aff *isl_multi_aff_flatten_domain(
4400                 __isl_take isl_multi_aff *ma);
4401         __isl_give isl_multi_aff *isl_multi_aff_flatten_range(
4402                 __isl_take isl_multi_aff *ma);
4403         __isl_give isl_multi_pw_aff *
4404         isl_multi_pw_aff_flatten_range(
4405                 __isl_take isl_multi_pw_aff *mpa);
4407         #include <isl/map.h>
4408         __isl_give isl_map *isl_set_flatten_map(
4409                 __isl_take isl_set *set);
4411 The function above constructs a relation
4412 that maps the input set to a flattened version of the set.
4414 =item * Lifting
4416 Lift the input set to a space with extra dimensions corresponding
4417 to the existentially quantified variables in the input.
4418 In particular, the result lives in a wrapped map where the domain
4419 is the original space and the range corresponds to the original
4420 existentially quantified variables.
4422         #include <isl/set.h>
4423         __isl_give isl_basic_set *isl_basic_set_lift(
4424                 __isl_take isl_basic_set *bset);
4425         __isl_give isl_set *isl_set_lift(
4426                 __isl_take isl_set *set);
4427         __isl_give isl_union_set *isl_union_set_lift(
4428                 __isl_take isl_union_set *uset);
4430 Given a local space that contains the existentially quantified
4431 variables of a set, a basic relation that, when applied to
4432 a basic set, has essentially the same effect as C<isl_basic_set_lift>,
4433 can be constructed using the following function.
4435         #include <isl/local_space.h>
4436         __isl_give isl_basic_map *isl_local_space_lifting(
4437                 __isl_take isl_local_space *ls);
4439         #include <isl/aff.h>
4440         __isl_give isl_multi_aff *isl_multi_aff_lift(
4441                 __isl_take isl_multi_aff *maff,
4442                 __isl_give isl_local_space **ls);
4444 If the C<ls> argument of C<isl_multi_aff_lift> is not C<NULL>,
4445 then it is assigned the local space that lies at the basis of
4446 the lifting applied.
4448 =item * Internal Product
4450         #include <isl/space.h>
4451         __isl_give isl_space *isl_space_zip(
4452                 __isl_take isl_space *space);
4454         #include <isl/map.h>
4455         __isl_give isl_basic_map *isl_basic_map_zip(
4456                 __isl_take isl_basic_map *bmap);
4457         __isl_give isl_map *isl_map_zip(
4458                 __isl_take isl_map *map);
4460         #include <isl/union_map.h>
4461         __isl_give isl_union_map *isl_union_map_zip(
4462                 __isl_take isl_union_map *umap);
4464 Given a relation with nested relations for domain and range,
4465 interchange the range of the domain with the domain of the range.
4467 =item * Currying
4469         #include <isl/space.h>
4470         __isl_give isl_space *isl_space_curry(
4471                 __isl_take isl_space *space);
4472         __isl_give isl_space *isl_space_uncurry(
4473                 __isl_take isl_space *space);
4475         #include <isl/map.h>
4476         __isl_give isl_basic_map *isl_basic_map_curry(
4477                 __isl_take isl_basic_map *bmap);
4478         __isl_give isl_basic_map *isl_basic_map_uncurry(
4479                 __isl_take isl_basic_map *bmap);
4480         __isl_give isl_map *isl_map_curry(
4481                 __isl_take isl_map *map);
4482         __isl_give isl_map *isl_map_uncurry(
4483                 __isl_take isl_map *map);
4485         #include <isl/union_map.h>
4486         __isl_give isl_union_map *isl_union_map_curry(
4487                 __isl_take isl_union_map *umap);
4488         __isl_give isl_union_map *isl_union_map_uncurry(
4489                 __isl_take isl_union_map *umap);
4491 Given a relation with a nested relation for domain,
4492 the C<curry> functions
4493 move the range of the nested relation out of the domain
4494 and use it as the domain of a nested relation in the range,
4495 with the original range as range of this nested relation.
4496 The C<uncurry> functions perform the inverse operation.
4498 =item * Aligning parameters
4500 Change the order of the parameters of the given set, relation
4501 or function
4502 such that the first parameters match those of C<model>.
4503 This may involve the introduction of extra parameters.
4504 All parameters need to be named.
4506         #include <isl/space.h>
4507         __isl_give isl_space *isl_space_align_params(
4508                 __isl_take isl_space *space1,
4509                 __isl_take isl_space *space2)
4511         #include <isl/set.h>
4512         __isl_give isl_basic_set *isl_basic_set_align_params(
4513                 __isl_take isl_basic_set *bset,
4514                 __isl_take isl_space *model);
4515         __isl_give isl_set *isl_set_align_params(
4516                 __isl_take isl_set *set,
4517                 __isl_take isl_space *model);
4519         #include <isl/map.h>
4520         __isl_give isl_basic_map *isl_basic_map_align_params(
4521                 __isl_take isl_basic_map *bmap,
4522                 __isl_take isl_space *model);
4523         __isl_give isl_map *isl_map_align_params(
4524                 __isl_take isl_map *map,
4525                 __isl_take isl_space *model);
4527         #include <isl/val.h>
4528         __isl_give isl_multi_val *isl_multi_val_align_params(
4529                 __isl_take isl_multi_val *mv,
4530                 __isl_take isl_space *model);
4532         #include <isl/aff.h>
4533         __isl_give isl_aff *isl_aff_align_params(
4534                 __isl_take isl_aff *aff,
4535                 __isl_take isl_space *model);
4536         __isl_give isl_multi_aff *isl_multi_aff_align_params(
4537                 __isl_take isl_multi_aff *multi,
4538                 __isl_take isl_space *model);
4539         __isl_give isl_pw_aff *isl_pw_aff_align_params(
4540                 __isl_take isl_pw_aff *pwaff,
4541                 __isl_take isl_space *model);
4542         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_align_params(
4543                 __isl_take isl_pw_multi_aff *pma,
4544                 __isl_take isl_space *model);
4545         __isl_give isl_union_pw_multi_aff *
4546         isl_union_pw_multi_aff_align_params(
4547                 __isl_take isl_union_pw_multi_aff *upma,
4548                 __isl_take isl_space *model);
4550         #include <isl/polynomial.h>
4551         __isl_give isl_qpolynomial *isl_qpolynomial_align_params(
4552                 __isl_take isl_qpolynomial *qp,
4553                 __isl_take isl_space *model);
4555 =item * Unary Arithmethic Operations
4557         #include <isl/aff.h>
4558         __isl_give isl_aff *isl_aff_neg(
4559                 __isl_take isl_aff *aff);
4560         __isl_give isl_pw_aff *isl_pw_aff_neg(
4561                 __isl_take isl_pw_aff *pwaff);
4562         __isl_give isl_aff *isl_aff_ceil(
4563                 __isl_take isl_aff *aff);
4564         __isl_give isl_pw_aff *isl_pw_aff_ceil(
4565                 __isl_take isl_pw_aff *pwaff);
4566         __isl_give isl_aff *isl_aff_floor(
4567                 __isl_take isl_aff *aff);
4568         __isl_give isl_multi_aff *isl_multi_aff_floor(
4569                 __isl_take isl_multi_aff *ma);
4570         __isl_give isl_pw_aff *isl_pw_aff_floor(
4571                 __isl_take isl_pw_aff *pwaff);
4573         #include <isl/aff.h>
4574         __isl_give isl_pw_aff *isl_pw_aff_list_min(
4575                 __isl_take isl_pw_aff_list *list);
4576         __isl_give isl_pw_aff *isl_pw_aff_list_max(
4577                 __isl_take isl_pw_aff_list *list);
4579         #include <isl/polynomial.h>
4580         __isl_give isl_qpolynomial *isl_qpolynomial_neg(
4581                 __isl_take isl_qpolynomial *qp);
4582         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg(
4583                 __isl_take isl_pw_qpolynomial *pwqp);
4584         __isl_give isl_union_pw_qpolynomial *
4585         isl_union_pw_qpolynomial_neg(
4586                 __isl_take isl_union_pw_qpolynomial *upwqp);
4587         __isl_give isl_qpolynomial *isl_qpolynomial_pow(
4588                 __isl_take isl_qpolynomial *qp,
4589                 unsigned exponent);
4590         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_pow(
4591                 __isl_take isl_pw_qpolynomial *pwqp,
4592                 unsigned exponent);
4594 =item * Evaluation
4596 The following functions evaluate a function in a point.
4598         #include <isl/polynomial.h>
4599         __isl_give isl_val *isl_pw_qpolynomial_eval(
4600                 __isl_take isl_pw_qpolynomial *pwqp,
4601                 __isl_take isl_point *pnt);
4602         __isl_give isl_val *isl_pw_qpolynomial_fold_eval(
4603                 __isl_take isl_pw_qpolynomial_fold *pwf,
4604                 __isl_take isl_point *pnt);
4605         __isl_give isl_val *isl_union_pw_qpolynomial_eval(
4606                 __isl_take isl_union_pw_qpolynomial *upwqp,
4607                 __isl_take isl_point *pnt);
4608         __isl_give isl_val *isl_union_pw_qpolynomial_fold_eval(
4609                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4610                 __isl_take isl_point *pnt);
4612 =item * Dimension manipulation
4614 It is usually not advisable to directly change the (input or output)
4615 space of a set or a relation as this removes the name and the internal
4616 structure of the space.  However, the functions below can be useful
4617 to add new parameters, assuming
4618 C<isl_set_align_params> and C<isl_map_align_params>
4619 are not sufficient.
4621         #include <isl/space.h>
4622         __isl_give isl_space *isl_space_add_dims(
4623                 __isl_take isl_space *space,
4624                 enum isl_dim_type type, unsigned n);
4625         __isl_give isl_space *isl_space_insert_dims(
4626                 __isl_take isl_space *space,
4627                 enum isl_dim_type type, unsigned pos, unsigned n);
4628         __isl_give isl_space *isl_space_drop_dims(
4629                 __isl_take isl_space *space,
4630                 enum isl_dim_type type, unsigned first, unsigned n);
4631         __isl_give isl_space *isl_space_move_dims(
4632                 __isl_take isl_space *space,
4633                 enum isl_dim_type dst_type, unsigned dst_pos,
4634                 enum isl_dim_type src_type, unsigned src_pos,
4635                 unsigned n);
4637         #include <isl/local_space.h>
4638         __isl_give isl_local_space *isl_local_space_add_dims(
4639                 __isl_take isl_local_space *ls,
4640                 enum isl_dim_type type, unsigned n);
4641         __isl_give isl_local_space *isl_local_space_insert_dims(
4642                 __isl_take isl_local_space *ls,
4643                 enum isl_dim_type type, unsigned first, unsigned n);
4644         __isl_give isl_local_space *isl_local_space_drop_dims(
4645                 __isl_take isl_local_space *ls,
4646                 enum isl_dim_type type, unsigned first, unsigned n);
4648         #include <isl/set.h>
4649         __isl_give isl_basic_set *isl_basic_set_add_dims(
4650                 __isl_take isl_basic_set *bset,
4651                 enum isl_dim_type type, unsigned n);
4652         __isl_give isl_set *isl_set_add_dims(
4653                 __isl_take isl_set *set,
4654                 enum isl_dim_type type, unsigned n);
4655         __isl_give isl_basic_set *isl_basic_set_insert_dims(
4656                 __isl_take isl_basic_set *bset,
4657                 enum isl_dim_type type, unsigned pos,
4658                 unsigned n);
4659         __isl_give isl_set *isl_set_insert_dims(
4660                 __isl_take isl_set *set,
4661                 enum isl_dim_type type, unsigned pos, unsigned n);
4662         __isl_give isl_basic_set *isl_basic_set_move_dims(
4663                 __isl_take isl_basic_set *bset,
4664                 enum isl_dim_type dst_type, unsigned dst_pos,
4665                 enum isl_dim_type src_type, unsigned src_pos,
4666                 unsigned n);
4667         __isl_give isl_set *isl_set_move_dims(
4668                 __isl_take isl_set *set,
4669                 enum isl_dim_type dst_type, unsigned dst_pos,
4670                 enum isl_dim_type src_type, unsigned src_pos,
4671                 unsigned n);
4673         #include <isl/map.h>
4674         __isl_give isl_map *isl_map_add_dims(
4675                 __isl_take isl_map *map,
4676                 enum isl_dim_type type, unsigned n);
4677         __isl_give isl_basic_map *isl_basic_map_insert_dims(
4678                 __isl_take isl_basic_map *bmap,
4679                 enum isl_dim_type type, unsigned pos,
4680                 unsigned n);
4681         __isl_give isl_map *isl_map_insert_dims(
4682                 __isl_take isl_map *map,
4683                 enum isl_dim_type type, unsigned pos, unsigned n);
4684         __isl_give isl_basic_map *isl_basic_map_move_dims(
4685                 __isl_take isl_basic_map *bmap,
4686                 enum isl_dim_type dst_type, unsigned dst_pos,
4687                 enum isl_dim_type src_type, unsigned src_pos,
4688                 unsigned n);
4689         __isl_give isl_map *isl_map_move_dims(
4690                 __isl_take isl_map *map,
4691                 enum isl_dim_type dst_type, unsigned dst_pos,
4692                 enum isl_dim_type src_type, unsigned src_pos,
4693                 unsigned n);
4695         #include <isl/val.h>
4696         __isl_give isl_multi_val *isl_multi_val_insert_dims(
4697                 __isl_take isl_multi_val *mv,
4698                 enum isl_dim_type type, unsigned first, unsigned n);
4699         __isl_give isl_multi_val *isl_multi_val_add_dims(
4700                 __isl_take isl_multi_val *mv,
4701                 enum isl_dim_type type, unsigned n);
4702         __isl_give isl_multi_val *isl_multi_val_drop_dims(
4703                 __isl_take isl_multi_val *mv,
4704                 enum isl_dim_type type, unsigned first, unsigned n);
4706         #include <isl/aff.h>
4707         __isl_give isl_aff *isl_aff_insert_dims(
4708                 __isl_take isl_aff *aff,
4709                 enum isl_dim_type type, unsigned first, unsigned n);
4710         __isl_give isl_multi_aff *isl_multi_aff_insert_dims(
4711                 __isl_take isl_multi_aff *ma,
4712                 enum isl_dim_type type, unsigned first, unsigned n);
4713         __isl_give isl_pw_aff *isl_pw_aff_insert_dims(
4714                 __isl_take isl_pw_aff *pwaff,
4715                 enum isl_dim_type type, unsigned first, unsigned n);
4716         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_insert_dims(
4717                 __isl_take isl_multi_pw_aff *mpa,
4718                 enum isl_dim_type type, unsigned first, unsigned n);
4719         __isl_give isl_aff *isl_aff_add_dims(
4720                 __isl_take isl_aff *aff,
4721                 enum isl_dim_type type, unsigned n);
4722         __isl_give isl_multi_aff *isl_multi_aff_add_dims(
4723                 __isl_take isl_multi_aff *ma,
4724                 enum isl_dim_type type, unsigned n);
4725         __isl_give isl_pw_aff *isl_pw_aff_add_dims(
4726                 __isl_take isl_pw_aff *pwaff,
4727                 enum isl_dim_type type, unsigned n);
4728         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_add_dims(
4729                 __isl_take isl_multi_pw_aff *mpa,
4730                 enum isl_dim_type type, unsigned n);
4731         __isl_give isl_aff *isl_aff_drop_dims(
4732                 __isl_take isl_aff *aff,
4733                 enum isl_dim_type type, unsigned first, unsigned n);
4734         __isl_give isl_multi_aff *isl_multi_aff_drop_dims(
4735                 __isl_take isl_multi_aff *maff,
4736                 enum isl_dim_type type, unsigned first, unsigned n);
4737         __isl_give isl_pw_aff *isl_pw_aff_drop_dims(
4738                 __isl_take isl_pw_aff *pwaff,
4739                 enum isl_dim_type type, unsigned first, unsigned n);
4740         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_drop_dims(
4741                 __isl_take isl_pw_multi_aff *pma,
4742                 enum isl_dim_type type, unsigned first, unsigned n);
4743         __isl_give isl_aff *isl_aff_move_dims(
4744                 __isl_take isl_aff *aff,
4745                 enum isl_dim_type dst_type, unsigned dst_pos,
4746                 enum isl_dim_type src_type, unsigned src_pos,
4747                 unsigned n);
4748         __isl_give isl_multi_aff *isl_multi_aff_move_dims(
4749                 __isl_take isl_multi_aff *ma,
4750                 enum isl_dim_type dst_type, unsigned dst_pos,
4751                 enum isl_dim_type src_type, unsigned src_pos,
4752                 unsigned n);
4753         __isl_give isl_pw_aff *isl_pw_aff_move_dims(
4754                 __isl_take isl_pw_aff *pa,
4755                 enum isl_dim_type dst_type, unsigned dst_pos,
4756                 enum isl_dim_type src_type, unsigned src_pos,
4757                 unsigned n);
4758         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_move_dims(
4759                 __isl_take isl_multi_pw_aff *pma,
4760                 enum isl_dim_type dst_type, unsigned dst_pos,
4761                 enum isl_dim_type src_type, unsigned src_pos,
4762                 unsigned n);
4764 =back
4766 =head2 Binary Operations
4768 The two arguments of a binary operation not only need to live
4769 in the same C<isl_ctx>, they currently also need to have
4770 the same (number of) parameters.
4772 =head3 Basic Operations
4774 =over
4776 =item * Intersection
4778         #include <isl/local_space.h>
4779         __isl_give isl_local_space *isl_local_space_intersect(
4780                 __isl_take isl_local_space *ls1,
4781                 __isl_take isl_local_space *ls2);
4783         #include <isl/set.h>
4784         __isl_give isl_basic_set *isl_basic_set_intersect_params(
4785                 __isl_take isl_basic_set *bset1,
4786                 __isl_take isl_basic_set *bset2);
4787         __isl_give isl_basic_set *isl_basic_set_intersect(
4788                 __isl_take isl_basic_set *bset1,
4789                 __isl_take isl_basic_set *bset2);
4790         __isl_give isl_basic_set *isl_basic_set_list_intersect(
4791                 __isl_take struct isl_basic_set_list *list);
4792         __isl_give isl_set *isl_set_intersect_params(
4793                 __isl_take isl_set *set,
4794                 __isl_take isl_set *params);
4795         __isl_give isl_set *isl_set_intersect(
4796                 __isl_take isl_set *set1,
4797                 __isl_take isl_set *set2);
4799         #include <isl/map.h>
4800         __isl_give isl_basic_map *isl_basic_map_intersect_domain(
4801                 __isl_take isl_basic_map *bmap,
4802                 __isl_take isl_basic_set *bset);
4803         __isl_give isl_basic_map *isl_basic_map_intersect_range(
4804                 __isl_take isl_basic_map *bmap,
4805                 __isl_take isl_basic_set *bset);
4806         __isl_give isl_basic_map *isl_basic_map_intersect(
4807                 __isl_take isl_basic_map *bmap1,
4808                 __isl_take isl_basic_map *bmap2);
4809         __isl_give isl_map *isl_map_intersect_params(
4810                 __isl_take isl_map *map,
4811                 __isl_take isl_set *params);
4812         __isl_give isl_map *isl_map_intersect_domain(
4813                 __isl_take isl_map *map,
4814                 __isl_take isl_set *set);
4815         __isl_give isl_map *isl_map_intersect_range(
4816                 __isl_take isl_map *map,
4817                 __isl_take isl_set *set);
4818         __isl_give isl_map *isl_map_intersect(
4819                 __isl_take isl_map *map1,
4820                 __isl_take isl_map *map2);
4822         #include <isl/union_set.h>
4823         __isl_give isl_union_set *isl_union_set_intersect_params(
4824                 __isl_take isl_union_set *uset,
4825                 __isl_take isl_set *set);
4826         __isl_give isl_union_set *isl_union_set_intersect(
4827                 __isl_take isl_union_set *uset1,
4828                 __isl_take isl_union_set *uset2);
4830         #include <isl/union_map.h>
4831         __isl_give isl_union_map *isl_union_map_intersect_params(
4832                 __isl_take isl_union_map *umap,
4833                 __isl_take isl_set *set);
4834         __isl_give isl_union_map *isl_union_map_intersect_domain(
4835                 __isl_take isl_union_map *umap,
4836                 __isl_take isl_union_set *uset);
4837         __isl_give isl_union_map *isl_union_map_intersect_range(
4838                 __isl_take isl_union_map *umap,
4839                 __isl_take isl_union_set *uset);
4840         __isl_give isl_union_map *isl_union_map_intersect(
4841                 __isl_take isl_union_map *umap1,
4842                 __isl_take isl_union_map *umap2);
4844         #include <isl/aff.h>
4845         __isl_give isl_pw_aff *isl_pw_aff_intersect_domain(
4846                 __isl_take isl_pw_aff *pa,
4847                 __isl_take isl_set *set);
4848         __isl_give isl_multi_pw_aff *
4849         isl_multi_pw_aff_intersect_domain(
4850                 __isl_take isl_multi_pw_aff *mpa,
4851                 __isl_take isl_set *domain);
4852         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_domain(
4853                 __isl_take isl_pw_multi_aff *pma,
4854                 __isl_take isl_set *set);
4855         __isl_give isl_union_pw_multi_aff *
4856         isl_union_pw_multi_aff_intersect_domain(
4857                 __isl_take isl_union_pw_multi_aff *upma,
4858                 __isl_take isl_union_set *uset);
4859         __isl_give isl_pw_aff *isl_pw_aff_intersect_params(
4860                 __isl_take isl_pw_aff *pa,
4861                 __isl_take isl_set *set);
4862         __isl_give isl_multi_pw_aff *
4863         isl_multi_pw_aff_intersect_params(
4864                 __isl_take isl_multi_pw_aff *mpa,
4865                 __isl_take isl_set *set);
4866         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_params(
4867                 __isl_take isl_pw_multi_aff *pma,
4868                 __isl_take isl_set *set);
4869         __isl_give isl_union_pw_multi_aff *
4870         isl_union_pw_multi_aff_intersect_params(
4871                 __isl_take isl_union_pw_multi_aff *upma,
4872                 __isl_take isl_set *set);
4874         #include <isl/polynomial.h>
4875         __isl_give isl_pw_qpolynomial *
4876         isl_pw_qpolynomial_intersect_domain(
4877                 __isl_take isl_pw_qpolynomial *pwpq,
4878                 __isl_take isl_set *set);
4879         __isl_give isl_union_pw_qpolynomial *
4880         isl_union_pw_qpolynomial_intersect_domain(
4881                 __isl_take isl_union_pw_qpolynomial *upwpq,
4882                 __isl_take isl_union_set *uset);
4883         __isl_give isl_union_pw_qpolynomial_fold *
4884         isl_union_pw_qpolynomial_fold_intersect_domain(
4885                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4886                 __isl_take isl_union_set *uset);
4887         __isl_give isl_pw_qpolynomial *
4888         isl_pw_qpolynomial_intersect_params(
4889                 __isl_take isl_pw_qpolynomial *pwpq,
4890                 __isl_take isl_set *set);
4891         __isl_give isl_pw_qpolynomial_fold *
4892         isl_pw_qpolynomial_fold_intersect_params(
4893                 __isl_take isl_pw_qpolynomial_fold *pwf,
4894                 __isl_take isl_set *set);
4895         __isl_give isl_union_pw_qpolynomial *
4896         isl_union_pw_qpolynomial_intersect_params(
4897                 __isl_take isl_union_pw_qpolynomial *upwpq,
4898                 __isl_take isl_set *set);
4899         __isl_give isl_union_pw_qpolynomial_fold *
4900         isl_union_pw_qpolynomial_fold_intersect_params(
4901                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4902                 __isl_take isl_set *set);
4904 The second argument to the C<_params> functions needs to be
4905 a parametric (basic) set.  For the other functions, a parametric set
4906 for either argument is only allowed if the other argument is
4907 a parametric set as well.
4908 The list passed to C<isl_basic_set_list_intersect> needs to have
4909 at least one element and all elements need to live in the same space.
4911 =item * Union
4913         __isl_give isl_set *isl_basic_set_union(
4914                 __isl_take isl_basic_set *bset1,
4915                 __isl_take isl_basic_set *bset2);
4916         __isl_give isl_map *isl_basic_map_union(
4917                 __isl_take isl_basic_map *bmap1,
4918                 __isl_take isl_basic_map *bmap2);
4919         __isl_give isl_set *isl_set_union(
4920                 __isl_take isl_set *set1,
4921                 __isl_take isl_set *set2);
4922         __isl_give isl_map *isl_map_union(
4923                 __isl_take isl_map *map1,
4924                 __isl_take isl_map *map2);
4925         __isl_give isl_union_set *isl_union_set_union(
4926                 __isl_take isl_union_set *uset1,
4927                 __isl_take isl_union_set *uset2);
4928         __isl_give isl_union_map *isl_union_map_union(
4929                 __isl_take isl_union_map *umap1,
4930                 __isl_take isl_union_map *umap2);
4932 =item * Set difference
4934         __isl_give isl_set *isl_set_subtract(
4935                 __isl_take isl_set *set1,
4936                 __isl_take isl_set *set2);
4937         __isl_give isl_map *isl_map_subtract(
4938                 __isl_take isl_map *map1,
4939                 __isl_take isl_map *map2);
4940         __isl_give isl_map *isl_map_subtract_domain(
4941                 __isl_take isl_map *map,
4942                 __isl_take isl_set *dom);
4943         __isl_give isl_map *isl_map_subtract_range(
4944                 __isl_take isl_map *map,
4945                 __isl_take isl_set *dom);
4946         __isl_give isl_union_set *isl_union_set_subtract(
4947                 __isl_take isl_union_set *uset1,
4948                 __isl_take isl_union_set *uset2);
4949         __isl_give isl_union_map *isl_union_map_subtract(
4950                 __isl_take isl_union_map *umap1,
4951                 __isl_take isl_union_map *umap2);
4952         __isl_give isl_union_map *isl_union_map_subtract_domain(
4953                 __isl_take isl_union_map *umap,
4954                 __isl_take isl_union_set *dom);
4955         __isl_give isl_union_map *isl_union_map_subtract_range(
4956                 __isl_take isl_union_map *umap,
4957                 __isl_take isl_union_set *dom);
4959 =item * Application
4961         #include <isl/space.h>
4962         __isl_give isl_space *isl_space_join(
4963                 __isl_take isl_space *left,
4964                 __isl_take isl_space *right);
4966         #include <isl/map.h>
4967         __isl_give isl_basic_set *isl_basic_set_apply(
4968                 __isl_take isl_basic_set *bset,
4969                 __isl_take isl_basic_map *bmap);
4970         __isl_give isl_set *isl_set_apply(
4971                 __isl_take isl_set *set,
4972                 __isl_take isl_map *map);
4973         __isl_give isl_union_set *isl_union_set_apply(
4974                 __isl_take isl_union_set *uset,
4975                 __isl_take isl_union_map *umap);
4976         __isl_give isl_basic_map *isl_basic_map_apply_domain(
4977                 __isl_take isl_basic_map *bmap1,
4978                 __isl_take isl_basic_map *bmap2);
4979         __isl_give isl_basic_map *isl_basic_map_apply_range(
4980                 __isl_take isl_basic_map *bmap1,
4981                 __isl_take isl_basic_map *bmap2);
4982         __isl_give isl_map *isl_map_apply_domain(
4983                 __isl_take isl_map *map1,
4984                 __isl_take isl_map *map2);
4985         __isl_give isl_map *isl_map_apply_range(
4986                 __isl_take isl_map *map1,
4987                 __isl_take isl_map *map2);
4989         #include <isl/union_map.h>
4990         __isl_give isl_union_map *isl_union_map_apply_domain(
4991                 __isl_take isl_union_map *umap1,
4992                 __isl_take isl_union_map *umap2);
4993         __isl_give isl_union_map *isl_union_map_apply_range(
4994                 __isl_take isl_union_map *umap1,
4995                 __isl_take isl_union_map *umap2);
4997         #include <isl/polynomial.h>
4998         __isl_give isl_pw_qpolynomial_fold *
4999         isl_set_apply_pw_qpolynomial_fold(
5000                 __isl_take isl_set *set,
5001                 __isl_take isl_pw_qpolynomial_fold *pwf,
5002                 int *tight);
5003         __isl_give isl_pw_qpolynomial_fold *
5004         isl_map_apply_pw_qpolynomial_fold(
5005                 __isl_take isl_map *map,
5006                 __isl_take isl_pw_qpolynomial_fold *pwf,
5007                 int *tight);
5008         __isl_give isl_union_pw_qpolynomial_fold *
5009         isl_union_set_apply_union_pw_qpolynomial_fold(
5010                 __isl_take isl_union_set *uset,
5011                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5012                 int *tight);
5013         __isl_give isl_union_pw_qpolynomial_fold *
5014         isl_union_map_apply_union_pw_qpolynomial_fold(
5015                 __isl_take isl_union_map *umap,
5016                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5017                 int *tight);
5019 The functions taking a map
5020 compose the given map with the given piecewise quasipolynomial reduction.
5021 That is, compute a bound (of the same type as C<pwf> or C<upwf> itself)
5022 over all elements in the intersection of the range of the map
5023 and the domain of the piecewise quasipolynomial reduction
5024 as a function of an element in the domain of the map.
5025 The functions taking a set compute a bound over all elements in the
5026 intersection of the set and the domain of the
5027 piecewise quasipolynomial reduction.
5029 =item * Preimage
5031         #include <isl/set.h>
5032         __isl_give isl_basic_set *
5033         isl_basic_set_preimage_multi_aff(
5034                 __isl_take isl_basic_set *bset,
5035                 __isl_take isl_multi_aff *ma);
5036         __isl_give isl_set *isl_set_preimage_multi_aff(
5037                 __isl_take isl_set *set,
5038                 __isl_take isl_multi_aff *ma);
5039         __isl_give isl_set *isl_set_preimage_pw_multi_aff(
5040                 __isl_take isl_set *set,
5041                 __isl_take isl_pw_multi_aff *pma);
5042         __isl_give isl_set *isl_set_preimage_multi_pw_aff(
5043                 __isl_take isl_set *set,
5044                 __isl_take isl_multi_pw_aff *mpa);
5046         #include <isl/union_set.h>
5047         __isl_give isl_union_set *
5048         isl_union_set_preimage_multi_aff(
5049                 __isl_take isl_union_set *uset,
5050                 __isl_take isl_multi_aff *ma);
5051         __isl_give isl_union_set *
5052         isl_union_set_preimage_pw_multi_aff(
5053                 __isl_take isl_union_set *uset,
5054                 __isl_take isl_pw_multi_aff *pma);
5055         __isl_give isl_union_set *
5056         isl_union_set_preimage_union_pw_multi_aff(
5057                 __isl_take isl_union_set *uset,
5058                 __isl_take isl_union_pw_multi_aff *upma);
5060         #include <isl/map.h>
5061         __isl_give isl_basic_map *
5062         isl_basic_map_preimage_domain_multi_aff(
5063                 __isl_take isl_basic_map *bmap,
5064                 __isl_take isl_multi_aff *ma);
5065         __isl_give isl_map *isl_map_preimage_domain_multi_aff(
5066                 __isl_take isl_map *map,
5067                 __isl_take isl_multi_aff *ma);
5068         __isl_give isl_map *isl_map_preimage_range_multi_aff(
5069                 __isl_take isl_map *map,
5070                 __isl_take isl_multi_aff *ma);
5071         __isl_give isl_map *
5072         isl_map_preimage_domain_pw_multi_aff(
5073                 __isl_take isl_map *map,
5074                 __isl_take isl_pw_multi_aff *pma);
5075         __isl_give isl_map *
5076         isl_map_preimage_range_pw_multi_aff(
5077                 __isl_take isl_map *map,
5078                 __isl_take isl_pw_multi_aff *pma);
5079         __isl_give isl_map *
5080         isl_map_preimage_domain_multi_pw_aff(
5081                 __isl_take isl_map *map,
5082                 __isl_take isl_multi_pw_aff *mpa);
5083         __isl_give isl_basic_map *
5084         isl_basic_map_preimage_range_multi_aff(
5085                 __isl_take isl_basic_map *bmap,
5086                 __isl_take isl_multi_aff *ma);
5088         #include <isl/union_map.h>
5089         __isl_give isl_union_map *
5090         isl_union_map_preimage_domain_multi_aff(
5091                 __isl_take isl_union_map *umap,
5092                 __isl_take isl_multi_aff *ma);
5093         __isl_give isl_union_map *
5094         isl_union_map_preimage_range_multi_aff(
5095                 __isl_take isl_union_map *umap,
5096                 __isl_take isl_multi_aff *ma);
5097         __isl_give isl_union_map *
5098         isl_union_map_preimage_domain_pw_multi_aff(
5099                 __isl_take isl_union_map *umap,
5100                 __isl_take isl_pw_multi_aff *pma);
5101         __isl_give isl_union_map *
5102         isl_union_map_preimage_range_pw_multi_aff(
5103                 __isl_take isl_union_map *umap,
5104                 __isl_take isl_pw_multi_aff *pma);
5105         __isl_give isl_union_map *
5106         isl_union_map_preimage_domain_union_pw_multi_aff(
5107                 __isl_take isl_union_map *umap,
5108                 __isl_take isl_union_pw_multi_aff *upma);
5109         __isl_give isl_union_map *
5110         isl_union_map_preimage_range_union_pw_multi_aff(
5111                 __isl_take isl_union_map *umap,
5112                 __isl_take isl_union_pw_multi_aff *upma);
5114 These functions compute the preimage of the given set or map domain/range under
5115 the given function.  In other words, the expression is plugged
5116 into the set description or into the domain/range of the map.
5118 =item * Pullback
5120         #include <isl/aff.h>
5121         __isl_give isl_aff *isl_aff_pullback_aff(
5122                 __isl_take isl_aff *aff1,
5123                 __isl_take isl_aff *aff2);
5124         __isl_give isl_aff *isl_aff_pullback_multi_aff(
5125                 __isl_take isl_aff *aff,
5126                 __isl_take isl_multi_aff *ma);
5127         __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_aff(
5128                 __isl_take isl_pw_aff *pa,
5129                 __isl_take isl_multi_aff *ma);
5130         __isl_give isl_pw_aff *isl_pw_aff_pullback_pw_multi_aff(
5131                 __isl_take isl_pw_aff *pa,
5132                 __isl_take isl_pw_multi_aff *pma);
5133         __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_pw_aff(
5134                 __isl_take isl_pw_aff *pa,
5135                 __isl_take isl_multi_pw_aff *mpa);
5136         __isl_give isl_multi_aff *isl_multi_aff_pullback_multi_aff(
5137                 __isl_take isl_multi_aff *ma1,
5138                 __isl_take isl_multi_aff *ma2);
5139         __isl_give isl_pw_multi_aff *
5140         isl_pw_multi_aff_pullback_multi_aff(
5141                 __isl_take isl_pw_multi_aff *pma,
5142                 __isl_take isl_multi_aff *ma);
5143         __isl_give isl_multi_pw_aff *
5144         isl_multi_pw_aff_pullback_multi_aff(
5145                 __isl_take isl_multi_pw_aff *mpa,
5146                 __isl_take isl_multi_aff *ma);
5147         __isl_give isl_pw_multi_aff *
5148         isl_pw_multi_aff_pullback_pw_multi_aff(
5149                 __isl_take isl_pw_multi_aff *pma1,
5150                 __isl_take isl_pw_multi_aff *pma2);
5151         __isl_give isl_multi_pw_aff *
5152         isl_multi_pw_aff_pullback_pw_multi_aff(
5153                 __isl_take isl_multi_pw_aff *mpa,
5154                 __isl_take isl_pw_multi_aff *pma);
5155         __isl_give isl_multi_pw_aff *
5156         isl_multi_pw_aff_pullback_multi_pw_aff(
5157                 __isl_take isl_multi_pw_aff *mpa1,
5158                 __isl_take isl_multi_pw_aff *mpa2);
5160 These functions precompose the first expression by the second function.
5161 In other words, the second function is plugged
5162 into the first expression.
5164 =item * Locus
5166         #include <isl/aff.h>
5167         __isl_give isl_basic_set *isl_aff_le_basic_set(
5168                 __isl_take isl_aff *aff1,
5169                 __isl_take isl_aff *aff2);
5170         __isl_give isl_basic_set *isl_aff_ge_basic_set(
5171                 __isl_take isl_aff *aff1,
5172                 __isl_take isl_aff *aff2);
5173         __isl_give isl_set *isl_pw_aff_eq_set(
5174                 __isl_take isl_pw_aff *pwaff1,
5175                 __isl_take isl_pw_aff *pwaff2);
5176         __isl_give isl_set *isl_pw_aff_ne_set(
5177                 __isl_take isl_pw_aff *pwaff1,
5178                 __isl_take isl_pw_aff *pwaff2);
5179         __isl_give isl_set *isl_pw_aff_le_set(
5180                 __isl_take isl_pw_aff *pwaff1,
5181                 __isl_take isl_pw_aff *pwaff2);
5182         __isl_give isl_set *isl_pw_aff_lt_set(
5183                 __isl_take isl_pw_aff *pwaff1,
5184                 __isl_take isl_pw_aff *pwaff2);
5185         __isl_give isl_set *isl_pw_aff_ge_set(
5186                 __isl_take isl_pw_aff *pwaff1,
5187                 __isl_take isl_pw_aff *pwaff2);
5188         __isl_give isl_set *isl_pw_aff_gt_set(
5189                 __isl_take isl_pw_aff *pwaff1,
5190                 __isl_take isl_pw_aff *pwaff2);
5192         __isl_give isl_set *isl_multi_aff_lex_le_set(
5193                 __isl_take isl_multi_aff *ma1,
5194                 __isl_take isl_multi_aff *ma2);
5195         __isl_give isl_set *isl_multi_aff_lex_ge_set(
5196                 __isl_take isl_multi_aff *ma1,
5197                 __isl_take isl_multi_aff *ma2);
5199         __isl_give isl_set *isl_pw_aff_list_eq_set(
5200                 __isl_take isl_pw_aff_list *list1,
5201                 __isl_take isl_pw_aff_list *list2);
5202         __isl_give isl_set *isl_pw_aff_list_ne_set(
5203                 __isl_take isl_pw_aff_list *list1,
5204                 __isl_take isl_pw_aff_list *list2);
5205         __isl_give isl_set *isl_pw_aff_list_le_set(
5206                 __isl_take isl_pw_aff_list *list1,
5207                 __isl_take isl_pw_aff_list *list2);
5208         __isl_give isl_set *isl_pw_aff_list_lt_set(
5209                 __isl_take isl_pw_aff_list *list1,
5210                 __isl_take isl_pw_aff_list *list2);
5211         __isl_give isl_set *isl_pw_aff_list_ge_set(
5212                 __isl_take isl_pw_aff_list *list1,
5213                 __isl_take isl_pw_aff_list *list2);
5214         __isl_give isl_set *isl_pw_aff_list_gt_set(
5215                 __isl_take isl_pw_aff_list *list1,
5216                 __isl_take isl_pw_aff_list *list2);
5218 The function C<isl_aff_ge_basic_set> returns a basic set
5219 containing those elements in the shared space
5220 of C<aff1> and C<aff2> where C<aff1> is greater than or equal to C<aff2>.
5221 The function C<isl_pw_aff_ge_set> returns a set
5222 containing those elements in the shared domain
5223 of C<pwaff1> and C<pwaff2> where C<pwaff1> is
5224 greater than or equal to C<pwaff2>.
5225 The function C<isl_multi_aff_lex_le_set> returns a set
5226 containing those elements in the shared domain space
5227 where C<ma1> is lexicographically smaller than or
5228 equal to C<ma2>.
5229 The functions operating on C<isl_pw_aff_list> apply the corresponding
5230 C<isl_pw_aff> function to each pair of elements in the two lists.
5232 =item * Cartesian Product
5234         #include <isl/space.h>
5235         __isl_give isl_space *isl_space_product(
5236                 __isl_take isl_space *space1,
5237                 __isl_take isl_space *space2);
5238         __isl_give isl_space *isl_space_domain_product(
5239                 __isl_take isl_space *space1,
5240                 __isl_take isl_space *space2);
5241         __isl_give isl_space *isl_space_range_product(
5242                 __isl_take isl_space *space1,
5243                 __isl_take isl_space *space2);
5245 The functions
5246 C<isl_space_product>, C<isl_space_domain_product>
5247 and C<isl_space_range_product> take pairs or relation spaces and
5248 produce a single relations space, where either the domain, the range
5249 or both domain and range are wrapped spaces of relations between
5250 the domains and/or ranges of the input spaces.
5251 If the product is only constructed over the domain or the range
5252 then the ranges or the domains of the inputs should be the same.
5253 The function C<isl_space_product> also accepts a pair of set spaces,
5254 in which case it returns a wrapped space of a relation between the
5255 two input spaces.
5257         #include <isl/set.h>
5258         __isl_give isl_set *isl_set_product(
5259                 __isl_take isl_set *set1,
5260                 __isl_take isl_set *set2);
5262         #include <isl/map.h>
5263         __isl_give isl_basic_map *isl_basic_map_domain_product(
5264                 __isl_take isl_basic_map *bmap1,
5265                 __isl_take isl_basic_map *bmap2);
5266         __isl_give isl_basic_map *isl_basic_map_range_product(
5267                 __isl_take isl_basic_map *bmap1,
5268                 __isl_take isl_basic_map *bmap2);
5269         __isl_give isl_basic_map *isl_basic_map_product(
5270                 __isl_take isl_basic_map *bmap1,
5271                 __isl_take isl_basic_map *bmap2);
5272         __isl_give isl_map *isl_map_domain_product(
5273                 __isl_take isl_map *map1,
5274                 __isl_take isl_map *map2);
5275         __isl_give isl_map *isl_map_range_product(
5276                 __isl_take isl_map *map1,
5277                 __isl_take isl_map *map2);
5278         __isl_give isl_map *isl_map_product(
5279                 __isl_take isl_map *map1,
5280                 __isl_take isl_map *map2);
5282         #include <isl/union_set.h>
5283         __isl_give isl_union_set *isl_union_set_product(
5284                 __isl_take isl_union_set *uset1,
5285                 __isl_take isl_union_set *uset2);
5287         #include <isl/union_map.h>
5288         __isl_give isl_union_map *isl_union_map_domain_product(
5289                 __isl_take isl_union_map *umap1,
5290                 __isl_take isl_union_map *umap2);
5291         __isl_give isl_union_map *isl_union_map_range_product(
5292                 __isl_take isl_union_map *umap1,
5293                 __isl_take isl_union_map *umap2);
5294         __isl_give isl_union_map *isl_union_map_product(
5295                 __isl_take isl_union_map *umap1,
5296                 __isl_take isl_union_map *umap2);
5298         #include <isl/val.h>
5299         __isl_give isl_multi_val *isl_multi_val_range_product(
5300                 __isl_take isl_multi_val *mv1,
5301                 __isl_take isl_multi_val *mv2);
5302         __isl_give isl_multi_val *isl_multi_val_product(
5303                 __isl_take isl_multi_val *mv1,
5304                 __isl_take isl_multi_val *mv2);
5306         #include <isl/aff.h>
5307         __isl_give isl_multi_aff *isl_multi_aff_range_product(
5308                 __isl_take isl_multi_aff *ma1,
5309                 __isl_take isl_multi_aff *ma2);
5310         __isl_give isl_multi_aff *isl_multi_aff_product(
5311                 __isl_take isl_multi_aff *ma1,
5312                 __isl_take isl_multi_aff *ma2);
5313         __isl_give isl_multi_pw_aff *
5314         isl_multi_pw_aff_range_product(
5315                 __isl_take isl_multi_pw_aff *mpa1,
5316                 __isl_take isl_multi_pw_aff *mpa2);
5317         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_product(
5318                 __isl_take isl_multi_pw_aff *mpa1,
5319                 __isl_take isl_multi_pw_aff *mpa2);
5320         __isl_give isl_pw_multi_aff *
5321         isl_pw_multi_aff_range_product(
5322                 __isl_take isl_pw_multi_aff *pma1,
5323                 __isl_take isl_pw_multi_aff *pma2);
5324         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_product(
5325                 __isl_take isl_pw_multi_aff *pma1,
5326                 __isl_take isl_pw_multi_aff *pma2);
5328 The above functions compute the cross product of the given
5329 sets, relations or functions.  The domains and ranges of the results
5330 are wrapped maps between domains and ranges of the inputs.
5331 To obtain a ``flat'' product, use the following functions
5332 instead.
5334         #include <isl/set.h>
5335         __isl_give isl_basic_set *isl_basic_set_flat_product(
5336                 __isl_take isl_basic_set *bset1,
5337                 __isl_take isl_basic_set *bset2);
5338         __isl_give isl_set *isl_set_flat_product(
5339                 __isl_take isl_set *set1,
5340                 __isl_take isl_set *set2);
5342         #include <isl/map.h>
5343         __isl_give isl_basic_map *isl_basic_map_flat_range_product(
5344                 __isl_take isl_basic_map *bmap1,
5345                 __isl_take isl_basic_map *bmap2);
5346         __isl_give isl_map *isl_map_flat_domain_product(
5347                 __isl_take isl_map *map1,
5348                 __isl_take isl_map *map2);
5349         __isl_give isl_map *isl_map_flat_range_product(
5350                 __isl_take isl_map *map1,
5351                 __isl_take isl_map *map2);
5352         __isl_give isl_basic_map *isl_basic_map_flat_product(
5353                 __isl_take isl_basic_map *bmap1,
5354                 __isl_take isl_basic_map *bmap2);
5355         __isl_give isl_map *isl_map_flat_product(
5356                 __isl_take isl_map *map1,
5357                 __isl_take isl_map *map2);
5359         #include <isl/union_map.h>
5360         __isl_give isl_union_map *
5361         isl_union_map_flat_range_product(
5362                 __isl_take isl_union_map *umap1,
5363                 __isl_take isl_union_map *umap2);
5365         #include <isl/val.h>
5366         __isl_give isl_multi_val *isl_multi_val_flat_range_product(
5367                 __isl_take isl_multi_val *mv1,
5368                 __isl_take isl_multi_aff *mv2);
5370         #include <isl/aff.h>
5371         __isl_give isl_multi_aff *isl_multi_aff_flat_range_product(
5372                 __isl_take isl_multi_aff *ma1,
5373                 __isl_take isl_multi_aff *ma2);
5374         __isl_give isl_pw_multi_aff *
5375         isl_pw_multi_aff_flat_range_product(
5376                 __isl_take isl_pw_multi_aff *pma1,
5377                 __isl_take isl_pw_multi_aff *pma2);
5378         __isl_give isl_multi_pw_aff *
5379         isl_multi_pw_aff_flat_range_product(
5380                 __isl_take isl_multi_pw_aff *mpa1,
5381                 __isl_take isl_multi_pw_aff *mpa2);
5382         __isl_give isl_union_pw_multi_aff *
5383         isl_union_pw_multi_aff_flat_range_product(
5384                 __isl_take isl_union_pw_multi_aff *upma1,
5385                 __isl_take isl_union_pw_multi_aff *upma2);
5387         #include <isl/space.h>
5388         __isl_give isl_space *isl_space_domain_factor_domain(
5389                 __isl_take isl_space *space);
5390         __isl_give isl_space *isl_space_range_factor_domain(
5391                 __isl_take isl_space *space);
5392         __isl_give isl_space *isl_space_range_factor_range(
5393                 __isl_take isl_space *space);
5395 The functions C<isl_space_range_factor_domain> and
5396 C<isl_space_range_factor_range> extract the two arguments from
5397 the result of a call to C<isl_space_range_product>.
5399 The arguments of a call to C<isl_map_range_product> can be extracted
5400 from the result using the following two functions.
5402         #include <isl/map.h>
5403         __isl_give isl_map *isl_map_range_factor_domain(
5404                 __isl_take isl_map *map);
5405         __isl_give isl_map *isl_map_range_factor_range(
5406                 __isl_take isl_map *map);
5408         #include <isl/val.h>
5409         __isl_give isl_multi_val *
5410         isl_multi_val_range_factor_domain(
5411                 __isl_take isl_multi_val *mv);
5412         __isl_give isl_multi_val *
5413         isl_multi_val_range_factor_range(
5414                 __isl_take isl_multi_val *mv);
5416         #include <isl/aff.h>
5417         __isl_give isl_multi_aff *
5418         isl_multi_aff_range_factor_domain(
5419                 __isl_take isl_multi_aff *ma);
5420         __isl_give isl_multi_aff *
5421         isl_multi_aff_range_factor_range(
5422                 __isl_take isl_multi_aff *ma);
5423         __isl_give isl_multi_pw_aff *
5424         isl_multi_pw_aff_range_factor_domain(
5425                 __isl_take isl_multi_pw_aff *mpa);
5426         __isl_give isl_multi_pw_aff *
5427         isl_multi_pw_aff_range_factor_range(
5428                 __isl_take isl_multi_pw_aff *mpa);
5430 The splice functions are a generalization of the flat product functions,
5431 where the second argument may be inserted at any position inside
5432 the first argument rather than being placed at the end.
5434         #include <isl/val.h>
5435         __isl_give isl_multi_val *isl_multi_val_range_splice(
5436                 __isl_take isl_multi_val *mv1, unsigned pos,
5437                 __isl_take isl_multi_val *mv2);
5439         #include <isl/aff.h>
5440         __isl_give isl_multi_aff *isl_multi_aff_range_splice(
5441                 __isl_take isl_multi_aff *ma1, unsigned pos,
5442                 __isl_take isl_multi_aff *ma2);
5443         __isl_give isl_multi_aff *isl_multi_aff_splice(
5444                 __isl_take isl_multi_aff *ma1,
5445                 unsigned in_pos, unsigned out_pos,
5446                 __isl_take isl_multi_aff *ma2);
5447         __isl_give isl_multi_pw_aff *
5448         isl_multi_pw_aff_range_splice(
5449                 __isl_take isl_multi_pw_aff *mpa1, unsigned pos,
5450                 __isl_take isl_multi_pw_aff *mpa2);
5451         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_splice(
5452                 __isl_take isl_multi_pw_aff *mpa1,
5453                 unsigned in_pos, unsigned out_pos,
5454                 __isl_take isl_multi_pw_aff *mpa2);
5456 =item * Simplification
5458 When applied to a set or relation,
5459 the gist operation returns a set or relation that has the
5460 same intersection with the context as the input set or relation.
5461 Any implicit equality in the intersection is made explicit in the result,
5462 while all inequalities that are redundant with respect to the intersection
5463 are removed.
5464 In case of union sets and relations, the gist operation is performed
5465 per space.
5467 When applied to a function,
5468 the gist operation applies the set gist operation to each of
5469 the cells in the domain of the input piecewise expression.
5470 The context is also exploited
5471 to simplify the expression associated to each cell.
5473         #include <isl/set.h>
5474         __isl_give isl_basic_set *isl_basic_set_gist(
5475                 __isl_take isl_basic_set *bset,
5476                 __isl_take isl_basic_set *context);
5477         __isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
5478                 __isl_take isl_set *context);
5479         __isl_give isl_set *isl_set_gist_params(
5480                 __isl_take isl_set *set,
5481                 __isl_take isl_set *context);
5483         #include <isl/map.h>
5484         __isl_give isl_basic_map *isl_basic_map_gist(
5485                 __isl_take isl_basic_map *bmap,
5486                 __isl_take isl_basic_map *context);
5487         __isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
5488                 __isl_take isl_map *context);
5489         __isl_give isl_map *isl_map_gist_params(
5490                 __isl_take isl_map *map,
5491                 __isl_take isl_set *context);
5492         __isl_give isl_map *isl_map_gist_domain(
5493                 __isl_take isl_map *map,
5494                 __isl_take isl_set *context);
5495         __isl_give isl_map *isl_map_gist_range(
5496                 __isl_take isl_map *map,
5497                 __isl_take isl_set *context);
5499         #include <isl/union_set.h>
5500         __isl_give isl_union_set *isl_union_set_gist(
5501                 __isl_take isl_union_set *uset,
5502                 __isl_take isl_union_set *context);
5503         __isl_give isl_union_set *isl_union_set_gist_params(
5504                 __isl_take isl_union_set *uset,
5505                 __isl_take isl_set *set);
5507         #include <isl/union_map.h>
5508         __isl_give isl_union_map *isl_union_map_gist(
5509                 __isl_take isl_union_map *umap,
5510                 __isl_take isl_union_map *context);
5511         __isl_give isl_union_map *isl_union_map_gist_params(
5512                 __isl_take isl_union_map *umap,
5513                 __isl_take isl_set *set);
5514         __isl_give isl_union_map *isl_union_map_gist_domain(
5515                 __isl_take isl_union_map *umap,
5516                 __isl_take isl_union_set *uset);
5517         __isl_give isl_union_map *isl_union_map_gist_range(
5518                 __isl_take isl_union_map *umap,
5519                 __isl_take isl_union_set *uset);
5521         #include <isl/aff.h>
5522         __isl_give isl_aff *isl_aff_gist_params(
5523                 __isl_take isl_aff *aff,
5524                 __isl_take isl_set *context);
5525         __isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff,
5526                 __isl_take isl_set *context);
5527         __isl_give isl_multi_aff *isl_multi_aff_gist_params(
5528                 __isl_take isl_multi_aff *maff,
5529                 __isl_take isl_set *context);
5530         __isl_give isl_multi_aff *isl_multi_aff_gist(
5531                 __isl_take isl_multi_aff *maff,
5532                 __isl_take isl_set *context);
5533         __isl_give isl_pw_aff *isl_pw_aff_gist_params(
5534                 __isl_take isl_pw_aff *pwaff,
5535                 __isl_take isl_set *context);
5536         __isl_give isl_pw_aff *isl_pw_aff_gist(
5537                 __isl_take isl_pw_aff *pwaff,
5538                 __isl_take isl_set *context);
5539         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist_params(
5540                 __isl_take isl_pw_multi_aff *pma,
5541                 __isl_take isl_set *set);
5542         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist(
5543                 __isl_take isl_pw_multi_aff *pma,
5544                 __isl_take isl_set *set);
5545         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist_params(
5546                 __isl_take isl_multi_pw_aff *mpa,
5547                 __isl_take isl_set *set);
5548         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist(
5549                 __isl_take isl_multi_pw_aff *mpa,
5550                 __isl_take isl_set *set);
5551         __isl_give isl_union_pw_multi_aff *
5552         isl_union_pw_multi_aff_gist_params(
5553                 __isl_take isl_union_pw_multi_aff *upma,
5554                 __isl_take isl_set *context);
5555         __isl_give isl_union_pw_multi_aff *
5556         isl_union_pw_multi_aff_gist(
5557                 __isl_take isl_union_pw_multi_aff *upma,
5558                 __isl_take isl_union_set *context);
5560         #include <isl/polynomial.h>
5561         __isl_give isl_qpolynomial *isl_qpolynomial_gist_params(
5562                 __isl_take isl_qpolynomial *qp,
5563                 __isl_take isl_set *context);
5564         __isl_give isl_qpolynomial *isl_qpolynomial_gist(
5565                 __isl_take isl_qpolynomial *qp,
5566                 __isl_take isl_set *context);
5567         __isl_give isl_qpolynomial_fold *
5568         isl_qpolynomial_fold_gist_params(
5569                 __isl_take isl_qpolynomial_fold *fold,
5570                 __isl_take isl_set *context);
5571         __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist(
5572                 __isl_take isl_qpolynomial_fold *fold,
5573                 __isl_take isl_set *context);
5574         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist_params(
5575                 __isl_take isl_pw_qpolynomial *pwqp,
5576                 __isl_take isl_set *context);
5577         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist(
5578                 __isl_take isl_pw_qpolynomial *pwqp,
5579                 __isl_take isl_set *context);
5580         __isl_give isl_pw_qpolynomial_fold *
5581         isl_pw_qpolynomial_fold_gist(
5582                 __isl_take isl_pw_qpolynomial_fold *pwf,
5583                 __isl_take isl_set *context);
5584         __isl_give isl_pw_qpolynomial_fold *
5585         isl_pw_qpolynomial_fold_gist_params(
5586                 __isl_take isl_pw_qpolynomial_fold *pwf,
5587                 __isl_take isl_set *context);
5588         __isl_give isl_union_pw_qpolynomial *
5589         isl_union_pw_qpolynomial_gist_params(
5590                 __isl_take isl_union_pw_qpolynomial *upwqp,
5591                 __isl_take isl_set *context);
5592         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist(
5593                 __isl_take isl_union_pw_qpolynomial *upwqp,
5594                 __isl_take isl_union_set *context);
5595         __isl_give isl_union_pw_qpolynomial_fold *
5596         isl_union_pw_qpolynomial_fold_gist(
5597                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5598                 __isl_take isl_union_set *context);
5599         __isl_give isl_union_pw_qpolynomial_fold *
5600         isl_union_pw_qpolynomial_fold_gist_params(
5601                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5602                 __isl_take isl_set *context);
5604 =item * Binary Arithmethic Operations
5606         #include <isl/aff.h>
5607         __isl_give isl_aff *isl_aff_add(
5608                 __isl_take isl_aff *aff1,
5609                 __isl_take isl_aff *aff2);
5610         __isl_give isl_multi_aff *isl_multi_aff_add(
5611                 __isl_take isl_multi_aff *maff1,
5612                 __isl_take isl_multi_aff *maff2);
5613         __isl_give isl_pw_aff *isl_pw_aff_add(
5614                 __isl_take isl_pw_aff *pwaff1,
5615                 __isl_take isl_pw_aff *pwaff2);
5616         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_add(
5617                 __isl_take isl_pw_multi_aff *pma1,
5618                 __isl_take isl_pw_multi_aff *pma2);
5619         __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_add(
5620                 __isl_take isl_union_pw_multi_aff *upma1,
5621                 __isl_take isl_union_pw_multi_aff *upma2);
5622         __isl_give isl_pw_aff *isl_pw_aff_min(
5623                 __isl_take isl_pw_aff *pwaff1,
5624                 __isl_take isl_pw_aff *pwaff2);
5625         __isl_give isl_pw_aff *isl_pw_aff_max(
5626                 __isl_take isl_pw_aff *pwaff1,
5627                 __isl_take isl_pw_aff *pwaff2);
5628         __isl_give isl_aff *isl_aff_sub(
5629                 __isl_take isl_aff *aff1,
5630                 __isl_take isl_aff *aff2);
5631         __isl_give isl_multi_aff *isl_multi_aff_sub(
5632                 __isl_take isl_multi_aff *ma1,
5633                 __isl_take isl_multi_aff *ma2);
5634         __isl_give isl_pw_aff *isl_pw_aff_sub(
5635                 __isl_take isl_pw_aff *pwaff1,
5636                 __isl_take isl_pw_aff *pwaff2);
5637         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_sub(
5638                 __isl_take isl_pw_multi_aff *pma1,
5639                 __isl_take isl_pw_multi_aff *pma2);
5640         __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_sub(
5641                 __isl_take isl_union_pw_multi_aff *upma1,
5642                 __isl_take isl_union_pw_multi_aff *upma2);
5644 C<isl_aff_sub> subtracts the second argument from the first.
5646         #include <isl/polynomial.h>
5647         __isl_give isl_qpolynomial *isl_qpolynomial_add(
5648                 __isl_take isl_qpolynomial *qp1,
5649                 __isl_take isl_qpolynomial *qp2);
5650         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
5651                 __isl_take isl_pw_qpolynomial *pwqp1,
5652                 __isl_take isl_pw_qpolynomial *pwqp2);
5653         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint(
5654                 __isl_take isl_pw_qpolynomial *pwqp1,
5655                 __isl_take isl_pw_qpolynomial *pwqp2);
5656         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
5657                 __isl_take isl_pw_qpolynomial_fold *pwf1,
5658                 __isl_take isl_pw_qpolynomial_fold *pwf2);
5659         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add(
5660                 __isl_take isl_union_pw_qpolynomial *upwqp1,
5661                 __isl_take isl_union_pw_qpolynomial *upwqp2);
5662         __isl_give isl_qpolynomial *isl_qpolynomial_sub(
5663                 __isl_take isl_qpolynomial *qp1,
5664                 __isl_take isl_qpolynomial *qp2);
5665         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub(
5666                 __isl_take isl_pw_qpolynomial *pwqp1,
5667                 __isl_take isl_pw_qpolynomial *pwqp2);
5668         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
5669                 __isl_take isl_union_pw_qpolynomial *upwqp1,
5670                 __isl_take isl_union_pw_qpolynomial *upwqp2);
5671         __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_fold(
5672                 __isl_take isl_pw_qpolynomial_fold *pwf1,
5673                 __isl_take isl_pw_qpolynomial_fold *pwf2);
5674         __isl_give isl_union_pw_qpolynomial_fold *
5675         isl_union_pw_qpolynomial_fold_fold(
5676                 __isl_take isl_union_pw_qpolynomial_fold *upwf1,
5677                 __isl_take isl_union_pw_qpolynomial_fold *upwf2);
5679         #include <isl/aff.h>
5680         __isl_give isl_pw_aff *isl_pw_aff_union_add(
5681                 __isl_take isl_pw_aff *pwaff1,
5682                 __isl_take isl_pw_aff *pwaff2);
5683         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_add(
5684                 __isl_take isl_pw_multi_aff *pma1,
5685                 __isl_take isl_pw_multi_aff *pma2);
5686         __isl_give isl_union_pw_multi_aff *
5687         isl_union_pw_multi_aff_union_add(
5688                 __isl_take isl_union_pw_multi_aff *upma1,
5689                 __isl_take isl_union_pw_multi_aff *upma2);
5690         __isl_give isl_pw_aff *isl_pw_aff_union_min(
5691                 __isl_take isl_pw_aff *pwaff1,
5692                 __isl_take isl_pw_aff *pwaff2);
5693         __isl_give isl_pw_aff *isl_pw_aff_union_max(
5694                 __isl_take isl_pw_aff *pwaff1,
5695                 __isl_take isl_pw_aff *pwaff2);
5697 The function C<isl_pw_aff_union_max> computes a piecewise quasi-affine
5698 expression with a domain that is the union of those of C<pwaff1> and
5699 C<pwaff2> and such that on each cell, the quasi-affine expression is
5700 the maximum of those of C<pwaff1> and C<pwaff2>.  If only one of
5701 C<pwaff1> or C<pwaff2> is defined on a given cell, then the
5702 associated expression is the defined one.
5703 This in contrast to the C<isl_pw_aff_max> function, which is
5704 only defined on the shared definition domain of the arguments.
5706         #include <isl/val.h>
5707         __isl_give isl_multi_val *isl_multi_val_add_val(
5708                 __isl_take isl_multi_val *mv,
5709                 __isl_take isl_val *v);
5710         __isl_give isl_multi_val *isl_multi_val_mod_val(
5711                 __isl_take isl_multi_val *mv,
5712                 __isl_take isl_val *v);
5713         __isl_give isl_multi_val *isl_multi_val_scale_val(
5714                 __isl_take isl_multi_val *mv,
5715                 __isl_take isl_val *v);
5717         #include <isl/aff.h>
5718         __isl_give isl_aff *isl_aff_mod_val(__isl_take isl_aff *aff,
5719                 __isl_take isl_val *mod);
5720         __isl_give isl_pw_aff *isl_pw_aff_mod_val(
5721                 __isl_take isl_pw_aff *pa,
5722                 __isl_take isl_val *mod);
5723         __isl_give isl_aff *isl_aff_scale_val(__isl_take isl_aff *aff,
5724                 __isl_take isl_val *v);
5725         __isl_give isl_multi_aff *isl_multi_aff_scale_val(
5726                 __isl_take isl_multi_aff *ma,
5727                 __isl_take isl_val *v);
5728         __isl_give isl_pw_aff *isl_pw_aff_scale_val(
5729                 __isl_take isl_pw_aff *pa, __isl_take isl_val *v);
5730         __isl_give isl_multi_pw_aff *isl_multi_pw_aff_scale_val(
5731                 __isl_take isl_multi_pw_aff *mpa,
5732                 __isl_take isl_val *v);
5733         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_val(
5734                 __isl_take isl_pw_multi_aff *pma,
5735                 __isl_take isl_val *v);
5736         __isl_give isl_union_pw_multi_aff *
5737         isl_union_pw_multi_aff_scale_val(
5738                 __isl_take isl_union_pw_multi_aff *upma,
5739                 __isl_take isl_val *val);
5740         __isl_give isl_aff *isl_aff_scale_down_ui(
5741                 __isl_take isl_aff *aff, unsigned f);
5742         __isl_give isl_aff *isl_aff_scale_down_val(
5743                 __isl_take isl_aff *aff, __isl_take isl_val *v);
5744         __isl_give isl_pw_aff *isl_pw_aff_scale_down_val(
5745                 __isl_take isl_pw_aff *pa,
5746                 __isl_take isl_val *f);
5748         #include <isl/polynomial.h>
5749         __isl_give isl_qpolynomial *isl_qpolynomial_scale_val(
5750                 __isl_take isl_qpolynomial *qp,
5751                 __isl_take isl_val *v);
5752         __isl_give isl_qpolynomial_fold *
5753         isl_qpolynomial_fold_scale_val(
5754                 __isl_take isl_qpolynomial_fold *fold,
5755                 __isl_take isl_val *v);
5756         __isl_give isl_pw_qpolynomial *
5757         isl_pw_qpolynomial_scale_val(
5758                 __isl_take isl_pw_qpolynomial *pwqp,
5759                 __isl_take isl_val *v);
5760         __isl_give isl_pw_qpolynomial_fold *
5761         isl_pw_qpolynomial_fold_scale_val(
5762                 __isl_take isl_pw_qpolynomial_fold *pwf,
5763                 __isl_take isl_val *v);
5764         __isl_give isl_union_pw_qpolynomial *
5765         isl_union_pw_qpolynomial_scale_val(
5766                 __isl_take isl_union_pw_qpolynomial *upwqp,
5767                 __isl_take isl_val *v);
5768         __isl_give isl_union_pw_qpolynomial_fold *
5769         isl_union_pw_qpolynomial_fold_scale_val(
5770                 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5771                 __isl_take isl_val *v);
5773         #include <isl/val.h>
5774         __isl_give isl_multi_val *isl_multi_val_scale_multi_val(
5775                 __isl_take isl_multi_val *mv1,
5776                 __isl_take isl_multi_val *mv2);
5777         __isl_give isl_multi_val *
5778         isl_multi_val_scale_down_multi_val(
5779                 __isl_take isl_multi_val *mv1,
5780                 __isl_take isl_multi_val *mv2);
5782         #include <isl/aff.h>
5783         __isl_give isl_multi_aff *isl_multi_aff_scale_multi_val(
5784                 __isl_take isl_multi_aff *ma,
5785                 __isl_take isl_multi_val *mv);
5786         __isl_give isl_pw_multi_aff *
5787         isl_pw_multi_aff_scale_multi_val(
5788                 __isl_take isl_pw_multi_aff *pma,
5789                 __isl_take isl_multi_val *mv);
5790         __isl_give isl_multi_pw_aff *
5791         isl_multi_pw_aff_scale_multi_val(
5792                 __isl_take isl_multi_pw_aff *mpa,
5793                 __isl_take isl_multi_val *mv);
5794         __isl_give isl_union_pw_multi_aff *
5795         isl_union_pw_multi_aff_scale_multi_val(
5796                 __isl_take isl_union_pw_multi_aff *upma,
5797                 __isl_take isl_multi_val *mv);
5798         __isl_give isl_multi_aff *
5799         isl_multi_aff_scale_down_multi_val(
5800                 __isl_take isl_multi_aff *ma,
5801                 __isl_take isl_multi_val *mv);
5802         __isl_give isl_multi_pw_aff *
5803         isl_multi_pw_aff_scale_down_multi_val(
5804                 __isl_take isl_multi_pw_aff *mpa,
5805                 __isl_take isl_multi_val *mv);
5807 C<isl_multi_aff_scale_multi_val> scales the elements of C<ma>
5808 by the corresponding elements of C<mv>.
5810         #include <isl/aff.h>
5811         __isl_give isl_aff *isl_aff_mul(
5812                 __isl_take isl_aff *aff1,
5813                 __isl_take isl_aff *aff2);
5814         __isl_give isl_aff *isl_aff_div(
5815                 __isl_take isl_aff *aff1,
5816                 __isl_take isl_aff *aff2);
5817         __isl_give isl_pw_aff *isl_pw_aff_mul(
5818                 __isl_take isl_pw_aff *pwaff1,
5819                 __isl_take isl_pw_aff *pwaff2);
5820         __isl_give isl_pw_aff *isl_pw_aff_div(
5821                 __isl_take isl_pw_aff *pa1,
5822                 __isl_take isl_pw_aff *pa2);
5823         __isl_give isl_pw_aff *isl_pw_aff_tdiv_q(
5824                 __isl_take isl_pw_aff *pa1,
5825                 __isl_take isl_pw_aff *pa2);
5826         __isl_give isl_pw_aff *isl_pw_aff_tdiv_r(
5827                 __isl_take isl_pw_aff *pa1,
5828                 __isl_take isl_pw_aff *pa2);
5830 When multiplying two affine expressions, at least one of the two needs
5831 to be a constant.  Similarly, when dividing an affine expression by another,
5832 the second expression needs to be a constant.
5833 C<isl_pw_aff_tdiv_q> computes the quotient of an integer division with
5834 rounding towards zero.  C<isl_pw_aff_tdiv_r> computes the corresponding
5835 remainder.
5837         #include <isl/polynomial.h>
5838         __isl_give isl_qpolynomial *isl_qpolynomial_mul(
5839                 __isl_take isl_qpolynomial *qp1,
5840                 __isl_take isl_qpolynomial *qp2);
5841         __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
5842                 __isl_take isl_pw_qpolynomial *pwqp1,
5843                 __isl_take isl_pw_qpolynomial *pwqp2);
5844         __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
5845                 __isl_take isl_union_pw_qpolynomial *upwqp1,
5846                 __isl_take isl_union_pw_qpolynomial *upwqp2);
5848 =back
5850 =head3 Lexicographic Optimization
5852 Given a (basic) set C<set> (or C<bset>) and a zero-dimensional domain C<dom>,
5853 the following functions
5854 compute a set that contains the lexicographic minimum or maximum
5855 of the elements in C<set> (or C<bset>) for those values of the parameters
5856 that satisfy C<dom>.
5857 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
5858 that contains the parameter values in C<dom> for which C<set> (or C<bset>)
5859 has no elements.
5860 In other words, the union of the parameter values
5861 for which the result is non-empty and of C<*empty>
5862 is equal to C<dom>.
5864         #include <isl/set.h>
5865         __isl_give isl_set *isl_basic_set_partial_lexmin(
5866                 __isl_take isl_basic_set *bset,
5867                 __isl_take isl_basic_set *dom,
5868                 __isl_give isl_set **empty);
5869         __isl_give isl_set *isl_basic_set_partial_lexmax(
5870                 __isl_take isl_basic_set *bset,
5871                 __isl_take isl_basic_set *dom,
5872                 __isl_give isl_set **empty);
5873         __isl_give isl_set *isl_set_partial_lexmin(
5874                 __isl_take isl_set *set, __isl_take isl_set *dom,
5875                 __isl_give isl_set **empty);
5876         __isl_give isl_set *isl_set_partial_lexmax(
5877                 __isl_take isl_set *set, __isl_take isl_set *dom,
5878                 __isl_give isl_set **empty);
5880 Given a (basic) set C<set> (or C<bset>), the following functions simply
5881 return a set containing the lexicographic minimum or maximum
5882 of the elements in C<set> (or C<bset>).
5883 In case of union sets, the optimum is computed per space.
5885         #include <isl/set.h>
5886         __isl_give isl_set *isl_basic_set_lexmin(
5887                 __isl_take isl_basic_set *bset);
5888         __isl_give isl_set *isl_basic_set_lexmax(
5889                 __isl_take isl_basic_set *bset);
5890         __isl_give isl_set *isl_set_lexmin(
5891                 __isl_take isl_set *set);
5892         __isl_give isl_set *isl_set_lexmax(
5893                 __isl_take isl_set *set);
5894         __isl_give isl_union_set *isl_union_set_lexmin(
5895                 __isl_take isl_union_set *uset);
5896         __isl_give isl_union_set *isl_union_set_lexmax(
5897                 __isl_take isl_union_set *uset);
5899 Given a (basic) relation C<map> (or C<bmap>) and a domain C<dom>,
5900 the following functions
5901 compute a relation that maps each element of C<dom>
5902 to the single lexicographic minimum or maximum
5903 of the elements that are associated to that same
5904 element in C<map> (or C<bmap>).
5905 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
5906 that contains the elements in C<dom> that do not map
5907 to any elements in C<map> (or C<bmap>).
5908 In other words, the union of the domain of the result and of C<*empty>
5909 is equal to C<dom>.
5911         #include <isl/map.h>
5912         __isl_give isl_map *isl_basic_map_partial_lexmax(
5913                 __isl_take isl_basic_map *bmap,
5914                 __isl_take isl_basic_set *dom,
5915                 __isl_give isl_set **empty);
5916         __isl_give isl_map *isl_basic_map_partial_lexmin(
5917                 __isl_take isl_basic_map *bmap,
5918                 __isl_take isl_basic_set *dom,
5919                 __isl_give isl_set **empty);
5920         __isl_give isl_map *isl_map_partial_lexmax(
5921                 __isl_take isl_map *map, __isl_take isl_set *dom,
5922                 __isl_give isl_set **empty);
5923         __isl_give isl_map *isl_map_partial_lexmin(
5924                 __isl_take isl_map *map, __isl_take isl_set *dom,
5925                 __isl_give isl_set **empty);
5927 Given a (basic) map C<map> (or C<bmap>), the following functions simply
5928 return a map mapping each element in the domain of
5929 C<map> (or C<bmap>) to the lexicographic minimum or maximum
5930 of all elements associated to that element.
5931 In case of union relations, the optimum is computed per space.
5933         #include <isl/map.h>
5934         __isl_give isl_map *isl_basic_map_lexmin(
5935                 __isl_take isl_basic_map *bmap);
5936         __isl_give isl_map *isl_basic_map_lexmax(
5937                 __isl_take isl_basic_map *bmap);
5938         __isl_give isl_map *isl_map_lexmin(
5939                 __isl_take isl_map *map);
5940         __isl_give isl_map *isl_map_lexmax(
5941                 __isl_take isl_map *map);
5942         __isl_give isl_union_map *isl_union_map_lexmin(
5943                 __isl_take isl_union_map *umap);
5944         __isl_give isl_union_map *isl_union_map_lexmax(
5945                 __isl_take isl_union_map *umap);
5947 The following functions return their result in the form of
5948 a piecewise multi-affine expression,
5949 but are otherwise equivalent to the corresponding functions
5950 returning a basic set or relation.
5952         #include <isl/set.h>
5953         __isl_give isl_pw_multi_aff *
5954         isl_basic_set_partial_lexmin_pw_multi_aff(
5955                 __isl_take isl_basic_set *bset,
5956                 __isl_take isl_basic_set *dom,
5957                 __isl_give isl_set **empty);
5958         __isl_give isl_pw_multi_aff *
5959         isl_basic_set_partial_lexmax_pw_multi_aff(
5960                 __isl_take isl_basic_set *bset,
5961                 __isl_take isl_basic_set *dom,
5962                 __isl_give isl_set **empty);
5963         __isl_give isl_pw_multi_aff *isl_set_lexmin_pw_multi_aff(
5964                 __isl_take isl_set *set);
5965         __isl_give isl_pw_multi_aff *isl_set_lexmax_pw_multi_aff(
5966                 __isl_take isl_set *set);
5968         #include <isl/map.h>
5969         __isl_give isl_pw_multi_aff *
5970         isl_basic_map_lexmin_pw_multi_aff(
5971                 __isl_take isl_basic_map *bmap);
5972         __isl_give isl_pw_multi_aff *
5973         isl_basic_map_partial_lexmin_pw_multi_aff(
5974                 __isl_take isl_basic_map *bmap,
5975                 __isl_take isl_basic_set *dom,
5976                 __isl_give isl_set **empty);
5977         __isl_give isl_pw_multi_aff *
5978         isl_basic_map_partial_lexmax_pw_multi_aff(
5979                 __isl_take isl_basic_map *bmap,
5980                 __isl_take isl_basic_set *dom,
5981                 __isl_give isl_set **empty);
5982         __isl_give isl_pw_multi_aff *isl_map_lexmin_pw_multi_aff(
5983                 __isl_take isl_map *map);
5984         __isl_give isl_pw_multi_aff *isl_map_lexmax_pw_multi_aff(
5985                 __isl_take isl_map *map);
5987 The following functions return the lexicographic minimum or maximum
5988 on the shared domain of the inputs and the single defined function
5989 on those parts of the domain where only a single function is defined.
5991         #include <isl/aff.h>
5992         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmin(
5993                 __isl_take isl_pw_multi_aff *pma1,
5994                 __isl_take isl_pw_multi_aff *pma2);
5995         __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmax(
5996                 __isl_take isl_pw_multi_aff *pma1,
5997                 __isl_take isl_pw_multi_aff *pma2);
5999 =head2 Ternary Operations
6001         #include <isl/aff.h>
6002         __isl_give isl_pw_aff *isl_pw_aff_cond(
6003                 __isl_take isl_pw_aff *cond,
6004                 __isl_take isl_pw_aff *pwaff_true,
6005                 __isl_take isl_pw_aff *pwaff_false);
6007 The function C<isl_pw_aff_cond> performs a conditional operator
6008 and returns an expression that is equal to C<pwaff_true>
6009 for elements where C<cond> is non-zero and equal to C<pwaff_false> for elements
6010 where C<cond> is zero.
6012 =head2 Lists
6014 Lists are defined over several element types, including
6015 C<isl_val>, C<isl_id>, C<isl_aff>, C<isl_pw_aff>, C<isl_constraint>,
6016 C<isl_basic_set>, C<isl_set>, C<isl_ast_expr> and C<isl_ast_node>.
6017 Here we take lists of C<isl_set>s as an example.
6018 Lists can be created, copied, modified and freed using the following functions.
6020         #include <isl/set.h>
6021         __isl_give isl_set_list *isl_set_list_from_set(
6022                 __isl_take isl_set *el);
6023         __isl_give isl_set_list *isl_set_list_alloc(
6024                 isl_ctx *ctx, int n);
6025         __isl_give isl_set_list *isl_set_list_copy(
6026                 __isl_keep isl_set_list *list);
6027         __isl_give isl_set_list *isl_set_list_insert(
6028                 __isl_take isl_set_list *list, unsigned pos,
6029                 __isl_take isl_set *el);
6030         __isl_give isl_set_list *isl_set_list_add(
6031                 __isl_take isl_set_list *list,
6032                 __isl_take isl_set *el);
6033         __isl_give isl_set_list *isl_set_list_drop(
6034                 __isl_take isl_set_list *list,
6035                 unsigned first, unsigned n);
6036         __isl_give isl_set_list *isl_set_list_set_set(
6037                 __isl_take isl_set_list *list, int index,
6038                 __isl_take isl_set *set);
6039         __isl_give isl_set_list *isl_set_list_concat(
6040                 __isl_take isl_set_list *list1,
6041                 __isl_take isl_set_list *list2);
6042         __isl_give isl_set_list *isl_set_list_sort(
6043                 __isl_take isl_set_list *list,
6044                 int (*cmp)(__isl_keep isl_set *a,
6045                         __isl_keep isl_set *b, void *user),
6046                 void *user);
6047         __isl_null isl_set_list *isl_set_list_free(
6048                 __isl_take isl_set_list *list);
6050 C<isl_set_list_alloc> creates an empty list with a capacity for
6051 C<n> elements.  C<isl_set_list_from_set> creates a list with a single
6052 element.
6054 Lists can be inspected using the following functions.
6056         #include <isl/set.h>
6057         int isl_set_list_n_set(__isl_keep isl_set_list *list);
6058         __isl_give isl_set *isl_set_list_get_set(
6059                 __isl_keep isl_set_list *list, int index);
6060         int isl_set_list_foreach(__isl_keep isl_set_list *list,
6061                 int (*fn)(__isl_take isl_set *el, void *user),
6062                 void *user);
6063         int isl_set_list_foreach_scc(__isl_keep isl_set_list *list,
6064                 int (*follows)(__isl_keep isl_set *a,
6065                         __isl_keep isl_set *b, void *user),
6066                 void *follows_user
6067                 int (*fn)(__isl_take isl_set *el, void *user),
6068                 void *fn_user);
6070 The function C<isl_set_list_foreach_scc> calls C<fn> on each of the
6071 strongly connected components of the graph with as vertices the elements
6072 of C<list> and a directed edge from vertex C<b> to vertex C<a>
6073 iff C<follows(a, b)> returns C<1>.  The callbacks C<follows> and C<fn>
6074 should return C<-1> on error.
6076 Lists can be printed using
6078         #include <isl/set.h>
6079         __isl_give isl_printer *isl_printer_print_set_list(
6080                 __isl_take isl_printer *p,
6081                 __isl_keep isl_set_list *list);
6083 =head2 Associative arrays
6085 Associative arrays map isl objects of a specific type to isl objects
6086 of some (other) specific type.  They are defined for several pairs
6087 of types, including (C<isl_map>, C<isl_basic_set>),
6088 (C<isl_id>, C<isl_ast_expr>) and.
6089 (C<isl_id>, C<isl_pw_aff>).
6090 Here, we take associative arrays that map C<isl_id>s to C<isl_ast_expr>s
6091 as an example.
6093 Associative arrays can be created, copied and freed using
6094 the following functions.
6096         #include <isl/id_to_ast_expr.h>
6097         __isl_give id_to_ast_expr *isl_id_to_ast_expr_alloc(
6098                 isl_ctx *ctx, int min_size);
6099         __isl_give id_to_ast_expr *isl_id_to_ast_expr_copy(
6100                 __isl_keep id_to_ast_expr *id2expr);
6101         __isl_null id_to_ast_expr *isl_id_to_ast_expr_free(
6102                 __isl_take id_to_ast_expr *id2expr);
6104 The C<min_size> argument to C<isl_id_to_ast_expr_alloc> can be used
6105 to specify the expected size of the associative array.
6106 The associative array will be grown automatically as needed.
6108 Associative arrays can be inspected using the following functions.
6110         #include <isl/id_to_ast_expr.h>
6111         int isl_id_to_ast_expr_has(
6112                 __isl_keep id_to_ast_expr *id2expr,
6113                 __isl_keep isl_id *key);
6114         __isl_give isl_ast_expr *isl_id_to_ast_expr_get(
6115                 __isl_keep id_to_ast_expr *id2expr,
6116                 __isl_take isl_id *key);
6117         int isl_id_to_ast_expr_foreach(
6118                 __isl_keep id_to_ast_expr *id2expr,
6119                 int (*fn)(__isl_take isl_id *key,
6120                         __isl_take isl_ast_expr *val, void *user),
6121                 void *user);
6123 They can be modified using the following function.
6125         #include <isl/id_to_ast_expr.h>
6126         __isl_give id_to_ast_expr *isl_id_to_ast_expr_set(
6127                 __isl_take id_to_ast_expr *id2expr,
6128                 __isl_take isl_id *key,
6129                 __isl_take isl_ast_expr *val);
6130         __isl_give id_to_ast_expr *isl_id_to_ast_expr_drop(
6131                 __isl_take id_to_ast_expr *id2expr,
6132                 __isl_take isl_id *key);
6134 Associative arrays can be printed using the following function.
6136         #include <isl/id_to_ast_expr.h>
6137         __isl_give isl_printer *isl_printer_print_id_to_ast_expr(
6138                 __isl_take isl_printer *p,
6139                 __isl_keep id_to_ast_expr *id2expr);
6141 =head2 Vectors
6143 Vectors can be created, copied and freed using the following functions.
6145         #include <isl/vec.h>
6146         __isl_give isl_vec *isl_vec_alloc(isl_ctx *ctx,
6147                 unsigned size);
6148         __isl_give isl_vec *isl_vec_copy(__isl_keep isl_vec *vec);
6149         __isl_null isl_vec *isl_vec_free(__isl_take isl_vec *vec);
6151 Note that the elements of a newly created vector may have arbitrary values.
6152 The elements can be changed and inspected using the following functions.
6154         int isl_vec_size(__isl_keep isl_vec *vec);
6155         __isl_give isl_val *isl_vec_get_element_val(
6156                 __isl_keep isl_vec *vec, int pos);
6157         __isl_give isl_vec *isl_vec_set_element_si(
6158                 __isl_take isl_vec *vec, int pos, int v);
6159         __isl_give isl_vec *isl_vec_set_element_val(
6160                 __isl_take isl_vec *vec, int pos,
6161                 __isl_take isl_val *v);
6162         __isl_give isl_vec *isl_vec_set_si(__isl_take isl_vec *vec,
6163                 int v);
6164         __isl_give isl_vec *isl_vec_set_val(
6165                 __isl_take isl_vec *vec, __isl_take isl_val *v);
6166         int isl_vec_cmp_element(__isl_keep isl_vec *vec1,
6167                 __isl_keep isl_vec *vec2, int pos);
6169 C<isl_vec_get_element> will return a negative value if anything went wrong.
6170 In that case, the value of C<*v> is undefined.
6172 The following function can be used to concatenate two vectors.
6174         __isl_give isl_vec *isl_vec_concat(__isl_take isl_vec *vec1,
6175                 __isl_take isl_vec *vec2);
6177 =head2 Matrices
6179 Matrices can be created, copied and freed using the following functions.
6181         #include <isl/mat.h>
6182         __isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx,
6183                 unsigned n_row, unsigned n_col);
6184         __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat);
6185         __isl_null isl_mat *isl_mat_free(__isl_take isl_mat *mat);
6187 Note that the elements of a newly created matrix may have arbitrary values.
6188 The elements can be changed and inspected using the following functions.
6190         int isl_mat_rows(__isl_keep isl_mat *mat);
6191         int isl_mat_cols(__isl_keep isl_mat *mat);
6192         __isl_give isl_val *isl_mat_get_element_val(
6193                 __isl_keep isl_mat *mat, int row, int col);
6194         __isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat,
6195                 int row, int col, int v);
6196         __isl_give isl_mat *isl_mat_set_element_val(
6197                 __isl_take isl_mat *mat, int row, int col,
6198                 __isl_take isl_val *v);
6200 C<isl_mat_get_element> will return a negative value if anything went wrong.
6201 In that case, the value of C<*v> is undefined.
6203 The following function can be used to compute the (right) inverse
6204 of a matrix, i.e., a matrix such that the product of the original
6205 and the inverse (in that order) is a multiple of the identity matrix.
6206 The input matrix is assumed to be of full row-rank.
6208         __isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat);
6210 The following function can be used to compute the (right) kernel
6211 (or null space) of a matrix, i.e., a matrix such that the product of
6212 the original and the kernel (in that order) is the zero matrix.
6214         __isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat);
6216 =head2 Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions
6218 The following functions determine
6219 an upper or lower bound on a quasipolynomial over its domain.
6221         __isl_give isl_pw_qpolynomial_fold *
6222         isl_pw_qpolynomial_bound(
6223                 __isl_take isl_pw_qpolynomial *pwqp,
6224                 enum isl_fold type, int *tight);
6226         __isl_give isl_union_pw_qpolynomial_fold *
6227         isl_union_pw_qpolynomial_bound(
6228                 __isl_take isl_union_pw_qpolynomial *upwqp,
6229                 enum isl_fold type, int *tight);
6231 The C<type> argument may be either C<isl_fold_min> or C<isl_fold_max>.
6232 If C<tight> is not C<NULL>, then C<*tight> is set to C<1>
6233 is the returned bound is known be tight, i.e., for each value
6234 of the parameters there is at least
6235 one element in the domain that reaches the bound.
6236 If the domain of C<pwqp> is not wrapping, then the bound is computed
6237 over all elements in that domain and the result has a purely parametric
6238 domain.  If the domain of C<pwqp> is wrapping, then the bound is
6239 computed over the range of the wrapped relation.  The domain of the
6240 wrapped relation becomes the domain of the result.
6242 =head2 Parametric Vertex Enumeration
6244 The parametric vertex enumeration described in this section
6245 is mainly intended to be used internally and by the C<barvinok>
6246 library.
6248         #include <isl/vertices.h>
6249         __isl_give isl_vertices *isl_basic_set_compute_vertices(
6250                 __isl_keep isl_basic_set *bset);
6252 The function C<isl_basic_set_compute_vertices> performs the
6253 actual computation of the parametric vertices and the chamber
6254 decomposition and store the result in an C<isl_vertices> object.
6255 This information can be queried by either iterating over all
6256 the vertices or iterating over all the chambers or cells
6257 and then iterating over all vertices that are active on the chamber.
6259         int isl_vertices_foreach_vertex(
6260                 __isl_keep isl_vertices *vertices,
6261                 int (*fn)(__isl_take isl_vertex *vertex, void *user),
6262                 void *user);
6264         int isl_vertices_foreach_cell(
6265                 __isl_keep isl_vertices *vertices,
6266                 int (*fn)(__isl_take isl_cell *cell, void *user),
6267                 void *user);
6268         int isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
6269                 int (*fn)(__isl_take isl_vertex *vertex, void *user),
6270                 void *user);
6272 Other operations that can be performed on an C<isl_vertices> object are
6273 the following.
6275         int isl_vertices_get_n_vertices(
6276                 __isl_keep isl_vertices *vertices);
6277         void isl_vertices_free(__isl_take isl_vertices *vertices);
6279 Vertices can be inspected and destroyed using the following functions.
6281         int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
6282         __isl_give isl_basic_set *isl_vertex_get_domain(
6283                 __isl_keep isl_vertex *vertex);
6284         __isl_give isl_multi_aff *isl_vertex_get_expr(
6285                 __isl_keep isl_vertex *vertex);
6286         void isl_vertex_free(__isl_take isl_vertex *vertex);
6288 C<isl_vertex_get_expr> returns a multiple quasi-affine expression
6289 describing the vertex in terms of the parameters,
6290 while C<isl_vertex_get_domain> returns the activity domain
6291 of the vertex.
6293 Chambers can be inspected and destroyed using the following functions.
6295         __isl_give isl_basic_set *isl_cell_get_domain(
6296                 __isl_keep isl_cell *cell);
6297         void isl_cell_free(__isl_take isl_cell *cell);
6299 =head1 Polyhedral Compilation Library
6301 This section collects functionality in C<isl> that has been specifically
6302 designed for use during polyhedral compilation.
6304 =head2 Dependence Analysis
6306 C<isl> contains specialized functionality for performing
6307 array dataflow analysis.  That is, given a I<sink> access relation
6308 and a collection of possible I<source> access relations,
6309 C<isl> can compute relations that describe
6310 for each iteration of the sink access, which iteration
6311 of which of the source access relations was the last
6312 to access the same data element before the given iteration
6313 of the sink access.
6314 The resulting dependence relations map source iterations
6315 to the corresponding sink iterations.
6316 To compute standard flow dependences, the sink should be
6317 a read, while the sources should be writes.
6318 If any of the source accesses are marked as being I<may>
6319 accesses, then there will be a dependence from the last
6320 I<must> access B<and> from any I<may> access that follows
6321 this last I<must> access.
6322 In particular, if I<all> sources are I<may> accesses,
6323 then memory based dependence analysis is performed.
6324 If, on the other hand, all sources are I<must> accesses,
6325 then value based dependence analysis is performed.
6327         #include <isl/flow.h>
6329         typedef int (*isl_access_level_before)(void *first, void *second);
6331         __isl_give isl_access_info *isl_access_info_alloc(
6332                 __isl_take isl_map *sink,
6333                 void *sink_user, isl_access_level_before fn,
6334                 int max_source);
6335         __isl_give isl_access_info *isl_access_info_add_source(
6336                 __isl_take isl_access_info *acc,
6337                 __isl_take isl_map *source, int must,
6338                 void *source_user);
6339         __isl_null isl_access_info *isl_access_info_free(
6340                 __isl_take isl_access_info *acc);
6342         __isl_give isl_flow *isl_access_info_compute_flow(
6343                 __isl_take isl_access_info *acc);
6345         int isl_flow_foreach(__isl_keep isl_flow *deps,
6346                 int (*fn)(__isl_take isl_map *dep, int must,
6347                           void *dep_user, void *user),
6348                 void *user);
6349         __isl_give isl_map *isl_flow_get_no_source(
6350                 __isl_keep isl_flow *deps, int must);
6351         void isl_flow_free(__isl_take isl_flow *deps);
6353 The function C<isl_access_info_compute_flow> performs the actual
6354 dependence analysis.  The other functions are used to construct
6355 the input for this function or to read off the output.
6357 The input is collected in an C<isl_access_info>, which can
6358 be created through a call to C<isl_access_info_alloc>.
6359 The arguments to this functions are the sink access relation
6360 C<sink>, a token C<sink_user> used to identify the sink
6361 access to the user, a callback function for specifying the
6362 relative order of source and sink accesses, and the number
6363 of source access relations that will be added.
6364 The callback function has type C<int (*)(void *first, void *second)>.
6365 The function is called with two user supplied tokens identifying
6366 either a source or the sink and it should return the shared nesting
6367 level and the relative order of the two accesses.
6368 In particular, let I<n> be the number of loops shared by
6369 the two accesses.  If C<first> precedes C<second> textually,
6370 then the function should return I<2 * n + 1>; otherwise,
6371 it should return I<2 * n>.
6372 The sources can be added to the C<isl_access_info> by performing
6373 (at most) C<max_source> calls to C<isl_access_info_add_source>.
6374 C<must> indicates whether the source is a I<must> access
6375 or a I<may> access.  Note that a multi-valued access relation
6376 should only be marked I<must> if every iteration in the domain
6377 of the relation accesses I<all> elements in its image.
6378 The C<source_user> token is again used to identify
6379 the source access.  The range of the source access relation
6380 C<source> should have the same dimension as the range
6381 of the sink access relation.
6382 The C<isl_access_info_free> function should usually not be
6383 called explicitly, because it is called implicitly by
6384 C<isl_access_info_compute_flow>.
6386 The result of the dependence analysis is collected in an
6387 C<isl_flow>.  There may be elements of
6388 the sink access for which no preceding source access could be
6389 found or for which all preceding sources are I<may> accesses.
6390 The relations containing these elements can be obtained through
6391 calls to C<isl_flow_get_no_source>, the first with C<must> set
6392 and the second with C<must> unset.
6393 In the case of standard flow dependence analysis,
6394 with the sink a read and the sources I<must> writes,
6395 the first relation corresponds to the reads from uninitialized
6396 array elements and the second relation is empty.
6397 The actual flow dependences can be extracted using
6398 C<isl_flow_foreach>.  This function will call the user-specified
6399 callback function C<fn> for each B<non-empty> dependence between
6400 a source and the sink.  The callback function is called
6401 with four arguments, the actual flow dependence relation
6402 mapping source iterations to sink iterations, a boolean that
6403 indicates whether it is a I<must> or I<may> dependence, a token
6404 identifying the source and an additional C<void *> with value
6405 equal to the third argument of the C<isl_flow_foreach> call.
6406 A dependence is marked I<must> if it originates from a I<must>
6407 source and if it is not followed by any I<may> sources.
6409 After finishing with an C<isl_flow>, the user should call
6410 C<isl_flow_free> to free all associated memory.
6412 A higher-level interface to dependence analysis is provided
6413 by the following function.
6415         #include <isl/flow.h>
6417         int isl_union_map_compute_flow(__isl_take isl_union_map *sink,
6418                 __isl_take isl_union_map *must_source,
6419                 __isl_take isl_union_map *may_source,
6420                 __isl_take isl_union_map *schedule,
6421                 __isl_give isl_union_map **must_dep,
6422                 __isl_give isl_union_map **may_dep,
6423                 __isl_give isl_union_map **must_no_source,
6424                 __isl_give isl_union_map **may_no_source);
6426 The arrays are identified by the tuple names of the ranges
6427 of the accesses.  The iteration domains by the tuple names
6428 of the domains of the accesses and of the schedule.
6429 The relative order of the iteration domains is given by the
6430 schedule.  The relations returned through C<must_no_source>
6431 and C<may_no_source> are subsets of C<sink>.
6432 Any of C<must_dep>, C<may_dep>, C<must_no_source>
6433 or C<may_no_source> may be C<NULL>, but a C<NULL> value for
6434 any of the other arguments is treated as an error.
6436 =head3 Interaction with Dependence Analysis
6438 During the dependence analysis, we frequently need to perform
6439 the following operation.  Given a relation between sink iterations
6440 and potential source iterations from a particular source domain,
6441 what is the last potential source iteration corresponding to each
6442 sink iteration.  It can sometimes be convenient to adjust
6443 the set of potential source iterations before or after each such operation.
6444 The prototypical example is fuzzy array dataflow analysis,
6445 where we need to analyze if, based on data-dependent constraints,
6446 the sink iteration can ever be executed without one or more of
6447 the corresponding potential source iterations being executed.
6448 If so, we can introduce extra parameters and select an unknown
6449 but fixed source iteration from the potential source iterations.
6450 To be able to perform such manipulations, C<isl> provides the following
6451 function.
6453         #include <isl/flow.h>
6455         typedef __isl_give isl_restriction *(*isl_access_restrict)(
6456                 __isl_keep isl_map *source_map,
6457                 __isl_keep isl_set *sink, void *source_user,
6458                 void *user);
6459         __isl_give isl_access_info *isl_access_info_set_restrict(
6460                 __isl_take isl_access_info *acc,
6461                 isl_access_restrict fn, void *user);
6463 The function C<isl_access_info_set_restrict> should be called
6464 before calling C<isl_access_info_compute_flow> and registers a callback function
6465 that will be called any time C<isl> is about to compute the last
6466 potential source.  The first argument is the (reverse) proto-dependence,
6467 mapping sink iterations to potential source iterations.
6468 The second argument represents the sink iterations for which
6469 we want to compute the last source iteration.
6470 The third argument is the token corresponding to the source
6471 and the final argument is the token passed to C<isl_access_info_set_restrict>.
6472 The callback is expected to return a restriction on either the input or
6473 the output of the operation computing the last potential source.
6474 If the input needs to be restricted then restrictions are needed
6475 for both the source and the sink iterations.  The sink iterations
6476 and the potential source iterations will be intersected with these sets.
6477 If the output needs to be restricted then only a restriction on the source
6478 iterations is required.
6479 If any error occurs, the callback should return C<NULL>.
6480 An C<isl_restriction> object can be created, freed and inspected
6481 using the following functions.
6483         #include <isl/flow.h>
6485         __isl_give isl_restriction *isl_restriction_input(
6486                 __isl_take isl_set *source_restr,
6487                 __isl_take isl_set *sink_restr);
6488         __isl_give isl_restriction *isl_restriction_output(
6489                 __isl_take isl_set *source_restr);
6490         __isl_give isl_restriction *isl_restriction_none(
6491                 __isl_take isl_map *source_map);
6492         __isl_give isl_restriction *isl_restriction_empty(
6493                 __isl_take isl_map *source_map);
6494         __isl_null isl_restriction *isl_restriction_free(
6495                 __isl_take isl_restriction *restr);
6497 C<isl_restriction_none> and C<isl_restriction_empty> are special
6498 cases of C<isl_restriction_input>.  C<isl_restriction_none>
6499 is essentially equivalent to
6501         isl_restriction_input(isl_set_universe(
6502             isl_space_range(isl_map_get_space(source_map))),
6503                             isl_set_universe(
6504             isl_space_domain(isl_map_get_space(source_map))));
6506 whereas C<isl_restriction_empty> is essentially equivalent to
6508         isl_restriction_input(isl_set_empty(
6509             isl_space_range(isl_map_get_space(source_map))),
6510                             isl_set_universe(
6511             isl_space_domain(isl_map_get_space(source_map))));
6513 =head2 Scheduling
6515 B<The functionality described in this section is fairly new
6516 and may be subject to change.>
6518         #include <isl/schedule.h>
6519         __isl_give isl_schedule *
6520         isl_schedule_constraints_compute_schedule(
6521                 __isl_take isl_schedule_constraints *sc);
6522         __isl_null isl_schedule *isl_schedule_free(
6523                 __isl_take isl_schedule *sched);
6525 The function C<isl_schedule_constraints_compute_schedule> can be
6526 used to compute a schedule that satisfies the given schedule constraints.
6527 These schedule constraints include the iteration domain for which
6528 a schedule should be computed and dependences between pairs of
6529 iterations.  In particular, these dependences include
6530 I<validity> dependences and I<proximity> dependences.
6531 By default, the algorithm used to construct the schedule is similar
6532 to that of C<Pluto>.
6533 Alternatively, Feautrier's multi-dimensional scheduling algorithm can
6534 be selected.
6535 The generated schedule respects all validity dependences.
6536 That is, all dependence distances over these dependences in the
6537 scheduled space are lexicographically positive.
6538 The default algorithm tries to ensure that the dependence distances
6539 over coincidence constraints are zero and to minimize the
6540 dependence distances over proximity dependences.
6541 Moreover, it tries to obtain sequences (bands) of schedule dimensions
6542 for groups of domains where the dependence distances over validity
6543 dependences have only non-negative values.
6544 When using Feautrier's algorithm, the coincidence and proximity constraints
6545 are only taken into account during the extension to a
6546 full-dimensional schedule.
6548 An C<isl_schedule_constraints> object can be constructed
6549 and manipulated using the following functions.
6551         #include <isl/schedule.h>
6552         __isl_give isl_schedule_constraints *
6553         isl_schedule_constraints_copy(
6554                 __isl_keep isl_schedule_constraints *sc);
6555         __isl_give isl_schedule_constraints *
6556         isl_schedule_constraints_on_domain(
6557                 __isl_take isl_union_set *domain);
6558         __isl_give isl_schedule_constraints *
6559         isl_schedule_constraints_set_validity(
6560                 __isl_take isl_schedule_constraints *sc,
6561                 __isl_take isl_union_map *validity);
6562         __isl_give isl_schedule_constraints *
6563         isl_schedule_constraints_set_coincidence(
6564                 __isl_take isl_schedule_constraints *sc,
6565                 __isl_take isl_union_map *coincidence);
6566         __isl_give isl_schedule_constraints *
6567         isl_schedule_constraints_set_proximity(
6568                 __isl_take isl_schedule_constraints *sc,
6569                 __isl_take isl_union_map *proximity);
6570         __isl_give isl_schedule_constraints *
6571         isl_schedule_constraints_set_conditional_validity(
6572                 __isl_take isl_schedule_constraints *sc,
6573                 __isl_take isl_union_map *condition,
6574                 __isl_take isl_union_map *validity);
6575         __isl_null isl_schedule_constraints *
6576         isl_schedule_constraints_free(
6577                 __isl_take isl_schedule_constraints *sc);
6579 The initial C<isl_schedule_constraints> object created by
6580 C<isl_schedule_constraints_on_domain> does not impose any constraints.
6581 That is, it has an empty set of dependences.
6582 The function C<isl_schedule_constraints_set_validity> replaces the
6583 validity dependences, mapping domain elements I<i> to domain
6584 elements that should be scheduled after I<i>.
6585 The function C<isl_schedule_constraints_set_coincidence> replaces the
6586 coincidence dependences, mapping domain elements I<i> to domain
6587 elements that should be scheduled together with I<I>, if possible.
6588 The function C<isl_schedule_constraints_set_proximity> replaces the
6589 proximity dependences, mapping domain elements I<i> to domain
6590 elements that should be scheduled either before I<I>
6591 or as early as possible after I<i>.
6593 The function C<isl_schedule_constraints_set_conditional_validity>
6594 replaces the conditional validity constraints.
6595 A conditional validity constraint is only imposed when any of the corresponding
6596 conditions is satisfied, i.e., when any of them is non-zero.
6597 That is, the scheduler ensures that within each band if the dependence
6598 distances over the condition constraints are not all zero
6599 then all corresponding conditional validity constraints are respected.
6600 A conditional validity constraint corresponds to a condition
6601 if the two are adjacent, i.e., if the domain of one relation intersect
6602 the range of the other relation.
6603 The typical use case of conditional validity constraints is
6604 to allow order constraints between live ranges to be violated
6605 as long as the live ranges themselves are local to the band.
6606 To allow more fine-grained control over which conditions correspond
6607 to which conditional validity constraints, the domains and ranges
6608 of these relations may include I<tags>.  That is, the domains and
6609 ranges of those relation may themselves be wrapped relations
6610 where the iteration domain appears in the domain of those wrapped relations
6611 and the range of the wrapped relations can be arbitrarily chosen
6612 by the user.  Conditions and conditional validity constraints are only
6613 considered adjacent to each other if the entire wrapped relation matches.
6614 In particular, a relation with a tag will never be considered adjacent
6615 to a relation without a tag.
6617 The following function computes a schedule directly from
6618 an iteration domain and validity and proximity dependences
6619 and is implemented in terms of the functions described above.
6620 The use of C<isl_union_set_compute_schedule> is discouraged.
6622         #include <isl/schedule.h>
6623         __isl_give isl_schedule *isl_union_set_compute_schedule(
6624                 __isl_take isl_union_set *domain,
6625                 __isl_take isl_union_map *validity,
6626                 __isl_take isl_union_map *proximity);
6628 A mapping from the domains to the scheduled space can be obtained
6629 from an C<isl_schedule> using the following function.
6631         __isl_give isl_union_map *isl_schedule_get_map(
6632                 __isl_keep isl_schedule *sched);
6634 A representation of the schedule can be printed using
6635          
6636         __isl_give isl_printer *isl_printer_print_schedule(
6637                 __isl_take isl_printer *p,
6638                 __isl_keep isl_schedule *schedule);
6640 A representation of the schedule as a forest of bands can be obtained
6641 using the following function.
6643         __isl_give isl_band_list *isl_schedule_get_band_forest(
6644                 __isl_keep isl_schedule *schedule);
6646 The individual bands can be visited in depth-first post-order
6647 using the following function.
6649         #include <isl/schedule.h>
6650         int isl_schedule_foreach_band(
6651                 __isl_keep isl_schedule *sched,
6652                 int (*fn)(__isl_keep isl_band *band, void *user),
6653                 void *user);
6655 The list can be manipulated as explained in L<"Lists">.
6656 The bands inside the list can be copied and freed using the following
6657 functions.
6659         #include <isl/band.h>
6660         __isl_give isl_band *isl_band_copy(
6661                 __isl_keep isl_band *band);
6662         __isl_null isl_band *isl_band_free(
6663                 __isl_take isl_band *band);
6665 Each band contains zero or more scheduling dimensions.
6666 These are referred to as the members of the band.
6667 The section of the schedule that corresponds to the band is
6668 referred to as the partial schedule of the band.
6669 For those nodes that participate in a band, the outer scheduling
6670 dimensions form the prefix schedule, while the inner scheduling
6671 dimensions form the suffix schedule.
6672 That is, if we take a cut of the band forest, then the union of
6673 the concatenations of the prefix, partial and suffix schedules of
6674 each band in the cut is equal to the entire schedule (modulo
6675 some possible padding at the end with zero scheduling dimensions).
6676 The properties of a band can be inspected using the following functions.
6678         #include <isl/band.h>
6679         int isl_band_has_children(__isl_keep isl_band *band);
6680         __isl_give isl_band_list *isl_band_get_children(
6681                 __isl_keep isl_band *band);
6683         __isl_give isl_union_map *isl_band_get_prefix_schedule(
6684                 __isl_keep isl_band *band);
6685         __isl_give isl_union_map *isl_band_get_partial_schedule(
6686                 __isl_keep isl_band *band);
6687         __isl_give isl_union_map *isl_band_get_suffix_schedule(
6688                 __isl_keep isl_band *band);
6690         int isl_band_n_member(__isl_keep isl_band *band);
6691         int isl_band_member_is_coincident(
6692                 __isl_keep isl_band *band, int pos);
6694         int isl_band_list_foreach_band(
6695                 __isl_keep isl_band_list *list,
6696                 int (*fn)(__isl_keep isl_band *band, void *user),
6697                 void *user);
6699 Note that a scheduling dimension is considered to be ``coincident''
6700 if it satisfies the coincidence constraints within its band.
6701 That is, if the dependence distances of the coincidence
6702 constraints are all zero in that direction (for fixed
6703 iterations of outer bands).
6704 Like C<isl_schedule_foreach_band>,
6705 the function C<isl_band_list_foreach_band> calls C<fn> on the bands
6706 in depth-first post-order.
6708 A band can be tiled using the following function.
6710         #include <isl/band.h>
6711         int isl_band_tile(__isl_keep isl_band *band,
6712                 __isl_take isl_vec *sizes);
6714         int isl_options_set_tile_scale_tile_loops(isl_ctx *ctx,
6715                 int val);
6716         int isl_options_get_tile_scale_tile_loops(isl_ctx *ctx);
6717         int isl_options_set_tile_shift_point_loops(isl_ctx *ctx,
6718                 int val);
6719         int isl_options_get_tile_shift_point_loops(isl_ctx *ctx);
6721 The C<isl_band_tile> function tiles the band using the given tile sizes
6722 inside its schedule.
6723 A new child band is created to represent the point loops and it is
6724 inserted between the modified band and its children.
6725 The C<tile_scale_tile_loops> option specifies whether the tile
6726 loops iterators should be scaled by the tile sizes.
6727 If the C<tile_shift_point_loops> option is set, then the point loops
6728 are shifted to start at zero.
6730 A band can be split into two nested bands using the following function.
6732         int isl_band_split(__isl_keep isl_band *band, int pos);
6734 The resulting outer band contains the first C<pos> dimensions of C<band>
6735 while the inner band contains the remaining dimensions.
6737 A representation of the band can be printed using
6739         #include <isl/band.h>
6740         __isl_give isl_printer *isl_printer_print_band(
6741                 __isl_take isl_printer *p,
6742                 __isl_keep isl_band *band);
6744 =head3 Options
6746         #include <isl/schedule.h>
6747         int isl_options_set_schedule_max_coefficient(
6748                 isl_ctx *ctx, int val);
6749         int isl_options_get_schedule_max_coefficient(
6750                 isl_ctx *ctx);
6751         int isl_options_set_schedule_max_constant_term(
6752                 isl_ctx *ctx, int val);
6753         int isl_options_get_schedule_max_constant_term(
6754                 isl_ctx *ctx);
6755         int isl_options_set_schedule_fuse(isl_ctx *ctx, int val);
6756         int isl_options_get_schedule_fuse(isl_ctx *ctx);
6757         int isl_options_set_schedule_maximize_band_depth(
6758                 isl_ctx *ctx, int val);
6759         int isl_options_get_schedule_maximize_band_depth(
6760                 isl_ctx *ctx);
6761         int isl_options_set_schedule_outer_coincidence(
6762                 isl_ctx *ctx, int val);
6763         int isl_options_get_schedule_outer_coincidence(
6764                 isl_ctx *ctx);
6765         int isl_options_set_schedule_split_scaled(
6766                 isl_ctx *ctx, int val);
6767         int isl_options_get_schedule_split_scaled(
6768                 isl_ctx *ctx);
6769         int isl_options_set_schedule_algorithm(
6770                 isl_ctx *ctx, int val);
6771         int isl_options_get_schedule_algorithm(
6772                 isl_ctx *ctx);
6773         int isl_options_set_schedule_separate_components(
6774                 isl_ctx *ctx, int val);
6775         int isl_options_get_schedule_separate_components(
6776                 isl_ctx *ctx);
6778 =over
6780 =item * schedule_max_coefficient
6782 This option enforces that the coefficients for variable and parameter
6783 dimensions in the calculated schedule are not larger than the specified value.
6784 This option can significantly increase the speed of the scheduling calculation
6785 and may also prevent fusing of unrelated dimensions. A value of -1 means that
6786 this option does not introduce bounds on the variable or parameter
6787 coefficients.
6789 =item * schedule_max_constant_term
6791 This option enforces that the constant coefficients in the calculated schedule
6792 are not larger than the maximal constant term. This option can significantly
6793 increase the speed of the scheduling calculation and may also prevent fusing of
6794 unrelated dimensions. A value of -1 means that this option does not introduce
6795 bounds on the constant coefficients.
6797 =item * schedule_fuse
6799 This option controls the level of fusion.
6800 If this option is set to C<ISL_SCHEDULE_FUSE_MIN>, then loops in the
6801 resulting schedule will be distributed as much as possible.
6802 If this option is set to C<ISL_SCHEDULE_FUSE_MAX>, then C<isl> will
6803 try to fuse loops in the resulting schedule.
6805 =item * schedule_maximize_band_depth
6807 If this option is set, we do not split bands at the point
6808 where we detect splitting is necessary. Instead, we
6809 backtrack and split bands as early as possible. This
6810 reduces the number of splits and maximizes the width of
6811 the bands. Wider bands give more possibilities for tiling.
6812 Note that if the C<schedule_fuse> option is set to C<ISL_SCHEDULE_FUSE_MIN>,
6813 then bands will be split as early as possible, even if there is no need.
6814 The C<schedule_maximize_band_depth> option therefore has no effect in this case.
6816 =item * schedule_outer_coincidence
6818 If this option is set, then we try to construct schedules
6819 where the outermost scheduling dimension in each band
6820 satisfies the coincidence constraints.
6822 =item * schedule_split_scaled
6824 If this option is set, then we try to construct schedules in which the
6825 constant term is split off from the linear part if the linear parts of
6826 the scheduling rows for all nodes in the graphs have a common non-trivial
6827 divisor.
6828 The constant term is then placed in a separate band and the linear
6829 part is reduced.
6831 =item * schedule_algorithm
6833 Selects the scheduling algorithm to be used.
6834 Available scheduling algorithms are C<ISL_SCHEDULE_ALGORITHM_ISL>
6835 and C<ISL_SCHEDULE_ALGORITHM_FEAUTRIER>.
6837 =item * schedule_separate_components
6839 If at any point the dependence graph contains any (weakly connected) components,
6840 then these components are scheduled separately.
6841 If this option is not set, then some iterations of the domains
6842 in these components may be scheduled together.
6843 If this option is set, then the components are given consecutive
6844 schedules.
6846 =back
6848 =head2 AST Generation
6850 This section describes the C<isl> functionality for generating
6851 ASTs that visit all the elements
6852 in a domain in an order specified by a schedule.
6853 In particular, given a C<isl_union_map>, an AST is generated
6854 that visits all the elements in the domain of the C<isl_union_map>
6855 according to the lexicographic order of the corresponding image
6856 element(s).  If the range of the C<isl_union_map> consists of
6857 elements in more than one space, then each of these spaces is handled
6858 separately in an arbitrary order.
6859 It should be noted that the image elements only specify the I<order>
6860 in which the corresponding domain elements should be visited.
6861 No direct relation between the image elements and the loop iterators
6862 in the generated AST should be assumed.
6864 Each AST is generated within a build.  The initial build
6865 simply specifies the constraints on the parameters (if any)
6866 and can be created, inspected, copied and freed using the following functions.
6868         #include <isl/ast_build.h>
6869         __isl_give isl_ast_build *isl_ast_build_from_context(
6870                 __isl_take isl_set *set);
6871         __isl_give isl_ast_build *isl_ast_build_copy(
6872                 __isl_keep isl_ast_build *build);
6873         __isl_null isl_ast_build *isl_ast_build_free(
6874                 __isl_take isl_ast_build *build);
6876 The C<set> argument is usually a parameter set with zero or more parameters.
6877 More C<isl_ast_build> functions are described in L</"Nested AST Generation">
6878 and L</"Fine-grained Control over AST Generation">.
6879 Finally, the AST itself can be constructed using the following
6880 function.
6882         #include <isl/ast_build.h>
6883         __isl_give isl_ast_node *isl_ast_build_ast_from_schedule(
6884                 __isl_keep isl_ast_build *build,
6885                 __isl_take isl_union_map *schedule);
6887 =head3 Inspecting the AST
6889 The basic properties of an AST node can be obtained as follows.
6891         #include <isl/ast.h>
6892         enum isl_ast_node_type isl_ast_node_get_type(
6893                 __isl_keep isl_ast_node *node);
6895 The type of an AST node is one of
6896 C<isl_ast_node_for>,
6897 C<isl_ast_node_if>,
6898 C<isl_ast_node_block> or
6899 C<isl_ast_node_user>.
6900 An C<isl_ast_node_for> represents a for node.
6901 An C<isl_ast_node_if> represents an if node.
6902 An C<isl_ast_node_block> represents a compound node.
6903 An C<isl_ast_node_user> represents an expression statement.
6904 An expression statement typically corresponds to a domain element, i.e.,
6905 one of the elements that is visited by the AST.
6907 Each type of node has its own additional properties.
6909         #include <isl/ast.h>
6910         __isl_give isl_ast_expr *isl_ast_node_for_get_iterator(
6911                 __isl_keep isl_ast_node *node);
6912         __isl_give isl_ast_expr *isl_ast_node_for_get_init(
6913                 __isl_keep isl_ast_node *node);
6914         __isl_give isl_ast_expr *isl_ast_node_for_get_cond(
6915                 __isl_keep isl_ast_node *node);
6916         __isl_give isl_ast_expr *isl_ast_node_for_get_inc(
6917                 __isl_keep isl_ast_node *node);
6918         __isl_give isl_ast_node *isl_ast_node_for_get_body(
6919                 __isl_keep isl_ast_node *node);
6920         int isl_ast_node_for_is_degenerate(
6921                 __isl_keep isl_ast_node *node);
6923 An C<isl_ast_for> is considered degenerate if it is known to execute
6924 exactly once.
6926         #include <isl/ast.h>
6927         __isl_give isl_ast_expr *isl_ast_node_if_get_cond(
6928                 __isl_keep isl_ast_node *node);
6929         __isl_give isl_ast_node *isl_ast_node_if_get_then(
6930                 __isl_keep isl_ast_node *node);
6931         int isl_ast_node_if_has_else(
6932                 __isl_keep isl_ast_node *node);
6933         __isl_give isl_ast_node *isl_ast_node_if_get_else(
6934                 __isl_keep isl_ast_node *node);
6936         __isl_give isl_ast_node_list *
6937         isl_ast_node_block_get_children(
6938                 __isl_keep isl_ast_node *node);
6940         __isl_give isl_ast_expr *isl_ast_node_user_get_expr(
6941                 __isl_keep isl_ast_node *node);
6943 Each of the returned C<isl_ast_expr>s can in turn be inspected using
6944 the following functions.
6946         #include <isl/ast.h>
6947         enum isl_ast_expr_type isl_ast_expr_get_type(
6948                 __isl_keep isl_ast_expr *expr);
6950 The type of an AST expression is one of
6951 C<isl_ast_expr_op>,
6952 C<isl_ast_expr_id> or
6953 C<isl_ast_expr_int>.
6954 An C<isl_ast_expr_op> represents the result of an operation.
6955 An C<isl_ast_expr_id> represents an identifier.
6956 An C<isl_ast_expr_int> represents an integer value.
6958 Each type of expression has its own additional properties.
6960         #include <isl/ast.h>
6961         enum isl_ast_op_type isl_ast_expr_get_op_type(
6962                 __isl_keep isl_ast_expr *expr);
6963         int isl_ast_expr_get_op_n_arg(__isl_keep isl_ast_expr *expr);
6964         __isl_give isl_ast_expr *isl_ast_expr_get_op_arg(
6965                 __isl_keep isl_ast_expr *expr, int pos);
6966         int isl_ast_node_foreach_ast_op_type(
6967                 __isl_keep isl_ast_node *node,
6968                 int (*fn)(enum isl_ast_op_type type, void *user),
6969                 void *user);
6971 C<isl_ast_expr_get_op_type> returns the type of the operation
6972 performed.  C<isl_ast_expr_get_op_n_arg> returns the number of
6973 arguments.  C<isl_ast_expr_get_op_arg> returns the specified
6974 argument.
6975 C<isl_ast_node_foreach_ast_op_type> calls C<fn> for each distinct
6976 C<isl_ast_op_type> that appears in C<node>.
6977 The operation type is one of the following.
6979 =over
6981 =item C<isl_ast_op_and>
6983 Logical I<and> of two arguments.
6984 Both arguments can be evaluated.
6986 =item C<isl_ast_op_and_then>
6988 Logical I<and> of two arguments.
6989 The second argument can only be evaluated if the first evaluates to true.
6991 =item C<isl_ast_op_or>
6993 Logical I<or> of two arguments.
6994 Both arguments can be evaluated.
6996 =item C<isl_ast_op_or_else>
6998 Logical I<or> of two arguments.
6999 The second argument can only be evaluated if the first evaluates to false.
7001 =item C<isl_ast_op_max>
7003 Maximum of two or more arguments.
7005 =item C<isl_ast_op_min>
7007 Minimum of two or more arguments.
7009 =item C<isl_ast_op_minus>
7011 Change sign.
7013 =item C<isl_ast_op_add>
7015 Sum of two arguments.
7017 =item C<isl_ast_op_sub>
7019 Difference of two arguments.
7021 =item C<isl_ast_op_mul>
7023 Product of two arguments.
7025 =item C<isl_ast_op_div>
7027 Exact division.  That is, the result is known to be an integer.
7029 =item C<isl_ast_op_fdiv_q>
7031 Result of integer division, rounded towards negative
7032 infinity.
7034 =item C<isl_ast_op_pdiv_q>
7036 Result of integer division, where dividend is known to be non-negative.
7038 =item C<isl_ast_op_pdiv_r>
7040 Remainder of integer division, where dividend is known to be non-negative.
7042 =item C<isl_ast_op_zdiv_r>
7044 Equal to zero iff the remainder on integer division is zero.
7046 =item C<isl_ast_op_cond>
7048 Conditional operator defined on three arguments.
7049 If the first argument evaluates to true, then the result
7050 is equal to the second argument.  Otherwise, the result
7051 is equal to the third argument.
7052 The second and third argument may only be evaluated if
7053 the first argument evaluates to true and false, respectively.
7054 Corresponds to C<a ? b : c> in C.
7056 =item C<isl_ast_op_select>
7058 Conditional operator defined on three arguments.
7059 If the first argument evaluates to true, then the result
7060 is equal to the second argument.  Otherwise, the result
7061 is equal to the third argument.
7062 The second and third argument may be evaluated independently
7063 of the value of the first argument.
7064 Corresponds to C<a * b + (1 - a) * c> in C.
7066 =item C<isl_ast_op_eq>
7068 Equality relation.
7070 =item C<isl_ast_op_le>
7072 Less than or equal relation.
7074 =item C<isl_ast_op_lt>
7076 Less than relation.
7078 =item C<isl_ast_op_ge>
7080 Greater than or equal relation.
7082 =item C<isl_ast_op_gt>
7084 Greater than relation.
7086 =item C<isl_ast_op_call>
7088 A function call.
7089 The number of arguments of the C<isl_ast_expr> is one more than
7090 the number of arguments in the function call, the first argument
7091 representing the function being called.
7093 =item C<isl_ast_op_access>
7095 An array access.
7096 The number of arguments of the C<isl_ast_expr> is one more than
7097 the number of index expressions in the array access, the first argument
7098 representing the array being accessed.
7100 =item C<isl_ast_op_member>
7102 A member access.
7103 This operation has two arguments, a structure and the name of
7104 the member of the structure being accessed.
7106 =back
7108         #include <isl/ast.h>
7109         __isl_give isl_id *isl_ast_expr_get_id(
7110                 __isl_keep isl_ast_expr *expr);
7112 Return the identifier represented by the AST expression.
7114         #include <isl/ast.h>
7115         __isl_give isl_val *isl_ast_expr_get_val(
7116                 __isl_keep isl_ast_expr *expr);
7118 Return the integer represented by the AST expression.
7120 =head3 Properties of ASTs
7122         #include <isl/ast.h>
7123         int isl_ast_expr_is_equal(__isl_keep isl_ast_expr *expr1,
7124                 __isl_keep isl_ast_expr *expr2);
7126 Check if two C<isl_ast_expr>s are equal to each other.
7128 =head3 Manipulating and printing the AST
7130 AST nodes can be copied and freed using the following functions.
7132         #include <isl/ast.h>
7133         __isl_give isl_ast_node *isl_ast_node_copy(
7134                 __isl_keep isl_ast_node *node);
7135         __isl_null isl_ast_node *isl_ast_node_free(
7136                 __isl_take isl_ast_node *node);
7138 AST expressions can be copied and freed using the following functions.
7140         #include <isl/ast.h>
7141         __isl_give isl_ast_expr *isl_ast_expr_copy(
7142                 __isl_keep isl_ast_expr *expr);
7143         __isl_null isl_ast_expr *isl_ast_expr_free(
7144                 __isl_take isl_ast_expr *expr);
7146 New AST expressions can be created either directly or within
7147 the context of an C<isl_ast_build>.
7149         #include <isl/ast.h>
7150         __isl_give isl_ast_expr *isl_ast_expr_from_val(
7151                 __isl_take isl_val *v);
7152         __isl_give isl_ast_expr *isl_ast_expr_from_id(
7153                 __isl_take isl_id *id);
7154         __isl_give isl_ast_expr *isl_ast_expr_neg(
7155                 __isl_take isl_ast_expr *expr);
7156         __isl_give isl_ast_expr *isl_ast_expr_address_of(
7157                 __isl_take isl_ast_expr *expr);
7158         __isl_give isl_ast_expr *isl_ast_expr_add(
7159                 __isl_take isl_ast_expr *expr1,
7160                 __isl_take isl_ast_expr *expr2);
7161         __isl_give isl_ast_expr *isl_ast_expr_sub(
7162                 __isl_take isl_ast_expr *expr1,
7163                 __isl_take isl_ast_expr *expr2);
7164         __isl_give isl_ast_expr *isl_ast_expr_mul(
7165                 __isl_take isl_ast_expr *expr1,
7166                 __isl_take isl_ast_expr *expr2);
7167         __isl_give isl_ast_expr *isl_ast_expr_div(
7168                 __isl_take isl_ast_expr *expr1,
7169                 __isl_take isl_ast_expr *expr2);
7170         __isl_give isl_ast_expr *isl_ast_expr_and(
7171                 __isl_take isl_ast_expr *expr1,
7172                 __isl_take isl_ast_expr *expr2)
7173         __isl_give isl_ast_expr *isl_ast_expr_or(
7174                 __isl_take isl_ast_expr *expr1,
7175                 __isl_take isl_ast_expr *expr2)
7176         __isl_give isl_ast_expr *isl_ast_expr_eq(
7177                 __isl_take isl_ast_expr *expr1,
7178                 __isl_take isl_ast_expr *expr2);
7179         __isl_give isl_ast_expr *isl_ast_expr_le(
7180                 __isl_take isl_ast_expr *expr1,
7181                 __isl_take isl_ast_expr *expr2);
7182         __isl_give isl_ast_expr *isl_ast_expr_lt(
7183                 __isl_take isl_ast_expr *expr1,
7184                 __isl_take isl_ast_expr *expr2);
7185         __isl_give isl_ast_expr *isl_ast_expr_ge(
7186                 __isl_take isl_ast_expr *expr1,
7187                 __isl_take isl_ast_expr *expr2);
7188         __isl_give isl_ast_expr *isl_ast_expr_gt(
7189                 __isl_take isl_ast_expr *expr1,
7190                 __isl_take isl_ast_expr *expr2);
7191         __isl_give isl_ast_expr *isl_ast_expr_access(
7192                 __isl_take isl_ast_expr *array,
7193                 __isl_take isl_ast_expr_list *indices);
7195 The function C<isl_ast_expr_address_of> can be applied to an
7196 C<isl_ast_expr> of type C<isl_ast_op_access> only. It is meant
7197 to represent the address of the C<isl_ast_expr_access>.
7199         #include <isl/ast_build.h>
7200         __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff(
7201                 __isl_keep isl_ast_build *build,
7202                 __isl_take isl_pw_aff *pa);
7203         __isl_give isl_ast_expr *
7204         isl_ast_build_access_from_pw_multi_aff(
7205                 __isl_keep isl_ast_build *build,
7206                 __isl_take isl_pw_multi_aff *pma);
7207         __isl_give isl_ast_expr *
7208         isl_ast_build_access_from_multi_pw_aff(
7209                 __isl_keep isl_ast_build *build,
7210                 __isl_take isl_multi_pw_aff *mpa);
7211         __isl_give isl_ast_expr *
7212         isl_ast_build_call_from_pw_multi_aff(
7213                 __isl_keep isl_ast_build *build,
7214                 __isl_take isl_pw_multi_aff *pma);
7215         __isl_give isl_ast_expr *
7216         isl_ast_build_call_from_multi_pw_aff(
7217                 __isl_keep isl_ast_build *build,
7218                 __isl_take isl_multi_pw_aff *mpa);
7220 The domains of C<pa>, C<mpa> and C<pma> should correspond
7221 to the schedule space of C<build>.
7222 The tuple id of C<mpa> or C<pma> is used as the array being accessed or
7223 the function being called.
7224 If the accessed space is a nested relation, then it is taken
7225 to represent an access of the member specified by the range
7226 of this nested relation of the structure specified by the domain
7227 of the nested relation.
7229 The following functions can be used to modify an C<isl_ast_expr>.
7231         #include <isl/ast.h>
7232         __isl_give isl_ast_expr *isl_ast_expr_set_op_arg(
7233                 __isl_take isl_ast_expr *expr, int pos,
7234                 __isl_take isl_ast_expr *arg);
7236 Replace the argument of C<expr> at position C<pos> by C<arg>.
7238         #include <isl/ast.h>
7239         __isl_give isl_ast_expr *isl_ast_expr_substitute_ids(
7240                 __isl_take isl_ast_expr *expr,
7241                 __isl_take isl_id_to_ast_expr *id2expr);
7243 The function C<isl_ast_expr_substitute_ids> replaces the
7244 subexpressions of C<expr> of type C<isl_ast_expr_id>
7245 by the corresponding expression in C<id2expr>, if there is any.
7248 User specified data can be attached to an C<isl_ast_node> and obtained
7249 from the same C<isl_ast_node> using the following functions.
7251         #include <isl/ast.h>
7252         __isl_give isl_ast_node *isl_ast_node_set_annotation(
7253                 __isl_take isl_ast_node *node,
7254                 __isl_take isl_id *annotation);
7255         __isl_give isl_id *isl_ast_node_get_annotation(
7256                 __isl_keep isl_ast_node *node);
7258 Basic printing can be performed using the following functions.
7260         #include <isl/ast.h>
7261         __isl_give isl_printer *isl_printer_print_ast_expr(
7262                 __isl_take isl_printer *p,
7263                 __isl_keep isl_ast_expr *expr);
7264         __isl_give isl_printer *isl_printer_print_ast_node(
7265                 __isl_take isl_printer *p,
7266                 __isl_keep isl_ast_node *node);
7267         __isl_give char *isl_ast_expr_to_str(
7268                 __isl_keep isl_ast_expr *expr);
7270 More advanced printing can be performed using the following functions.
7272         #include <isl/ast.h>
7273         __isl_give isl_printer *isl_ast_op_type_print_macro(
7274                 enum isl_ast_op_type type,
7275                 __isl_take isl_printer *p);
7276         __isl_give isl_printer *isl_ast_node_print_macros(
7277                 __isl_keep isl_ast_node *node,
7278                 __isl_take isl_printer *p);
7279         __isl_give isl_printer *isl_ast_node_print(
7280                 __isl_keep isl_ast_node *node,
7281                 __isl_take isl_printer *p,
7282                 __isl_take isl_ast_print_options *options);
7283         __isl_give isl_printer *isl_ast_node_for_print(
7284                 __isl_keep isl_ast_node *node,
7285                 __isl_take isl_printer *p,
7286                 __isl_take isl_ast_print_options *options);
7287         __isl_give isl_printer *isl_ast_node_if_print(
7288                 __isl_keep isl_ast_node *node,
7289                 __isl_take isl_printer *p,
7290                 __isl_take isl_ast_print_options *options);
7292 While printing an C<isl_ast_node> in C<ISL_FORMAT_C>,
7293 C<isl> may print out an AST that makes use of macros such
7294 as C<floord>, C<min> and C<max>.
7295 C<isl_ast_op_type_print_macro> prints out the macro
7296 corresponding to a specific C<isl_ast_op_type>.
7297 C<isl_ast_node_print_macros> scans the C<isl_ast_node>
7298 for expressions where these macros would be used and prints
7299 out the required macro definitions.
7300 Essentially, C<isl_ast_node_print_macros> calls
7301 C<isl_ast_node_foreach_ast_op_type> with C<isl_ast_op_type_print_macro>
7302 as function argument.
7303 C<isl_ast_node_print>, C<isl_ast_node_for_print> and
7304 C<isl_ast_node_if_print> print an C<isl_ast_node>
7305 in C<ISL_FORMAT_C>, but allow for some extra control
7306 through an C<isl_ast_print_options> object.
7307 This object can be created using the following functions.
7309         #include <isl/ast.h>
7310         __isl_give isl_ast_print_options *
7311         isl_ast_print_options_alloc(isl_ctx *ctx);
7312         __isl_give isl_ast_print_options *
7313         isl_ast_print_options_copy(
7314                 __isl_keep isl_ast_print_options *options);
7315         __isl_null isl_ast_print_options *
7316         isl_ast_print_options_free(
7317                 __isl_take isl_ast_print_options *options);
7319         __isl_give isl_ast_print_options *
7320         isl_ast_print_options_set_print_user(
7321                 __isl_take isl_ast_print_options *options,
7322                 __isl_give isl_printer *(*print_user)(
7323                         __isl_take isl_printer *p,
7324                         __isl_take isl_ast_print_options *options,
7325                         __isl_keep isl_ast_node *node, void *user),
7326                 void *user);
7327         __isl_give isl_ast_print_options *
7328         isl_ast_print_options_set_print_for(
7329                 __isl_take isl_ast_print_options *options,
7330                 __isl_give isl_printer *(*print_for)(
7331                         __isl_take isl_printer *p,
7332                         __isl_take isl_ast_print_options *options,
7333                         __isl_keep isl_ast_node *node, void *user),
7334                 void *user);
7336 The callback set by C<isl_ast_print_options_set_print_user>
7337 is called whenever a node of type C<isl_ast_node_user> needs to
7338 be printed.
7339 The callback set by C<isl_ast_print_options_set_print_for>
7340 is called whenever a node of type C<isl_ast_node_for> needs to
7341 be printed.
7342 Note that C<isl_ast_node_for_print> will I<not> call the
7343 callback set by C<isl_ast_print_options_set_print_for> on the node
7344 on which C<isl_ast_node_for_print> is called, but only on nested
7345 nodes of type C<isl_ast_node_for>.  It is therefore safe to
7346 call C<isl_ast_node_for_print> from within the callback set by
7347 C<isl_ast_print_options_set_print_for>.
7349 The following option determines the type to be used for iterators
7350 while printing the AST.
7352         int isl_options_set_ast_iterator_type(
7353                 isl_ctx *ctx, const char *val);
7354         const char *isl_options_get_ast_iterator_type(
7355                 isl_ctx *ctx);
7357 The AST printer only prints body nodes as blocks if these
7358 blocks cannot be safely omitted.
7359 For example, a C<for> node with one body node will not be
7360 surrounded with braces in C<ISL_FORMAT_C>.
7361 A block will always be printed by setting the following option.
7363         int isl_options_set_ast_always_print_block(isl_ctx *ctx,
7364                 int val);
7365         int isl_options_get_ast_always_print_block(isl_ctx *ctx);
7367 =head3 Options
7369         #include <isl/ast_build.h>
7370         int isl_options_set_ast_build_atomic_upper_bound(
7371                 isl_ctx *ctx, int val);
7372         int isl_options_get_ast_build_atomic_upper_bound(
7373                 isl_ctx *ctx);
7374         int isl_options_set_ast_build_prefer_pdiv(isl_ctx *ctx,
7375                 int val);
7376         int isl_options_get_ast_build_prefer_pdiv(isl_ctx *ctx);
7377         int isl_options_set_ast_build_exploit_nested_bounds(
7378                 isl_ctx *ctx, int val);
7379         int isl_options_get_ast_build_exploit_nested_bounds(
7380                 isl_ctx *ctx);
7381         int isl_options_set_ast_build_group_coscheduled(
7382                 isl_ctx *ctx, int val);
7383         int isl_options_get_ast_build_group_coscheduled(
7384                 isl_ctx *ctx);
7385         int isl_options_set_ast_build_scale_strides(
7386                 isl_ctx *ctx, int val);
7387         int isl_options_get_ast_build_scale_strides(
7388                 isl_ctx *ctx);
7389         int isl_options_set_ast_build_allow_else(isl_ctx *ctx,
7390                 int val);
7391         int isl_options_get_ast_build_allow_else(isl_ctx *ctx);
7392         int isl_options_set_ast_build_allow_or(isl_ctx *ctx,
7393                 int val);
7394         int isl_options_get_ast_build_allow_or(isl_ctx *ctx);
7396 =over
7398 =item * ast_build_atomic_upper_bound
7400 Generate loop upper bounds that consist of the current loop iterator,
7401 an operator and an expression not involving the iterator.
7402 If this option is not set, then the current loop iterator may appear
7403 several times in the upper bound.
7404 For example, when this option is turned off, AST generation
7405 for the schedule
7407         [n] -> { A[i] -> [i] : 0 <= i <= 100, n }
7409 produces
7411         for (int c0 = 0; c0 <= 100 && n >= c0; c0 += 1)
7412           A(c0);
7414 When the option is turned on, the following AST is generated
7416         for (int c0 = 0; c0 <= min(100, n); c0 += 1)
7417           A(c0);
7419 =item * ast_build_prefer_pdiv
7421 If this option is turned off, then the AST generation will
7422 produce ASTs that may only contain C<isl_ast_op_fdiv_q>
7423 operators, but no C<isl_ast_op_pdiv_q> or
7424 C<isl_ast_op_pdiv_r> operators.
7425 If this options is turned on, then C<isl> will try to convert
7426 some of the C<isl_ast_op_fdiv_q> operators to (expressions containing)
7427 C<isl_ast_op_pdiv_q> or C<isl_ast_op_pdiv_r> operators.
7429 =item * ast_build_exploit_nested_bounds
7431 Simplify conditions based on bounds of nested for loops.
7432 In particular, remove conditions that are implied by the fact
7433 that one or more nested loops have at least one iteration,
7434 meaning that the upper bound is at least as large as the lower bound.
7435 For example, when this option is turned off, AST generation
7436 for the schedule
7438         [N,M] -> { A[i,j] -> [i,j] : 0 <= i <= N and
7439                                         0 <= j <= M }
7441 produces
7443         if (M >= 0)
7444           for (int c0 = 0; c0 <= N; c0 += 1)
7445             for (int c1 = 0; c1 <= M; c1 += 1)
7446               A(c0, c1);
7448 When the option is turned on, the following AST is generated
7450         for (int c0 = 0; c0 <= N; c0 += 1)
7451           for (int c1 = 0; c1 <= M; c1 += 1)
7452             A(c0, c1);
7454 =item * ast_build_group_coscheduled
7456 If two domain elements are assigned the same schedule point, then
7457 they may be executed in any order and they may even appear in different
7458 loops.  If this options is set, then the AST generator will make
7459 sure that coscheduled domain elements do not appear in separate parts
7460 of the AST.  This is useful in case of nested AST generation
7461 if the outer AST generation is given only part of a schedule
7462 and the inner AST generation should handle the domains that are
7463 coscheduled by this initial part of the schedule together.
7464 For example if an AST is generated for a schedule
7466         { A[i] -> [0]; B[i] -> [0] }
7468 then the C<isl_ast_build_set_create_leaf> callback described
7469 below may get called twice, once for each domain.
7470 Setting this option ensures that the callback is only called once
7471 on both domains together.
7473 =item * ast_build_separation_bounds
7475 This option specifies which bounds to use during separation.
7476 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT>
7477 then all (possibly implicit) bounds on the current dimension will
7478 be used during separation.
7479 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT>
7480 then only those bounds that are explicitly available will
7481 be used during separation.
7483 =item * ast_build_scale_strides
7485 This option specifies whether the AST generator is allowed
7486 to scale down iterators of strided loops.
7488 =item * ast_build_allow_else
7490 This option specifies whether the AST generator is allowed
7491 to construct if statements with else branches.
7493 =item * ast_build_allow_or
7495 This option specifies whether the AST generator is allowed
7496 to construct if conditions with disjunctions.
7498 =back
7500 =head3 Fine-grained Control over AST Generation
7502 Besides specifying the constraints on the parameters,
7503 an C<isl_ast_build> object can be used to control
7504 various aspects of the AST generation process.
7505 The most prominent way of control is through ``options'',
7506 which can be set using the following function.
7508         #include <isl/ast_build.h>
7509         __isl_give isl_ast_build *
7510         isl_ast_build_set_options(
7511                 __isl_take isl_ast_build *control,
7512                 __isl_take isl_union_map *options);
7514 The options are encoded in an C<isl_union_map>.
7515 The domain of this union relation refers to the schedule domain,
7516 i.e., the range of the schedule passed to C<isl_ast_build_ast_from_schedule>.
7517 In the case of nested AST generation (see L</"Nested AST Generation">),
7518 the domain of C<options> should refer to the extra piece of the schedule.
7519 That is, it should be equal to the range of the wrapped relation in the
7520 range of the schedule.
7521 The range of the options can consist of elements in one or more spaces,
7522 the names of which determine the effect of the option.
7523 The values of the range typically also refer to the schedule dimension
7524 to which the option applies.  In case of nested AST generation
7525 (see L</"Nested AST Generation">), these values refer to the position
7526 of the schedule dimension within the innermost AST generation.
7527 The constraints on the domain elements of
7528 the option should only refer to this dimension and earlier dimensions.
7529 We consider the following spaces.
7531 =over
7533 =item C<separation_class>
7535 This space is a wrapped relation between two one dimensional spaces.
7536 The input space represents the schedule dimension to which the option
7537 applies and the output space represents the separation class.
7538 While constructing a loop corresponding to the specified schedule
7539 dimension(s), the AST generator will try to generate separate loops
7540 for domain elements that are assigned different classes.
7541 If only some of the elements are assigned a class, then those elements
7542 that are not assigned any class will be treated as belonging to a class
7543 that is separate from the explicitly assigned classes.
7544 The typical use case for this option is to separate full tiles from
7545 partial tiles.
7546 The other options, described below, are applied after the separation
7547 into classes.
7549 As an example, consider the separation into full and partial tiles
7550 of a tiling of a triangular domain.
7551 Take, for example, the domain
7553         { A[i,j] : 0 <= i,j and i + j <= 100 }
7555 and a tiling into tiles of 10 by 10.  The input to the AST generator
7556 is then the schedule
7558         { A[i,j] -> [([i/10]),[j/10],i,j] : 0 <= i,j and
7559                                                 i + j <= 100 }
7561 Without any options, the following AST is generated
7563         for (int c0 = 0; c0 <= 10; c0 += 1)
7564           for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7565             for (int c2 = 10 * c0;
7566                  c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7567                  c2 += 1)
7568               for (int c3 = 10 * c1;
7569                    c3 <= min(10 * c1 + 9, -c2 + 100);
7570                    c3 += 1)
7571                 A(c2, c3);
7573 Separation into full and partial tiles can be obtained by assigning
7574 a class, say C<0>, to the full tiles.  The full tiles are represented by those
7575 values of the first and second schedule dimensions for which there are
7576 values of the third and fourth dimensions to cover an entire tile.
7577 That is, we need to specify the following option
7579         { [a,b,c,d] -> separation_class[[0]->[0]] :
7580                 exists b': 0 <= 10a,10b' and
7581                            10a+9+10b'+9 <= 100;
7582           [a,b,c,d] -> separation_class[[1]->[0]] :
7583                 0 <= 10a,10b and 10a+9+10b+9 <= 100 }
7585 which simplifies to
7587         { [a, b, c, d] -> separation_class[[1] -> [0]] :
7588                 a >= 0 and b >= 0 and b <= 8 - a;
7589           [a, b, c, d] -> separation_class[[0] -> [0]] :
7590                 a >= 0 and a <= 8 }
7592 With this option, the generated AST is as follows
7594         {
7595           for (int c0 = 0; c0 <= 8; c0 += 1) {
7596             for (int c1 = 0; c1 <= -c0 + 8; c1 += 1)
7597               for (int c2 = 10 * c0;
7598                    c2 <= 10 * c0 + 9; c2 += 1)
7599                 for (int c3 = 10 * c1;
7600                      c3 <= 10 * c1 + 9; c3 += 1)
7601                   A(c2, c3);
7602             for (int c1 = -c0 + 9; c1 <= -c0 + 10; c1 += 1)
7603               for (int c2 = 10 * c0;
7604                    c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7605                    c2 += 1)
7606                 for (int c3 = 10 * c1;
7607                      c3 <= min(-c2 + 100, 10 * c1 + 9);
7608                      c3 += 1)
7609                   A(c2, c3);
7610           }
7611           for (int c0 = 9; c0 <= 10; c0 += 1)
7612             for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7613               for (int c2 = 10 * c0;
7614                    c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7615                    c2 += 1)
7616                 for (int c3 = 10 * c1;
7617                      c3 <= min(10 * c1 + 9, -c2 + 100);
7618                      c3 += 1)
7619                   A(c2, c3);
7620         }
7622 =item C<separate>
7624 This is a single-dimensional space representing the schedule dimension(s)
7625 to which ``separation'' should be applied.  Separation tries to split
7626 a loop into several pieces if this can avoid the generation of guards
7627 inside the loop.
7628 See also the C<atomic> option.
7630 =item C<atomic>
7632 This is a single-dimensional space representing the schedule dimension(s)
7633 for which the domains should be considered ``atomic''.  That is, the
7634 AST generator will make sure that any given domain space will only appear
7635 in a single loop at the specified level.
7637 Consider the following schedule
7639         { a[i] -> [i] : 0 <= i < 10;
7640           b[i] -> [i+1] : 0 <= i < 10 }
7642 If the following option is specified
7644         { [i] -> separate[x] }
7646 then the following AST will be generated
7648         {
7649           a(0);
7650           for (int c0 = 1; c0 <= 9; c0 += 1) {
7651             a(c0);
7652             b(c0 - 1);
7653           }
7654           b(9);
7655         }
7657 If, on the other hand, the following option is specified
7659         { [i] -> atomic[x] }
7661 then the following AST will be generated
7663         for (int c0 = 0; c0 <= 10; c0 += 1) {
7664           if (c0 <= 9)
7665             a(c0);
7666           if (c0 >= 1)
7667             b(c0 - 1);
7668         }
7670 If neither C<atomic> nor C<separate> is specified, then the AST generator
7671 may produce either of these two results or some intermediate form.
7673 =item C<unroll>
7675 This is a single-dimensional space representing the schedule dimension(s)
7676 that should be I<completely> unrolled.
7677 To obtain a partial unrolling, the user should apply an additional
7678 strip-mining to the schedule and fully unroll the inner loop.
7680 =back
7682 Additional control is available through the following functions.
7684         #include <isl/ast_build.h>
7685         __isl_give isl_ast_build *
7686         isl_ast_build_set_iterators(
7687                 __isl_take isl_ast_build *control,
7688                 __isl_take isl_id_list *iterators);
7690 The function C<isl_ast_build_set_iterators> allows the user to
7691 specify a list of iterator C<isl_id>s to be used as iterators.
7692 If the input schedule is injective, then
7693 the number of elements in this list should be as large as the dimension
7694 of the schedule space, but no direct correspondence should be assumed
7695 between dimensions and elements.
7696 If the input schedule is not injective, then an additional number
7697 of C<isl_id>s equal to the largest dimension of the input domains
7698 may be required.
7699 If the number of provided C<isl_id>s is insufficient, then additional
7700 names are automatically generated.
7702         #include <isl/ast_build.h>
7703         __isl_give isl_ast_build *
7704         isl_ast_build_set_create_leaf(
7705                 __isl_take isl_ast_build *control,
7706                 __isl_give isl_ast_node *(*fn)(
7707                         __isl_take isl_ast_build *build,
7708                         void *user), void *user);
7711 C<isl_ast_build_set_create_leaf> function allows for the
7712 specification of a callback that should be called whenever the AST
7713 generator arrives at an element of the schedule domain.
7714 The callback should return an AST node that should be inserted
7715 at the corresponding position of the AST.  The default action (when
7716 the callback is not set) is to continue generating parts of the AST to scan
7717 all the domain elements associated to the schedule domain element
7718 and to insert user nodes, ``calling'' the domain element, for each of them.
7719 The C<build> argument contains the current state of the C<isl_ast_build>.
7720 To ease nested AST generation (see L</"Nested AST Generation">),
7721 all control information that is
7722 specific to the current AST generation such as the options and
7723 the callbacks has been removed from this C<isl_ast_build>.
7724 The callback would typically return the result of a nested
7725 AST generation or a
7726 user defined node created using the following function.
7728         #include <isl/ast.h>
7729         __isl_give isl_ast_node *isl_ast_node_alloc_user(
7730                 __isl_take isl_ast_expr *expr);
7732         #include <isl/ast_build.h>
7733         __isl_give isl_ast_build *
7734         isl_ast_build_set_at_each_domain(
7735                 __isl_take isl_ast_build *build,
7736                 __isl_give isl_ast_node *(*fn)(
7737                         __isl_take isl_ast_node *node,
7738                         __isl_keep isl_ast_build *build,
7739                         void *user), void *user);
7740         __isl_give isl_ast_build *
7741         isl_ast_build_set_before_each_for(
7742                 __isl_take isl_ast_build *build,
7743                 __isl_give isl_id *(*fn)(
7744                         __isl_keep isl_ast_build *build,
7745                         void *user), void *user);
7746         __isl_give isl_ast_build *
7747         isl_ast_build_set_after_each_for(
7748                 __isl_take isl_ast_build *build,
7749                 __isl_give isl_ast_node *(*fn)(
7750                         __isl_take isl_ast_node *node,
7751                         __isl_keep isl_ast_build *build,
7752                         void *user), void *user);
7754 The callback set by C<isl_ast_build_set_at_each_domain> will
7755 be called for each domain AST node.
7756 The callbacks set by C<isl_ast_build_set_before_each_for>
7757 and C<isl_ast_build_set_after_each_for> will be called
7758 for each for AST node.  The first will be called in depth-first
7759 pre-order, while the second will be called in depth-first post-order.
7760 Since C<isl_ast_build_set_before_each_for> is called before the for
7761 node is actually constructed, it is only passed an C<isl_ast_build>.
7762 The returned C<isl_id> will be added as an annotation (using
7763 C<isl_ast_node_set_annotation>) to the constructed for node.
7764 In particular, if the user has also specified an C<after_each_for>
7765 callback, then the annotation can be retrieved from the node passed to
7766 that callback using C<isl_ast_node_get_annotation>.
7767 All callbacks should C<NULL> on failure.
7768 The given C<isl_ast_build> can be used to create new
7769 C<isl_ast_expr> objects using C<isl_ast_build_expr_from_pw_aff>
7770 or C<isl_ast_build_call_from_pw_multi_aff>.
7772 =head3 Nested AST Generation
7774 C<isl> allows the user to create an AST within the context
7775 of another AST.  These nested ASTs are created using the
7776 same C<isl_ast_build_ast_from_schedule> function that is used to create the
7777 outer AST.  The C<build> argument should be an C<isl_ast_build>
7778 passed to a callback set by
7779 C<isl_ast_build_set_create_leaf>.
7780 The space of the range of the C<schedule> argument should refer
7781 to this build.  In particular, the space should be a wrapped
7782 relation and the domain of this wrapped relation should be the
7783 same as that of the range of the schedule returned by
7784 C<isl_ast_build_get_schedule> below.
7785 In practice, the new schedule is typically
7786 created by calling C<isl_union_map_range_product> on the old schedule
7787 and some extra piece of the schedule.
7788 The space of the schedule domain is also available from
7789 the C<isl_ast_build>.
7791         #include <isl/ast_build.h>
7792         __isl_give isl_union_map *isl_ast_build_get_schedule(
7793                 __isl_keep isl_ast_build *build);
7794         __isl_give isl_space *isl_ast_build_get_schedule_space(
7795                 __isl_keep isl_ast_build *build);
7796         __isl_give isl_ast_build *isl_ast_build_restrict(
7797                 __isl_take isl_ast_build *build,
7798                 __isl_take isl_set *set);
7800 The C<isl_ast_build_get_schedule> function returns a (partial)
7801 schedule for the domains elements for which part of the AST still needs to
7802 be generated in the current build.
7803 In particular, the domain elements are mapped to those iterations of the loops
7804 enclosing the current point of the AST generation inside which
7805 the domain elements are executed.
7806 No direct correspondence between
7807 the input schedule and this schedule should be assumed.
7808 The space obtained from C<isl_ast_build_get_schedule_space> can be used
7809 to create a set for C<isl_ast_build_restrict> to intersect
7810 with the current build.  In particular, the set passed to
7811 C<isl_ast_build_restrict> can have additional parameters.
7812 The ids of the set dimensions in the space returned by
7813 C<isl_ast_build_get_schedule_space> correspond to the
7814 iterators of the already generated loops.
7815 The user should not rely on the ids of the output dimensions
7816 of the relations in the union relation returned by
7817 C<isl_ast_build_get_schedule> having any particular value.
7819 =head1 Applications
7821 Although C<isl> is mainly meant to be used as a library,
7822 it also contains some basic applications that use some
7823 of the functionality of C<isl>.
7824 The input may be specified in either the L<isl format>
7825 or the L<PolyLib format>.
7827 =head2 C<isl_polyhedron_sample>
7829 C<isl_polyhedron_sample> takes a polyhedron as input and prints
7830 an integer element of the polyhedron, if there is any.
7831 The first column in the output is the denominator and is always
7832 equal to 1.  If the polyhedron contains no integer points,
7833 then a vector of length zero is printed.
7835 =head2 C<isl_pip>
7837 C<isl_pip> takes the same input as the C<example> program
7838 from the C<piplib> distribution, i.e., a set of constraints
7839 on the parameters, a line containing only -1 and finally a set
7840 of constraints on a parametric polyhedron.
7841 The coefficients of the parameters appear in the last columns
7842 (but before the final constant column).
7843 The output is the lexicographic minimum of the parametric polyhedron.
7844 As C<isl> currently does not have its own output format, the output
7845 is just a dump of the internal state.
7847 =head2 C<isl_polyhedron_minimize>
7849 C<isl_polyhedron_minimize> computes the minimum of some linear
7850 or affine objective function over the integer points in a polyhedron.
7851 If an affine objective function
7852 is given, then the constant should appear in the last column.
7854 =head2 C<isl_polytope_scan>
7856 Given a polytope, C<isl_polytope_scan> prints
7857 all integer points in the polytope.
7859 =head2 C<isl_codegen>
7861 Given a schedule, a context set and an options relation,
7862 C<isl_codegen> prints out an AST that scans the domain elements
7863 of the schedule in the order of their image(s) taking into account
7864 the constraints in the context set.