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