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
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>.
38 =head3 Changes since isl-0.03
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>.
49 =head3 Changes since isl-0.04
53 =item * All header files have been renamed from C<isl_header.h>
58 =head3 Changes since isl-0.05
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.
81 =head3 Changes since isl-0.06
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.
95 =head3 Changes since isl-0.07
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
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
139 A call to C<isl_qpolynomial_div(div)> call be replaced by
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.
156 =head3 Changes since isl-0.09
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)
171 =head3 Changes since isl-0.10
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.
184 =head3 Changes since isl-0.12
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.
211 =head3 Changes since isl-0.14
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.
222 C<isl> is released under the MIT license.
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
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.
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
261 =head2 Installation from the git repository
265 =item 1 Clone or update the repository
267 The first time the source is obtained, you need to clone
270 git clone git://repo.or.cz/isl.git
272 To obtain updates, you need to pull in the latest changes
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>
284 This will fetch the required version of C<imath> in a subdirectory of C<isl>.
286 =item 2 Generate C<configure>
292 After performing the above steps, continue
293 with the L<Common installation instructions>.
295 =head2 Common installation instructions
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>.
310 C<isl> uses the standard C<autoconf> C<configure> script.
315 optionally followed by some configure options.
316 A complete list of options can be obtained by running
320 Below we discuss some of the more common options.
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).
347 =item 4 Install (optional)
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
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
389 C<__isl_null> means that a C<NULL> value is returned.
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
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.
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.
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);
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);
476 isl_ctx *isl_set_list_get_ctx(
477 __isl_keep isl_set_list *list);
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);
499 isl_ctx *isl_vec_get_ctx(__isl_keep isl_vec *vec);
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);
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);
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.
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.
548 __isl_give isl_val *isl_val_int_from_si(isl_ctx *ctx,
550 __isl_give isl_val *isl_val_int_from_ui(isl_ctx *ctx,
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.
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.
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,
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
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.
589 __isl_give isl_val *isl_val_set_si(__isl_take isl_val *v,
592 The following unary properties are defined on C<isl_val>s.
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.
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.
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.
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.
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.
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,
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,
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,
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.
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>
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,
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.
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
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);
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
786 Identifiers can be constructed, copied, freed, inspected and printed
787 using the following functions.
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.
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,
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
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.
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);
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);
929 __isl_give isl_space *isl_multi_val_get_space(
930 __isl_keep isl_multi_val *mv);
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);
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);
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);
993 unsigned isl_multi_val_dim(__isl_keep isl_multi_val *mv,
994 enum isl_dim_type type);
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,
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,
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,
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,
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,
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
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 int isl_multi_aff_has_tuple_id(__isl_keep isl_multi_aff *ma,
1353 enum isl_dim_type type);
1354 __isl_give isl_id *isl_multi_aff_get_tuple_id(
1355 __isl_keep isl_multi_aff *ma,
1356 enum isl_dim_type type);
1357 int isl_pw_aff_has_tuple_id(__isl_keep isl_pw_aff *pa,
1358 enum isl_dim_type type);
1359 __isl_give isl_id *isl_pw_aff_get_tuple_id(
1360 __isl_keep isl_pw_aff *pa,
1361 enum isl_dim_type type);
1362 int isl_pw_multi_aff_has_tuple_id(
1363 __isl_keep isl_pw_multi_aff *pma,
1364 enum isl_dim_type type);
1365 __isl_give isl_id *isl_pw_multi_aff_get_tuple_id(
1366 __isl_keep isl_pw_multi_aff *pma,
1367 enum isl_dim_type type);
1368 int isl_multi_pw_aff_has_tuple_id(
1369 __isl_keep isl_multi_pw_aff *mpa,
1370 enum isl_dim_type type);
1371 __isl_give isl_id *isl_multi_pw_aff_get_tuple_id(
1372 __isl_keep isl_multi_pw_aff *mpa,
1373 enum isl_dim_type type);
1374 __isl_give isl_multi_aff *isl_multi_aff_set_tuple_name(
1375 __isl_take isl_multi_aff *maff,
1376 enum isl_dim_type type, const char *s);
1377 __isl_give isl_multi_pw_aff *
1378 isl_multi_pw_aff_set_tuple_name(
1379 __isl_take isl_multi_pw_aff *mpa,
1380 enum isl_dim_type type, const char *s);
1381 const char *isl_multi_aff_get_tuple_name(
1382 __isl_keep isl_multi_aff *multi,
1383 enum isl_dim_type type);
1384 int isl_pw_multi_aff_has_tuple_name(
1385 __isl_keep isl_pw_multi_aff *pma,
1386 enum isl_dim_type type);
1387 const char *isl_pw_multi_aff_get_tuple_name(
1388 __isl_keep isl_pw_multi_aff *pma,
1389 enum isl_dim_type type);
1391 The C<type> argument needs to be one of C<isl_dim_in>, C<isl_dim_out>
1392 or C<isl_dim_set>. As with C<isl_space_get_name>,
1393 the C<isl_space_get_tuple_name> function returns a pointer to some internal
1395 Binary operations require the corresponding spaces of their arguments
1396 to have the same name.
1398 To keep the names of all parameters and tuples, but reset the user pointers
1399 of all the corresponding identifiers, use the following function.
1401 #include <isl/space.h>
1402 __isl_give isl_space *isl_space_reset_user(
1403 __isl_take isl_space *space);
1405 #include <isl/set.h>
1406 __isl_give isl_set *isl_set_reset_user(
1407 __isl_take isl_set *set);
1409 #include <isl/map.h>
1410 __isl_give isl_map *isl_map_reset_user(
1411 __isl_take isl_map *map);
1413 #include <isl/union_set.h>
1414 __isl_give isl_union_set *isl_union_set_reset_user(
1415 __isl_take isl_union_set *uset);
1417 #include <isl/union_map.h>
1418 __isl_give isl_union_map *isl_union_map_reset_user(
1419 __isl_take isl_union_map *umap);
1421 #include <isl/val.h>
1422 __isl_give isl_multi_val *isl_multi_val_reset_user(
1423 __isl_take isl_multi_val *mv);
1425 #include <isl/aff.h>
1426 __isl_give isl_multi_aff *isl_multi_aff_reset_user(
1427 __isl_take isl_multi_aff *ma);
1428 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_reset_user(
1429 __isl_take isl_multi_pw_aff *mpa);
1431 Spaces can be nested. In particular, the domain of a set or
1432 the domain or range of a relation can be a nested relation.
1433 This process is also called I<wrapping>.
1434 The functions for detecting, constructing and deconstructing
1435 such nested spaces can be found in the wrapping properties
1436 of L</"Unary Properties">, the wrapping operations
1437 of L</"Unary Operations"> and the Cartesian product operations
1438 of L</"Basic Operations">.
1440 Spaces can be created from other spaces
1441 using the functions described in L</"Unary Operations">
1442 and L</"Binary Operations">.
1446 A local space is essentially a space with
1447 zero or more existentially quantified variables.
1448 The local space of various objects can be obtained
1449 using the following functions.
1451 #include <isl/constraint.h>
1452 __isl_give isl_local_space *isl_constraint_get_local_space(
1453 __isl_keep isl_constraint *constraint);
1455 #include <isl/set.h>
1456 __isl_give isl_local_space *isl_basic_set_get_local_space(
1457 __isl_keep isl_basic_set *bset);
1459 #include <isl/map.h>
1460 __isl_give isl_local_space *isl_basic_map_get_local_space(
1461 __isl_keep isl_basic_map *bmap);
1463 #include <isl/aff.h>
1464 __isl_give isl_local_space *isl_aff_get_domain_local_space(
1465 __isl_keep isl_aff *aff);
1466 __isl_give isl_local_space *isl_aff_get_local_space(
1467 __isl_keep isl_aff *aff);
1469 A new local space can be created from a space using
1471 #include <isl/local_space.h>
1472 __isl_give isl_local_space *isl_local_space_from_space(
1473 __isl_take isl_space *space);
1475 They can be inspected, modified, copied and freed using the following functions.
1477 #include <isl/local_space.h>
1478 int isl_local_space_is_set(__isl_keep isl_local_space *ls);
1479 __isl_give isl_space *isl_local_space_get_space(
1480 __isl_keep isl_local_space *ls);
1481 __isl_give isl_aff *isl_local_space_get_div(
1482 __isl_keep isl_local_space *ls, int pos);
1483 __isl_give isl_local_space *isl_local_space_copy(
1484 __isl_keep isl_local_space *ls);
1485 __isl_null isl_local_space *isl_local_space_free(
1486 __isl_take isl_local_space *ls);
1488 Note that C<isl_local_space_get_div> can only be used on local spaces
1491 Two local spaces can be compared using
1493 int isl_local_space_is_equal(__isl_keep isl_local_space *ls1,
1494 __isl_keep isl_local_space *ls2);
1496 Local spaces can be created from other local spaces
1497 using the functions described in L</"Unary Operations">
1498 and L</"Binary Operations">.
1500 =head2 Creating New Sets and Relations
1502 C<isl> has functions for creating some standard sets and relations.
1506 =item * Empty sets and relations
1508 __isl_give isl_basic_set *isl_basic_set_empty(
1509 __isl_take isl_space *space);
1510 __isl_give isl_basic_map *isl_basic_map_empty(
1511 __isl_take isl_space *space);
1512 __isl_give isl_set *isl_set_empty(
1513 __isl_take isl_space *space);
1514 __isl_give isl_map *isl_map_empty(
1515 __isl_take isl_space *space);
1516 __isl_give isl_union_set *isl_union_set_empty(
1517 __isl_take isl_space *space);
1518 __isl_give isl_union_map *isl_union_map_empty(
1519 __isl_take isl_space *space);
1521 For C<isl_union_set>s and C<isl_union_map>s, the space
1522 is only used to specify the parameters.
1524 =item * Universe sets and relations
1526 __isl_give isl_basic_set *isl_basic_set_universe(
1527 __isl_take isl_space *space);
1528 __isl_give isl_basic_map *isl_basic_map_universe(
1529 __isl_take isl_space *space);
1530 __isl_give isl_set *isl_set_universe(
1531 __isl_take isl_space *space);
1532 __isl_give isl_map *isl_map_universe(
1533 __isl_take isl_space *space);
1534 __isl_give isl_union_set *isl_union_set_universe(
1535 __isl_take isl_union_set *uset);
1536 __isl_give isl_union_map *isl_union_map_universe(
1537 __isl_take isl_union_map *umap);
1539 The sets and relations constructed by the functions above
1540 contain all integer values, while those constructed by the
1541 functions below only contain non-negative values.
1543 __isl_give isl_basic_set *isl_basic_set_nat_universe(
1544 __isl_take isl_space *space);
1545 __isl_give isl_basic_map *isl_basic_map_nat_universe(
1546 __isl_take isl_space *space);
1547 __isl_give isl_set *isl_set_nat_universe(
1548 __isl_take isl_space *space);
1549 __isl_give isl_map *isl_map_nat_universe(
1550 __isl_take isl_space *space);
1552 =item * Identity relations
1554 __isl_give isl_basic_map *isl_basic_map_identity(
1555 __isl_take isl_space *space);
1556 __isl_give isl_map *isl_map_identity(
1557 __isl_take isl_space *space);
1559 The number of input and output dimensions in C<space> needs
1562 =item * Lexicographic order
1564 __isl_give isl_map *isl_map_lex_lt(
1565 __isl_take isl_space *set_space);
1566 __isl_give isl_map *isl_map_lex_le(
1567 __isl_take isl_space *set_space);
1568 __isl_give isl_map *isl_map_lex_gt(
1569 __isl_take isl_space *set_space);
1570 __isl_give isl_map *isl_map_lex_ge(
1571 __isl_take isl_space *set_space);
1572 __isl_give isl_map *isl_map_lex_lt_first(
1573 __isl_take isl_space *space, unsigned n);
1574 __isl_give isl_map *isl_map_lex_le_first(
1575 __isl_take isl_space *space, unsigned n);
1576 __isl_give isl_map *isl_map_lex_gt_first(
1577 __isl_take isl_space *space, unsigned n);
1578 __isl_give isl_map *isl_map_lex_ge_first(
1579 __isl_take isl_space *space, unsigned n);
1581 The first four functions take a space for a B<set>
1582 and return relations that express that the elements in the domain
1583 are lexicographically less
1584 (C<isl_map_lex_lt>), less or equal (C<isl_map_lex_le>),
1585 greater (C<isl_map_lex_gt>) or greater or equal (C<isl_map_lex_ge>)
1586 than the elements in the range.
1587 The last four functions take a space for a map
1588 and return relations that express that the first C<n> dimensions
1589 in the domain are lexicographically less
1590 (C<isl_map_lex_lt_first>), less or equal (C<isl_map_lex_le_first>),
1591 greater (C<isl_map_lex_gt_first>) or greater or equal (C<isl_map_lex_ge_first>)
1592 than the first C<n> dimensions in the range.
1596 A basic set or relation can be converted to a set or relation
1597 using the following functions.
1599 __isl_give isl_set *isl_set_from_basic_set(
1600 __isl_take isl_basic_set *bset);
1601 __isl_give isl_map *isl_map_from_basic_map(
1602 __isl_take isl_basic_map *bmap);
1604 Sets and relations can be converted to union sets and relations
1605 using the following functions.
1607 __isl_give isl_union_set *isl_union_set_from_basic_set(
1608 __isl_take isl_basic_set *bset);
1609 __isl_give isl_union_map *isl_union_map_from_basic_map(
1610 __isl_take isl_basic_map *bmap);
1611 __isl_give isl_union_set *isl_union_set_from_set(
1612 __isl_take isl_set *set);
1613 __isl_give isl_union_map *isl_union_map_from_map(
1614 __isl_take isl_map *map);
1616 The inverse conversions below can only be used if the input
1617 union set or relation is known to contain elements in exactly one
1620 __isl_give isl_set *isl_set_from_union_set(
1621 __isl_take isl_union_set *uset);
1622 __isl_give isl_map *isl_map_from_union_map(
1623 __isl_take isl_union_map *umap);
1625 Sets and relations can be copied and freed again using the following
1628 __isl_give isl_basic_set *isl_basic_set_copy(
1629 __isl_keep isl_basic_set *bset);
1630 __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set);
1631 __isl_give isl_union_set *isl_union_set_copy(
1632 __isl_keep isl_union_set *uset);
1633 __isl_give isl_basic_map *isl_basic_map_copy(
1634 __isl_keep isl_basic_map *bmap);
1635 __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
1636 __isl_give isl_union_map *isl_union_map_copy(
1637 __isl_keep isl_union_map *umap);
1638 __isl_null isl_basic_set *isl_basic_set_free(
1639 __isl_take isl_basic_set *bset);
1640 __isl_null isl_set *isl_set_free(__isl_take isl_set *set);
1641 __isl_null isl_union_set *isl_union_set_free(
1642 __isl_take isl_union_set *uset);
1643 __isl_null isl_basic_map *isl_basic_map_free(
1644 __isl_take isl_basic_map *bmap);
1645 __isl_null isl_map *isl_map_free(__isl_take isl_map *map);
1646 __isl_null isl_union_map *isl_union_map_free(
1647 __isl_take isl_union_map *umap);
1649 Other sets and relations can be constructed by starting
1650 from a universe set or relation, adding equality and/or
1651 inequality constraints and then projecting out the
1652 existentially quantified variables, if any.
1653 Constraints can be constructed, manipulated and
1654 added to (or removed from) (basic) sets and relations
1655 using the following functions.
1657 #include <isl/constraint.h>
1658 __isl_give isl_constraint *isl_equality_alloc(
1659 __isl_take isl_local_space *ls);
1660 __isl_give isl_constraint *isl_inequality_alloc(
1661 __isl_take isl_local_space *ls);
1662 __isl_give isl_constraint *isl_constraint_set_constant_si(
1663 __isl_take isl_constraint *constraint, int v);
1664 __isl_give isl_constraint *isl_constraint_set_constant_val(
1665 __isl_take isl_constraint *constraint,
1666 __isl_take isl_val *v);
1667 __isl_give isl_constraint *isl_constraint_set_coefficient_si(
1668 __isl_take isl_constraint *constraint,
1669 enum isl_dim_type type, int pos, int v);
1670 __isl_give isl_constraint *
1671 isl_constraint_set_coefficient_val(
1672 __isl_take isl_constraint *constraint,
1673 enum isl_dim_type type, int pos,
1674 __isl_take isl_val *v);
1675 __isl_give isl_basic_map *isl_basic_map_add_constraint(
1676 __isl_take isl_basic_map *bmap,
1677 __isl_take isl_constraint *constraint);
1678 __isl_give isl_basic_set *isl_basic_set_add_constraint(
1679 __isl_take isl_basic_set *bset,
1680 __isl_take isl_constraint *constraint);
1681 __isl_give isl_map *isl_map_add_constraint(
1682 __isl_take isl_map *map,
1683 __isl_take isl_constraint *constraint);
1684 __isl_give isl_set *isl_set_add_constraint(
1685 __isl_take isl_set *set,
1686 __isl_take isl_constraint *constraint);
1687 __isl_give isl_basic_set *isl_basic_set_drop_constraint(
1688 __isl_take isl_basic_set *bset,
1689 __isl_take isl_constraint *constraint);
1691 For example, to create a set containing the even integers
1692 between 10 and 42, you would use the following code.
1695 isl_local_space *ls;
1697 isl_basic_set *bset;
1699 space = isl_space_set_alloc(ctx, 0, 2);
1700 bset = isl_basic_set_universe(isl_space_copy(space));
1701 ls = isl_local_space_from_space(space);
1703 c = isl_equality_alloc(isl_local_space_copy(ls));
1704 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1705 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 1, 2);
1706 bset = isl_basic_set_add_constraint(bset, c);
1708 c = isl_inequality_alloc(isl_local_space_copy(ls));
1709 c = isl_constraint_set_constant_si(c, -10);
1710 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, 1);
1711 bset = isl_basic_set_add_constraint(bset, c);
1713 c = isl_inequality_alloc(ls);
1714 c = isl_constraint_set_constant_si(c, 42);
1715 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1716 bset = isl_basic_set_add_constraint(bset, c);
1718 bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 1);
1722 isl_basic_set *bset;
1723 bset = isl_basic_set_read_from_str(ctx,
1724 "{[i] : exists (a : i = 2a and i >= 10 and i <= 42)}");
1726 A basic set or relation can also be constructed from two matrices
1727 describing the equalities and the inequalities.
1729 __isl_give isl_basic_set *isl_basic_set_from_constraint_matrices(
1730 __isl_take isl_space *space,
1731 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1732 enum isl_dim_type c1,
1733 enum isl_dim_type c2, enum isl_dim_type c3,
1734 enum isl_dim_type c4);
1735 __isl_give isl_basic_map *isl_basic_map_from_constraint_matrices(
1736 __isl_take isl_space *space,
1737 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1738 enum isl_dim_type c1,
1739 enum isl_dim_type c2, enum isl_dim_type c3,
1740 enum isl_dim_type c4, enum isl_dim_type c5);
1742 The C<isl_dim_type> arguments indicate the order in which
1743 different kinds of variables appear in the input matrices
1744 and should be a permutation of C<isl_dim_cst>, C<isl_dim_param>,
1745 C<isl_dim_set> and C<isl_dim_div> for sets and
1746 of C<isl_dim_cst>, C<isl_dim_param>,
1747 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div> for relations.
1749 A (basic or union) set or relation can also be constructed from a
1750 (union) (piecewise) (multiple) affine expression
1751 or a list of affine expressions
1752 (See L</"Functions">).
1754 __isl_give isl_basic_map *isl_basic_map_from_aff(
1755 __isl_take isl_aff *aff);
1756 __isl_give isl_map *isl_map_from_aff(
1757 __isl_take isl_aff *aff);
1758 __isl_give isl_set *isl_set_from_pw_aff(
1759 __isl_take isl_pw_aff *pwaff);
1760 __isl_give isl_map *isl_map_from_pw_aff(
1761 __isl_take isl_pw_aff *pwaff);
1762 __isl_give isl_basic_map *isl_basic_map_from_aff_list(
1763 __isl_take isl_space *domain_space,
1764 __isl_take isl_aff_list *list);
1765 __isl_give isl_basic_map *isl_basic_map_from_multi_aff(
1766 __isl_take isl_multi_aff *maff)
1767 __isl_give isl_map *isl_map_from_multi_aff(
1768 __isl_take isl_multi_aff *maff)
1769 __isl_give isl_set *isl_set_from_pw_multi_aff(
1770 __isl_take isl_pw_multi_aff *pma);
1771 __isl_give isl_map *isl_map_from_pw_multi_aff(
1772 __isl_take isl_pw_multi_aff *pma);
1773 __isl_give isl_set *isl_set_from_multi_pw_aff(
1774 __isl_take isl_multi_pw_aff *mpa);
1775 __isl_give isl_map *isl_map_from_multi_pw_aff(
1776 __isl_take isl_multi_pw_aff *mpa);
1777 __isl_give isl_union_map *
1778 isl_union_map_from_union_pw_multi_aff(
1779 __isl_take isl_union_pw_multi_aff *upma);
1781 The C<domain_space> argument describes the domain of the resulting
1782 basic relation. It is required because the C<list> may consist
1783 of zero affine expressions.
1785 =head2 Inspecting Sets and Relations
1787 Usually, the user should not have to care about the actual constraints
1788 of the sets and maps, but should instead apply the abstract operations
1789 explained in the following sections.
1790 Occasionally, however, it may be required to inspect the individual
1791 coefficients of the constraints. This section explains how to do so.
1792 In these cases, it may also be useful to have C<isl> compute
1793 an explicit representation of the existentially quantified variables.
1795 __isl_give isl_set *isl_set_compute_divs(
1796 __isl_take isl_set *set);
1797 __isl_give isl_map *isl_map_compute_divs(
1798 __isl_take isl_map *map);
1799 __isl_give isl_union_set *isl_union_set_compute_divs(
1800 __isl_take isl_union_set *uset);
1801 __isl_give isl_union_map *isl_union_map_compute_divs(
1802 __isl_take isl_union_map *umap);
1804 This explicit representation defines the existentially quantified
1805 variables as integer divisions of the other variables, possibly
1806 including earlier existentially quantified variables.
1807 An explicitly represented existentially quantified variable therefore
1808 has a unique value when the values of the other variables are known.
1809 If, furthermore, the same existentials, i.e., existentials
1810 with the same explicit representations, should appear in the
1811 same order in each of the disjuncts of a set or map, then the user should call
1812 either of the following functions.
1814 __isl_give isl_set *isl_set_align_divs(
1815 __isl_take isl_set *set);
1816 __isl_give isl_map *isl_map_align_divs(
1817 __isl_take isl_map *map);
1819 Alternatively, the existentially quantified variables can be removed
1820 using the following functions, which compute an overapproximation.
1822 __isl_give isl_basic_set *isl_basic_set_remove_divs(
1823 __isl_take isl_basic_set *bset);
1824 __isl_give isl_basic_map *isl_basic_map_remove_divs(
1825 __isl_take isl_basic_map *bmap);
1826 __isl_give isl_set *isl_set_remove_divs(
1827 __isl_take isl_set *set);
1828 __isl_give isl_map *isl_map_remove_divs(
1829 __isl_take isl_map *map);
1831 It is also possible to only remove those divs that are defined
1832 in terms of a given range of dimensions or only those for which
1833 no explicit representation is known.
1835 __isl_give isl_basic_set *
1836 isl_basic_set_remove_divs_involving_dims(
1837 __isl_take isl_basic_set *bset,
1838 enum isl_dim_type type,
1839 unsigned first, unsigned n);
1840 __isl_give isl_basic_map *
1841 isl_basic_map_remove_divs_involving_dims(
1842 __isl_take isl_basic_map *bmap,
1843 enum isl_dim_type type,
1844 unsigned first, unsigned n);
1845 __isl_give isl_set *isl_set_remove_divs_involving_dims(
1846 __isl_take isl_set *set, enum isl_dim_type type,
1847 unsigned first, unsigned n);
1848 __isl_give isl_map *isl_map_remove_divs_involving_dims(
1849 __isl_take isl_map *map, enum isl_dim_type type,
1850 unsigned first, unsigned n);
1852 __isl_give isl_basic_set *
1853 isl_basic_set_remove_unknown_divs(
1854 __isl_take isl_basic_set *bset);
1855 __isl_give isl_set *isl_set_remove_unknown_divs(
1856 __isl_take isl_set *set);
1857 __isl_give isl_map *isl_map_remove_unknown_divs(
1858 __isl_take isl_map *map);
1860 To iterate over all the sets or maps in a union set or map, use
1862 int isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
1863 int (*fn)(__isl_take isl_set *set, void *user),
1865 int isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
1866 int (*fn)(__isl_take isl_map *map, void *user),
1869 The number of sets or maps in a union set or map can be obtained
1872 int isl_union_set_n_set(__isl_keep isl_union_set *uset);
1873 int isl_union_map_n_map(__isl_keep isl_union_map *umap);
1875 To extract the set or map in a given space from a union, use
1877 __isl_give isl_set *isl_union_set_extract_set(
1878 __isl_keep isl_union_set *uset,
1879 __isl_take isl_space *space);
1880 __isl_give isl_map *isl_union_map_extract_map(
1881 __isl_keep isl_union_map *umap,
1882 __isl_take isl_space *space);
1884 To iterate over all the basic sets or maps in a set or map, use
1886 int isl_set_foreach_basic_set(__isl_keep isl_set *set,
1887 int (*fn)(__isl_take isl_basic_set *bset, void *user),
1889 int isl_map_foreach_basic_map(__isl_keep isl_map *map,
1890 int (*fn)(__isl_take isl_basic_map *bmap, void *user),
1893 The callback function C<fn> should return 0 if successful and
1894 -1 if an error occurs. In the latter case, or if any other error
1895 occurs, the above functions will return -1.
1897 It should be noted that C<isl> does not guarantee that
1898 the basic sets or maps passed to C<fn> are disjoint.
1899 If this is required, then the user should call one of
1900 the following functions first.
1902 __isl_give isl_set *isl_set_make_disjoint(
1903 __isl_take isl_set *set);
1904 __isl_give isl_map *isl_map_make_disjoint(
1905 __isl_take isl_map *map);
1907 The number of basic sets in a set can be obtained
1908 or the number of basic maps in a map can be obtained
1911 #include <isl/set.h>
1912 int isl_set_n_basic_set(__isl_keep isl_set *set);
1914 #include <isl/map.h>
1915 int isl_map_n_basic_map(__isl_keep isl_map *map);
1917 To iterate over the constraints of a basic set or map, use
1919 #include <isl/constraint.h>
1921 int isl_basic_set_n_constraint(
1922 __isl_keep isl_basic_set *bset);
1923 int isl_basic_set_foreach_constraint(
1924 __isl_keep isl_basic_set *bset,
1925 int (*fn)(__isl_take isl_constraint *c, void *user),
1927 int isl_basic_map_n_constraint(
1928 __isl_keep isl_basic_map *bmap);
1929 int isl_basic_map_foreach_constraint(
1930 __isl_keep isl_basic_map *bmap,
1931 int (*fn)(__isl_take isl_constraint *c, void *user),
1933 __isl_null isl_constraint *isl_constraint_free(
1934 __isl_take isl_constraint *c);
1936 Again, the callback function C<fn> should return 0 if successful and
1937 -1 if an error occurs. In the latter case, or if any other error
1938 occurs, the above functions will return -1.
1939 The constraint C<c> represents either an equality or an inequality.
1940 Use the following function to find out whether a constraint
1941 represents an equality. If not, it represents an inequality.
1943 int isl_constraint_is_equality(
1944 __isl_keep isl_constraint *constraint);
1946 It is also possible to obtain a list of constraints from a basic
1949 #include <isl/constraint.h>
1950 __isl_give isl_constraint_list *
1951 isl_basic_map_get_constraint_list(
1952 __isl_keep isl_basic_map *bmap);
1953 __isl_give isl_constraint_list *
1954 isl_basic_set_get_constraint_list(
1955 __isl_keep isl_basic_set *bset);
1957 These functions require that all existentially quantified variables
1958 have an explicit representation.
1959 The returned list can be manipulated using the functions in L<"Lists">.
1961 The coefficients of the constraints can be inspected using
1962 the following functions.
1964 int isl_constraint_is_lower_bound(
1965 __isl_keep isl_constraint *constraint,
1966 enum isl_dim_type type, unsigned pos);
1967 int isl_constraint_is_upper_bound(
1968 __isl_keep isl_constraint *constraint,
1969 enum isl_dim_type type, unsigned pos);
1970 __isl_give isl_val *isl_constraint_get_constant_val(
1971 __isl_keep isl_constraint *constraint);
1972 __isl_give isl_val *isl_constraint_get_coefficient_val(
1973 __isl_keep isl_constraint *constraint,
1974 enum isl_dim_type type, int pos);
1976 The explicit representations of the existentially quantified
1977 variables can be inspected using the following function.
1978 Note that the user is only allowed to use this function
1979 if the inspected set or map is the result of a call
1980 to C<isl_set_compute_divs> or C<isl_map_compute_divs>.
1981 The existentially quantified variable is equal to the floor
1982 of the returned affine expression. The affine expression
1983 itself can be inspected using the functions in
1986 __isl_give isl_aff *isl_constraint_get_div(
1987 __isl_keep isl_constraint *constraint, int pos);
1989 To obtain the constraints of a basic set or map in matrix
1990 form, use the following functions.
1992 __isl_give isl_mat *isl_basic_set_equalities_matrix(
1993 __isl_keep isl_basic_set *bset,
1994 enum isl_dim_type c1, enum isl_dim_type c2,
1995 enum isl_dim_type c3, enum isl_dim_type c4);
1996 __isl_give isl_mat *isl_basic_set_inequalities_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_map_equalities_matrix(
2001 __isl_keep isl_basic_map *bmap,
2002 enum isl_dim_type c1,
2003 enum isl_dim_type c2, enum isl_dim_type c3,
2004 enum isl_dim_type c4, enum isl_dim_type c5);
2005 __isl_give isl_mat *isl_basic_map_inequalities_matrix(
2006 __isl_keep isl_basic_map *bmap,
2007 enum isl_dim_type c1,
2008 enum isl_dim_type c2, enum isl_dim_type c3,
2009 enum isl_dim_type c4, enum isl_dim_type c5);
2011 The C<isl_dim_type> arguments dictate the order in which
2012 different kinds of variables appear in the resulting matrix.
2013 For set inputs, they should be a permutation of
2014 C<isl_dim_cst>, C<isl_dim_param>, C<isl_dim_set> and C<isl_dim_div>.
2015 For map inputs, they should be a permutation of
2016 C<isl_dim_cst>, C<isl_dim_param>,
2017 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div>.
2021 Points are elements of a set. They can be used to construct
2022 simple sets (boxes) or they can be used to represent the
2023 individual elements of a set.
2024 The zero point (the origin) can be created using
2026 __isl_give isl_point *isl_point_zero(__isl_take isl_space *space);
2028 The coordinates of a point can be inspected, set and changed
2031 __isl_give isl_val *isl_point_get_coordinate_val(
2032 __isl_keep isl_point *pnt,
2033 enum isl_dim_type type, int pos);
2034 __isl_give isl_point *isl_point_set_coordinate_val(
2035 __isl_take isl_point *pnt,
2036 enum isl_dim_type type, int pos,
2037 __isl_take isl_val *v);
2039 __isl_give isl_point *isl_point_add_ui(
2040 __isl_take isl_point *pnt,
2041 enum isl_dim_type type, int pos, unsigned val);
2042 __isl_give isl_point *isl_point_sub_ui(
2043 __isl_take isl_point *pnt,
2044 enum isl_dim_type type, int pos, unsigned val);
2046 Points can be copied or freed using
2048 __isl_give isl_point *isl_point_copy(
2049 __isl_keep isl_point *pnt);
2050 void isl_point_free(__isl_take isl_point *pnt);
2052 A singleton set can be created from a point using
2054 __isl_give isl_basic_set *isl_basic_set_from_point(
2055 __isl_take isl_point *pnt);
2056 __isl_give isl_set *isl_set_from_point(
2057 __isl_take isl_point *pnt);
2059 and a box can be created from two opposite extremal points using
2061 __isl_give isl_basic_set *isl_basic_set_box_from_points(
2062 __isl_take isl_point *pnt1,
2063 __isl_take isl_point *pnt2);
2064 __isl_give isl_set *isl_set_box_from_points(
2065 __isl_take isl_point *pnt1,
2066 __isl_take isl_point *pnt2);
2068 All elements of a B<bounded> (union) set can be enumerated using
2069 the following functions.
2071 int isl_set_foreach_point(__isl_keep isl_set *set,
2072 int (*fn)(__isl_take isl_point *pnt, void *user),
2074 int isl_union_set_foreach_point(__isl_keep isl_union_set *uset,
2075 int (*fn)(__isl_take isl_point *pnt, void *user),
2078 The function C<fn> is called for each integer point in
2079 C<set> with as second argument the last argument of
2080 the C<isl_set_foreach_point> call. The function C<fn>
2081 should return C<0> on success and C<-1> on failure.
2082 In the latter case, C<isl_set_foreach_point> will stop
2083 enumerating and return C<-1> as well.
2084 If the enumeration is performed successfully and to completion,
2085 then C<isl_set_foreach_point> returns C<0>.
2087 To obtain a single point of a (basic) set, use
2089 __isl_give isl_point *isl_basic_set_sample_point(
2090 __isl_take isl_basic_set *bset);
2091 __isl_give isl_point *isl_set_sample_point(
2092 __isl_take isl_set *set);
2094 If C<set> does not contain any (integer) points, then the
2095 resulting point will be ``void'', a property that can be
2098 int isl_point_is_void(__isl_keep isl_point *pnt);
2102 Besides sets and relation, C<isl> also supports various types of functions.
2103 Each of these types is derived from the value type (see L</"Values">)
2104 or from one of two primitive function types
2105 through the application of zero or more type constructors.
2106 We first describe the primitive type and then we describe
2107 the types derived from these primitive types.
2109 =head3 Primitive Functions
2111 C<isl> support two primitive function types, quasi-affine
2112 expressions and quasipolynomials.
2113 A quasi-affine expression is defined either over a parameter
2114 space or over a set and is composed of integer constants,
2115 parameters and set variables, addition, subtraction and
2116 integer division by an integer constant.
2117 For example, the quasi-affine expression
2119 [n] -> { [x] -> [2*floor((4 n + x)/9] }
2121 maps C<x> to C<2*floor((4 n + x)/9>.
2122 A quasipolynomial is a polynomial expression in quasi-affine
2123 expression. That is, it additionally allows for multiplication.
2124 Note, though, that it is not allowed to construct an integer
2125 division of an expression involving multiplications.
2126 Here is an example of a quasipolynomial that is not
2127 quasi-affine expression
2129 [n] -> { [x] -> (n*floor((4 n + x)/9) }
2131 Note that the external representations of quasi-affine expressions
2132 and quasipolynomials are different. Quasi-affine expressions
2133 use a notation with square brackets just like binary relations,
2134 while quasipolynomials do not. This might change at some point.
2136 If a primitive function is defined over a parameter space,
2137 then the space of the function itself is that of a set.
2138 If it is defined over a set, then the space of the function
2139 is that of a relation. In both cases, the set space (or
2140 the output space) is single-dimensional, anonymous and unstructured.
2141 To create functions with multiple dimensions or with other kinds
2142 of set or output spaces, use multiple expressions
2143 (see L</"Multiple Expressions">).
2147 =item * Quasi-affine Expressions
2149 Besides the expressions described above, a quasi-affine
2150 expression can also be set to NaN. Such expressions
2151 typically represent a failure to represent a result
2152 as a quasi-affine expression.
2154 The zero quasi affine expression or the quasi affine expression
2155 that is equal to a given value or
2156 a specified dimension on a given domain can be created using
2158 #include <isl/aff.h>
2159 __isl_give isl_aff *isl_aff_zero_on_domain(
2160 __isl_take isl_local_space *ls);
2161 __isl_give isl_aff *isl_aff_val_on_domain(
2162 __isl_take isl_local_space *ls,
2163 __isl_take isl_val *val);
2164 __isl_give isl_aff *isl_aff_var_on_domain(
2165 __isl_take isl_local_space *ls,
2166 enum isl_dim_type type, unsigned pos);
2167 __isl_give isl_aff *isl_aff_nan_on_domain(
2168 __isl_take isl_local_space *ls);
2170 Quasi affine expressions can be copied and freed using
2172 #include <isl/aff.h>
2173 __isl_give isl_aff *isl_aff_copy(
2174 __isl_keep isl_aff *aff);
2175 __isl_null isl_aff *isl_aff_free(
2176 __isl_take isl_aff *aff);
2178 A (rational) bound on a dimension can be extracted from an C<isl_constraint>
2179 using the following function. The constraint is required to have
2180 a non-zero coefficient for the specified dimension.
2182 #include <isl/constraint.h>
2183 __isl_give isl_aff *isl_constraint_get_bound(
2184 __isl_keep isl_constraint *constraint,
2185 enum isl_dim_type type, int pos);
2187 The entire affine expression of the constraint can also be extracted
2188 using the following function.
2190 #include <isl/constraint.h>
2191 __isl_give isl_aff *isl_constraint_get_aff(
2192 __isl_keep isl_constraint *constraint);
2194 Conversely, an equality constraint equating
2195 the affine expression to zero or an inequality constraint enforcing
2196 the affine expression to be non-negative, can be constructed using
2198 __isl_give isl_constraint *isl_equality_from_aff(
2199 __isl_take isl_aff *aff);
2200 __isl_give isl_constraint *isl_inequality_from_aff(
2201 __isl_take isl_aff *aff);
2203 The coefficients and the integer divisions of an affine expression
2204 can be inspected using the following functions.
2206 #include <isl/aff.h>
2207 __isl_give isl_val *isl_aff_get_constant_val(
2208 __isl_keep isl_aff *aff);
2209 __isl_give isl_val *isl_aff_get_coefficient_val(
2210 __isl_keep isl_aff *aff,
2211 enum isl_dim_type type, int pos);
2212 int isl_aff_coefficient_sgn(__isl_keep isl_aff *aff,
2213 enum isl_dim_type type, int pos);
2214 __isl_give isl_val *isl_aff_get_denominator_val(
2215 __isl_keep isl_aff *aff);
2216 __isl_give isl_aff *isl_aff_get_div(
2217 __isl_keep isl_aff *aff, int pos);
2219 They can be modified using the following functions.
2221 #include <isl/aff.h>
2222 __isl_give isl_aff *isl_aff_set_constant_si(
2223 __isl_take isl_aff *aff, int v);
2224 __isl_give isl_aff *isl_aff_set_constant_val(
2225 __isl_take isl_aff *aff, __isl_take isl_val *v);
2226 __isl_give isl_aff *isl_aff_set_coefficient_si(
2227 __isl_take isl_aff *aff,
2228 enum isl_dim_type type, int pos, int v);
2229 __isl_give isl_aff *isl_aff_set_coefficient_val(
2230 __isl_take isl_aff *aff,
2231 enum isl_dim_type type, int pos,
2232 __isl_take isl_val *v);
2234 __isl_give isl_aff *isl_aff_add_constant_si(
2235 __isl_take isl_aff *aff, int v);
2236 __isl_give isl_aff *isl_aff_add_constant_val(
2237 __isl_take isl_aff *aff, __isl_take isl_val *v);
2238 __isl_give isl_aff *isl_aff_add_constant_num_si(
2239 __isl_take isl_aff *aff, int v);
2240 __isl_give isl_aff *isl_aff_add_coefficient_si(
2241 __isl_take isl_aff *aff,
2242 enum isl_dim_type type, int pos, int v);
2243 __isl_give isl_aff *isl_aff_add_coefficient_val(
2244 __isl_take isl_aff *aff,
2245 enum isl_dim_type type, int pos,
2246 __isl_take isl_val *v);
2248 Note that C<isl_aff_set_constant_si> and C<isl_aff_set_coefficient_si>
2249 set the I<numerator> of the constant or coefficient, while
2250 C<isl_aff_set_constant_val> and C<isl_aff_set_coefficient_val> set
2251 the constant or coefficient as a whole.
2252 The C<add_constant> and C<add_coefficient> functions add an integer
2253 or rational value to
2254 the possibly rational constant or coefficient.
2255 The C<add_constant_num> functions add an integer value to
2258 =item * Quasipolynomials
2260 Some simple quasipolynomials can be created using the following functions.
2262 #include <isl/polynomial.h>
2263 __isl_give isl_qpolynomial *isl_qpolynomial_zero_on_domain(
2264 __isl_take isl_space *domain);
2265 __isl_give isl_qpolynomial *isl_qpolynomial_one_on_domain(
2266 __isl_take isl_space *domain);
2267 __isl_give isl_qpolynomial *isl_qpolynomial_infty_on_domain(
2268 __isl_take isl_space *domain);
2269 __isl_give isl_qpolynomial *isl_qpolynomial_neginfty_on_domain(
2270 __isl_take isl_space *domain);
2271 __isl_give isl_qpolynomial *isl_qpolynomial_nan_on_domain(
2272 __isl_take isl_space *domain);
2273 __isl_give isl_qpolynomial *isl_qpolynomial_val_on_domain(
2274 __isl_take isl_space *domain,
2275 __isl_take isl_val *val);
2276 __isl_give isl_qpolynomial *isl_qpolynomial_var_on_domain(
2277 __isl_take isl_space *domain,
2278 enum isl_dim_type type, unsigned pos);
2279 __isl_give isl_qpolynomial *isl_qpolynomial_from_aff(
2280 __isl_take isl_aff *aff);
2282 Recall that the space in which a quasipolynomial lives is a map space
2283 with a one-dimensional range. The C<domain> argument in some of
2284 the functions above corresponds to the domain of this map space.
2286 Quasipolynomials can be copied and freed again using the following
2289 #include <isl/polynomial.h>
2290 __isl_give isl_qpolynomial *isl_qpolynomial_copy(
2291 __isl_keep isl_qpolynomial *qp);
2292 __isl_null isl_qpolynomial *isl_qpolynomial_free(
2293 __isl_take isl_qpolynomial *qp);
2295 The constant term of a quasipolynomial can be extracted using
2297 __isl_give isl_val *isl_qpolynomial_get_constant_val(
2298 __isl_keep isl_qpolynomial *qp);
2300 To iterate over all terms in a quasipolynomial,
2303 int isl_qpolynomial_foreach_term(
2304 __isl_keep isl_qpolynomial *qp,
2305 int (*fn)(__isl_take isl_term *term,
2306 void *user), void *user);
2308 The terms themselves can be inspected and freed using
2311 unsigned isl_term_dim(__isl_keep isl_term *term,
2312 enum isl_dim_type type);
2313 __isl_give isl_val *isl_term_get_coefficient_val(
2314 __isl_keep isl_term *term);
2315 int isl_term_get_exp(__isl_keep isl_term *term,
2316 enum isl_dim_type type, unsigned pos);
2317 __isl_give isl_aff *isl_term_get_div(
2318 __isl_keep isl_term *term, unsigned pos);
2319 void isl_term_free(__isl_take isl_term *term);
2321 Each term is a product of parameters, set variables and
2322 integer divisions. The function C<isl_term_get_exp>
2323 returns the exponent of a given dimensions in the given term.
2329 A reduction represents a maximum or a minimum of its
2331 The only reduction type defined by C<isl> is
2332 C<isl_qpolynomial_fold>.
2334 There are currently no functions to directly create such
2335 objects, but they do appear in the piecewise quasipolynomial
2336 reductions returned by the C<isl_pw_qpolynomial_bound> function.
2338 L</"Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions">.
2340 Reductions can be copied and freed using
2341 the following functions.
2343 #include <isl/polynomial.h>
2344 __isl_give isl_qpolynomial_fold *
2345 isl_qpolynomial_fold_copy(
2346 __isl_keep isl_qpolynomial_fold *fold);
2347 void isl_qpolynomial_fold_free(
2348 __isl_take isl_qpolynomial_fold *fold);
2350 To iterate over all quasipolynomials in a reduction, use
2352 int isl_qpolynomial_fold_foreach_qpolynomial(
2353 __isl_keep isl_qpolynomial_fold *fold,
2354 int (*fn)(__isl_take isl_qpolynomial *qp,
2355 void *user), void *user);
2357 =head3 Multiple Expressions
2359 A multiple expression represents a sequence of zero or
2360 more base expressions, all defined on the same domain space.
2361 The domain space of the multiple expression is the same
2362 as that of the base expressions, but the range space
2363 can be any space. In case the base expressions have
2364 a set space, the corresponding multiple expression
2365 also has a set space.
2366 Objects of the value type do not have an associated space.
2367 The space of a multiple value is therefore always a set space.
2369 The multiple expression types defined by C<isl>
2370 are C<isl_multi_val>, C<isl_multi_aff> and C<isl_multi_pw_aff>.
2372 A multiple expression with the value zero for
2373 each output (or set) dimension can be created
2374 using the following functions.
2376 #include <isl/val.h>
2377 __isl_give isl_multi_val *isl_multi_val_zero(
2378 __isl_take isl_space *space);
2380 #include <isl/aff.h>
2381 __isl_give isl_multi_aff *isl_multi_aff_zero(
2382 __isl_take isl_space *space);
2383 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_zero(
2384 __isl_take isl_space *space);
2386 An identity function can be created using the following
2387 functions. The space needs to be that of a relation
2388 with the same number of input and output dimensions.
2390 #include <isl/aff.h>
2391 __isl_give isl_multi_aff *isl_multi_aff_identity(
2392 __isl_take isl_space *space);
2393 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_identity(
2394 __isl_take isl_space *space);
2396 A function that performs a projection on a universe
2397 relation or set can be created using the following functions.
2398 See also the corresponding
2399 projection operations in L</"Unary Operations">.
2401 #include <isl/aff.h>
2402 __isl_give isl_multi_aff *isl_multi_aff_domain_map(
2403 __isl_take isl_space *space);
2404 __isl_give isl_multi_aff *isl_multi_aff_range_map(
2405 __isl_take isl_space *space);
2406 __isl_give isl_multi_aff *isl_multi_aff_project_out_map(
2407 __isl_take isl_space *space,
2408 enum isl_dim_type type,
2409 unsigned first, unsigned n);
2411 A multiple expression can be created from a single
2412 base expression using the following functions.
2413 The space of the created multiple expression is the same
2414 as that of the base expression.
2416 #include <isl/aff.h>
2417 __isl_give isl_multi_aff *isl_multi_aff_from_aff(
2418 __isl_take isl_aff *aff);
2419 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_aff(
2420 __isl_take isl_pw_aff *pa);
2422 A multiple expression can be created from a list
2423 of base expression in a specified space.
2424 The domain of this space needs to be the same
2425 as the domains of the base expressions in the list.
2426 If the base expressions have a set space (or no associated space),
2427 then this space also needs to be a set space.
2429 #include <isl/val.h>
2430 __isl_give isl_multi_val *isl_multi_val_from_val_list(
2431 __isl_take isl_space *space,
2432 __isl_take isl_val_list *list);
2434 #include <isl/aff.h>
2435 __isl_give isl_multi_aff *isl_multi_aff_from_aff_list(
2436 __isl_take isl_space *space,
2437 __isl_take isl_aff_list *list);
2439 As a convenience, a multiple piecewise expression can
2440 also be created from a multiple expression.
2441 Each piecewise expression in the result has a single
2444 #include <isl/aff.h>
2445 __isl_give isl_multi_pw_aff *
2446 isl_multi_pw_aff_from_multi_aff(
2447 __isl_take isl_multi_aff *ma);
2449 Multiple expressions can be copied and freed using
2450 the following functions.
2452 #include <isl/val.h>
2453 __isl_give isl_multi_val *isl_multi_val_copy(
2454 __isl_keep isl_multi_val *mv);
2455 __isl_null isl_multi_val *isl_multi_val_free(
2456 __isl_take isl_multi_val *mv);
2458 #include <isl/aff.h>
2459 __isl_give isl_multi_aff *isl_multi_aff_copy(
2460 __isl_keep isl_multi_aff *maff);
2461 __isl_null isl_multi_aff *isl_multi_aff_free(
2462 __isl_take isl_multi_aff *maff);
2463 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_copy(
2464 __isl_keep isl_multi_pw_aff *mpa);
2465 __isl_null isl_multi_pw_aff *isl_multi_pw_aff_free(
2466 __isl_take isl_multi_pw_aff *mpa);
2468 The base expression at a given position of a multiple
2469 expression can be extracted using the following functions.
2471 #include <isl/val.h>
2472 __isl_give isl_val *isl_multi_val_get_val(
2473 __isl_keep isl_multi_val *mv, int pos);
2475 #include <isl/aff.h>
2476 __isl_give isl_aff *isl_multi_aff_get_aff(
2477 __isl_keep isl_multi_aff *multi, int pos);
2478 __isl_give isl_pw_aff *isl_multi_pw_aff_get_pw_aff(
2479 __isl_keep isl_multi_pw_aff *mpa, int pos);
2481 It can be replaced using the following functions.
2483 #include <isl/val.h>
2484 __isl_give isl_multi_val *isl_multi_val_set_val(
2485 __isl_take isl_multi_val *mv, int pos,
2486 __isl_take isl_val *val);
2488 #include <isl/aff.h>
2489 __isl_give isl_multi_aff *isl_multi_aff_set_aff(
2490 __isl_take isl_multi_aff *multi, int pos,
2491 __isl_take isl_aff *aff);
2493 =head3 Piecewise Expressions
2495 A piecewise expression is an expression that is described
2496 using zero or more base expression defined over the same
2497 number of cells in the domain space of the base expressions.
2498 All base expressions are defined over the same
2499 domain space and the cells are disjoint.
2500 The space of a piecewise expression is the same as
2501 that of the base expressions.
2502 If the union of the cells is a strict subset of the domain
2503 space, then the value of the piecewise expression outside
2504 this union is different for types derived from quasi-affine
2505 expressions and those derived from quasipolynomials.
2506 Piecewise expressions derived from quasi-affine expressions
2507 are considered to be undefined outside the union of their cells.
2508 Piecewise expressions derived from quasipolynomials
2509 are considered to be zero outside the union of their cells.
2511 Piecewise quasipolynomials are mainly used by the C<barvinok>
2512 library for representing the number of elements in a parametric set or map.
2513 For example, the piecewise quasipolynomial
2515 [n] -> { [x] -> ((1 + n) - x) : x <= n and x >= 0 }
2517 represents the number of points in the map
2519 [n] -> { [x] -> [y] : x,y >= 0 and 0 <= x + y <= n }
2521 The piecewise expression types defined by C<isl>
2522 are C<isl_pw_aff>, C<isl_pw_multi_aff>,
2523 C<isl_pw_qpolynomial> and C<isl_pw_qpolynomial_fold>.
2525 A piecewise expression with no cells can be created using
2526 the following functions.
2528 #include <isl/aff.h>
2529 __isl_give isl_pw_aff *isl_pw_aff_empty(
2530 __isl_take isl_space *space);
2531 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_empty(
2532 __isl_take isl_space *space);
2534 A piecewise expression with a single universe cell can be
2535 created using the following functions.
2537 #include <isl/aff.h>
2538 __isl_give isl_pw_aff *isl_pw_aff_from_aff(
2539 __isl_take isl_aff *aff);
2540 __isl_give isl_pw_multi_aff *
2541 isl_pw_multi_aff_from_multi_aff(
2542 __isl_take isl_multi_aff *ma);
2544 #include <isl/polynomial.h>
2545 __isl_give isl_pw_qpolynomial *
2546 isl_pw_qpolynomial_from_qpolynomial(
2547 __isl_take isl_qpolynomial *qp);
2549 A piecewise expression with a single specified cell can be
2550 created using the following functions.
2552 #include <isl/aff.h>
2553 __isl_give isl_pw_aff *isl_pw_aff_alloc(
2554 __isl_take isl_set *set, __isl_take isl_aff *aff);
2555 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_alloc(
2556 __isl_take isl_set *set,
2557 __isl_take isl_multi_aff *maff);
2559 #include <isl/polynomial.h>
2560 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_alloc(
2561 __isl_take isl_set *set,
2562 __isl_take isl_qpolynomial *qp);
2564 The following convenience functions first create a base expression and
2565 then create a piecewise expression over a universe domain.
2567 #include <isl/aff.h>
2568 __isl_give isl_pw_aff *isl_pw_aff_zero_on_domain(
2569 __isl_take isl_local_space *ls);
2570 __isl_give isl_pw_aff *isl_pw_aff_var_on_domain(
2571 __isl_take isl_local_space *ls,
2572 enum isl_dim_type type, unsigned pos);
2573 __isl_give isl_pw_aff *isl_pw_aff_nan_on_domain(
2574 __isl_take isl_local_space *ls);
2575 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_zero(
2576 __isl_take isl_space *space);
2577 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_identity(
2578 __isl_take isl_space *space);
2579 __isl_give isl_pw_multi_aff *
2580 isl_pw_multi_aff_project_out_map(
2581 __isl_take isl_space *space,
2582 enum isl_dim_type type,
2583 unsigned first, unsigned n);
2585 #include <isl/polynomial.h>
2586 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero(
2587 __isl_take isl_space *space);
2589 As a convenience, a piecewise multiple expression can
2590 also be created from a piecewise expression.
2591 Each multiple expression in the result is derived
2592 from the corresponding base expression.
2594 #include <isl/aff.h>
2595 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_pw_aff(
2596 __isl_take isl_pw_aff *pa);
2598 Similarly, a piecewise quasipolynomial can be
2599 created from a piecewise quasi-affine expression using
2600 the following function.
2602 #include <isl/polynomial.h>
2603 __isl_give isl_pw_qpolynomial *
2604 isl_pw_qpolynomial_from_pw_aff(
2605 __isl_take isl_pw_aff *pwaff);
2607 Piecewise expressions can be copied and freed using the following functions.
2609 #include <isl/aff.h>
2610 __isl_give isl_pw_aff *isl_pw_aff_copy(
2611 __isl_keep isl_pw_aff *pwaff);
2612 __isl_null isl_pw_aff *isl_pw_aff_free(
2613 __isl_take isl_pw_aff *pwaff);
2614 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_copy(
2615 __isl_keep isl_pw_multi_aff *pma);
2616 __isl_null isl_pw_multi_aff *isl_pw_multi_aff_free(
2617 __isl_take isl_pw_multi_aff *pma);
2619 #include <isl/polynomial.h>
2620 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy(
2621 __isl_keep isl_pw_qpolynomial *pwqp);
2622 __isl_null isl_pw_qpolynomial *isl_pw_qpolynomial_free(
2623 __isl_take isl_pw_qpolynomial *pwqp);
2624 __isl_give isl_pw_qpolynomial_fold *
2625 isl_pw_qpolynomial_fold_copy(
2626 __isl_keep isl_pw_qpolynomial_fold *pwf);
2627 __isl_null isl_pw_qpolynomial_fold *
2628 isl_pw_qpolynomial_fold_free(
2629 __isl_take isl_pw_qpolynomial_fold *pwf);
2631 To iterate over the different cells of a piecewise expression,
2632 use the following functions.
2634 #include <isl/aff.h>
2635 int isl_pw_aff_is_empty(__isl_keep isl_pw_aff *pwaff);
2636 int isl_pw_aff_n_piece(__isl_keep isl_pw_aff *pwaff);
2637 int isl_pw_aff_foreach_piece(__isl_keep isl_pw_aff *pwaff,
2638 int (*fn)(__isl_take isl_set *set,
2639 __isl_take isl_aff *aff,
2640 void *user), void *user);
2641 int isl_pw_multi_aff_foreach_piece(
2642 __isl_keep isl_pw_multi_aff *pma,
2643 int (*fn)(__isl_take isl_set *set,
2644 __isl_take isl_multi_aff *maff,
2645 void *user), void *user);
2647 #include <isl/polynomial.h>
2648 int isl_pw_qpolynomial_foreach_piece(
2649 __isl_keep isl_pw_qpolynomial *pwqp,
2650 int (*fn)(__isl_take isl_set *set,
2651 __isl_take isl_qpolynomial *qp,
2652 void *user), void *user);
2653 int isl_pw_qpolynomial_foreach_lifted_piece(
2654 __isl_keep isl_pw_qpolynomial *pwqp,
2655 int (*fn)(__isl_take isl_set *set,
2656 __isl_take isl_qpolynomial *qp,
2657 void *user), void *user);
2658 int isl_pw_qpolynomial_fold_foreach_piece(
2659 __isl_keep isl_pw_qpolynomial_fold *pwf,
2660 int (*fn)(__isl_take isl_set *set,
2661 __isl_take isl_qpolynomial_fold *fold,
2662 void *user), void *user);
2663 int isl_pw_qpolynomial_fold_foreach_lifted_piece(
2664 __isl_keep isl_pw_qpolynomial_fold *pwf,
2665 int (*fn)(__isl_take isl_set *set,
2666 __isl_take isl_qpolynomial_fold *fold,
2667 void *user), void *user);
2669 As usual, the function C<fn> should return C<0> on success
2670 and C<-1> on failure. The difference between
2671 C<isl_pw_qpolynomial_foreach_piece> and
2672 C<isl_pw_qpolynomial_foreach_lifted_piece> is that
2673 C<isl_pw_qpolynomial_foreach_lifted_piece> will first
2674 compute unique representations for all existentially quantified
2675 variables and then turn these existentially quantified variables
2676 into extra set variables, adapting the associated quasipolynomial
2677 accordingly. This means that the C<set> passed to C<fn>
2678 will not have any existentially quantified variables, but that
2679 the dimensions of the sets may be different for different
2680 invocations of C<fn>.
2681 Similarly for C<isl_pw_qpolynomial_fold_foreach_piece>
2682 and C<isl_pw_qpolynomial_fold_foreach_lifted_piece>.
2684 A piecewise expression consisting of the expressions at a given
2685 position of a piecewise multiple expression can be extracted
2686 using the following function.
2688 #include <isl/aff.h>
2689 __isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff(
2690 __isl_keep isl_pw_multi_aff *pma, int pos);
2692 These expressions can be replaced using the following function.
2694 #include <isl/aff.h>
2695 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_pw_aff(
2696 __isl_take isl_pw_multi_aff *pma, unsigned pos,
2697 __isl_take isl_pw_aff *pa);
2699 Note that there is a difference between C<isl_multi_pw_aff> and
2700 C<isl_pw_multi_aff> objects. The first is a sequence of piecewise
2701 affine expressions, while the second is a piecewise sequence
2702 of affine expressions. In particular, each of the piecewise
2703 affine expressions in an C<isl_multi_pw_aff> may have a different
2704 domain, while all multiple expressions associated to a cell
2705 in an C<isl_pw_multi_aff> have the same domain.
2706 It is possible to convert between the two, but when converting
2707 an C<isl_multi_pw_aff> to an C<isl_pw_multi_aff>, the domain
2708 of the result is the intersection of the domains of the input.
2709 The reverse conversion is exact.
2711 #include <isl/aff.h>
2712 __isl_give isl_pw_multi_aff *
2713 isl_pw_multi_aff_from_multi_pw_aff(
2714 __isl_take isl_multi_pw_aff *mpa);
2715 __isl_give isl_multi_pw_aff *
2716 isl_multi_pw_aff_from_pw_multi_aff(
2717 __isl_take isl_pw_multi_aff *pma);
2719 =head3 Union Expressions
2721 A union expression collects base expressions defined
2722 over different domains. The space of a union expression
2723 is that of the shared parameter space.
2725 The union expression types defined by C<isl>
2726 are C<isl_union_pw_multi_aff>, C<isl_union_pw_qpolynomial> and
2727 C<isl_union_pw_qpolynomial_fold>.
2729 An empty union expression can be created using the following functions.
2731 #include <isl/aff.h>
2732 __isl_give isl_union_pw_multi_aff *
2733 isl_union_pw_multi_aff_empty(
2734 __isl_take isl_space *space);
2736 #include <isl/polynomial.h>
2737 __isl_give isl_union_pw_qpolynomial *
2738 isl_union_pw_qpolynomial_zero(
2739 __isl_take isl_space *space);
2741 A union expression containing a single base expression
2742 can be created using the following function.
2744 #include <isl/polynomial.h>
2745 __isl_give isl_union_pw_qpolynomial *
2746 isl_union_pw_qpolynomial_from_pw_qpolynomial(
2747 __isl_take isl_pw_qpolynomial *pwqp);
2749 A base expression can be added to a union expression using
2750 the following functions.
2752 #include <isl/aff.h>
2753 __isl_give isl_union_pw_multi_aff *
2754 isl_union_pw_multi_aff_add_pw_multi_aff(
2755 __isl_take isl_union_pw_multi_aff *upma,
2756 __isl_take isl_pw_multi_aff *pma);
2758 #include <isl/polynomial.h>
2759 __isl_give isl_union_pw_qpolynomial *
2760 isl_union_pw_qpolynomial_add_pw_qpolynomial(
2761 __isl_take isl_union_pw_qpolynomial *upwqp,
2762 __isl_take isl_pw_qpolynomial *pwqp);
2764 Union expressions can be copied and freed using
2765 the following functions.
2767 #include <isl/aff.h>
2768 __isl_give isl_union_pw_multi_aff *
2769 isl_union_pw_multi_aff_copy(
2770 __isl_keep isl_union_pw_multi_aff *upma);
2771 __isl_null isl_union_pw_multi_aff *
2772 isl_union_pw_multi_aff_free(
2773 __isl_take isl_union_pw_multi_aff *upma);
2775 #include <isl/polynomial.h>
2776 __isl_give isl_union_pw_qpolynomial *
2777 isl_union_pw_qpolynomial_copy(
2778 __isl_keep isl_union_pw_qpolynomial *upwqp);
2779 __isl_null isl_union_pw_qpolynomial *
2780 isl_union_pw_qpolynomial_free(
2781 __isl_take isl_union_pw_qpolynomial *upwqp);
2782 __isl_give isl_union_pw_qpolynomial_fold *
2783 isl_union_pw_qpolynomial_fold_copy(
2784 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
2785 __isl_null isl_union_pw_qpolynomial_fold *
2786 isl_union_pw_qpolynomial_fold_free(
2787 __isl_take isl_union_pw_qpolynomial_fold *upwf);
2789 To iterate over the base expressions in a union expression,
2790 use the following functions.
2792 #include <isl/aff.h>
2793 int isl_union_pw_multi_aff_foreach_pw_multi_aff(
2794 __isl_keep isl_union_pw_multi_aff *upma,
2795 int (*fn)(__isl_take isl_pw_multi_aff *pma,
2796 void *user), void *user);
2798 #include <isl/polynomial.h>
2799 int isl_union_pw_qpolynomial_foreach_pw_qpolynomial(
2800 __isl_keep isl_union_pw_qpolynomial *upwqp,
2801 int (*fn)(__isl_take isl_pw_qpolynomial *pwqp,
2802 void *user), void *user);
2803 int isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(
2804 __isl_keep isl_union_pw_qpolynomial_fold *upwf,
2805 int (*fn)(__isl_take isl_pw_qpolynomial_fold *pwf,
2806 void *user), void *user);
2808 To extract the base expression in a given space from a union, use
2809 the following function.
2811 #include <isl/polynomial.h>
2812 __isl_give isl_pw_qpolynomial *
2813 isl_union_pw_qpolynomial_extract_pw_qpolynomial(
2814 __isl_keep isl_union_pw_qpolynomial *upwqp,
2815 __isl_take isl_space *space);
2817 =head2 Input and Output
2819 For set and relation,
2820 C<isl> supports its own input/output format, which is similar
2821 to the C<Omega> format, but also supports the C<PolyLib> format
2823 For other object types, typically only an C<isl> format is supported.
2825 =head3 C<isl> format
2827 The C<isl> format is similar to that of C<Omega>, but has a different
2828 syntax for describing the parameters and allows for the definition
2829 of an existentially quantified variable as the integer division
2830 of an affine expression.
2831 For example, the set of integers C<i> between C<0> and C<n>
2832 such that C<i % 10 <= 6> can be described as
2834 [n] -> { [i] : exists (a = [i/10] : 0 <= i and i <= n and
2837 A set or relation can have several disjuncts, separated
2838 by the keyword C<or>. Each disjunct is either a conjunction
2839 of constraints or a projection (C<exists>) of a conjunction
2840 of constraints. The constraints are separated by the keyword
2843 =head3 C<PolyLib> format
2845 If the represented set is a union, then the first line
2846 contains a single number representing the number of disjuncts.
2847 Otherwise, a line containing the number C<1> is optional.
2849 Each disjunct is represented by a matrix of constraints.
2850 The first line contains two numbers representing
2851 the number of rows and columns,
2852 where the number of rows is equal to the number of constraints
2853 and the number of columns is equal to two plus the number of variables.
2854 The following lines contain the actual rows of the constraint matrix.
2855 In each row, the first column indicates whether the constraint
2856 is an equality (C<0>) or inequality (C<1>). The final column
2857 corresponds to the constant term.
2859 If the set is parametric, then the coefficients of the parameters
2860 appear in the last columns before the constant column.
2861 The coefficients of any existentially quantified variables appear
2862 between those of the set variables and those of the parameters.
2864 =head3 Extended C<PolyLib> format
2866 The extended C<PolyLib> format is nearly identical to the
2867 C<PolyLib> format. The only difference is that the line
2868 containing the number of rows and columns of a constraint matrix
2869 also contains four additional numbers:
2870 the number of output dimensions, the number of input dimensions,
2871 the number of local dimensions (i.e., the number of existentially
2872 quantified variables) and the number of parameters.
2873 For sets, the number of ``output'' dimensions is equal
2874 to the number of set dimensions, while the number of ``input''
2879 Objects can be read from input using the following functions.
2881 #include <isl/val.h>
2882 __isl_give isl_val *isl_val_read_from_str(isl_ctx *ctx,
2885 #include <isl/set.h>
2886 __isl_give isl_basic_set *isl_basic_set_read_from_file(
2887 isl_ctx *ctx, FILE *input);
2888 __isl_give isl_basic_set *isl_basic_set_read_from_str(
2889 isl_ctx *ctx, const char *str);
2890 __isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx,
2892 __isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx,
2895 #include <isl/map.h>
2896 __isl_give isl_basic_map *isl_basic_map_read_from_file(
2897 isl_ctx *ctx, FILE *input);
2898 __isl_give isl_basic_map *isl_basic_map_read_from_str(
2899 isl_ctx *ctx, const char *str);
2900 __isl_give isl_map *isl_map_read_from_file(
2901 isl_ctx *ctx, FILE *input);
2902 __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx,
2905 #include <isl/union_set.h>
2906 __isl_give isl_union_set *isl_union_set_read_from_file(
2907 isl_ctx *ctx, FILE *input);
2908 __isl_give isl_union_set *isl_union_set_read_from_str(
2909 isl_ctx *ctx, const char *str);
2911 #include <isl/union_map.h>
2912 __isl_give isl_union_map *isl_union_map_read_from_file(
2913 isl_ctx *ctx, FILE *input);
2914 __isl_give isl_union_map *isl_union_map_read_from_str(
2915 isl_ctx *ctx, const char *str);
2917 #include <isl/aff.h>
2918 __isl_give isl_aff *isl_aff_read_from_str(
2919 isl_ctx *ctx, const char *str);
2920 __isl_give isl_multi_aff *isl_multi_aff_read_from_str(
2921 isl_ctx *ctx, const char *str);
2922 __isl_give isl_pw_aff *isl_pw_aff_read_from_str(
2923 isl_ctx *ctx, const char *str);
2924 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str(
2925 isl_ctx *ctx, const char *str);
2926 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_read_from_str(
2927 isl_ctx *ctx, const char *str);
2928 __isl_give isl_union_pw_multi_aff *
2929 isl_union_pw_multi_aff_read_from_str(
2930 isl_ctx *ctx, const char *str);
2932 #include <isl/polynomial.h>
2933 __isl_give isl_union_pw_qpolynomial *
2934 isl_union_pw_qpolynomial_read_from_str(
2935 isl_ctx *ctx, const char *str);
2937 For sets and relations,
2938 the input format is autodetected and may be either the C<PolyLib> format
2939 or the C<isl> format.
2943 Before anything can be printed, an C<isl_printer> needs to
2946 __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx,
2948 __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx);
2949 __isl_null isl_printer *isl_printer_free(
2950 __isl_take isl_printer *printer);
2951 __isl_give char *isl_printer_get_str(
2952 __isl_keep isl_printer *printer);
2954 The printer can be inspected using the following functions.
2956 FILE *isl_printer_get_file(
2957 __isl_keep isl_printer *printer);
2958 int isl_printer_get_output_format(
2959 __isl_keep isl_printer *p);
2961 The behavior of the printer can be modified in various ways
2963 __isl_give isl_printer *isl_printer_set_output_format(
2964 __isl_take isl_printer *p, int output_format);
2965 __isl_give isl_printer *isl_printer_set_indent(
2966 __isl_take isl_printer *p, int indent);
2967 __isl_give isl_printer *isl_printer_set_indent_prefix(
2968 __isl_take isl_printer *p, const char *prefix);
2969 __isl_give isl_printer *isl_printer_indent(
2970 __isl_take isl_printer *p, int indent);
2971 __isl_give isl_printer *isl_printer_set_prefix(
2972 __isl_take isl_printer *p, const char *prefix);
2973 __isl_give isl_printer *isl_printer_set_suffix(
2974 __isl_take isl_printer *p, const char *suffix);
2976 The C<output_format> may be either C<ISL_FORMAT_ISL>, C<ISL_FORMAT_OMEGA>,
2977 C<ISL_FORMAT_POLYLIB>, C<ISL_FORMAT_EXT_POLYLIB> or C<ISL_FORMAT_LATEX>
2978 and defaults to C<ISL_FORMAT_ISL>.
2979 Each line in the output is prefixed by C<indent_prefix>,
2980 indented by C<indent> (set by C<isl_printer_set_indent>) spaces
2981 (default: 0), prefixed by C<prefix> and suffixed by C<suffix>.
2982 In the C<PolyLib> format output,
2983 the coefficients of the existentially quantified variables
2984 appear between those of the set variables and those
2986 The function C<isl_printer_indent> increases the indentation
2987 by the specified amount (which may be negative).
2989 To actually print something, use
2991 #include <isl/printer.h>
2992 __isl_give isl_printer *isl_printer_print_double(
2993 __isl_take isl_printer *p, double d);
2995 #include <isl/val.h>
2996 __isl_give isl_printer *isl_printer_print_val(
2997 __isl_take isl_printer *p, __isl_keep isl_val *v);
2999 #include <isl/set.h>
3000 __isl_give isl_printer *isl_printer_print_basic_set(
3001 __isl_take isl_printer *printer,
3002 __isl_keep isl_basic_set *bset);
3003 __isl_give isl_printer *isl_printer_print_set(
3004 __isl_take isl_printer *printer,
3005 __isl_keep isl_set *set);
3007 #include <isl/map.h>
3008 __isl_give isl_printer *isl_printer_print_basic_map(
3009 __isl_take isl_printer *printer,
3010 __isl_keep isl_basic_map *bmap);
3011 __isl_give isl_printer *isl_printer_print_map(
3012 __isl_take isl_printer *printer,
3013 __isl_keep isl_map *map);
3015 #include <isl/union_set.h>
3016 __isl_give isl_printer *isl_printer_print_union_set(
3017 __isl_take isl_printer *p,
3018 __isl_keep isl_union_set *uset);
3020 #include <isl/union_map.h>
3021 __isl_give isl_printer *isl_printer_print_union_map(
3022 __isl_take isl_printer *p,
3023 __isl_keep isl_union_map *umap);
3025 #include <isl/val.h>
3026 __isl_give isl_printer *isl_printer_print_multi_val(
3027 __isl_take isl_printer *p,
3028 __isl_keep isl_multi_val *mv);
3030 #include <isl/aff.h>
3031 __isl_give isl_printer *isl_printer_print_aff(
3032 __isl_take isl_printer *p, __isl_keep isl_aff *aff);
3033 __isl_give isl_printer *isl_printer_print_multi_aff(
3034 __isl_take isl_printer *p,
3035 __isl_keep isl_multi_aff *maff);
3036 __isl_give isl_printer *isl_printer_print_pw_aff(
3037 __isl_take isl_printer *p,
3038 __isl_keep isl_pw_aff *pwaff);
3039 __isl_give isl_printer *isl_printer_print_pw_multi_aff(
3040 __isl_take isl_printer *p,
3041 __isl_keep isl_pw_multi_aff *pma);
3042 __isl_give isl_printer *isl_printer_print_multi_pw_aff(
3043 __isl_take isl_printer *p,
3044 __isl_keep isl_multi_pw_aff *mpa);
3045 __isl_give isl_printer *isl_printer_print_union_pw_multi_aff(
3046 __isl_take isl_printer *p,
3047 __isl_keep isl_union_pw_multi_aff *upma);
3049 #include <isl/polynomial.h>
3050 __isl_give isl_printer *isl_printer_print_qpolynomial(
3051 __isl_take isl_printer *p,
3052 __isl_keep isl_qpolynomial *qp);
3053 __isl_give isl_printer *isl_printer_print_pw_qpolynomial(
3054 __isl_take isl_printer *p,
3055 __isl_keep isl_pw_qpolynomial *pwqp);
3056 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial(
3057 __isl_take isl_printer *p,
3058 __isl_keep isl_union_pw_qpolynomial *upwqp);
3060 __isl_give isl_printer *
3061 isl_printer_print_pw_qpolynomial_fold(
3062 __isl_take isl_printer *p,
3063 __isl_keep isl_pw_qpolynomial_fold *pwf);
3064 __isl_give isl_printer *
3065 isl_printer_print_union_pw_qpolynomial_fold(
3066 __isl_take isl_printer *p,
3067 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
3069 For C<isl_printer_print_qpolynomial>,
3070 C<isl_printer_print_pw_qpolynomial> and
3071 C<isl_printer_print_pw_qpolynomial_fold>,
3072 the output format of the printer
3073 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
3074 For C<isl_printer_print_union_pw_qpolynomial> and
3075 C<isl_printer_print_union_pw_qpolynomial_fold>, only C<ISL_FORMAT_ISL>
3077 In case of printing in C<ISL_FORMAT_C>, the user may want
3078 to set the names of all dimensions first.
3080 When called on a file printer, the following function flushes
3081 the file. When called on a string printer, the buffer is cleared.
3083 __isl_give isl_printer *isl_printer_flush(
3084 __isl_take isl_printer *p);
3086 Alternatively, a string representation can be obtained
3087 directly using the following functions, which always print
3090 #include <isl/val.h>
3091 __isl_give char *isl_val_to_str(__isl_keep isl_val *v);
3092 __isl_give char *isl_multi_val_to_str(
3093 __isl_keep isl_multi_val *mv);
3095 #include <isl/set.h>
3096 __isl_give char *isl_set_to_str(
3097 __isl_keep isl_set *set);
3099 #include <isl/aff.h>
3100 __isl_give char *isl_union_pw_multi_aff_to_str(
3101 __isl_keep isl_union_pw_multi_aff *upma);
3105 =head3 Unary Properties
3111 The following functions test whether the given set or relation
3112 contains any integer points. The ``plain'' variants do not perform
3113 any computations, but simply check if the given set or relation
3114 is already known to be empty.
3116 int isl_basic_set_plain_is_empty(__isl_keep isl_basic_set *bset);
3117 int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
3118 int isl_set_plain_is_empty(__isl_keep isl_set *set);
3119 int isl_set_is_empty(__isl_keep isl_set *set);
3120 int isl_union_set_is_empty(__isl_keep isl_union_set *uset);
3121 int isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap);
3122 int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
3123 int isl_map_plain_is_empty(__isl_keep isl_map *map);
3124 int isl_map_is_empty(__isl_keep isl_map *map);
3125 int isl_union_map_is_empty(__isl_keep isl_union_map *umap);
3127 =item * Universality
3129 int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
3130 int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
3131 int isl_set_plain_is_universe(__isl_keep isl_set *set);
3133 =item * Single-valuedness
3135 #include <isl/set.h>
3136 int isl_set_is_singleton(__isl_keep isl_set *set);
3138 #include <isl/map.h>
3139 int isl_basic_map_is_single_valued(
3140 __isl_keep isl_basic_map *bmap);
3141 int isl_map_plain_is_single_valued(
3142 __isl_keep isl_map *map);
3143 int isl_map_is_single_valued(__isl_keep isl_map *map);
3145 #include <isl/union_map.h>
3146 int isl_union_map_is_single_valued(__isl_keep isl_union_map *umap);
3150 int isl_map_plain_is_injective(__isl_keep isl_map *map);
3151 int isl_map_is_injective(__isl_keep isl_map *map);
3152 int isl_union_map_plain_is_injective(
3153 __isl_keep isl_union_map *umap);
3154 int isl_union_map_is_injective(
3155 __isl_keep isl_union_map *umap);
3159 int isl_map_is_bijective(__isl_keep isl_map *map);
3160 int isl_union_map_is_bijective(__isl_keep isl_union_map *umap);
3164 __isl_give isl_val *
3165 isl_basic_map_plain_get_val_if_fixed(
3166 __isl_keep isl_basic_map *bmap,
3167 enum isl_dim_type type, unsigned pos);
3168 __isl_give isl_val *isl_set_plain_get_val_if_fixed(
3169 __isl_keep isl_set *set,
3170 enum isl_dim_type type, unsigned pos);
3171 __isl_give isl_val *isl_map_plain_get_val_if_fixed(
3172 __isl_keep isl_map *map,
3173 enum isl_dim_type type, unsigned pos);
3175 If the set or relation obviously lies on a hyperplane where the given dimension
3176 has a fixed value, then return that value.
3177 Otherwise return NaN.
3181 int isl_set_dim_residue_class_val(
3182 __isl_keep isl_set *set,
3183 int pos, __isl_give isl_val **modulo,
3184 __isl_give isl_val **residue);
3186 Check if the values of the given set dimension are equal to a fixed
3187 value modulo some integer value. If so, assign the modulo to C<*modulo>
3188 and the fixed value to C<*residue>. If the given dimension attains only
3189 a single value, then assign C<0> to C<*modulo> and the fixed value to
3191 If the dimension does not attain only a single value and if no modulo
3192 can be found then assign C<1> to C<*modulo> and C<1> to C<*residue>.
3196 To check whether the description of a set, relation or function depends
3197 on one or more given dimensions,
3198 the following functions can be used.
3200 #include <isl/constraint.h>
3201 int isl_constraint_involves_dims(
3202 __isl_keep isl_constraint *constraint,
3203 enum isl_dim_type type, unsigned first, unsigned n);
3205 #include <isl/set.h>
3206 int isl_basic_set_involves_dims(
3207 __isl_keep isl_basic_set *bset,
3208 enum isl_dim_type type, unsigned first, unsigned n);
3209 int isl_set_involves_dims(__isl_keep isl_set *set,
3210 enum isl_dim_type type, unsigned first, unsigned n);
3212 #include <isl/map.h>
3213 int isl_basic_map_involves_dims(
3214 __isl_keep isl_basic_map *bmap,
3215 enum isl_dim_type type, unsigned first, unsigned n);
3216 int isl_map_involves_dims(__isl_keep isl_map *map,
3217 enum isl_dim_type type, unsigned first, unsigned n);
3219 #include <isl/aff.h>
3220 int isl_aff_involves_dims(__isl_keep isl_aff *aff,
3221 enum isl_dim_type type, unsigned first, unsigned n);
3222 int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff,
3223 enum isl_dim_type type, unsigned first, unsigned n);
3224 int isl_multi_aff_involves_dims(
3225 __isl_keep isl_multi_aff *ma,
3226 enum isl_dim_type type, unsigned first, unsigned n);
3227 int isl_multi_pw_aff_involves_dims(
3228 __isl_keep isl_multi_pw_aff *mpa,
3229 enum isl_dim_type type, unsigned first, unsigned n);
3231 Similarly, the following functions can be used to check whether
3232 a given dimension is involved in any lower or upper bound.
3234 #include <isl/set.h>
3235 int isl_set_dim_has_any_lower_bound(__isl_keep isl_set *set,
3236 enum isl_dim_type type, unsigned pos);
3237 int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set,
3238 enum isl_dim_type type, unsigned pos);
3240 Note that these functions return true even if there is a bound on
3241 the dimension on only some of the basic sets of C<set>.
3242 To check if they have a bound for all of the basic sets in C<set>,
3243 use the following functions instead.
3245 #include <isl/set.h>
3246 int isl_set_dim_has_lower_bound(__isl_keep isl_set *set,
3247 enum isl_dim_type type, unsigned pos);
3248 int isl_set_dim_has_upper_bound(__isl_keep isl_set *set,
3249 enum isl_dim_type type, unsigned pos);
3253 To check whether a set is a parameter domain, use this function:
3255 int isl_set_is_params(__isl_keep isl_set *set);
3256 int isl_union_set_is_params(
3257 __isl_keep isl_union_set *uset);
3261 The following functions check whether the space of the given
3262 (basic) set or relation range is a wrapped relation.
3264 #include <isl/space.h>
3265 int isl_space_is_wrapping(
3266 __isl_keep isl_space *space);
3267 int isl_space_domain_is_wrapping(
3268 __isl_keep isl_space *space);
3269 int isl_space_range_is_wrapping(
3270 __isl_keep isl_space *space);
3272 #include <isl/set.h>
3273 int isl_basic_set_is_wrapping(
3274 __isl_keep isl_basic_set *bset);
3275 int isl_set_is_wrapping(__isl_keep isl_set *set);
3277 #include <isl/map.h>
3278 int isl_map_domain_is_wrapping(
3279 __isl_keep isl_map *map);
3280 int isl_map_range_is_wrapping(
3281 __isl_keep isl_map *map);
3283 #include <isl/val.h>
3284 int isl_multi_val_range_is_wrapping(
3285 __isl_keep isl_multi_val *mv);
3287 #include <isl/aff.h>
3288 int isl_multi_aff_range_is_wrapping(
3289 __isl_keep isl_multi_aff *ma);
3290 int isl_multi_pw_aff_range_is_wrapping(
3291 __isl_keep isl_multi_pw_aff *mpa);
3293 The input to C<isl_space_is_wrapping> should
3294 be the space of a set, while that of
3295 C<isl_space_domain_is_wrapping> and
3296 C<isl_space_range_is_wrapping> should be the space of a relation.
3298 =item * Internal Product
3300 int isl_basic_map_can_zip(
3301 __isl_keep isl_basic_map *bmap);
3302 int isl_map_can_zip(__isl_keep isl_map *map);
3304 Check whether the product of domain and range of the given relation
3306 i.e., whether both domain and range are nested relations.
3310 int isl_basic_map_can_curry(
3311 __isl_keep isl_basic_map *bmap);
3312 int isl_map_can_curry(__isl_keep isl_map *map);
3314 Check whether the domain of the (basic) relation is a wrapped relation.
3316 int isl_basic_map_can_uncurry(
3317 __isl_keep isl_basic_map *bmap);
3318 int isl_map_can_uncurry(__isl_keep isl_map *map);
3320 Check whether the range of the (basic) relation is a wrapped relation.
3322 =item * Special Values
3324 #include <isl/aff.h>
3325 int isl_aff_is_cst(__isl_keep isl_aff *aff);
3326 int isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff);
3328 Check whether the given expression is a constant.
3330 #include <isl/aff.h>
3331 int isl_aff_is_nan(__isl_keep isl_aff *aff);
3332 int isl_pw_aff_involves_nan(__isl_keep isl_pw_aff *pa);
3334 Check whether the given expression is equal to or involves NaN.
3336 #include <isl/aff.h>
3337 int isl_aff_plain_is_zero(__isl_keep isl_aff *aff);
3339 Check whether the affine expression is obviously zero.
3343 =head3 Binary Properties
3349 The following functions check whether two objects
3350 represent the same set, relation or function.
3351 The C<plain> variants only return true if the objects
3352 are obviously the same. That is, they may return false
3353 even if the objects are the same, but they will never
3354 return true if the objects are not the same.
3356 #include <isl/set.h>
3357 int isl_basic_set_plain_is_equal(
3358 __isl_keep isl_basic_set *bset1,
3359 __isl_keep isl_basic_set *bset2);
3360 int isl_set_plain_is_equal(__isl_keep isl_set *set1,
3361 __isl_keep isl_set *set2);
3362 int isl_set_is_equal(__isl_keep isl_set *set1,
3363 __isl_keep isl_set *set2);
3365 #include <isl/map.h>
3366 int isl_basic_map_is_equal(
3367 __isl_keep isl_basic_map *bmap1,
3368 __isl_keep isl_basic_map *bmap2);
3369 int isl_map_is_equal(__isl_keep isl_map *map1,
3370 __isl_keep isl_map *map2);
3371 int isl_map_plain_is_equal(__isl_keep isl_map *map1,
3372 __isl_keep isl_map *map2);
3374 #include <isl/union_set.h>
3375 int isl_union_set_is_equal(
3376 __isl_keep isl_union_set *uset1,
3377 __isl_keep isl_union_set *uset2);
3379 #include <isl/union_map.h>
3380 int isl_union_map_is_equal(
3381 __isl_keep isl_union_map *umap1,
3382 __isl_keep isl_union_map *umap2);
3384 #include <isl/aff.h>
3385 int isl_aff_plain_is_equal(__isl_keep isl_aff *aff1,
3386 __isl_keep isl_aff *aff2);
3387 int isl_multi_aff_plain_is_equal(
3388 __isl_keep isl_multi_aff *maff1,
3389 __isl_keep isl_multi_aff *maff2);
3390 int isl_pw_aff_plain_is_equal(
3391 __isl_keep isl_pw_aff *pwaff1,
3392 __isl_keep isl_pw_aff *pwaff2);
3393 int isl_pw_multi_aff_plain_is_equal(
3394 __isl_keep isl_pw_multi_aff *pma1,
3395 __isl_keep isl_pw_multi_aff *pma2);
3396 int isl_multi_pw_aff_plain_is_equal(
3397 __isl_keep isl_multi_pw_aff *mpa1,
3398 __isl_keep isl_multi_pw_aff *mpa2);
3399 int isl_multi_pw_aff_is_equal(
3400 __isl_keep isl_multi_pw_aff *mpa1,
3401 __isl_keep isl_multi_pw_aff *mpa2);
3403 #include <isl/polynomial.h>
3404 int isl_union_pw_qpolynomial_plain_is_equal(
3405 __isl_keep isl_union_pw_qpolynomial *upwqp1,
3406 __isl_keep isl_union_pw_qpolynomial *upwqp2);
3407 int isl_union_pw_qpolynomial_fold_plain_is_equal(
3408 __isl_keep isl_union_pw_qpolynomial_fold *upwf1,
3409 __isl_keep isl_union_pw_qpolynomial_fold *upwf2);
3411 =item * Disjointness
3413 int isl_basic_set_is_disjoint(
3414 __isl_keep isl_basic_set *bset1,
3415 __isl_keep isl_basic_set *bset2);
3416 int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
3417 __isl_keep isl_set *set2);
3418 int isl_set_is_disjoint(__isl_keep isl_set *set1,
3419 __isl_keep isl_set *set2);
3420 int isl_basic_map_is_disjoint(
3421 __isl_keep isl_basic_map *bmap1,
3422 __isl_keep isl_basic_map *bmap2);
3423 int isl_map_is_disjoint(__isl_keep isl_map *map1,
3424 __isl_keep isl_map *map2);
3428 int isl_basic_set_is_subset(
3429 __isl_keep isl_basic_set *bset1,
3430 __isl_keep isl_basic_set *bset2);
3431 int isl_set_is_subset(__isl_keep isl_set *set1,
3432 __isl_keep isl_set *set2);
3433 int isl_set_is_strict_subset(
3434 __isl_keep isl_set *set1,
3435 __isl_keep isl_set *set2);
3436 int isl_union_set_is_subset(
3437 __isl_keep isl_union_set *uset1,
3438 __isl_keep isl_union_set *uset2);
3439 int isl_union_set_is_strict_subset(
3440 __isl_keep isl_union_set *uset1,
3441 __isl_keep isl_union_set *uset2);
3442 int isl_basic_map_is_subset(
3443 __isl_keep isl_basic_map *bmap1,
3444 __isl_keep isl_basic_map *bmap2);
3445 int isl_basic_map_is_strict_subset(
3446 __isl_keep isl_basic_map *bmap1,
3447 __isl_keep isl_basic_map *bmap2);
3448 int isl_map_is_subset(
3449 __isl_keep isl_map *map1,
3450 __isl_keep isl_map *map2);
3451 int isl_map_is_strict_subset(
3452 __isl_keep isl_map *map1,
3453 __isl_keep isl_map *map2);
3454 int isl_union_map_is_subset(
3455 __isl_keep isl_union_map *umap1,
3456 __isl_keep isl_union_map *umap2);
3457 int isl_union_map_is_strict_subset(
3458 __isl_keep isl_union_map *umap1,
3459 __isl_keep isl_union_map *umap2);
3461 Check whether the first argument is a (strict) subset of the
3466 Every comparison function returns a negative value if the first
3467 argument is considered smaller than the second, a positive value
3468 if the first argument is considered greater and zero if the two
3469 constraints are considered the same by the comparison criterion.
3471 #include <isl/constraint.h>
3472 int isl_constraint_plain_cmp(
3473 __isl_keep isl_constraint *c1,
3474 __isl_keep isl_constraint *c2);
3476 This function is useful for sorting C<isl_constraint>s.
3477 The order depends on the internal representation of the inputs.
3478 The order is fixed over different calls to the function (assuming
3479 the internal representation of the inputs has not changed), but may
3480 change over different versions of C<isl>.
3482 #include <isl/constraint.h>
3483 int isl_constraint_cmp_last_non_zero(
3484 __isl_keep isl_constraint *c1,
3485 __isl_keep isl_constraint *c2);
3487 This function can be used to sort constraints that live in the same
3488 local space. Constraints that involve ``earlier'' dimensions or
3489 that have a smaller coefficient for the shared latest dimension
3490 are considered smaller than other constraints.
3491 This function only defines a B<partial> order.
3493 #include <isl/set.h>
3494 int isl_set_plain_cmp(__isl_keep isl_set *set1,
3495 __isl_keep isl_set *set2);
3497 This function is useful for sorting C<isl_set>s.
3498 The order depends on the internal representation of the inputs.
3499 The order is fixed over different calls to the function (assuming
3500 the internal representation of the inputs has not changed), but may
3501 change over different versions of C<isl>.
3503 #include <isl/aff.h>
3504 int isl_pw_aff_plain_cmp(__isl_keep isl_pw_aff *pa1,
3505 __isl_keep isl_pw_aff *pa2);
3507 The function C<isl_pw_aff_plain_cmp> can be used to sort
3508 C<isl_pw_aff>s. The order is not strictly defined.
3509 The current order sorts expressions that only involve
3510 earlier dimensions before those that involve later dimensions.
3514 =head2 Unary Operations
3520 __isl_give isl_set *isl_set_complement(
3521 __isl_take isl_set *set);
3522 __isl_give isl_map *isl_map_complement(
3523 __isl_take isl_map *map);
3527 #include <isl/space.h>
3528 __isl_give isl_space *isl_space_reverse(
3529 __isl_take isl_space *space);
3531 #include <isl/map.h>
3532 __isl_give isl_basic_map *isl_basic_map_reverse(
3533 __isl_take isl_basic_map *bmap);
3534 __isl_give isl_map *isl_map_reverse(
3535 __isl_take isl_map *map);
3537 #include <isl/union_map.h>
3538 __isl_give isl_union_map *isl_union_map_reverse(
3539 __isl_take isl_union_map *umap);
3543 #include <isl/space.h>
3544 __isl_give isl_space *isl_space_domain(
3545 __isl_take isl_space *space);
3546 __isl_give isl_space *isl_space_range(
3547 __isl_take isl_space *space);
3548 __isl_give isl_space *isl_space_params(
3549 __isl_take isl_space *space);
3551 #include <isl/local_space.h>
3552 __isl_give isl_local_space *isl_local_space_domain(
3553 __isl_take isl_local_space *ls);
3554 __isl_give isl_local_space *isl_local_space_range(
3555 __isl_take isl_local_space *ls);
3557 #include <isl/set.h>
3558 __isl_give isl_basic_set *isl_basic_set_project_out(
3559 __isl_take isl_basic_set *bset,
3560 enum isl_dim_type type, unsigned first, unsigned n);
3561 __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
3562 enum isl_dim_type type, unsigned first, unsigned n);
3563 __isl_give isl_basic_set *isl_basic_set_params(
3564 __isl_take isl_basic_set *bset);
3565 __isl_give isl_set *isl_set_params(__isl_take isl_set *set);
3567 #include <isl/map.h>
3568 __isl_give isl_basic_map *isl_basic_map_project_out(
3569 __isl_take isl_basic_map *bmap,
3570 enum isl_dim_type type, unsigned first, unsigned n);
3571 __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
3572 enum isl_dim_type type, unsigned first, unsigned n);
3573 __isl_give isl_basic_set *isl_basic_map_domain(
3574 __isl_take isl_basic_map *bmap);
3575 __isl_give isl_basic_set *isl_basic_map_range(
3576 __isl_take isl_basic_map *bmap);
3577 __isl_give isl_set *isl_map_params(__isl_take isl_map *map);
3578 __isl_give isl_set *isl_map_domain(
3579 __isl_take isl_map *bmap);
3580 __isl_give isl_set *isl_map_range(
3581 __isl_take isl_map *map);
3583 #include <isl/union_set.h>
3584 __isl_give isl_set *isl_union_set_params(
3585 __isl_take isl_union_set *uset);
3587 #include <isl/union_map.h>
3588 __isl_give isl_union_map *isl_union_map_project_out(
3589 __isl_take isl_union_map *umap,
3590 enum isl_dim_type type, unsigned first, unsigned n);
3591 __isl_give isl_set *isl_union_map_params(
3592 __isl_take isl_union_map *umap);
3593 __isl_give isl_union_set *isl_union_map_domain(
3594 __isl_take isl_union_map *umap);
3595 __isl_give isl_union_set *isl_union_map_range(
3596 __isl_take isl_union_map *umap);
3598 The function C<isl_union_map_project_out> can only project out
3601 #include <isl/aff.h>
3602 __isl_give isl_aff *isl_aff_project_domain_on_params(
3603 __isl_take isl_aff *aff);
3604 __isl_give isl_pw_multi_aff *
3605 isl_pw_multi_aff_project_domain_on_params(
3606 __isl_take isl_pw_multi_aff *pma);
3607 __isl_give isl_set *isl_pw_aff_domain(
3608 __isl_take isl_pw_aff *pwaff);
3609 __isl_give isl_set *isl_pw_multi_aff_domain(
3610 __isl_take isl_pw_multi_aff *pma);
3611 __isl_give isl_set *isl_multi_pw_aff_domain(
3612 __isl_take isl_multi_pw_aff *mpa);
3613 __isl_give isl_union_set *isl_union_pw_multi_aff_domain(
3614 __isl_take isl_union_pw_multi_aff *upma);
3615 __isl_give isl_set *isl_pw_aff_params(
3616 __isl_take isl_pw_aff *pwa);
3618 #include <isl/polynomial.h>
3619 __isl_give isl_qpolynomial *
3620 isl_qpolynomial_project_domain_on_params(
3621 __isl_take isl_qpolynomial *qp);
3622 __isl_give isl_pw_qpolynomial *
3623 isl_pw_qpolynomial_project_domain_on_params(
3624 __isl_take isl_pw_qpolynomial *pwqp);
3625 __isl_give isl_pw_qpolynomial_fold *
3626 isl_pw_qpolynomial_fold_project_domain_on_params(
3627 __isl_take isl_pw_qpolynomial_fold *pwf);
3628 __isl_give isl_set *isl_pw_qpolynomial_domain(
3629 __isl_take isl_pw_qpolynomial *pwqp);
3630 __isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain(
3631 __isl_take isl_union_pw_qpolynomial_fold *upwf);
3632 __isl_give isl_union_set *isl_union_pw_qpolynomial_domain(
3633 __isl_take isl_union_pw_qpolynomial *upwqp);
3635 #include <isl/space.h>
3636 __isl_give isl_space *isl_space_domain_map(
3637 __isl_take isl_space *space);
3638 __isl_give isl_space *isl_space_range_map(
3639 __isl_take isl_space *space);
3641 #include <isl/map.h>
3642 __isl_give isl_basic_map *isl_basic_map_domain_map(
3643 __isl_take isl_basic_map *bmap);
3644 __isl_give isl_basic_map *isl_basic_map_range_map(
3645 __isl_take isl_basic_map *bmap);
3646 __isl_give isl_map *isl_map_domain_map(__isl_take isl_map *map);
3647 __isl_give isl_map *isl_map_range_map(__isl_take isl_map *map);
3649 #include <isl/union_map.h>
3650 __isl_give isl_union_map *isl_union_map_domain_map(
3651 __isl_take isl_union_map *umap);
3652 __isl_give isl_union_map *isl_union_map_range_map(
3653 __isl_take isl_union_map *umap);
3655 The functions above construct a (basic, regular or union) relation
3656 that maps (a wrapped version of) the input relation to its domain or range.
3660 __isl_give isl_basic_set *isl_basic_set_eliminate(
3661 __isl_take isl_basic_set *bset,
3662 enum isl_dim_type type,
3663 unsigned first, unsigned n);
3664 __isl_give isl_set *isl_set_eliminate(
3665 __isl_take isl_set *set, enum isl_dim_type type,
3666 unsigned first, unsigned n);
3667 __isl_give isl_basic_map *isl_basic_map_eliminate(
3668 __isl_take isl_basic_map *bmap,
3669 enum isl_dim_type type,
3670 unsigned first, unsigned n);
3671 __isl_give isl_map *isl_map_eliminate(
3672 __isl_take isl_map *map, enum isl_dim_type type,
3673 unsigned first, unsigned n);
3675 Eliminate the coefficients for the given dimensions from the constraints,
3676 without removing the dimensions.
3678 =item * Constructing a set from a parameter domain
3680 A zero-dimensional space or (basic) set can be constructed
3681 on a given parameter domain using the following functions.
3683 #include <isl/space.h>
3684 __isl_give isl_space *isl_space_set_from_params(
3685 __isl_take isl_space *space);
3687 #include <isl/set.h>
3688 __isl_give isl_basic_set *isl_basic_set_from_params(
3689 __isl_take isl_basic_set *bset);
3690 __isl_give isl_set *isl_set_from_params(
3691 __isl_take isl_set *set);
3693 =item * Constructing a relation from a set
3695 Create a relation with the given set as domain or range.
3696 The range or domain of the created relation is a zero-dimensional
3697 flat anonymous space.
3699 #include <isl/space.h>
3700 __isl_give isl_space *isl_space_from_domain(
3701 __isl_take isl_space *space);
3702 __isl_give isl_space *isl_space_from_range(
3703 __isl_take isl_space *space);
3704 __isl_give isl_space *isl_space_map_from_set(
3705 __isl_take isl_space *space);
3706 __isl_give isl_space *isl_space_map_from_domain_and_range(
3707 __isl_take isl_space *domain,
3708 __isl_take isl_space *range);
3710 #include <isl/local_space.h>
3711 __isl_give isl_local_space *isl_local_space_from_domain(
3712 __isl_take isl_local_space *ls);
3714 #include <isl/map.h>
3715 __isl_give isl_map *isl_map_from_domain(
3716 __isl_take isl_set *set);
3717 __isl_give isl_map *isl_map_from_range(
3718 __isl_take isl_set *set);
3720 #include <isl/val.h>
3721 __isl_give isl_multi_val *isl_multi_val_from_range(
3722 __isl_take isl_multi_val *mv);
3724 #include <isl/aff.h>
3725 __isl_give isl_multi_aff *isl_multi_aff_from_range(
3726 __isl_take isl_multi_aff *ma);
3727 __isl_give isl_pw_aff *isl_pw_aff_from_range(
3728 __isl_take isl_pw_aff *pwa);
3729 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_range(
3730 __isl_take isl_multi_pw_aff *mpa);
3731 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_domain(
3732 __isl_take isl_set *set);
3733 __isl_give isl_union_pw_multi_aff *
3734 isl_union_pw_multi_aff_from_domain(
3735 __isl_take isl_union_set *uset);
3739 #include <isl/set.h>
3740 __isl_give isl_basic_set *isl_basic_set_fix_si(
3741 __isl_take isl_basic_set *bset,
3742 enum isl_dim_type type, unsigned pos, int value);
3743 __isl_give isl_basic_set *isl_basic_set_fix_val(
3744 __isl_take isl_basic_set *bset,
3745 enum isl_dim_type type, unsigned pos,
3746 __isl_take isl_val *v);
3747 __isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set,
3748 enum isl_dim_type type, unsigned pos, int value);
3749 __isl_give isl_set *isl_set_fix_val(
3750 __isl_take isl_set *set,
3751 enum isl_dim_type type, unsigned pos,
3752 __isl_take isl_val *v);
3754 #include <isl/map.h>
3755 __isl_give isl_basic_map *isl_basic_map_fix_si(
3756 __isl_take isl_basic_map *bmap,
3757 enum isl_dim_type type, unsigned pos, int value);
3758 __isl_give isl_basic_map *isl_basic_map_fix_val(
3759 __isl_take isl_basic_map *bmap,
3760 enum isl_dim_type type, unsigned pos,
3761 __isl_take isl_val *v);
3762 __isl_give isl_map *isl_map_fix_si(__isl_take isl_map *map,
3763 enum isl_dim_type type, unsigned pos, int value);
3764 __isl_give isl_map *isl_map_fix_val(
3765 __isl_take isl_map *map,
3766 enum isl_dim_type type, unsigned pos,
3767 __isl_take isl_val *v);
3769 #include <isl/aff.h>
3770 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_fix_si(
3771 __isl_take isl_pw_multi_aff *pma,
3772 enum isl_dim_type type, unsigned pos, int value);
3774 #include <isl/polynomial.h>
3775 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_fix_val(
3776 __isl_take isl_pw_qpolynomial *pwqp,
3777 enum isl_dim_type type, unsigned n,
3778 __isl_take isl_val *v);
3780 Intersect the set, relation or function domain
3781 with the hyperplane where the given
3782 dimension has the fixed given value.
3784 __isl_give isl_basic_map *isl_basic_map_lower_bound_si(
3785 __isl_take isl_basic_map *bmap,
3786 enum isl_dim_type type, unsigned pos, int value);
3787 __isl_give isl_basic_map *isl_basic_map_upper_bound_si(
3788 __isl_take isl_basic_map *bmap,
3789 enum isl_dim_type type, unsigned pos, int value);
3790 __isl_give isl_set *isl_set_lower_bound_si(
3791 __isl_take isl_set *set,
3792 enum isl_dim_type type, unsigned pos, int value);
3793 __isl_give isl_set *isl_set_lower_bound_val(
3794 __isl_take isl_set *set,
3795 enum isl_dim_type type, unsigned pos,
3796 __isl_take isl_val *value);
3797 __isl_give isl_map *isl_map_lower_bound_si(
3798 __isl_take isl_map *map,
3799 enum isl_dim_type type, unsigned pos, int value);
3800 __isl_give isl_set *isl_set_upper_bound_si(
3801 __isl_take isl_set *set,
3802 enum isl_dim_type type, unsigned pos, int value);
3803 __isl_give isl_set *isl_set_upper_bound_val(
3804 __isl_take isl_set *set,
3805 enum isl_dim_type type, unsigned pos,
3806 __isl_take isl_val *value);
3807 __isl_give isl_map *isl_map_upper_bound_si(
3808 __isl_take isl_map *map,
3809 enum isl_dim_type type, unsigned pos, int value);
3811 Intersect the set or relation with the half-space where the given
3812 dimension has a value bounded by the fixed given integer value.
3814 __isl_give isl_set *isl_set_equate(__isl_take isl_set *set,
3815 enum isl_dim_type type1, int pos1,
3816 enum isl_dim_type type2, int pos2);
3817 __isl_give isl_basic_map *isl_basic_map_equate(
3818 __isl_take isl_basic_map *bmap,
3819 enum isl_dim_type type1, int pos1,
3820 enum isl_dim_type type2, int pos2);
3821 __isl_give isl_map *isl_map_equate(__isl_take isl_map *map,
3822 enum isl_dim_type type1, int pos1,
3823 enum isl_dim_type type2, int pos2);
3825 Intersect the set or relation with the hyperplane where the given
3826 dimensions are equal to each other.
3828 __isl_give isl_map *isl_map_oppose(__isl_take isl_map *map,
3829 enum isl_dim_type type1, int pos1,
3830 enum isl_dim_type type2, int pos2);
3832 Intersect the relation with the hyperplane where the given
3833 dimensions have opposite values.
3835 __isl_give isl_map *isl_map_order_le(
3836 __isl_take isl_map *map,
3837 enum isl_dim_type type1, int pos1,
3838 enum isl_dim_type type2, int pos2);
3839 __isl_give isl_basic_map *isl_basic_map_order_ge(
3840 __isl_take isl_basic_map *bmap,
3841 enum isl_dim_type type1, int pos1,
3842 enum isl_dim_type type2, int pos2);
3843 __isl_give isl_map *isl_map_order_ge(
3844 __isl_take isl_map *map,
3845 enum isl_dim_type type1, int pos1,
3846 enum isl_dim_type type2, int pos2);
3847 __isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map,
3848 enum isl_dim_type type1, int pos1,
3849 enum isl_dim_type type2, int pos2);
3850 __isl_give isl_basic_map *isl_basic_map_order_gt(
3851 __isl_take isl_basic_map *bmap,
3852 enum isl_dim_type type1, int pos1,
3853 enum isl_dim_type type2, int pos2);
3854 __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
3855 enum isl_dim_type type1, int pos1,
3856 enum isl_dim_type type2, int pos2);
3858 Intersect the relation with the half-space where the given
3859 dimensions satisfy the given ordering.
3863 #include <isl/aff.h>
3864 __isl_give isl_basic_set *isl_aff_zero_basic_set(
3865 __isl_take isl_aff *aff);
3866 __isl_give isl_basic_set *isl_aff_neg_basic_set(
3867 __isl_take isl_aff *aff);
3868 __isl_give isl_set *isl_pw_aff_nonneg_set(
3869 __isl_take isl_pw_aff *pwaff);
3870 __isl_give isl_set *isl_pw_aff_zero_set(
3871 __isl_take isl_pw_aff *pwaff);
3872 __isl_give isl_set *isl_pw_aff_non_zero_set(
3873 __isl_take isl_pw_aff *pwaff);
3875 The function C<isl_aff_neg_basic_set> returns a basic set
3876 containing those elements in the domain space
3877 of C<aff> where C<aff> is negative.
3878 The function C<isl_pw_aff_nonneg_set> returns a set
3879 containing those elements in the domain
3880 of C<pwaff> where C<pwaff> is non-negative.
3884 __isl_give isl_map *isl_set_identity(
3885 __isl_take isl_set *set);
3886 __isl_give isl_union_map *isl_union_set_identity(
3887 __isl_take isl_union_set *uset);
3889 Construct an identity relation on the given (union) set.
3891 =item * Function Extraction
3893 A piecewise quasi affine expression that is equal to 1 on a set
3894 and 0 outside the set can be created using the following function.
3896 #include <isl/aff.h>
3897 __isl_give isl_pw_aff *isl_set_indicator_function(
3898 __isl_take isl_set *set);
3900 A piecewise multiple quasi affine expression can be extracted
3901 from an C<isl_set> or C<isl_map>, provided the C<isl_set> is a singleton
3902 and the C<isl_map> is single-valued.
3903 In case of a conversion from an C<isl_union_map>
3904 to an C<isl_union_pw_multi_aff>, these properties need to hold
3905 in each domain space.
3907 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_set(
3908 __isl_take isl_set *set);
3909 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_map(
3910 __isl_take isl_map *map);
3912 __isl_give isl_union_pw_multi_aff *
3913 isl_union_pw_multi_aff_from_union_set(
3914 __isl_take isl_union_set *uset);
3915 __isl_give isl_union_pw_multi_aff *
3916 isl_union_pw_multi_aff_from_union_map(
3917 __isl_take isl_union_map *umap);
3921 __isl_give isl_basic_set *isl_basic_map_deltas(
3922 __isl_take isl_basic_map *bmap);
3923 __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
3924 __isl_give isl_union_set *isl_union_map_deltas(
3925 __isl_take isl_union_map *umap);
3927 These functions return a (basic) set containing the differences
3928 between image elements and corresponding domain elements in the input.
3930 __isl_give isl_basic_map *isl_basic_map_deltas_map(
3931 __isl_take isl_basic_map *bmap);
3932 __isl_give isl_map *isl_map_deltas_map(
3933 __isl_take isl_map *map);
3934 __isl_give isl_union_map *isl_union_map_deltas_map(
3935 __isl_take isl_union_map *umap);
3937 The functions above construct a (basic, regular or union) relation
3938 that maps (a wrapped version of) the input relation to its delta set.
3942 Simplify the representation of a set, relation or functions by trying
3943 to combine pairs of basic sets or relations into a single
3944 basic set or relation.
3946 #include <isl/set.h>
3947 __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
3949 #include <isl/map.h>
3950 __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
3952 #include <isl/union_set.h>
3953 __isl_give isl_union_set *isl_union_set_coalesce(
3954 __isl_take isl_union_set *uset);
3956 #include <isl/union_map.h>
3957 __isl_give isl_union_map *isl_union_map_coalesce(
3958 __isl_take isl_union_map *umap);
3960 #include <isl/aff.h>
3961 __isl_give isl_pw_aff *isl_pw_aff_coalesce(
3962 __isl_take isl_pw_aff *pwqp);
3963 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_coalesce(
3964 __isl_take isl_pw_multi_aff *pma);
3965 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_coalesce(
3966 __isl_take isl_multi_pw_aff *mpa);
3968 #include <isl/polynomial.h>
3969 __isl_give isl_pw_qpolynomial_fold *
3970 isl_pw_qpolynomial_fold_coalesce(
3971 __isl_take isl_pw_qpolynomial_fold *pwf);
3972 __isl_give isl_union_pw_qpolynomial *
3973 isl_union_pw_qpolynomial_coalesce(
3974 __isl_take isl_union_pw_qpolynomial *upwqp);
3975 __isl_give isl_union_pw_qpolynomial_fold *
3976 isl_union_pw_qpolynomial_fold_coalesce(
3977 __isl_take isl_union_pw_qpolynomial_fold *upwf);
3979 One of the methods for combining pairs of basic sets or relations
3980 can result in coefficients that are much larger than those that appear
3981 in the constraints of the input. By default, the coefficients are
3982 not allowed to grow larger, but this can be changed by unsetting
3983 the following option.
3985 int isl_options_set_coalesce_bounded_wrapping(
3986 isl_ctx *ctx, int val);
3987 int isl_options_get_coalesce_bounded_wrapping(
3990 =item * Detecting equalities
3992 __isl_give isl_basic_set *isl_basic_set_detect_equalities(
3993 __isl_take isl_basic_set *bset);
3994 __isl_give isl_basic_map *isl_basic_map_detect_equalities(
3995 __isl_take isl_basic_map *bmap);
3996 __isl_give isl_set *isl_set_detect_equalities(
3997 __isl_take isl_set *set);
3998 __isl_give isl_map *isl_map_detect_equalities(
3999 __isl_take isl_map *map);
4000 __isl_give isl_union_set *isl_union_set_detect_equalities(
4001 __isl_take isl_union_set *uset);
4002 __isl_give isl_union_map *isl_union_map_detect_equalities(
4003 __isl_take isl_union_map *umap);
4005 Simplify the representation of a set or relation by detecting implicit
4008 =item * Removing redundant constraints
4010 __isl_give isl_basic_set *isl_basic_set_remove_redundancies(
4011 __isl_take isl_basic_set *bset);
4012 __isl_give isl_set *isl_set_remove_redundancies(
4013 __isl_take isl_set *set);
4014 __isl_give isl_basic_map *isl_basic_map_remove_redundancies(
4015 __isl_take isl_basic_map *bmap);
4016 __isl_give isl_map *isl_map_remove_redundancies(
4017 __isl_take isl_map *map);
4021 __isl_give isl_basic_set *isl_set_convex_hull(
4022 __isl_take isl_set *set);
4023 __isl_give isl_basic_map *isl_map_convex_hull(
4024 __isl_take isl_map *map);
4026 If the input set or relation has any existentially quantified
4027 variables, then the result of these operations is currently undefined.
4031 #include <isl/set.h>
4032 __isl_give isl_basic_set *
4033 isl_set_unshifted_simple_hull(
4034 __isl_take isl_set *set);
4035 __isl_give isl_basic_set *isl_set_simple_hull(
4036 __isl_take isl_set *set);
4037 __isl_give isl_basic_set *
4038 isl_set_unshifted_simple_hull_from_set_list(
4039 __isl_take isl_set *set,
4040 __isl_take isl_set_list *list);
4042 #include <isl/map.h>
4043 __isl_give isl_basic_map *
4044 isl_map_unshifted_simple_hull(
4045 __isl_take isl_map *map);
4046 __isl_give isl_basic_map *isl_map_simple_hull(
4047 __isl_take isl_map *map);
4049 #include <isl/union_map.h>
4050 __isl_give isl_union_map *isl_union_map_simple_hull(
4051 __isl_take isl_union_map *umap);
4053 These functions compute a single basic set or relation
4054 that contains the whole input set or relation.
4055 In particular, the output is described by translates
4056 of the constraints describing the basic sets or relations in the input.
4057 In case of C<isl_set_unshifted_simple_hull>, only the original
4058 constraints are used, without any translation.
4059 In case of C<isl_set_unshifted_simple_hull_from_set_list>, the
4060 constraints are taken from the elements of the second argument.
4064 (See \autoref{s:simple hull}.)
4070 __isl_give isl_basic_set *isl_basic_set_affine_hull(
4071 __isl_take isl_basic_set *bset);
4072 __isl_give isl_basic_set *isl_set_affine_hull(
4073 __isl_take isl_set *set);
4074 __isl_give isl_union_set *isl_union_set_affine_hull(
4075 __isl_take isl_union_set *uset);
4076 __isl_give isl_basic_map *isl_basic_map_affine_hull(
4077 __isl_take isl_basic_map *bmap);
4078 __isl_give isl_basic_map *isl_map_affine_hull(
4079 __isl_take isl_map *map);
4080 __isl_give isl_union_map *isl_union_map_affine_hull(
4081 __isl_take isl_union_map *umap);
4083 In case of union sets and relations, the affine hull is computed
4086 =item * Polyhedral hull
4088 __isl_give isl_basic_set *isl_set_polyhedral_hull(
4089 __isl_take isl_set *set);
4090 __isl_give isl_basic_map *isl_map_polyhedral_hull(
4091 __isl_take isl_map *map);
4092 __isl_give isl_union_set *isl_union_set_polyhedral_hull(
4093 __isl_take isl_union_set *uset);
4094 __isl_give isl_union_map *isl_union_map_polyhedral_hull(
4095 __isl_take isl_union_map *umap);
4097 These functions compute a single basic set or relation
4098 not involving any existentially quantified variables
4099 that contains the whole input set or relation.
4100 In case of union sets and relations, the polyhedral hull is computed
4103 =item * Other approximations
4105 #include <isl/set.h>
4106 __isl_give isl_basic_set *
4107 isl_basic_set_drop_constraints_involving_dims(
4108 __isl_take isl_basic_set *bset,
4109 enum isl_dim_type type,
4110 unsigned first, unsigned n);
4111 __isl_give isl_basic_set *
4112 isl_basic_set_drop_constraints_not_involving_dims(
4113 __isl_take isl_basic_set *bset,
4114 enum isl_dim_type type,
4115 unsigned first, unsigned n);
4116 __isl_give isl_set *
4117 isl_set_drop_constraints_involving_dims(
4118 __isl_take isl_set *set,
4119 enum isl_dim_type type,
4120 unsigned first, unsigned n);
4122 #include <isl/map.h>
4123 __isl_give isl_basic_map *
4124 isl_basic_map_drop_constraints_involving_dims(
4125 __isl_take isl_basic_map *bmap,
4126 enum isl_dim_type type,
4127 unsigned first, unsigned n);
4128 __isl_give isl_map *
4129 isl_map_drop_constraints_involving_dims(
4130 __isl_take isl_map *map,
4131 enum isl_dim_type type,
4132 unsigned first, unsigned n);
4134 These functions drop any constraints (not) involving the specified dimensions.
4135 Note that the result depends on the representation of the input.
4137 #include <isl/polynomial.h>
4138 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_to_polynomial(
4139 __isl_take isl_pw_qpolynomial *pwqp, int sign);
4140 __isl_give isl_union_pw_qpolynomial *
4141 isl_union_pw_qpolynomial_to_polynomial(
4142 __isl_take isl_union_pw_qpolynomial *upwqp, int sign);
4144 Approximate each quasipolynomial by a polynomial. If C<sign> is positive,
4145 the polynomial will be an overapproximation. If C<sign> is negative,
4146 it will be an underapproximation. If C<sign> is zero, the approximation
4147 will lie somewhere in between.
4151 __isl_give isl_basic_set *isl_basic_set_sample(
4152 __isl_take isl_basic_set *bset);
4153 __isl_give isl_basic_set *isl_set_sample(
4154 __isl_take isl_set *set);
4155 __isl_give isl_basic_map *isl_basic_map_sample(
4156 __isl_take isl_basic_map *bmap);
4157 __isl_give isl_basic_map *isl_map_sample(
4158 __isl_take isl_map *map);
4160 If the input (basic) set or relation is non-empty, then return
4161 a singleton subset of the input. Otherwise, return an empty set.
4163 =item * Optimization
4165 #include <isl/ilp.h>
4166 __isl_give isl_val *isl_basic_set_max_val(
4167 __isl_keep isl_basic_set *bset,
4168 __isl_keep isl_aff *obj);
4169 __isl_give isl_val *isl_set_min_val(
4170 __isl_keep isl_set *set,
4171 __isl_keep isl_aff *obj);
4172 __isl_give isl_val *isl_set_max_val(
4173 __isl_keep isl_set *set,
4174 __isl_keep isl_aff *obj);
4176 Compute the minimum or maximum of the integer affine expression C<obj>
4177 over the points in C<set>, returning the result in C<opt>.
4178 The result is C<NULL> in case of an error, the optimal value in case
4179 there is one, negative infinity or infinity if the problem is unbounded and
4180 NaN if the problem is empty.
4182 =item * Parametric optimization
4184 __isl_give isl_pw_aff *isl_set_dim_min(
4185 __isl_take isl_set *set, int pos);
4186 __isl_give isl_pw_aff *isl_set_dim_max(
4187 __isl_take isl_set *set, int pos);
4188 __isl_give isl_pw_aff *isl_map_dim_max(
4189 __isl_take isl_map *map, int pos);
4191 Compute the minimum or maximum of the given set or output dimension
4192 as a function of the parameters (and input dimensions), but independently
4193 of the other set or output dimensions.
4194 For lexicographic optimization, see L<"Lexicographic Optimization">.
4198 The following functions compute either the set of (rational) coefficient
4199 values of valid constraints for the given set or the set of (rational)
4200 values satisfying the constraints with coefficients from the given set.
4201 Internally, these two sets of functions perform essentially the
4202 same operations, except that the set of coefficients is assumed to
4203 be a cone, while the set of values may be any polyhedron.
4204 The current implementation is based on the Farkas lemma and
4205 Fourier-Motzkin elimination, but this may change or be made optional
4206 in future. In particular, future implementations may use different
4207 dualization algorithms or skip the elimination step.
4209 __isl_give isl_basic_set *isl_basic_set_coefficients(
4210 __isl_take isl_basic_set *bset);
4211 __isl_give isl_basic_set *isl_set_coefficients(
4212 __isl_take isl_set *set);
4213 __isl_give isl_union_set *isl_union_set_coefficients(
4214 __isl_take isl_union_set *bset);
4215 __isl_give isl_basic_set *isl_basic_set_solutions(
4216 __isl_take isl_basic_set *bset);
4217 __isl_give isl_basic_set *isl_set_solutions(
4218 __isl_take isl_set *set);
4219 __isl_give isl_union_set *isl_union_set_solutions(
4220 __isl_take isl_union_set *bset);
4224 __isl_give isl_map *isl_map_fixed_power_val(
4225 __isl_take isl_map *map,
4226 __isl_take isl_val *exp);
4227 __isl_give isl_union_map *
4228 isl_union_map_fixed_power_val(
4229 __isl_take isl_union_map *umap,
4230 __isl_take isl_val *exp);
4232 Compute the given power of C<map>, where C<exp> is assumed to be non-zero.
4233 If the exponent C<exp> is negative, then the -C<exp> th power of the inverse
4234 of C<map> is computed.
4236 __isl_give isl_map *isl_map_power(__isl_take isl_map *map,
4238 __isl_give isl_union_map *isl_union_map_power(
4239 __isl_take isl_union_map *umap, int *exact);
4241 Compute a parametric representation for all positive powers I<k> of C<map>.
4242 The result maps I<k> to a nested relation corresponding to the
4243 I<k>th power of C<map>.
4244 The result may be an overapproximation. If the result is known to be exact,
4245 then C<*exact> is set to C<1>.
4247 =item * Transitive closure
4249 __isl_give isl_map *isl_map_transitive_closure(
4250 __isl_take isl_map *map, int *exact);
4251 __isl_give isl_union_map *isl_union_map_transitive_closure(
4252 __isl_take isl_union_map *umap, int *exact);
4254 Compute the transitive closure of C<map>.
4255 The result may be an overapproximation. If the result is known to be exact,
4256 then C<*exact> is set to C<1>.
4258 =item * Reaching path lengths
4260 __isl_give isl_map *isl_map_reaching_path_lengths(
4261 __isl_take isl_map *map, int *exact);
4263 Compute a relation that maps each element in the range of C<map>
4264 to the lengths of all paths composed of edges in C<map> that
4265 end up in the given element.
4266 The result may be an overapproximation. If the result is known to be exact,
4267 then C<*exact> is set to C<1>.
4268 To compute the I<maximal> path length, the resulting relation
4269 should be postprocessed by C<isl_map_lexmax>.
4270 In particular, if the input relation is a dependence relation
4271 (mapping sources to sinks), then the maximal path length corresponds
4272 to the free schedule.
4273 Note, however, that C<isl_map_lexmax> expects the maximum to be
4274 finite, so if the path lengths are unbounded (possibly due to
4275 the overapproximation), then you will get an error message.
4279 #include <isl/space.h>
4280 __isl_give isl_space *isl_space_wrap(
4281 __isl_take isl_space *space);
4282 __isl_give isl_space *isl_space_unwrap(
4283 __isl_take isl_space *space);
4285 #include <isl/set.h>
4286 __isl_give isl_basic_map *isl_basic_set_unwrap(
4287 __isl_take isl_basic_set *bset);
4288 __isl_give isl_map *isl_set_unwrap(
4289 __isl_take isl_set *set);
4291 #include <isl/map.h>
4292 __isl_give isl_basic_set *isl_basic_map_wrap(
4293 __isl_take isl_basic_map *bmap);
4294 __isl_give isl_set *isl_map_wrap(
4295 __isl_take isl_map *map);
4297 #include <isl/union_set.h>
4298 __isl_give isl_union_map *isl_union_set_unwrap(
4299 __isl_take isl_union_set *uset);
4301 #include <isl/union_map.h>
4302 __isl_give isl_union_set *isl_union_map_wrap(
4303 __isl_take isl_union_map *umap);
4305 The input to C<isl_space_unwrap> should
4306 be the space of a set, while that of
4307 C<isl_space_wrap> should be the space of a relation.
4308 Conversely, the output of C<isl_space_unwrap> is the space
4309 of a relation, while that of C<isl_space_wrap> is the space of a set.
4313 Remove any internal structure of domain (and range) of the given
4314 set or relation. If there is any such internal structure in the input,
4315 then the name of the space is also removed.
4317 #include <isl/local_space.h>
4318 __isl_give isl_local_space *
4319 isl_local_space_flatten_domain(
4320 __isl_take isl_local_space *ls);
4321 __isl_give isl_local_space *
4322 isl_local_space_flatten_range(
4323 __isl_take isl_local_space *ls);
4325 #include <isl/set.h>
4326 __isl_give isl_basic_set *isl_basic_set_flatten(
4327 __isl_take isl_basic_set *bset);
4328 __isl_give isl_set *isl_set_flatten(
4329 __isl_take isl_set *set);
4331 #include <isl/map.h>
4332 __isl_give isl_basic_map *isl_basic_map_flatten_domain(
4333 __isl_take isl_basic_map *bmap);
4334 __isl_give isl_basic_map *isl_basic_map_flatten_range(
4335 __isl_take isl_basic_map *bmap);
4336 __isl_give isl_map *isl_map_flatten_range(
4337 __isl_take isl_map *map);
4338 __isl_give isl_map *isl_map_flatten_domain(
4339 __isl_take isl_map *map);
4340 __isl_give isl_basic_map *isl_basic_map_flatten(
4341 __isl_take isl_basic_map *bmap);
4342 __isl_give isl_map *isl_map_flatten(
4343 __isl_take isl_map *map);
4345 #include <isl/aff.h>
4346 __isl_give isl_multi_aff *isl_multi_aff_flatten_domain(
4347 __isl_take isl_multi_aff *ma);
4349 #include <isl/map.h>
4350 __isl_give isl_map *isl_set_flatten_map(
4351 __isl_take isl_set *set);
4353 The function above constructs a relation
4354 that maps the input set to a flattened version of the set.
4358 Lift the input set to a space with extra dimensions corresponding
4359 to the existentially quantified variables in the input.
4360 In particular, the result lives in a wrapped map where the domain
4361 is the original space and the range corresponds to the original
4362 existentially quantified variables.
4364 #include <isl/set.h>
4365 __isl_give isl_basic_set *isl_basic_set_lift(
4366 __isl_take isl_basic_set *bset);
4367 __isl_give isl_set *isl_set_lift(
4368 __isl_take isl_set *set);
4369 __isl_give isl_union_set *isl_union_set_lift(
4370 __isl_take isl_union_set *uset);
4372 Given a local space that contains the existentially quantified
4373 variables of a set, a basic relation that, when applied to
4374 a basic set, has essentially the same effect as C<isl_basic_set_lift>,
4375 can be constructed using the following function.
4377 #include <isl/local_space.h>
4378 __isl_give isl_basic_map *isl_local_space_lifting(
4379 __isl_take isl_local_space *ls);
4381 #include <isl/aff.h>
4382 __isl_give isl_multi_aff *isl_multi_aff_lift(
4383 __isl_take isl_multi_aff *maff,
4384 __isl_give isl_local_space **ls);
4386 If the C<ls> argument of C<isl_multi_aff_lift> is not C<NULL>,
4387 then it is assigned the local space that lies at the basis of
4388 the lifting applied.
4390 =item * Internal Product
4392 #include <isl/space.h>
4393 __isl_give isl_space *isl_space_zip(
4394 __isl_take isl_space *space);
4396 #include <isl/map.h>
4397 __isl_give isl_basic_map *isl_basic_map_zip(
4398 __isl_take isl_basic_map *bmap);
4399 __isl_give isl_map *isl_map_zip(
4400 __isl_take isl_map *map);
4402 #include <isl/union_map.h>
4403 __isl_give isl_union_map *isl_union_map_zip(
4404 __isl_take isl_union_map *umap);
4406 Given a relation with nested relations for domain and range,
4407 interchange the range of the domain with the domain of the range.
4411 #include <isl/space.h>
4412 __isl_give isl_space *isl_space_curry(
4413 __isl_take isl_space *space);
4414 __isl_give isl_space *isl_space_uncurry(
4415 __isl_take isl_space *space);
4417 #include <isl/map.h>
4418 __isl_give isl_basic_map *isl_basic_map_curry(
4419 __isl_take isl_basic_map *bmap);
4420 __isl_give isl_basic_map *isl_basic_map_uncurry(
4421 __isl_take isl_basic_map *bmap);
4422 __isl_give isl_map *isl_map_curry(
4423 __isl_take isl_map *map);
4424 __isl_give isl_map *isl_map_uncurry(
4425 __isl_take isl_map *map);
4427 #include <isl/union_map.h>
4428 __isl_give isl_union_map *isl_union_map_curry(
4429 __isl_take isl_union_map *umap);
4430 __isl_give isl_union_map *isl_union_map_uncurry(
4431 __isl_take isl_union_map *umap);
4433 Given a relation with a nested relation for domain,
4434 the C<curry> functions
4435 move the range of the nested relation out of the domain
4436 and use it as the domain of a nested relation in the range,
4437 with the original range as range of this nested relation.
4438 The C<uncurry> functions perform the inverse operation.
4440 =item * Aligning parameters
4442 Change the order of the parameters of the given set, relation
4444 such that the first parameters match those of C<model>.
4445 This may involve the introduction of extra parameters.
4446 All parameters need to be named.
4448 #include <isl/space.h>
4449 __isl_give isl_space *isl_space_align_params(
4450 __isl_take isl_space *space1,
4451 __isl_take isl_space *space2)
4453 #include <isl/set.h>
4454 __isl_give isl_basic_set *isl_basic_set_align_params(
4455 __isl_take isl_basic_set *bset,
4456 __isl_take isl_space *model);
4457 __isl_give isl_set *isl_set_align_params(
4458 __isl_take isl_set *set,
4459 __isl_take isl_space *model);
4461 #include <isl/map.h>
4462 __isl_give isl_basic_map *isl_basic_map_align_params(
4463 __isl_take isl_basic_map *bmap,
4464 __isl_take isl_space *model);
4465 __isl_give isl_map *isl_map_align_params(
4466 __isl_take isl_map *map,
4467 __isl_take isl_space *model);
4469 #include <isl/val.h>
4470 __isl_give isl_multi_val *isl_multi_val_align_params(
4471 __isl_take isl_multi_val *mv,
4472 __isl_take isl_space *model);
4474 #include <isl/aff.h>
4475 __isl_give isl_aff *isl_aff_align_params(
4476 __isl_take isl_aff *aff,
4477 __isl_take isl_space *model);
4478 __isl_give isl_multi_aff *isl_multi_aff_align_params(
4479 __isl_take isl_multi_aff *multi,
4480 __isl_take isl_space *model);
4481 __isl_give isl_pw_aff *isl_pw_aff_align_params(
4482 __isl_take isl_pw_aff *pwaff,
4483 __isl_take isl_space *model);
4484 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_align_params(
4485 __isl_take isl_pw_multi_aff *pma,
4486 __isl_take isl_space *model);
4487 __isl_give isl_union_pw_multi_aff *
4488 isl_union_pw_multi_aff_align_params(
4489 __isl_take isl_union_pw_multi_aff *upma,
4490 __isl_take isl_space *model);
4492 #include <isl/polynomial.h>
4493 __isl_give isl_qpolynomial *isl_qpolynomial_align_params(
4494 __isl_take isl_qpolynomial *qp,
4495 __isl_take isl_space *model);
4497 =item * Unary Arithmethic Operations
4499 #include <isl/aff.h>
4500 __isl_give isl_aff *isl_aff_neg(
4501 __isl_take isl_aff *aff);
4502 __isl_give isl_pw_aff *isl_pw_aff_neg(
4503 __isl_take isl_pw_aff *pwaff);
4504 __isl_give isl_aff *isl_aff_ceil(
4505 __isl_take isl_aff *aff);
4506 __isl_give isl_pw_aff *isl_pw_aff_ceil(
4507 __isl_take isl_pw_aff *pwaff);
4508 __isl_give isl_aff *isl_aff_floor(
4509 __isl_take isl_aff *aff);
4510 __isl_give isl_multi_aff *isl_multi_aff_floor(
4511 __isl_take isl_multi_aff *ma);
4512 __isl_give isl_pw_aff *isl_pw_aff_floor(
4513 __isl_take isl_pw_aff *pwaff);
4515 #include <isl/aff.h>
4516 __isl_give isl_pw_aff *isl_pw_aff_list_min(
4517 __isl_take isl_pw_aff_list *list);
4518 __isl_give isl_pw_aff *isl_pw_aff_list_max(
4519 __isl_take isl_pw_aff_list *list);
4521 #include <isl/polynomial.h>
4522 __isl_give isl_qpolynomial *isl_qpolynomial_neg(
4523 __isl_take isl_qpolynomial *qp);
4524 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg(
4525 __isl_take isl_pw_qpolynomial *pwqp);
4526 __isl_give isl_qpolynomial *isl_qpolynomial_pow(
4527 __isl_take isl_qpolynomial *qp,
4529 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_pow(
4530 __isl_take isl_pw_qpolynomial *pwqp,
4535 The following functions evaluate a function in a point.
4537 #include <isl/polynomial.h>
4538 __isl_give isl_val *isl_pw_qpolynomial_eval(
4539 __isl_take isl_pw_qpolynomial *pwqp,
4540 __isl_take isl_point *pnt);
4541 __isl_give isl_val *isl_pw_qpolynomial_fold_eval(
4542 __isl_take isl_pw_qpolynomial_fold *pwf,
4543 __isl_take isl_point *pnt);
4544 __isl_give isl_val *isl_union_pw_qpolynomial_eval(
4545 __isl_take isl_union_pw_qpolynomial *upwqp,
4546 __isl_take isl_point *pnt);
4547 __isl_give isl_val *isl_union_pw_qpolynomial_fold_eval(
4548 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4549 __isl_take isl_point *pnt);
4551 =item * Dimension manipulation
4553 It is usually not advisable to directly change the (input or output)
4554 space of a set or a relation as this removes the name and the internal
4555 structure of the space. However, the functions below can be useful
4556 to add new parameters, assuming
4557 C<isl_set_align_params> and C<isl_map_align_params>
4560 #include <isl/space.h>
4561 __isl_give isl_space *isl_space_add_dims(
4562 __isl_take isl_space *space,
4563 enum isl_dim_type type, unsigned n);
4564 __isl_give isl_space *isl_space_insert_dims(
4565 __isl_take isl_space *space,
4566 enum isl_dim_type type, unsigned pos, unsigned n);
4567 __isl_give isl_space *isl_space_drop_dims(
4568 __isl_take isl_space *space,
4569 enum isl_dim_type type, unsigned first, unsigned n);
4570 __isl_give isl_space *isl_space_move_dims(
4571 __isl_take isl_space *space,
4572 enum isl_dim_type dst_type, unsigned dst_pos,
4573 enum isl_dim_type src_type, unsigned src_pos,
4576 #include <isl/local_space.h>
4577 __isl_give isl_local_space *isl_local_space_add_dims(
4578 __isl_take isl_local_space *ls,
4579 enum isl_dim_type type, unsigned n);
4580 __isl_give isl_local_space *isl_local_space_insert_dims(
4581 __isl_take isl_local_space *ls,
4582 enum isl_dim_type type, unsigned first, unsigned n);
4583 __isl_give isl_local_space *isl_local_space_drop_dims(
4584 __isl_take isl_local_space *ls,
4585 enum isl_dim_type type, unsigned first, unsigned n);
4587 #include <isl/set.h>
4588 __isl_give isl_basic_set *isl_basic_set_add_dims(
4589 __isl_take isl_basic_set *bset,
4590 enum isl_dim_type type, unsigned n);
4591 __isl_give isl_set *isl_set_add_dims(
4592 __isl_take isl_set *set,
4593 enum isl_dim_type type, unsigned n);
4594 __isl_give isl_basic_set *isl_basic_set_insert_dims(
4595 __isl_take isl_basic_set *bset,
4596 enum isl_dim_type type, unsigned pos,
4598 __isl_give isl_set *isl_set_insert_dims(
4599 __isl_take isl_set *set,
4600 enum isl_dim_type type, unsigned pos, unsigned n);
4601 __isl_give isl_basic_set *isl_basic_set_move_dims(
4602 __isl_take isl_basic_set *bset,
4603 enum isl_dim_type dst_type, unsigned dst_pos,
4604 enum isl_dim_type src_type, unsigned src_pos,
4606 __isl_give isl_set *isl_set_move_dims(
4607 __isl_take isl_set *set,
4608 enum isl_dim_type dst_type, unsigned dst_pos,
4609 enum isl_dim_type src_type, unsigned src_pos,
4612 #include <isl/map.h>
4613 __isl_give isl_map *isl_map_add_dims(
4614 __isl_take isl_map *map,
4615 enum isl_dim_type type, unsigned n);
4616 __isl_give isl_basic_map *isl_basic_map_insert_dims(
4617 __isl_take isl_basic_map *bmap,
4618 enum isl_dim_type type, unsigned pos,
4620 __isl_give isl_map *isl_map_insert_dims(
4621 __isl_take isl_map *map,
4622 enum isl_dim_type type, unsigned pos, unsigned n);
4623 __isl_give isl_basic_map *isl_basic_map_move_dims(
4624 __isl_take isl_basic_map *bmap,
4625 enum isl_dim_type dst_type, unsigned dst_pos,
4626 enum isl_dim_type src_type, unsigned src_pos,
4628 __isl_give isl_map *isl_map_move_dims(
4629 __isl_take isl_map *map,
4630 enum isl_dim_type dst_type, unsigned dst_pos,
4631 enum isl_dim_type src_type, unsigned src_pos,
4634 #include <isl/val.h>
4635 __isl_give isl_multi_val *isl_multi_val_insert_dims(
4636 __isl_take isl_multi_val *mv,
4637 enum isl_dim_type type, unsigned first, unsigned n);
4638 __isl_give isl_multi_val *isl_multi_val_add_dims(
4639 __isl_take isl_multi_val *mv,
4640 enum isl_dim_type type, unsigned n);
4641 __isl_give isl_multi_val *isl_multi_val_drop_dims(
4642 __isl_take isl_multi_val *mv,
4643 enum isl_dim_type type, unsigned first, unsigned n);
4645 #include <isl/aff.h>
4646 __isl_give isl_aff *isl_aff_insert_dims(
4647 __isl_take isl_aff *aff,
4648 enum isl_dim_type type, unsigned first, unsigned n);
4649 __isl_give isl_multi_aff *isl_multi_aff_insert_dims(
4650 __isl_take isl_multi_aff *ma,
4651 enum isl_dim_type type, unsigned first, unsigned n);
4652 __isl_give isl_pw_aff *isl_pw_aff_insert_dims(
4653 __isl_take isl_pw_aff *pwaff,
4654 enum isl_dim_type type, unsigned first, unsigned n);
4655 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_insert_dims(
4656 __isl_take isl_multi_pw_aff *mpa,
4657 enum isl_dim_type type, unsigned first, unsigned n);
4658 __isl_give isl_aff *isl_aff_add_dims(
4659 __isl_take isl_aff *aff,
4660 enum isl_dim_type type, unsigned n);
4661 __isl_give isl_multi_aff *isl_multi_aff_add_dims(
4662 __isl_take isl_multi_aff *ma,
4663 enum isl_dim_type type, unsigned n);
4664 __isl_give isl_pw_aff *isl_pw_aff_add_dims(
4665 __isl_take isl_pw_aff *pwaff,
4666 enum isl_dim_type type, unsigned n);
4667 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_add_dims(
4668 __isl_take isl_multi_pw_aff *mpa,
4669 enum isl_dim_type type, unsigned n);
4670 __isl_give isl_aff *isl_aff_drop_dims(
4671 __isl_take isl_aff *aff,
4672 enum isl_dim_type type, unsigned first, unsigned n);
4673 __isl_give isl_multi_aff *isl_multi_aff_drop_dims(
4674 __isl_take isl_multi_aff *maff,
4675 enum isl_dim_type type, unsigned first, unsigned n);
4676 __isl_give isl_pw_aff *isl_pw_aff_drop_dims(
4677 __isl_take isl_pw_aff *pwaff,
4678 enum isl_dim_type type, unsigned first, unsigned n);
4679 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_drop_dims(
4680 __isl_take isl_pw_multi_aff *pma,
4681 enum isl_dim_type type, unsigned first, unsigned n);
4682 __isl_give isl_aff *isl_aff_move_dims(
4683 __isl_take isl_aff *aff,
4684 enum isl_dim_type dst_type, unsigned dst_pos,
4685 enum isl_dim_type src_type, unsigned src_pos,
4687 __isl_give isl_pw_aff *isl_pw_aff_move_dims(
4688 __isl_take isl_pw_aff *pa,
4689 enum isl_dim_type dst_type, unsigned dst_pos,
4690 enum isl_dim_type src_type, unsigned src_pos,
4692 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_move_dims(
4693 __isl_take isl_multi_pw_aff *pma,
4694 enum isl_dim_type dst_type, unsigned dst_pos,
4695 enum isl_dim_type src_type, unsigned src_pos,
4700 =head2 Binary Operations
4702 The two arguments of a binary operation not only need to live
4703 in the same C<isl_ctx>, they currently also need to have
4704 the same (number of) parameters.
4706 =head3 Basic Operations
4710 =item * Intersection
4712 #include <isl/local_space.h>
4713 __isl_give isl_local_space *isl_local_space_intersect(
4714 __isl_take isl_local_space *ls1,
4715 __isl_take isl_local_space *ls2);
4717 #include <isl/set.h>
4718 __isl_give isl_basic_set *isl_basic_set_intersect_params(
4719 __isl_take isl_basic_set *bset1,
4720 __isl_take isl_basic_set *bset2);
4721 __isl_give isl_basic_set *isl_basic_set_intersect(
4722 __isl_take isl_basic_set *bset1,
4723 __isl_take isl_basic_set *bset2);
4724 __isl_give isl_basic_set *isl_basic_set_list_intersect(
4725 __isl_take struct isl_basic_set_list *list);
4726 __isl_give isl_set *isl_set_intersect_params(
4727 __isl_take isl_set *set,
4728 __isl_take isl_set *params);
4729 __isl_give isl_set *isl_set_intersect(
4730 __isl_take isl_set *set1,
4731 __isl_take isl_set *set2);
4733 #include <isl/map.h>
4734 __isl_give isl_basic_map *isl_basic_map_intersect_domain(
4735 __isl_take isl_basic_map *bmap,
4736 __isl_take isl_basic_set *bset);
4737 __isl_give isl_basic_map *isl_basic_map_intersect_range(
4738 __isl_take isl_basic_map *bmap,
4739 __isl_take isl_basic_set *bset);
4740 __isl_give isl_basic_map *isl_basic_map_intersect(
4741 __isl_take isl_basic_map *bmap1,
4742 __isl_take isl_basic_map *bmap2);
4743 __isl_give isl_map *isl_map_intersect_params(
4744 __isl_take isl_map *map,
4745 __isl_take isl_set *params);
4746 __isl_give isl_map *isl_map_intersect_domain(
4747 __isl_take isl_map *map,
4748 __isl_take isl_set *set);
4749 __isl_give isl_map *isl_map_intersect_range(
4750 __isl_take isl_map *map,
4751 __isl_take isl_set *set);
4752 __isl_give isl_map *isl_map_intersect(
4753 __isl_take isl_map *map1,
4754 __isl_take isl_map *map2);
4756 #include <isl/union_set.h>
4757 __isl_give isl_union_set *isl_union_set_intersect_params(
4758 __isl_take isl_union_set *uset,
4759 __isl_take isl_set *set);
4760 __isl_give isl_union_set *isl_union_set_intersect(
4761 __isl_take isl_union_set *uset1,
4762 __isl_take isl_union_set *uset2);
4764 #include <isl/union_map.h>
4765 __isl_give isl_union_map *isl_union_map_intersect_params(
4766 __isl_take isl_union_map *umap,
4767 __isl_take isl_set *set);
4768 __isl_give isl_union_map *isl_union_map_intersect_domain(
4769 __isl_take isl_union_map *umap,
4770 __isl_take isl_union_set *uset);
4771 __isl_give isl_union_map *isl_union_map_intersect_range(
4772 __isl_take isl_union_map *umap,
4773 __isl_take isl_union_set *uset);
4774 __isl_give isl_union_map *isl_union_map_intersect(
4775 __isl_take isl_union_map *umap1,
4776 __isl_take isl_union_map *umap2);
4778 #include <isl/aff.h>
4779 __isl_give isl_pw_aff *isl_pw_aff_intersect_domain(
4780 __isl_take isl_pw_aff *pa,
4781 __isl_take isl_set *set);
4782 __isl_give isl_multi_pw_aff *
4783 isl_multi_pw_aff_intersect_domain(
4784 __isl_take isl_multi_pw_aff *mpa,
4785 __isl_take isl_set *domain);
4786 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_domain(
4787 __isl_take isl_pw_multi_aff *pma,
4788 __isl_take isl_set *set);
4789 __isl_give isl_union_pw_multi_aff *
4790 isl_union_pw_multi_aff_intersect_domain(
4791 __isl_take isl_union_pw_multi_aff *upma,
4792 __isl_take isl_union_set *uset);
4793 __isl_give isl_pw_aff *isl_pw_aff_intersect_params(
4794 __isl_take isl_pw_aff *pa,
4795 __isl_take isl_set *set);
4796 __isl_give isl_multi_pw_aff *
4797 isl_multi_pw_aff_intersect_params(
4798 __isl_take isl_multi_pw_aff *mpa,
4799 __isl_take isl_set *set);
4800 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_params(
4801 __isl_take isl_pw_multi_aff *pma,
4802 __isl_take isl_set *set);
4804 #include <isl/polynomial.h>
4805 __isl_give isl_pw_qpolynomial *
4806 isl_pw_qpolynomial_intersect_domain(
4807 __isl_take isl_pw_qpolynomial *pwpq,
4808 __isl_take isl_set *set);
4809 __isl_give isl_union_pw_qpolynomial *
4810 isl_union_pw_qpolynomial_intersect_domain(
4811 __isl_take isl_union_pw_qpolynomial *upwpq,
4812 __isl_take isl_union_set *uset);
4813 __isl_give isl_union_pw_qpolynomial_fold *
4814 isl_union_pw_qpolynomial_fold_intersect_domain(
4815 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4816 __isl_take isl_union_set *uset);
4817 __isl_give isl_pw_qpolynomial *
4818 isl_pw_qpolynomial_intersect_params(
4819 __isl_take isl_pw_qpolynomial *pwpq,
4820 __isl_take isl_set *set);
4821 __isl_give isl_pw_qpolynomial_fold *
4822 isl_pw_qpolynomial_fold_intersect_params(
4823 __isl_take isl_pw_qpolynomial_fold *pwf,
4824 __isl_take isl_set *set);
4825 __isl_give isl_union_pw_qpolynomial *
4826 isl_union_pw_qpolynomial_intersect_params(
4827 __isl_take isl_union_pw_qpolynomial *upwpq,
4828 __isl_take isl_set *set);
4829 __isl_give isl_union_pw_qpolynomial_fold *
4830 isl_union_pw_qpolynomial_fold_intersect_params(
4831 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4832 __isl_take isl_set *set);
4834 The second argument to the C<_params> functions needs to be
4835 a parametric (basic) set. For the other functions, a parametric set
4836 for either argument is only allowed if the other argument is
4837 a parametric set as well.
4838 The list passed to C<isl_basic_set_list_intersect> needs to have
4839 at least one element and all elements need to live in the same space.
4843 __isl_give isl_set *isl_basic_set_union(
4844 __isl_take isl_basic_set *bset1,
4845 __isl_take isl_basic_set *bset2);
4846 __isl_give isl_map *isl_basic_map_union(
4847 __isl_take isl_basic_map *bmap1,
4848 __isl_take isl_basic_map *bmap2);
4849 __isl_give isl_set *isl_set_union(
4850 __isl_take isl_set *set1,
4851 __isl_take isl_set *set2);
4852 __isl_give isl_map *isl_map_union(
4853 __isl_take isl_map *map1,
4854 __isl_take isl_map *map2);
4855 __isl_give isl_union_set *isl_union_set_union(
4856 __isl_take isl_union_set *uset1,
4857 __isl_take isl_union_set *uset2);
4858 __isl_give isl_union_map *isl_union_map_union(
4859 __isl_take isl_union_map *umap1,
4860 __isl_take isl_union_map *umap2);
4862 =item * Set difference
4864 __isl_give isl_set *isl_set_subtract(
4865 __isl_take isl_set *set1,
4866 __isl_take isl_set *set2);
4867 __isl_give isl_map *isl_map_subtract(
4868 __isl_take isl_map *map1,
4869 __isl_take isl_map *map2);
4870 __isl_give isl_map *isl_map_subtract_domain(
4871 __isl_take isl_map *map,
4872 __isl_take isl_set *dom);
4873 __isl_give isl_map *isl_map_subtract_range(
4874 __isl_take isl_map *map,
4875 __isl_take isl_set *dom);
4876 __isl_give isl_union_set *isl_union_set_subtract(
4877 __isl_take isl_union_set *uset1,
4878 __isl_take isl_union_set *uset2);
4879 __isl_give isl_union_map *isl_union_map_subtract(
4880 __isl_take isl_union_map *umap1,
4881 __isl_take isl_union_map *umap2);
4882 __isl_give isl_union_map *isl_union_map_subtract_domain(
4883 __isl_take isl_union_map *umap,
4884 __isl_take isl_union_set *dom);
4885 __isl_give isl_union_map *isl_union_map_subtract_range(
4886 __isl_take isl_union_map *umap,
4887 __isl_take isl_union_set *dom);
4891 #include <isl/space.h>
4892 __isl_give isl_space *isl_space_join(
4893 __isl_take isl_space *left,
4894 __isl_take isl_space *right);
4896 #include <isl/map.h>
4897 __isl_give isl_basic_set *isl_basic_set_apply(
4898 __isl_take isl_basic_set *bset,
4899 __isl_take isl_basic_map *bmap);
4900 __isl_give isl_set *isl_set_apply(
4901 __isl_take isl_set *set,
4902 __isl_take isl_map *map);
4903 __isl_give isl_union_set *isl_union_set_apply(
4904 __isl_take isl_union_set *uset,
4905 __isl_take isl_union_map *umap);
4906 __isl_give isl_basic_map *isl_basic_map_apply_domain(
4907 __isl_take isl_basic_map *bmap1,
4908 __isl_take isl_basic_map *bmap2);
4909 __isl_give isl_basic_map *isl_basic_map_apply_range(
4910 __isl_take isl_basic_map *bmap1,
4911 __isl_take isl_basic_map *bmap2);
4912 __isl_give isl_map *isl_map_apply_domain(
4913 __isl_take isl_map *map1,
4914 __isl_take isl_map *map2);
4915 __isl_give isl_map *isl_map_apply_range(
4916 __isl_take isl_map *map1,
4917 __isl_take isl_map *map2);
4919 #include <isl/union_map.h>
4920 __isl_give isl_union_map *isl_union_map_apply_domain(
4921 __isl_take isl_union_map *umap1,
4922 __isl_take isl_union_map *umap2);
4923 __isl_give isl_union_map *isl_union_map_apply_range(
4924 __isl_take isl_union_map *umap1,
4925 __isl_take isl_union_map *umap2);
4927 #include <isl/polynomial.h>
4928 __isl_give isl_pw_qpolynomial_fold *
4929 isl_set_apply_pw_qpolynomial_fold(
4930 __isl_take isl_set *set,
4931 __isl_take isl_pw_qpolynomial_fold *pwf,
4933 __isl_give isl_pw_qpolynomial_fold *
4934 isl_map_apply_pw_qpolynomial_fold(
4935 __isl_take isl_map *map,
4936 __isl_take isl_pw_qpolynomial_fold *pwf,
4938 __isl_give isl_union_pw_qpolynomial_fold *
4939 isl_union_set_apply_union_pw_qpolynomial_fold(
4940 __isl_take isl_union_set *uset,
4941 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4943 __isl_give isl_union_pw_qpolynomial_fold *
4944 isl_union_map_apply_union_pw_qpolynomial_fold(
4945 __isl_take isl_union_map *umap,
4946 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4949 The functions taking a map
4950 compose the given map with the given piecewise quasipolynomial reduction.
4951 That is, compute a bound (of the same type as C<pwf> or C<upwf> itself)
4952 over all elements in the intersection of the range of the map
4953 and the domain of the piecewise quasipolynomial reduction
4954 as a function of an element in the domain of the map.
4955 The functions taking a set compute a bound over all elements in the
4956 intersection of the set and the domain of the
4957 piecewise quasipolynomial reduction.
4961 #include <isl/set.h>
4962 __isl_give isl_basic_set *
4963 isl_basic_set_preimage_multi_aff(
4964 __isl_take isl_basic_set *bset,
4965 __isl_take isl_multi_aff *ma);
4966 __isl_give isl_set *isl_set_preimage_multi_aff(
4967 __isl_take isl_set *set,
4968 __isl_take isl_multi_aff *ma);
4969 __isl_give isl_set *isl_set_preimage_pw_multi_aff(
4970 __isl_take isl_set *set,
4971 __isl_take isl_pw_multi_aff *pma);
4972 __isl_give isl_set *isl_set_preimage_multi_pw_aff(
4973 __isl_take isl_set *set,
4974 __isl_take isl_multi_pw_aff *mpa);
4976 #include <isl/union_set.h>
4977 __isl_give isl_union_set *
4978 isl_union_set_preimage_multi_aff(
4979 __isl_take isl_union_set *uset,
4980 __isl_take isl_multi_aff *ma);
4981 __isl_give isl_union_set *
4982 isl_union_set_preimage_pw_multi_aff(
4983 __isl_take isl_union_set *uset,
4984 __isl_take isl_pw_multi_aff *pma);
4985 __isl_give isl_union_set *
4986 isl_union_set_preimage_union_pw_multi_aff(
4987 __isl_take isl_union_set *uset,
4988 __isl_take isl_union_pw_multi_aff *upma);
4990 #include <isl/map.h>
4991 __isl_give isl_basic_map *
4992 isl_basic_map_preimage_domain_multi_aff(
4993 __isl_take isl_basic_map *bmap,
4994 __isl_take isl_multi_aff *ma);
4995 __isl_give isl_map *isl_map_preimage_domain_multi_aff(
4996 __isl_take isl_map *map,
4997 __isl_take isl_multi_aff *ma);
4998 __isl_give isl_map *isl_map_preimage_range_multi_aff(
4999 __isl_take isl_map *map,
5000 __isl_take isl_multi_aff *ma);
5001 __isl_give isl_map *
5002 isl_map_preimage_domain_pw_multi_aff(
5003 __isl_take isl_map *map,
5004 __isl_take isl_pw_multi_aff *pma);
5005 __isl_give isl_map *
5006 isl_map_preimage_range_pw_multi_aff(
5007 __isl_take isl_map *map,
5008 __isl_take isl_pw_multi_aff *pma);
5009 __isl_give isl_map *
5010 isl_map_preimage_domain_multi_pw_aff(
5011 __isl_take isl_map *map,
5012 __isl_take isl_multi_pw_aff *mpa);
5013 __isl_give isl_basic_map *
5014 isl_basic_map_preimage_range_multi_aff(
5015 __isl_take isl_basic_map *bmap,
5016 __isl_take isl_multi_aff *ma);
5018 #include <isl/union_map.h>
5019 __isl_give isl_union_map *
5020 isl_union_map_preimage_domain_multi_aff(
5021 __isl_take isl_union_map *umap,
5022 __isl_take isl_multi_aff *ma);
5023 __isl_give isl_union_map *
5024 isl_union_map_preimage_range_multi_aff(
5025 __isl_take isl_union_map *umap,
5026 __isl_take isl_multi_aff *ma);
5027 __isl_give isl_union_map *
5028 isl_union_map_preimage_domain_pw_multi_aff(
5029 __isl_take isl_union_map *umap,
5030 __isl_take isl_pw_multi_aff *pma);
5031 __isl_give isl_union_map *
5032 isl_union_map_preimage_range_pw_multi_aff(
5033 __isl_take isl_union_map *umap,
5034 __isl_take isl_pw_multi_aff *pma);
5035 __isl_give isl_union_map *
5036 isl_union_map_preimage_domain_union_pw_multi_aff(
5037 __isl_take isl_union_map *umap,
5038 __isl_take isl_union_pw_multi_aff *upma);
5039 __isl_give isl_union_map *
5040 isl_union_map_preimage_range_union_pw_multi_aff(
5041 __isl_take isl_union_map *umap,
5042 __isl_take isl_union_pw_multi_aff *upma);
5044 These functions compute the preimage of the given set or map domain/range under
5045 the given function. In other words, the expression is plugged
5046 into the set description or into the domain/range of the map.
5050 #include <isl/aff.h>
5051 __isl_give isl_aff *isl_aff_pullback_aff(
5052 __isl_take isl_aff *aff1,
5053 __isl_take isl_aff *aff2);
5054 __isl_give isl_aff *isl_aff_pullback_multi_aff(
5055 __isl_take isl_aff *aff,
5056 __isl_take isl_multi_aff *ma);
5057 __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_aff(
5058 __isl_take isl_pw_aff *pa,
5059 __isl_take isl_multi_aff *ma);
5060 __isl_give isl_pw_aff *isl_pw_aff_pullback_pw_multi_aff(
5061 __isl_take isl_pw_aff *pa,
5062 __isl_take isl_pw_multi_aff *pma);
5063 __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_pw_aff(
5064 __isl_take isl_pw_aff *pa,
5065 __isl_take isl_multi_pw_aff *mpa);
5066 __isl_give isl_multi_aff *isl_multi_aff_pullback_multi_aff(
5067 __isl_take isl_multi_aff *ma1,
5068 __isl_take isl_multi_aff *ma2);
5069 __isl_give isl_pw_multi_aff *
5070 isl_pw_multi_aff_pullback_multi_aff(
5071 __isl_take isl_pw_multi_aff *pma,
5072 __isl_take isl_multi_aff *ma);
5073 __isl_give isl_multi_pw_aff *
5074 isl_multi_pw_aff_pullback_multi_aff(
5075 __isl_take isl_multi_pw_aff *mpa,
5076 __isl_take isl_multi_aff *ma);
5077 __isl_give isl_pw_multi_aff *
5078 isl_pw_multi_aff_pullback_pw_multi_aff(
5079 __isl_take isl_pw_multi_aff *pma1,
5080 __isl_take isl_pw_multi_aff *pma2);
5081 __isl_give isl_multi_pw_aff *
5082 isl_multi_pw_aff_pullback_pw_multi_aff(
5083 __isl_take isl_multi_pw_aff *mpa,
5084 __isl_take isl_pw_multi_aff *pma);
5085 __isl_give isl_multi_pw_aff *
5086 isl_multi_pw_aff_pullback_multi_pw_aff(
5087 __isl_take isl_multi_pw_aff *mpa1,
5088 __isl_take isl_multi_pw_aff *mpa2);
5090 These functions precompose the first expression by the second function.
5091 In other words, the second function is plugged
5092 into the first expression.
5096 #include <isl/aff.h>
5097 __isl_give isl_basic_set *isl_aff_le_basic_set(
5098 __isl_take isl_aff *aff1,
5099 __isl_take isl_aff *aff2);
5100 __isl_give isl_basic_set *isl_aff_ge_basic_set(
5101 __isl_take isl_aff *aff1,
5102 __isl_take isl_aff *aff2);
5103 __isl_give isl_set *isl_pw_aff_eq_set(
5104 __isl_take isl_pw_aff *pwaff1,
5105 __isl_take isl_pw_aff *pwaff2);
5106 __isl_give isl_set *isl_pw_aff_ne_set(
5107 __isl_take isl_pw_aff *pwaff1,
5108 __isl_take isl_pw_aff *pwaff2);
5109 __isl_give isl_set *isl_pw_aff_le_set(
5110 __isl_take isl_pw_aff *pwaff1,
5111 __isl_take isl_pw_aff *pwaff2);
5112 __isl_give isl_set *isl_pw_aff_lt_set(
5113 __isl_take isl_pw_aff *pwaff1,
5114 __isl_take isl_pw_aff *pwaff2);
5115 __isl_give isl_set *isl_pw_aff_ge_set(
5116 __isl_take isl_pw_aff *pwaff1,
5117 __isl_take isl_pw_aff *pwaff2);
5118 __isl_give isl_set *isl_pw_aff_gt_set(
5119 __isl_take isl_pw_aff *pwaff1,
5120 __isl_take isl_pw_aff *pwaff2);
5122 __isl_give isl_set *isl_multi_aff_lex_le_set(
5123 __isl_take isl_multi_aff *ma1,
5124 __isl_take isl_multi_aff *ma2);
5125 __isl_give isl_set *isl_multi_aff_lex_ge_set(
5126 __isl_take isl_multi_aff *ma1,
5127 __isl_take isl_multi_aff *ma2);
5129 __isl_give isl_set *isl_pw_aff_list_eq_set(
5130 __isl_take isl_pw_aff_list *list1,
5131 __isl_take isl_pw_aff_list *list2);
5132 __isl_give isl_set *isl_pw_aff_list_ne_set(
5133 __isl_take isl_pw_aff_list *list1,
5134 __isl_take isl_pw_aff_list *list2);
5135 __isl_give isl_set *isl_pw_aff_list_le_set(
5136 __isl_take isl_pw_aff_list *list1,
5137 __isl_take isl_pw_aff_list *list2);
5138 __isl_give isl_set *isl_pw_aff_list_lt_set(
5139 __isl_take isl_pw_aff_list *list1,
5140 __isl_take isl_pw_aff_list *list2);
5141 __isl_give isl_set *isl_pw_aff_list_ge_set(
5142 __isl_take isl_pw_aff_list *list1,
5143 __isl_take isl_pw_aff_list *list2);
5144 __isl_give isl_set *isl_pw_aff_list_gt_set(
5145 __isl_take isl_pw_aff_list *list1,
5146 __isl_take isl_pw_aff_list *list2);
5148 The function C<isl_aff_ge_basic_set> returns a basic set
5149 containing those elements in the shared space
5150 of C<aff1> and C<aff2> where C<aff1> is greater than or equal to C<aff2>.
5151 The function C<isl_pw_aff_ge_set> returns a set
5152 containing those elements in the shared domain
5153 of C<pwaff1> and C<pwaff2> where C<pwaff1> is
5154 greater than or equal to C<pwaff2>.
5155 The function C<isl_multi_aff_lex_le_set> returns a set
5156 containing those elements in the shared domain space
5157 where C<ma1> is lexicographically smaller than or
5159 The functions operating on C<isl_pw_aff_list> apply the corresponding
5160 C<isl_pw_aff> function to each pair of elements in the two lists.
5162 =item * Cartesian Product
5164 #include <isl/space.h>
5165 __isl_give isl_space *isl_space_product(
5166 __isl_take isl_space *space1,
5167 __isl_take isl_space *space2);
5168 __isl_give isl_space *isl_space_domain_product(
5169 __isl_take isl_space *space1,
5170 __isl_take isl_space *space2);
5171 __isl_give isl_space *isl_space_range_product(
5172 __isl_take isl_space *space1,
5173 __isl_take isl_space *space2);
5176 C<isl_space_product>, C<isl_space_domain_product>
5177 and C<isl_space_range_product> take pairs or relation spaces and
5178 produce a single relations space, where either the domain, the range
5179 or both domain and range are wrapped spaces of relations between
5180 the domains and/or ranges of the input spaces.
5181 If the product is only constructed over the domain or the range
5182 then the ranges or the domains of the inputs should be the same.
5183 The function C<isl_space_product> also accepts a pair of set spaces,
5184 in which case it returns a wrapped space of a relation between the
5187 #include <isl/set.h>
5188 __isl_give isl_set *isl_set_product(
5189 __isl_take isl_set *set1,
5190 __isl_take isl_set *set2);
5192 #include <isl/map.h>
5193 __isl_give isl_basic_map *isl_basic_map_domain_product(
5194 __isl_take isl_basic_map *bmap1,
5195 __isl_take isl_basic_map *bmap2);
5196 __isl_give isl_basic_map *isl_basic_map_range_product(
5197 __isl_take isl_basic_map *bmap1,
5198 __isl_take isl_basic_map *bmap2);
5199 __isl_give isl_basic_map *isl_basic_map_product(
5200 __isl_take isl_basic_map *bmap1,
5201 __isl_take isl_basic_map *bmap2);
5202 __isl_give isl_map *isl_map_domain_product(
5203 __isl_take isl_map *map1,
5204 __isl_take isl_map *map2);
5205 __isl_give isl_map *isl_map_range_product(
5206 __isl_take isl_map *map1,
5207 __isl_take isl_map *map2);
5208 __isl_give isl_map *isl_map_product(
5209 __isl_take isl_map *map1,
5210 __isl_take isl_map *map2);
5212 #include <isl/union_set.h>
5213 __isl_give isl_union_set *isl_union_set_product(
5214 __isl_take isl_union_set *uset1,
5215 __isl_take isl_union_set *uset2);
5217 #include <isl/union_map.h>
5218 __isl_give isl_union_map *isl_union_map_domain_product(
5219 __isl_take isl_union_map *umap1,
5220 __isl_take isl_union_map *umap2);
5221 __isl_give isl_union_map *isl_union_map_range_product(
5222 __isl_take isl_union_map *umap1,
5223 __isl_take isl_union_map *umap2);
5224 __isl_give isl_union_map *isl_union_map_product(
5225 __isl_take isl_union_map *umap1,
5226 __isl_take isl_union_map *umap2);
5228 #include <isl/val.h>
5229 __isl_give isl_multi_val *isl_multi_val_range_product(
5230 __isl_take isl_multi_val *mv1,
5231 __isl_take isl_multi_val *mv2);
5232 __isl_give isl_multi_val *isl_multi_val_product(
5233 __isl_take isl_multi_val *mv1,
5234 __isl_take isl_multi_val *mv2);
5236 #include <isl/aff.h>
5237 __isl_give isl_multi_aff *isl_multi_aff_range_product(
5238 __isl_take isl_multi_aff *ma1,
5239 __isl_take isl_multi_aff *ma2);
5240 __isl_give isl_multi_aff *isl_multi_aff_product(
5241 __isl_take isl_multi_aff *ma1,
5242 __isl_take isl_multi_aff *ma2);
5243 __isl_give isl_multi_pw_aff *
5244 isl_multi_pw_aff_range_product(
5245 __isl_take isl_multi_pw_aff *mpa1,
5246 __isl_take isl_multi_pw_aff *mpa2);
5247 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_product(
5248 __isl_take isl_multi_pw_aff *mpa1,
5249 __isl_take isl_multi_pw_aff *mpa2);
5250 __isl_give isl_pw_multi_aff *
5251 isl_pw_multi_aff_range_product(
5252 __isl_take isl_pw_multi_aff *pma1,
5253 __isl_take isl_pw_multi_aff *pma2);
5254 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_product(
5255 __isl_take isl_pw_multi_aff *pma1,
5256 __isl_take isl_pw_multi_aff *pma2);
5258 The above functions compute the cross product of the given
5259 sets, relations or functions. The domains and ranges of the results
5260 are wrapped maps between domains and ranges of the inputs.
5261 To obtain a ``flat'' product, use the following functions
5264 #include <isl/set.h>
5265 __isl_give isl_basic_set *isl_basic_set_flat_product(
5266 __isl_take isl_basic_set *bset1,
5267 __isl_take isl_basic_set *bset2);
5268 __isl_give isl_set *isl_set_flat_product(
5269 __isl_take isl_set *set1,
5270 __isl_take isl_set *set2);
5272 #include <isl/map.h>
5273 __isl_give isl_basic_map *isl_basic_map_flat_range_product(
5274 __isl_take isl_basic_map *bmap1,
5275 __isl_take isl_basic_map *bmap2);
5276 __isl_give isl_map *isl_map_flat_domain_product(
5277 __isl_take isl_map *map1,
5278 __isl_take isl_map *map2);
5279 __isl_give isl_map *isl_map_flat_range_product(
5280 __isl_take isl_map *map1,
5281 __isl_take isl_map *map2);
5282 __isl_give isl_basic_map *isl_basic_map_flat_product(
5283 __isl_take isl_basic_map *bmap1,
5284 __isl_take isl_basic_map *bmap2);
5285 __isl_give isl_map *isl_map_flat_product(
5286 __isl_take isl_map *map1,
5287 __isl_take isl_map *map2);
5289 #include <isl/union_map.h>
5290 __isl_give isl_union_map *
5291 isl_union_map_flat_range_product(
5292 __isl_take isl_union_map *umap1,
5293 __isl_take isl_union_map *umap2);
5295 #include <isl/val.h>
5296 __isl_give isl_multi_val *isl_multi_val_flat_range_product(
5297 __isl_take isl_multi_val *mv1,
5298 __isl_take isl_multi_aff *mv2);
5300 #include <isl/aff.h>
5301 __isl_give isl_multi_aff *isl_multi_aff_flat_range_product(
5302 __isl_take isl_multi_aff *ma1,
5303 __isl_take isl_multi_aff *ma2);
5304 __isl_give isl_pw_multi_aff *
5305 isl_pw_multi_aff_flat_range_product(
5306 __isl_take isl_pw_multi_aff *pma1,
5307 __isl_take isl_pw_multi_aff *pma2);
5308 __isl_give isl_multi_pw_aff *
5309 isl_multi_pw_aff_flat_range_product(
5310 __isl_take isl_multi_pw_aff *mpa1,
5311 __isl_take isl_multi_pw_aff *mpa2);
5312 __isl_give isl_union_pw_multi_aff *
5313 isl_union_pw_multi_aff_flat_range_product(
5314 __isl_take isl_union_pw_multi_aff *upma1,
5315 __isl_take isl_union_pw_multi_aff *upma2);
5317 #include <isl/space.h>
5318 __isl_give isl_space *isl_space_domain_factor_domain(
5319 __isl_take isl_space *space);
5320 __isl_give isl_space *isl_space_range_factor_domain(
5321 __isl_take isl_space *space);
5322 __isl_give isl_space *isl_space_range_factor_range(
5323 __isl_take isl_space *space);
5325 The functions C<isl_space_range_factor_domain> and
5326 C<isl_space_range_factor_range> extract the two arguments from
5327 the result of a call to C<isl_space_range_product>.
5329 The arguments of a call to C<isl_map_range_product> can be extracted
5330 from the result using the following two functions.
5332 #include <isl/map.h>
5333 __isl_give isl_map *isl_map_range_factor_domain(
5334 __isl_take isl_map *map);
5335 __isl_give isl_map *isl_map_range_factor_range(
5336 __isl_take isl_map *map);
5338 #include <isl/val.h>
5339 __isl_give isl_multi_val *
5340 isl_multi_val_range_factor_domain(
5341 __isl_take isl_multi_val *mv);
5342 __isl_give isl_multi_val *
5343 isl_multi_val_range_factor_range(
5344 __isl_take isl_multi_val *mv);
5346 #include <isl/aff.h>
5347 __isl_give isl_multi_aff *
5348 isl_multi_aff_range_factor_domain(
5349 __isl_take isl_multi_aff *ma);
5350 __isl_give isl_multi_aff *
5351 isl_multi_aff_range_factor_range(
5352 __isl_take isl_multi_aff *ma);
5353 __isl_give isl_multi_pw_aff *
5354 isl_multi_pw_aff_range_factor_domain(
5355 __isl_take isl_multi_pw_aff *mpa);
5356 __isl_give isl_multi_pw_aff *
5357 isl_multi_pw_aff_range_factor_range(
5358 __isl_take isl_multi_pw_aff *mpa);
5360 The splice functions are a generalization of the flat product functions,
5361 where the second argument may be inserted at any position inside
5362 the first argument rather than being placed at the end.
5364 #include <isl/val.h>
5365 __isl_give isl_multi_val *isl_multi_val_range_splice(
5366 __isl_take isl_multi_val *mv1, unsigned pos,
5367 __isl_take isl_multi_val *mv2);
5369 #include <isl/aff.h>
5370 __isl_give isl_multi_aff *isl_multi_aff_range_splice(
5371 __isl_take isl_multi_aff *ma1, unsigned pos,
5372 __isl_take isl_multi_aff *ma2);
5373 __isl_give isl_multi_aff *isl_multi_aff_splice(
5374 __isl_take isl_multi_aff *ma1,
5375 unsigned in_pos, unsigned out_pos,
5376 __isl_take isl_multi_aff *ma2);
5377 __isl_give isl_multi_pw_aff *
5378 isl_multi_pw_aff_range_splice(
5379 __isl_take isl_multi_pw_aff *mpa1, unsigned pos,
5380 __isl_take isl_multi_pw_aff *mpa2);
5381 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_splice(
5382 __isl_take isl_multi_pw_aff *mpa1,
5383 unsigned in_pos, unsigned out_pos,
5384 __isl_take isl_multi_pw_aff *mpa2);
5386 =item * Simplification
5388 When applied to a set or relation,
5389 the gist operation returns a set or relation that has the
5390 same intersection with the context as the input set or relation.
5391 Any implicit equality in the intersection is made explicit in the result,
5392 while all inequalities that are redundant with respect to the intersection
5394 In case of union sets and relations, the gist operation is performed
5397 When applied to a function,
5398 the gist operation applies the set gist operation to each of
5399 the cells in the domain of the input piecewise expression.
5400 The context is also exploited
5401 to simplify the expression associated to each cell.
5403 #include <isl/set.h>
5404 __isl_give isl_basic_set *isl_basic_set_gist(
5405 __isl_take isl_basic_set *bset,
5406 __isl_take isl_basic_set *context);
5407 __isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
5408 __isl_take isl_set *context);
5409 __isl_give isl_set *isl_set_gist_params(
5410 __isl_take isl_set *set,
5411 __isl_take isl_set *context);
5413 #include <isl/map.h>
5414 __isl_give isl_basic_map *isl_basic_map_gist(
5415 __isl_take isl_basic_map *bmap,
5416 __isl_take isl_basic_map *context);
5417 __isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
5418 __isl_take isl_map *context);
5419 __isl_give isl_map *isl_map_gist_params(
5420 __isl_take isl_map *map,
5421 __isl_take isl_set *context);
5422 __isl_give isl_map *isl_map_gist_domain(
5423 __isl_take isl_map *map,
5424 __isl_take isl_set *context);
5425 __isl_give isl_map *isl_map_gist_range(
5426 __isl_take isl_map *map,
5427 __isl_take isl_set *context);
5429 #include <isl/union_set.h>
5430 __isl_give isl_union_set *isl_union_set_gist(
5431 __isl_take isl_union_set *uset,
5432 __isl_take isl_union_set *context);
5433 __isl_give isl_union_set *isl_union_set_gist_params(
5434 __isl_take isl_union_set *uset,
5435 __isl_take isl_set *set);
5437 #include <isl/union_map.h>
5438 __isl_give isl_union_map *isl_union_map_gist(
5439 __isl_take isl_union_map *umap,
5440 __isl_take isl_union_map *context);
5441 __isl_give isl_union_map *isl_union_map_gist_params(
5442 __isl_take isl_union_map *umap,
5443 __isl_take isl_set *set);
5444 __isl_give isl_union_map *isl_union_map_gist_domain(
5445 __isl_take isl_union_map *umap,
5446 __isl_take isl_union_set *uset);
5447 __isl_give isl_union_map *isl_union_map_gist_range(
5448 __isl_take isl_union_map *umap,
5449 __isl_take isl_union_set *uset);
5451 #include <isl/aff.h>
5452 __isl_give isl_aff *isl_aff_gist_params(
5453 __isl_take isl_aff *aff,
5454 __isl_take isl_set *context);
5455 __isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff,
5456 __isl_take isl_set *context);
5457 __isl_give isl_multi_aff *isl_multi_aff_gist_params(
5458 __isl_take isl_multi_aff *maff,
5459 __isl_take isl_set *context);
5460 __isl_give isl_multi_aff *isl_multi_aff_gist(
5461 __isl_take isl_multi_aff *maff,
5462 __isl_take isl_set *context);
5463 __isl_give isl_pw_aff *isl_pw_aff_gist_params(
5464 __isl_take isl_pw_aff *pwaff,
5465 __isl_take isl_set *context);
5466 __isl_give isl_pw_aff *isl_pw_aff_gist(
5467 __isl_take isl_pw_aff *pwaff,
5468 __isl_take isl_set *context);
5469 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist_params(
5470 __isl_take isl_pw_multi_aff *pma,
5471 __isl_take isl_set *set);
5472 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist(
5473 __isl_take isl_pw_multi_aff *pma,
5474 __isl_take isl_set *set);
5475 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist_params(
5476 __isl_take isl_multi_pw_aff *mpa,
5477 __isl_take isl_set *set);
5478 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist(
5479 __isl_take isl_multi_pw_aff *mpa,
5480 __isl_take isl_set *set);
5482 #include <isl/polynomial.h>
5483 __isl_give isl_qpolynomial *isl_qpolynomial_gist_params(
5484 __isl_take isl_qpolynomial *qp,
5485 __isl_take isl_set *context);
5486 __isl_give isl_qpolynomial *isl_qpolynomial_gist(
5487 __isl_take isl_qpolynomial *qp,
5488 __isl_take isl_set *context);
5489 __isl_give isl_qpolynomial_fold *
5490 isl_qpolynomial_fold_gist_params(
5491 __isl_take isl_qpolynomial_fold *fold,
5492 __isl_take isl_set *context);
5493 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist(
5494 __isl_take isl_qpolynomial_fold *fold,
5495 __isl_take isl_set *context);
5496 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist_params(
5497 __isl_take isl_pw_qpolynomial *pwqp,
5498 __isl_take isl_set *context);
5499 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist(
5500 __isl_take isl_pw_qpolynomial *pwqp,
5501 __isl_take isl_set *context);
5502 __isl_give isl_pw_qpolynomial_fold *
5503 isl_pw_qpolynomial_fold_gist(
5504 __isl_take isl_pw_qpolynomial_fold *pwf,
5505 __isl_take isl_set *context);
5506 __isl_give isl_pw_qpolynomial_fold *
5507 isl_pw_qpolynomial_fold_gist_params(
5508 __isl_take isl_pw_qpolynomial_fold *pwf,
5509 __isl_take isl_set *context);
5510 __isl_give isl_union_pw_qpolynomial *
5511 isl_union_pw_qpolynomial_gist_params(
5512 __isl_take isl_union_pw_qpolynomial *upwqp,
5513 __isl_take isl_set *context);
5514 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist(
5515 __isl_take isl_union_pw_qpolynomial *upwqp,
5516 __isl_take isl_union_set *context);
5517 __isl_give isl_union_pw_qpolynomial_fold *
5518 isl_union_pw_qpolynomial_fold_gist(
5519 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5520 __isl_take isl_union_set *context);
5521 __isl_give isl_union_pw_qpolynomial_fold *
5522 isl_union_pw_qpolynomial_fold_gist_params(
5523 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5524 __isl_take isl_set *context);
5526 =item * Binary Arithmethic Operations
5528 #include <isl/aff.h>
5529 __isl_give isl_aff *isl_aff_add(
5530 __isl_take isl_aff *aff1,
5531 __isl_take isl_aff *aff2);
5532 __isl_give isl_multi_aff *isl_multi_aff_add(
5533 __isl_take isl_multi_aff *maff1,
5534 __isl_take isl_multi_aff *maff2);
5535 __isl_give isl_pw_aff *isl_pw_aff_add(
5536 __isl_take isl_pw_aff *pwaff1,
5537 __isl_take isl_pw_aff *pwaff2);
5538 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_add(
5539 __isl_take isl_pw_multi_aff *pma1,
5540 __isl_take isl_pw_multi_aff *pma2);
5541 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_add(
5542 __isl_take isl_union_pw_multi_aff *upma1,
5543 __isl_take isl_union_pw_multi_aff *upma2);
5544 __isl_give isl_pw_aff *isl_pw_aff_min(
5545 __isl_take isl_pw_aff *pwaff1,
5546 __isl_take isl_pw_aff *pwaff2);
5547 __isl_give isl_pw_aff *isl_pw_aff_max(
5548 __isl_take isl_pw_aff *pwaff1,
5549 __isl_take isl_pw_aff *pwaff2);
5550 __isl_give isl_aff *isl_aff_sub(
5551 __isl_take isl_aff *aff1,
5552 __isl_take isl_aff *aff2);
5553 __isl_give isl_multi_aff *isl_multi_aff_sub(
5554 __isl_take isl_multi_aff *ma1,
5555 __isl_take isl_multi_aff *ma2);
5556 __isl_give isl_pw_aff *isl_pw_aff_sub(
5557 __isl_take isl_pw_aff *pwaff1,
5558 __isl_take isl_pw_aff *pwaff2);
5559 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_sub(
5560 __isl_take isl_pw_multi_aff *pma1,
5561 __isl_take isl_pw_multi_aff *pma2);
5562 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_sub(
5563 __isl_take isl_union_pw_multi_aff *upma1,
5564 __isl_take isl_union_pw_multi_aff *upma2);
5566 C<isl_aff_sub> subtracts the second argument from the first.
5568 #include <isl/polynomial.h>
5569 __isl_give isl_qpolynomial *isl_qpolynomial_add(
5570 __isl_take isl_qpolynomial *qp1,
5571 __isl_take isl_qpolynomial *qp2);
5572 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
5573 __isl_take isl_pw_qpolynomial *pwqp1,
5574 __isl_take isl_pw_qpolynomial *pwqp2);
5575 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint(
5576 __isl_take isl_pw_qpolynomial *pwqp1,
5577 __isl_take isl_pw_qpolynomial *pwqp2);
5578 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
5579 __isl_take isl_pw_qpolynomial_fold *pwf1,
5580 __isl_take isl_pw_qpolynomial_fold *pwf2);
5581 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add(
5582 __isl_take isl_union_pw_qpolynomial *upwqp1,
5583 __isl_take isl_union_pw_qpolynomial *upwqp2);
5584 __isl_give isl_qpolynomial *isl_qpolynomial_sub(
5585 __isl_take isl_qpolynomial *qp1,
5586 __isl_take isl_qpolynomial *qp2);
5587 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub(
5588 __isl_take isl_pw_qpolynomial *pwqp1,
5589 __isl_take isl_pw_qpolynomial *pwqp2);
5590 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
5591 __isl_take isl_union_pw_qpolynomial *upwqp1,
5592 __isl_take isl_union_pw_qpolynomial *upwqp2);
5593 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_fold(
5594 __isl_take isl_pw_qpolynomial_fold *pwf1,
5595 __isl_take isl_pw_qpolynomial_fold *pwf2);
5596 __isl_give isl_union_pw_qpolynomial_fold *
5597 isl_union_pw_qpolynomial_fold_fold(
5598 __isl_take isl_union_pw_qpolynomial_fold *upwf1,
5599 __isl_take isl_union_pw_qpolynomial_fold *upwf2);
5601 #include <isl/aff.h>
5602 __isl_give isl_pw_aff *isl_pw_aff_union_add(
5603 __isl_take isl_pw_aff *pwaff1,
5604 __isl_take isl_pw_aff *pwaff2);
5605 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_add(
5606 __isl_take isl_pw_multi_aff *pma1,
5607 __isl_take isl_pw_multi_aff *pma2);
5608 __isl_give isl_pw_aff *isl_pw_aff_union_min(
5609 __isl_take isl_pw_aff *pwaff1,
5610 __isl_take isl_pw_aff *pwaff2);
5611 __isl_give isl_pw_aff *isl_pw_aff_union_max(
5612 __isl_take isl_pw_aff *pwaff1,
5613 __isl_take isl_pw_aff *pwaff2);
5615 The function C<isl_pw_aff_union_max> computes a piecewise quasi-affine
5616 expression with a domain that is the union of those of C<pwaff1> and
5617 C<pwaff2> and such that on each cell, the quasi-affine expression is
5618 the maximum of those of C<pwaff1> and C<pwaff2>. If only one of
5619 C<pwaff1> or C<pwaff2> is defined on a given cell, then the
5620 associated expression is the defined one.
5621 This in contrast to the C<isl_pw_aff_max> function, which is
5622 only defined on the shared definition domain of the arguments.
5624 #include <isl/val.h>
5625 __isl_give isl_multi_val *isl_multi_val_add_val(
5626 __isl_take isl_multi_val *mv,
5627 __isl_take isl_val *v);
5628 __isl_give isl_multi_val *isl_multi_val_mod_val(
5629 __isl_take isl_multi_val *mv,
5630 __isl_take isl_val *v);
5631 __isl_give isl_multi_val *isl_multi_val_scale_val(
5632 __isl_take isl_multi_val *mv,
5633 __isl_take isl_val *v);
5635 #include <isl/aff.h>
5636 __isl_give isl_aff *isl_aff_mod_val(__isl_take isl_aff *aff,
5637 __isl_take isl_val *mod);
5638 __isl_give isl_pw_aff *isl_pw_aff_mod_val(
5639 __isl_take isl_pw_aff *pa,
5640 __isl_take isl_val *mod);
5641 __isl_give isl_aff *isl_aff_scale_val(__isl_take isl_aff *aff,
5642 __isl_take isl_val *v);
5643 __isl_give isl_multi_aff *isl_multi_aff_scale_val(
5644 __isl_take isl_multi_aff *ma,
5645 __isl_take isl_val *v);
5646 __isl_give isl_pw_aff *isl_pw_aff_scale_val(
5647 __isl_take isl_pw_aff *pa, __isl_take isl_val *v);
5648 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_scale_val(
5649 __isl_take isl_multi_pw_aff *mpa,
5650 __isl_take isl_val *v);
5651 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_val(
5652 __isl_take isl_pw_multi_aff *pma,
5653 __isl_take isl_val *v);
5654 __isl_give isl_aff *isl_aff_scale_down_ui(
5655 __isl_take isl_aff *aff, unsigned f);
5656 __isl_give isl_aff *isl_aff_scale_down_val(
5657 __isl_take isl_aff *aff, __isl_take isl_val *v);
5658 __isl_give isl_pw_aff *isl_pw_aff_scale_down_val(
5659 __isl_take isl_pw_aff *pa,
5660 __isl_take isl_val *f);
5662 #include <isl/polynomial.h>
5663 __isl_give isl_qpolynomial *isl_qpolynomial_scale_val(
5664 __isl_take isl_qpolynomial *qp,
5665 __isl_take isl_val *v);
5666 __isl_give isl_qpolynomial_fold *
5667 isl_qpolynomial_fold_scale_val(
5668 __isl_take isl_qpolynomial_fold *fold,
5669 __isl_take isl_val *v);
5670 __isl_give isl_pw_qpolynomial *
5671 isl_pw_qpolynomial_scale_val(
5672 __isl_take isl_pw_qpolynomial *pwqp,
5673 __isl_take isl_val *v);
5674 __isl_give isl_pw_qpolynomial_fold *
5675 isl_pw_qpolynomial_fold_scale_val(
5676 __isl_take isl_pw_qpolynomial_fold *pwf,
5677 __isl_take isl_val *v);
5678 __isl_give isl_union_pw_qpolynomial *
5679 isl_union_pw_qpolynomial_scale_val(
5680 __isl_take isl_union_pw_qpolynomial *upwqp,
5681 __isl_take isl_val *v);
5682 __isl_give isl_union_pw_qpolynomial_fold *
5683 isl_union_pw_qpolynomial_fold_scale_val(
5684 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5685 __isl_take isl_val *v);
5687 #include <isl/val.h>
5688 __isl_give isl_multi_val *isl_multi_val_scale_multi_val(
5689 __isl_take isl_multi_val *mv1,
5690 __isl_take isl_multi_val *mv2);
5691 __isl_give isl_multi_val *
5692 isl_multi_val_scale_down_multi_val(
5693 __isl_take isl_multi_val *mv1,
5694 __isl_take isl_multi_val *mv2);
5696 #include <isl/aff.h>
5697 __isl_give isl_multi_aff *isl_multi_aff_scale_multi_val(
5698 __isl_take isl_multi_aff *ma,
5699 __isl_take isl_multi_val *mv);
5700 __isl_give isl_pw_multi_aff *
5701 isl_pw_multi_aff_scale_multi_val(
5702 __isl_take isl_pw_multi_aff *pma,
5703 __isl_take isl_multi_val *mv);
5704 __isl_give isl_multi_pw_aff *
5705 isl_multi_pw_aff_scale_multi_val(
5706 __isl_take isl_multi_pw_aff *mpa,
5707 __isl_take isl_multi_val *mv);
5708 __isl_give isl_union_pw_multi_aff *
5709 isl_union_pw_multi_aff_scale_multi_val(
5710 __isl_take isl_union_pw_multi_aff *upma,
5711 __isl_take isl_multi_val *mv);
5712 __isl_give isl_multi_aff *
5713 isl_multi_aff_scale_down_multi_val(
5714 __isl_take isl_multi_aff *ma,
5715 __isl_take isl_multi_val *mv);
5716 __isl_give isl_multi_pw_aff *
5717 isl_multi_pw_aff_scale_down_multi_val(
5718 __isl_take isl_multi_pw_aff *mpa,
5719 __isl_take isl_multi_val *mv);
5721 C<isl_multi_aff_scale_multi_val> scales the elements of C<ma>
5722 by the corresponding elements of C<mv>.
5724 #include <isl/aff.h>
5725 __isl_give isl_aff *isl_aff_mul(
5726 __isl_take isl_aff *aff1,
5727 __isl_take isl_aff *aff2);
5728 __isl_give isl_aff *isl_aff_div(
5729 __isl_take isl_aff *aff1,
5730 __isl_take isl_aff *aff2);
5731 __isl_give isl_pw_aff *isl_pw_aff_mul(
5732 __isl_take isl_pw_aff *pwaff1,
5733 __isl_take isl_pw_aff *pwaff2);
5734 __isl_give isl_pw_aff *isl_pw_aff_div(
5735 __isl_take isl_pw_aff *pa1,
5736 __isl_take isl_pw_aff *pa2);
5737 __isl_give isl_pw_aff *isl_pw_aff_tdiv_q(
5738 __isl_take isl_pw_aff *pa1,
5739 __isl_take isl_pw_aff *pa2);
5740 __isl_give isl_pw_aff *isl_pw_aff_tdiv_r(
5741 __isl_take isl_pw_aff *pa1,
5742 __isl_take isl_pw_aff *pa2);
5744 When multiplying two affine expressions, at least one of the two needs
5745 to be a constant. Similarly, when dividing an affine expression by another,
5746 the second expression needs to be a constant.
5747 C<isl_pw_aff_tdiv_q> computes the quotient of an integer division with
5748 rounding towards zero. C<isl_pw_aff_tdiv_r> computes the corresponding
5751 #include <isl/polynomial.h>
5752 __isl_give isl_qpolynomial *isl_qpolynomial_mul(
5753 __isl_take isl_qpolynomial *qp1,
5754 __isl_take isl_qpolynomial *qp2);
5755 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
5756 __isl_take isl_pw_qpolynomial *pwqp1,
5757 __isl_take isl_pw_qpolynomial *pwqp2);
5758 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
5759 __isl_take isl_union_pw_qpolynomial *upwqp1,
5760 __isl_take isl_union_pw_qpolynomial *upwqp2);
5764 =head3 Lexicographic Optimization
5766 Given a (basic) set C<set> (or C<bset>) and a zero-dimensional domain C<dom>,
5767 the following functions
5768 compute a set that contains the lexicographic minimum or maximum
5769 of the elements in C<set> (or C<bset>) for those values of the parameters
5770 that satisfy C<dom>.
5771 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
5772 that contains the parameter values in C<dom> for which C<set> (or C<bset>)
5774 In other words, the union of the parameter values
5775 for which the result is non-empty and of C<*empty>
5778 #include <isl/set.h>
5779 __isl_give isl_set *isl_basic_set_partial_lexmin(
5780 __isl_take isl_basic_set *bset,
5781 __isl_take isl_basic_set *dom,
5782 __isl_give isl_set **empty);
5783 __isl_give isl_set *isl_basic_set_partial_lexmax(
5784 __isl_take isl_basic_set *bset,
5785 __isl_take isl_basic_set *dom,
5786 __isl_give isl_set **empty);
5787 __isl_give isl_set *isl_set_partial_lexmin(
5788 __isl_take isl_set *set, __isl_take isl_set *dom,
5789 __isl_give isl_set **empty);
5790 __isl_give isl_set *isl_set_partial_lexmax(
5791 __isl_take isl_set *set, __isl_take isl_set *dom,
5792 __isl_give isl_set **empty);
5794 Given a (basic) set C<set> (or C<bset>), the following functions simply
5795 return a set containing the lexicographic minimum or maximum
5796 of the elements in C<set> (or C<bset>).
5797 In case of union sets, the optimum is computed per space.
5799 #include <isl/set.h>
5800 __isl_give isl_set *isl_basic_set_lexmin(
5801 __isl_take isl_basic_set *bset);
5802 __isl_give isl_set *isl_basic_set_lexmax(
5803 __isl_take isl_basic_set *bset);
5804 __isl_give isl_set *isl_set_lexmin(
5805 __isl_take isl_set *set);
5806 __isl_give isl_set *isl_set_lexmax(
5807 __isl_take isl_set *set);
5808 __isl_give isl_union_set *isl_union_set_lexmin(
5809 __isl_take isl_union_set *uset);
5810 __isl_give isl_union_set *isl_union_set_lexmax(
5811 __isl_take isl_union_set *uset);
5813 Given a (basic) relation C<map> (or C<bmap>) and a domain C<dom>,
5814 the following functions
5815 compute a relation that maps each element of C<dom>
5816 to the single lexicographic minimum or maximum
5817 of the elements that are associated to that same
5818 element in C<map> (or C<bmap>).
5819 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
5820 that contains the elements in C<dom> that do not map
5821 to any elements in C<map> (or C<bmap>).
5822 In other words, the union of the domain of the result and of C<*empty>
5825 #include <isl/map.h>
5826 __isl_give isl_map *isl_basic_map_partial_lexmax(
5827 __isl_take isl_basic_map *bmap,
5828 __isl_take isl_basic_set *dom,
5829 __isl_give isl_set **empty);
5830 __isl_give isl_map *isl_basic_map_partial_lexmin(
5831 __isl_take isl_basic_map *bmap,
5832 __isl_take isl_basic_set *dom,
5833 __isl_give isl_set **empty);
5834 __isl_give isl_map *isl_map_partial_lexmax(
5835 __isl_take isl_map *map, __isl_take isl_set *dom,
5836 __isl_give isl_set **empty);
5837 __isl_give isl_map *isl_map_partial_lexmin(
5838 __isl_take isl_map *map, __isl_take isl_set *dom,
5839 __isl_give isl_set **empty);
5841 Given a (basic) map C<map> (or C<bmap>), the following functions simply
5842 return a map mapping each element in the domain of
5843 C<map> (or C<bmap>) to the lexicographic minimum or maximum
5844 of all elements associated to that element.
5845 In case of union relations, the optimum is computed per space.
5847 #include <isl/map.h>
5848 __isl_give isl_map *isl_basic_map_lexmin(
5849 __isl_take isl_basic_map *bmap);
5850 __isl_give isl_map *isl_basic_map_lexmax(
5851 __isl_take isl_basic_map *bmap);
5852 __isl_give isl_map *isl_map_lexmin(
5853 __isl_take isl_map *map);
5854 __isl_give isl_map *isl_map_lexmax(
5855 __isl_take isl_map *map);
5856 __isl_give isl_union_map *isl_union_map_lexmin(
5857 __isl_take isl_union_map *umap);
5858 __isl_give isl_union_map *isl_union_map_lexmax(
5859 __isl_take isl_union_map *umap);
5861 The following functions return their result in the form of
5862 a piecewise multi-affine expression,
5863 but are otherwise equivalent to the corresponding functions
5864 returning a basic set or relation.
5866 #include <isl/set.h>
5867 __isl_give isl_pw_multi_aff *
5868 isl_basic_set_partial_lexmin_pw_multi_aff(
5869 __isl_take isl_basic_set *bset,
5870 __isl_take isl_basic_set *dom,
5871 __isl_give isl_set **empty);
5872 __isl_give isl_pw_multi_aff *
5873 isl_basic_set_partial_lexmax_pw_multi_aff(
5874 __isl_take isl_basic_set *bset,
5875 __isl_take isl_basic_set *dom,
5876 __isl_give isl_set **empty);
5877 __isl_give isl_pw_multi_aff *isl_set_lexmin_pw_multi_aff(
5878 __isl_take isl_set *set);
5879 __isl_give isl_pw_multi_aff *isl_set_lexmax_pw_multi_aff(
5880 __isl_take isl_set *set);
5882 #include <isl/map.h>
5883 __isl_give isl_pw_multi_aff *
5884 isl_basic_map_lexmin_pw_multi_aff(
5885 __isl_take isl_basic_map *bmap);
5886 __isl_give isl_pw_multi_aff *
5887 isl_basic_map_partial_lexmin_pw_multi_aff(
5888 __isl_take isl_basic_map *bmap,
5889 __isl_take isl_basic_set *dom,
5890 __isl_give isl_set **empty);
5891 __isl_give isl_pw_multi_aff *
5892 isl_basic_map_partial_lexmax_pw_multi_aff(
5893 __isl_take isl_basic_map *bmap,
5894 __isl_take isl_basic_set *dom,
5895 __isl_give isl_set **empty);
5896 __isl_give isl_pw_multi_aff *isl_map_lexmin_pw_multi_aff(
5897 __isl_take isl_map *map);
5898 __isl_give isl_pw_multi_aff *isl_map_lexmax_pw_multi_aff(
5899 __isl_take isl_map *map);
5901 The following functions return the lexicographic minimum or maximum
5902 on the shared domain of the inputs and the single defined function
5903 on those parts of the domain where only a single function is defined.
5905 #include <isl/aff.h>
5906 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmin(
5907 __isl_take isl_pw_multi_aff *pma1,
5908 __isl_take isl_pw_multi_aff *pma2);
5909 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmax(
5910 __isl_take isl_pw_multi_aff *pma1,
5911 __isl_take isl_pw_multi_aff *pma2);
5913 =head2 Ternary Operations
5915 #include <isl/aff.h>
5916 __isl_give isl_pw_aff *isl_pw_aff_cond(
5917 __isl_take isl_pw_aff *cond,
5918 __isl_take isl_pw_aff *pwaff_true,
5919 __isl_take isl_pw_aff *pwaff_false);
5921 The function C<isl_pw_aff_cond> performs a conditional operator
5922 and returns an expression that is equal to C<pwaff_true>
5923 for elements where C<cond> is non-zero and equal to C<pwaff_false> for elements
5924 where C<cond> is zero.
5928 Lists are defined over several element types, including
5929 C<isl_val>, C<isl_id>, C<isl_aff>, C<isl_pw_aff>, C<isl_constraint>,
5930 C<isl_basic_set>, C<isl_set>, C<isl_ast_expr> and C<isl_ast_node>.
5931 Here we take lists of C<isl_set>s as an example.
5932 Lists can be created, copied, modified and freed using the following functions.
5934 #include <isl/set.h>
5935 __isl_give isl_set_list *isl_set_list_from_set(
5936 __isl_take isl_set *el);
5937 __isl_give isl_set_list *isl_set_list_alloc(
5938 isl_ctx *ctx, int n);
5939 __isl_give isl_set_list *isl_set_list_copy(
5940 __isl_keep isl_set_list *list);
5941 __isl_give isl_set_list *isl_set_list_insert(
5942 __isl_take isl_set_list *list, unsigned pos,
5943 __isl_take isl_set *el);
5944 __isl_give isl_set_list *isl_set_list_add(
5945 __isl_take isl_set_list *list,
5946 __isl_take isl_set *el);
5947 __isl_give isl_set_list *isl_set_list_drop(
5948 __isl_take isl_set_list *list,
5949 unsigned first, unsigned n);
5950 __isl_give isl_set_list *isl_set_list_set_set(
5951 __isl_take isl_set_list *list, int index,
5952 __isl_take isl_set *set);
5953 __isl_give isl_set_list *isl_set_list_concat(
5954 __isl_take isl_set_list *list1,
5955 __isl_take isl_set_list *list2);
5956 __isl_give isl_set_list *isl_set_list_sort(
5957 __isl_take isl_set_list *list,
5958 int (*cmp)(__isl_keep isl_set *a,
5959 __isl_keep isl_set *b, void *user),
5961 __isl_null isl_set_list *isl_set_list_free(
5962 __isl_take isl_set_list *list);
5964 C<isl_set_list_alloc> creates an empty list with a capacity for
5965 C<n> elements. C<isl_set_list_from_set> creates a list with a single
5968 Lists can be inspected using the following functions.
5970 #include <isl/set.h>
5971 int isl_set_list_n_set(__isl_keep isl_set_list *list);
5972 __isl_give isl_set *isl_set_list_get_set(
5973 __isl_keep isl_set_list *list, int index);
5974 int isl_set_list_foreach(__isl_keep isl_set_list *list,
5975 int (*fn)(__isl_take isl_set *el, void *user),
5977 int isl_set_list_foreach_scc(__isl_keep isl_set_list *list,
5978 int (*follows)(__isl_keep isl_set *a,
5979 __isl_keep isl_set *b, void *user),
5981 int (*fn)(__isl_take isl_set *el, void *user),
5984 The function C<isl_set_list_foreach_scc> calls C<fn> on each of the
5985 strongly connected components of the graph with as vertices the elements
5986 of C<list> and a directed edge from vertex C<b> to vertex C<a>
5987 iff C<follows(a, b)> returns C<1>. The callbacks C<follows> and C<fn>
5988 should return C<-1> on error.
5990 Lists can be printed using
5992 #include <isl/set.h>
5993 __isl_give isl_printer *isl_printer_print_set_list(
5994 __isl_take isl_printer *p,
5995 __isl_keep isl_set_list *list);
5997 =head2 Associative arrays
5999 Associative arrays map isl objects of a specific type to isl objects
6000 of some (other) specific type. They are defined for several pairs
6001 of types, including (C<isl_map>, C<isl_basic_set>),
6002 (C<isl_id>, C<isl_ast_expr>) and.
6003 (C<isl_id>, C<isl_pw_aff>).
6004 Here, we take associative arrays that map C<isl_id>s to C<isl_ast_expr>s
6007 Associative arrays can be created, copied and freed using
6008 the following functions.
6010 #include <isl/id_to_ast_expr.h>
6011 __isl_give id_to_ast_expr *isl_id_to_ast_expr_alloc(
6012 isl_ctx *ctx, int min_size);
6013 __isl_give id_to_ast_expr *isl_id_to_ast_expr_copy(
6014 __isl_keep id_to_ast_expr *id2expr);
6015 __isl_null id_to_ast_expr *isl_id_to_ast_expr_free(
6016 __isl_take id_to_ast_expr *id2expr);
6018 The C<min_size> argument to C<isl_id_to_ast_expr_alloc> can be used
6019 to specify the expected size of the associative array.
6020 The associative array will be grown automatically as needed.
6022 Associative arrays can be inspected using the following functions.
6024 #include <isl/id_to_ast_expr.h>
6025 int isl_id_to_ast_expr_has(
6026 __isl_keep id_to_ast_expr *id2expr,
6027 __isl_keep isl_id *key);
6028 __isl_give isl_ast_expr *isl_id_to_ast_expr_get(
6029 __isl_keep id_to_ast_expr *id2expr,
6030 __isl_take isl_id *key);
6031 int isl_id_to_ast_expr_foreach(
6032 __isl_keep id_to_ast_expr *id2expr,
6033 int (*fn)(__isl_take isl_id *key,
6034 __isl_take isl_ast_expr *val, void *user),
6037 They can be modified using the following function.
6039 #include <isl/id_to_ast_expr.h>
6040 __isl_give id_to_ast_expr *isl_id_to_ast_expr_set(
6041 __isl_take id_to_ast_expr *id2expr,
6042 __isl_take isl_id *key,
6043 __isl_take isl_ast_expr *val);
6044 __isl_give id_to_ast_expr *isl_id_to_ast_expr_drop(
6045 __isl_take id_to_ast_expr *id2expr,
6046 __isl_take isl_id *key);
6048 Associative arrays can be printed using the following function.
6050 #include <isl/id_to_ast_expr.h>
6051 __isl_give isl_printer *isl_printer_print_id_to_ast_expr(
6052 __isl_take isl_printer *p,
6053 __isl_keep id_to_ast_expr *id2expr);
6057 Vectors can be created, copied and freed using the following functions.
6059 #include <isl/vec.h>
6060 __isl_give isl_vec *isl_vec_alloc(isl_ctx *ctx,
6062 __isl_give isl_vec *isl_vec_copy(__isl_keep isl_vec *vec);
6063 __isl_null isl_vec *isl_vec_free(__isl_take isl_vec *vec);
6065 Note that the elements of a newly created vector may have arbitrary values.
6066 The elements can be changed and inspected using the following functions.
6068 int isl_vec_size(__isl_keep isl_vec *vec);
6069 __isl_give isl_val *isl_vec_get_element_val(
6070 __isl_keep isl_vec *vec, int pos);
6071 __isl_give isl_vec *isl_vec_set_element_si(
6072 __isl_take isl_vec *vec, int pos, int v);
6073 __isl_give isl_vec *isl_vec_set_element_val(
6074 __isl_take isl_vec *vec, int pos,
6075 __isl_take isl_val *v);
6076 __isl_give isl_vec *isl_vec_set_si(__isl_take isl_vec *vec,
6078 __isl_give isl_vec *isl_vec_set_val(
6079 __isl_take isl_vec *vec, __isl_take isl_val *v);
6080 int isl_vec_cmp_element(__isl_keep isl_vec *vec1,
6081 __isl_keep isl_vec *vec2, int pos);
6083 C<isl_vec_get_element> will return a negative value if anything went wrong.
6084 In that case, the value of C<*v> is undefined.
6086 The following function can be used to concatenate two vectors.
6088 __isl_give isl_vec *isl_vec_concat(__isl_take isl_vec *vec1,
6089 __isl_take isl_vec *vec2);
6093 Matrices can be created, copied and freed using the following functions.
6095 #include <isl/mat.h>
6096 __isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx,
6097 unsigned n_row, unsigned n_col);
6098 __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat);
6099 __isl_null isl_mat *isl_mat_free(__isl_take isl_mat *mat);
6101 Note that the elements of a newly created matrix may have arbitrary values.
6102 The elements can be changed and inspected using the following functions.
6104 int isl_mat_rows(__isl_keep isl_mat *mat);
6105 int isl_mat_cols(__isl_keep isl_mat *mat);
6106 __isl_give isl_val *isl_mat_get_element_val(
6107 __isl_keep isl_mat *mat, int row, int col);
6108 __isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat,
6109 int row, int col, int v);
6110 __isl_give isl_mat *isl_mat_set_element_val(
6111 __isl_take isl_mat *mat, int row, int col,
6112 __isl_take isl_val *v);
6114 C<isl_mat_get_element> will return a negative value if anything went wrong.
6115 In that case, the value of C<*v> is undefined.
6117 The following function can be used to compute the (right) inverse
6118 of a matrix, i.e., a matrix such that the product of the original
6119 and the inverse (in that order) is a multiple of the identity matrix.
6120 The input matrix is assumed to be of full row-rank.
6122 __isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat);
6124 The following function can be used to compute the (right) kernel
6125 (or null space) of a matrix, i.e., a matrix such that the product of
6126 the original and the kernel (in that order) is the zero matrix.
6128 __isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat);
6130 =head2 Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions
6132 The following functions determine
6133 an upper or lower bound on a quasipolynomial over its domain.
6135 __isl_give isl_pw_qpolynomial_fold *
6136 isl_pw_qpolynomial_bound(
6137 __isl_take isl_pw_qpolynomial *pwqp,
6138 enum isl_fold type, int *tight);
6140 __isl_give isl_union_pw_qpolynomial_fold *
6141 isl_union_pw_qpolynomial_bound(
6142 __isl_take isl_union_pw_qpolynomial *upwqp,
6143 enum isl_fold type, int *tight);
6145 The C<type> argument may be either C<isl_fold_min> or C<isl_fold_max>.
6146 If C<tight> is not C<NULL>, then C<*tight> is set to C<1>
6147 is the returned bound is known be tight, i.e., for each value
6148 of the parameters there is at least
6149 one element in the domain that reaches the bound.
6150 If the domain of C<pwqp> is not wrapping, then the bound is computed
6151 over all elements in that domain and the result has a purely parametric
6152 domain. If the domain of C<pwqp> is wrapping, then the bound is
6153 computed over the range of the wrapped relation. The domain of the
6154 wrapped relation becomes the domain of the result.
6156 =head2 Parametric Vertex Enumeration
6158 The parametric vertex enumeration described in this section
6159 is mainly intended to be used internally and by the C<barvinok>
6162 #include <isl/vertices.h>
6163 __isl_give isl_vertices *isl_basic_set_compute_vertices(
6164 __isl_keep isl_basic_set *bset);
6166 The function C<isl_basic_set_compute_vertices> performs the
6167 actual computation of the parametric vertices and the chamber
6168 decomposition and store the result in an C<isl_vertices> object.
6169 This information can be queried by either iterating over all
6170 the vertices or iterating over all the chambers or cells
6171 and then iterating over all vertices that are active on the chamber.
6173 int isl_vertices_foreach_vertex(
6174 __isl_keep isl_vertices *vertices,
6175 int (*fn)(__isl_take isl_vertex *vertex, void *user),
6178 int isl_vertices_foreach_cell(
6179 __isl_keep isl_vertices *vertices,
6180 int (*fn)(__isl_take isl_cell *cell, void *user),
6182 int isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
6183 int (*fn)(__isl_take isl_vertex *vertex, void *user),
6186 Other operations that can be performed on an C<isl_vertices> object are
6189 int isl_vertices_get_n_vertices(
6190 __isl_keep isl_vertices *vertices);
6191 void isl_vertices_free(__isl_take isl_vertices *vertices);
6193 Vertices can be inspected and destroyed using the following functions.
6195 int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
6196 __isl_give isl_basic_set *isl_vertex_get_domain(
6197 __isl_keep isl_vertex *vertex);
6198 __isl_give isl_multi_aff *isl_vertex_get_expr(
6199 __isl_keep isl_vertex *vertex);
6200 void isl_vertex_free(__isl_take isl_vertex *vertex);
6202 C<isl_vertex_get_expr> returns a multiple quasi-affine expression
6203 describing the vertex in terms of the parameters,
6204 while C<isl_vertex_get_domain> returns the activity domain
6207 Chambers can be inspected and destroyed using the following functions.
6209 __isl_give isl_basic_set *isl_cell_get_domain(
6210 __isl_keep isl_cell *cell);
6211 void isl_cell_free(__isl_take isl_cell *cell);
6213 =head1 Polyhedral Compilation Library
6215 This section collects functionality in C<isl> that has been specifically
6216 designed for use during polyhedral compilation.
6218 =head2 Dependence Analysis
6220 C<isl> contains specialized functionality for performing
6221 array dataflow analysis. That is, given a I<sink> access relation
6222 and a collection of possible I<source> access relations,
6223 C<isl> can compute relations that describe
6224 for each iteration of the sink access, which iteration
6225 of which of the source access relations was the last
6226 to access the same data element before the given iteration
6228 The resulting dependence relations map source iterations
6229 to the corresponding sink iterations.
6230 To compute standard flow dependences, the sink should be
6231 a read, while the sources should be writes.
6232 If any of the source accesses are marked as being I<may>
6233 accesses, then there will be a dependence from the last
6234 I<must> access B<and> from any I<may> access that follows
6235 this last I<must> access.
6236 In particular, if I<all> sources are I<may> accesses,
6237 then memory based dependence analysis is performed.
6238 If, on the other hand, all sources are I<must> accesses,
6239 then value based dependence analysis is performed.
6241 #include <isl/flow.h>
6243 typedef int (*isl_access_level_before)(void *first, void *second);
6245 __isl_give isl_access_info *isl_access_info_alloc(
6246 __isl_take isl_map *sink,
6247 void *sink_user, isl_access_level_before fn,
6249 __isl_give isl_access_info *isl_access_info_add_source(
6250 __isl_take isl_access_info *acc,
6251 __isl_take isl_map *source, int must,
6253 __isl_null isl_access_info *isl_access_info_free(
6254 __isl_take isl_access_info *acc);
6256 __isl_give isl_flow *isl_access_info_compute_flow(
6257 __isl_take isl_access_info *acc);
6259 int isl_flow_foreach(__isl_keep isl_flow *deps,
6260 int (*fn)(__isl_take isl_map *dep, int must,
6261 void *dep_user, void *user),
6263 __isl_give isl_map *isl_flow_get_no_source(
6264 __isl_keep isl_flow *deps, int must);
6265 void isl_flow_free(__isl_take isl_flow *deps);
6267 The function C<isl_access_info_compute_flow> performs the actual
6268 dependence analysis. The other functions are used to construct
6269 the input for this function or to read off the output.
6271 The input is collected in an C<isl_access_info>, which can
6272 be created through a call to C<isl_access_info_alloc>.
6273 The arguments to this functions are the sink access relation
6274 C<sink>, a token C<sink_user> used to identify the sink
6275 access to the user, a callback function for specifying the
6276 relative order of source and sink accesses, and the number
6277 of source access relations that will be added.
6278 The callback function has type C<int (*)(void *first, void *second)>.
6279 The function is called with two user supplied tokens identifying
6280 either a source or the sink and it should return the shared nesting
6281 level and the relative order of the two accesses.
6282 In particular, let I<n> be the number of loops shared by
6283 the two accesses. If C<first> precedes C<second> textually,
6284 then the function should return I<2 * n + 1>; otherwise,
6285 it should return I<2 * n>.
6286 The sources can be added to the C<isl_access_info> by performing
6287 (at most) C<max_source> calls to C<isl_access_info_add_source>.
6288 C<must> indicates whether the source is a I<must> access
6289 or a I<may> access. Note that a multi-valued access relation
6290 should only be marked I<must> if every iteration in the domain
6291 of the relation accesses I<all> elements in its image.
6292 The C<source_user> token is again used to identify
6293 the source access. The range of the source access relation
6294 C<source> should have the same dimension as the range
6295 of the sink access relation.
6296 The C<isl_access_info_free> function should usually not be
6297 called explicitly, because it is called implicitly by
6298 C<isl_access_info_compute_flow>.
6300 The result of the dependence analysis is collected in an
6301 C<isl_flow>. There may be elements of
6302 the sink access for which no preceding source access could be
6303 found or for which all preceding sources are I<may> accesses.
6304 The relations containing these elements can be obtained through
6305 calls to C<isl_flow_get_no_source>, the first with C<must> set
6306 and the second with C<must> unset.
6307 In the case of standard flow dependence analysis,
6308 with the sink a read and the sources I<must> writes,
6309 the first relation corresponds to the reads from uninitialized
6310 array elements and the second relation is empty.
6311 The actual flow dependences can be extracted using
6312 C<isl_flow_foreach>. This function will call the user-specified
6313 callback function C<fn> for each B<non-empty> dependence between
6314 a source and the sink. The callback function is called
6315 with four arguments, the actual flow dependence relation
6316 mapping source iterations to sink iterations, a boolean that
6317 indicates whether it is a I<must> or I<may> dependence, a token
6318 identifying the source and an additional C<void *> with value
6319 equal to the third argument of the C<isl_flow_foreach> call.
6320 A dependence is marked I<must> if it originates from a I<must>
6321 source and if it is not followed by any I<may> sources.
6323 After finishing with an C<isl_flow>, the user should call
6324 C<isl_flow_free> to free all associated memory.
6326 A higher-level interface to dependence analysis is provided
6327 by the following function.
6329 #include <isl/flow.h>
6331 int isl_union_map_compute_flow(__isl_take isl_union_map *sink,
6332 __isl_take isl_union_map *must_source,
6333 __isl_take isl_union_map *may_source,
6334 __isl_take isl_union_map *schedule,
6335 __isl_give isl_union_map **must_dep,
6336 __isl_give isl_union_map **may_dep,
6337 __isl_give isl_union_map **must_no_source,
6338 __isl_give isl_union_map **may_no_source);
6340 The arrays are identified by the tuple names of the ranges
6341 of the accesses. The iteration domains by the tuple names
6342 of the domains of the accesses and of the schedule.
6343 The relative order of the iteration domains is given by the
6344 schedule. The relations returned through C<must_no_source>
6345 and C<may_no_source> are subsets of C<sink>.
6346 Any of C<must_dep>, C<may_dep>, C<must_no_source>
6347 or C<may_no_source> may be C<NULL>, but a C<NULL> value for
6348 any of the other arguments is treated as an error.
6350 =head3 Interaction with Dependence Analysis
6352 During the dependence analysis, we frequently need to perform
6353 the following operation. Given a relation between sink iterations
6354 and potential source iterations from a particular source domain,
6355 what is the last potential source iteration corresponding to each
6356 sink iteration. It can sometimes be convenient to adjust
6357 the set of potential source iterations before or after each such operation.
6358 The prototypical example is fuzzy array dataflow analysis,
6359 where we need to analyze if, based on data-dependent constraints,
6360 the sink iteration can ever be executed without one or more of
6361 the corresponding potential source iterations being executed.
6362 If so, we can introduce extra parameters and select an unknown
6363 but fixed source iteration from the potential source iterations.
6364 To be able to perform such manipulations, C<isl> provides the following
6367 #include <isl/flow.h>
6369 typedef __isl_give isl_restriction *(*isl_access_restrict)(
6370 __isl_keep isl_map *source_map,
6371 __isl_keep isl_set *sink, void *source_user,
6373 __isl_give isl_access_info *isl_access_info_set_restrict(
6374 __isl_take isl_access_info *acc,
6375 isl_access_restrict fn, void *user);
6377 The function C<isl_access_info_set_restrict> should be called
6378 before calling C<isl_access_info_compute_flow> and registers a callback function
6379 that will be called any time C<isl> is about to compute the last
6380 potential source. The first argument is the (reverse) proto-dependence,
6381 mapping sink iterations to potential source iterations.
6382 The second argument represents the sink iterations for which
6383 we want to compute the last source iteration.
6384 The third argument is the token corresponding to the source
6385 and the final argument is the token passed to C<isl_access_info_set_restrict>.
6386 The callback is expected to return a restriction on either the input or
6387 the output of the operation computing the last potential source.
6388 If the input needs to be restricted then restrictions are needed
6389 for both the source and the sink iterations. The sink iterations
6390 and the potential source iterations will be intersected with these sets.
6391 If the output needs to be restricted then only a restriction on the source
6392 iterations is required.
6393 If any error occurs, the callback should return C<NULL>.
6394 An C<isl_restriction> object can be created, freed and inspected
6395 using the following functions.
6397 #include <isl/flow.h>
6399 __isl_give isl_restriction *isl_restriction_input(
6400 __isl_take isl_set *source_restr,
6401 __isl_take isl_set *sink_restr);
6402 __isl_give isl_restriction *isl_restriction_output(
6403 __isl_take isl_set *source_restr);
6404 __isl_give isl_restriction *isl_restriction_none(
6405 __isl_take isl_map *source_map);
6406 __isl_give isl_restriction *isl_restriction_empty(
6407 __isl_take isl_map *source_map);
6408 __isl_null isl_restriction *isl_restriction_free(
6409 __isl_take isl_restriction *restr);
6411 C<isl_restriction_none> and C<isl_restriction_empty> are special
6412 cases of C<isl_restriction_input>. C<isl_restriction_none>
6413 is essentially equivalent to
6415 isl_restriction_input(isl_set_universe(
6416 isl_space_range(isl_map_get_space(source_map))),
6418 isl_space_domain(isl_map_get_space(source_map))));
6420 whereas C<isl_restriction_empty> is essentially equivalent to
6422 isl_restriction_input(isl_set_empty(
6423 isl_space_range(isl_map_get_space(source_map))),
6425 isl_space_domain(isl_map_get_space(source_map))));
6429 B<The functionality described in this section is fairly new
6430 and may be subject to change.>
6432 #include <isl/schedule.h>
6433 __isl_give isl_schedule *
6434 isl_schedule_constraints_compute_schedule(
6435 __isl_take isl_schedule_constraints *sc);
6436 __isl_null isl_schedule *isl_schedule_free(
6437 __isl_take isl_schedule *sched);
6439 The function C<isl_schedule_constraints_compute_schedule> can be
6440 used to compute a schedule that satisfies the given schedule constraints.
6441 These schedule constraints include the iteration domain for which
6442 a schedule should be computed and dependences between pairs of
6443 iterations. In particular, these dependences include
6444 I<validity> dependences and I<proximity> dependences.
6445 By default, the algorithm used to construct the schedule is similar
6446 to that of C<Pluto>.
6447 Alternatively, Feautrier's multi-dimensional scheduling algorithm can
6449 The generated schedule respects all validity dependences.
6450 That is, all dependence distances over these dependences in the
6451 scheduled space are lexicographically positive.
6452 The default algorithm tries to ensure that the dependence distances
6453 over coincidence constraints are zero and to minimize the
6454 dependence distances over proximity dependences.
6455 Moreover, it tries to obtain sequences (bands) of schedule dimensions
6456 for groups of domains where the dependence distances over validity
6457 dependences have only non-negative values.
6458 When using Feautrier's algorithm, the coincidence and proximity constraints
6459 are only taken into account during the extension to a
6460 full-dimensional schedule.
6462 An C<isl_schedule_constraints> object can be constructed
6463 and manipulated using the following functions.
6465 #include <isl/schedule.h>
6466 __isl_give isl_schedule_constraints *
6467 isl_schedule_constraints_copy(
6468 __isl_keep isl_schedule_constraints *sc);
6469 __isl_give isl_schedule_constraints *
6470 isl_schedule_constraints_on_domain(
6471 __isl_take isl_union_set *domain);
6472 __isl_give isl_schedule_constraints *
6473 isl_schedule_constraints_set_validity(
6474 __isl_take isl_schedule_constraints *sc,
6475 __isl_take isl_union_map *validity);
6476 __isl_give isl_schedule_constraints *
6477 isl_schedule_constraints_set_coincidence(
6478 __isl_take isl_schedule_constraints *sc,
6479 __isl_take isl_union_map *coincidence);
6480 __isl_give isl_schedule_constraints *
6481 isl_schedule_constraints_set_proximity(
6482 __isl_take isl_schedule_constraints *sc,
6483 __isl_take isl_union_map *proximity);
6484 __isl_give isl_schedule_constraints *
6485 isl_schedule_constraints_set_conditional_validity(
6486 __isl_take isl_schedule_constraints *sc,
6487 __isl_take isl_union_map *condition,
6488 __isl_take isl_union_map *validity);
6489 __isl_null isl_schedule_constraints *
6490 isl_schedule_constraints_free(
6491 __isl_take isl_schedule_constraints *sc);
6493 The initial C<isl_schedule_constraints> object created by
6494 C<isl_schedule_constraints_on_domain> does not impose any constraints.
6495 That is, it has an empty set of dependences.
6496 The function C<isl_schedule_constraints_set_validity> replaces the
6497 validity dependences, mapping domain elements I<i> to domain
6498 elements that should be scheduled after I<i>.
6499 The function C<isl_schedule_constraints_set_coincidence> replaces the
6500 coincidence dependences, mapping domain elements I<i> to domain
6501 elements that should be scheduled together with I<I>, if possible.
6502 The function C<isl_schedule_constraints_set_proximity> replaces the
6503 proximity dependences, mapping domain elements I<i> to domain
6504 elements that should be scheduled either before I<I>
6505 or as early as possible after I<i>.
6507 The function C<isl_schedule_constraints_set_conditional_validity>
6508 replaces the conditional validity constraints.
6509 A conditional validity constraint is only imposed when any of the corresponding
6510 conditions is satisfied, i.e., when any of them is non-zero.
6511 That is, the scheduler ensures that within each band if the dependence
6512 distances over the condition constraints are not all zero
6513 then all corresponding conditional validity constraints are respected.
6514 A conditional validity constraint corresponds to a condition
6515 if the two are adjacent, i.e., if the domain of one relation intersect
6516 the range of the other relation.
6517 The typical use case of conditional validity constraints is
6518 to allow order constraints between live ranges to be violated
6519 as long as the live ranges themselves are local to the band.
6520 To allow more fine-grained control over which conditions correspond
6521 to which conditional validity constraints, the domains and ranges
6522 of these relations may include I<tags>. That is, the domains and
6523 ranges of those relation may themselves be wrapped relations
6524 where the iteration domain appears in the domain of those wrapped relations
6525 and the range of the wrapped relations can be arbitrarily chosen
6526 by the user. Conditions and conditional validity constraints are only
6527 considered adjacent to each other if the entire wrapped relation matches.
6528 In particular, a relation with a tag will never be considered adjacent
6529 to a relation without a tag.
6531 The following function computes a schedule directly from
6532 an iteration domain and validity and proximity dependences
6533 and is implemented in terms of the functions described above.
6534 The use of C<isl_union_set_compute_schedule> is discouraged.
6536 #include <isl/schedule.h>
6537 __isl_give isl_schedule *isl_union_set_compute_schedule(
6538 __isl_take isl_union_set *domain,
6539 __isl_take isl_union_map *validity,
6540 __isl_take isl_union_map *proximity);
6542 A mapping from the domains to the scheduled space can be obtained
6543 from an C<isl_schedule> using the following function.
6545 __isl_give isl_union_map *isl_schedule_get_map(
6546 __isl_keep isl_schedule *sched);
6548 A representation of the schedule can be printed using
6550 __isl_give isl_printer *isl_printer_print_schedule(
6551 __isl_take isl_printer *p,
6552 __isl_keep isl_schedule *schedule);
6554 A representation of the schedule as a forest of bands can be obtained
6555 using the following function.
6557 __isl_give isl_band_list *isl_schedule_get_band_forest(
6558 __isl_keep isl_schedule *schedule);
6560 The individual bands can be visited in depth-first post-order
6561 using the following function.
6563 #include <isl/schedule.h>
6564 int isl_schedule_foreach_band(
6565 __isl_keep isl_schedule *sched,
6566 int (*fn)(__isl_keep isl_band *band, void *user),
6569 The list can be manipulated as explained in L<"Lists">.
6570 The bands inside the list can be copied and freed using the following
6573 #include <isl/band.h>
6574 __isl_give isl_band *isl_band_copy(
6575 __isl_keep isl_band *band);
6576 __isl_null isl_band *isl_band_free(
6577 __isl_take isl_band *band);
6579 Each band contains zero or more scheduling dimensions.
6580 These are referred to as the members of the band.
6581 The section of the schedule that corresponds to the band is
6582 referred to as the partial schedule of the band.
6583 For those nodes that participate in a band, the outer scheduling
6584 dimensions form the prefix schedule, while the inner scheduling
6585 dimensions form the suffix schedule.
6586 That is, if we take a cut of the band forest, then the union of
6587 the concatenations of the prefix, partial and suffix schedules of
6588 each band in the cut is equal to the entire schedule (modulo
6589 some possible padding at the end with zero scheduling dimensions).
6590 The properties of a band can be inspected using the following functions.
6592 #include <isl/band.h>
6593 int isl_band_has_children(__isl_keep isl_band *band);
6594 __isl_give isl_band_list *isl_band_get_children(
6595 __isl_keep isl_band *band);
6597 __isl_give isl_union_map *isl_band_get_prefix_schedule(
6598 __isl_keep isl_band *band);
6599 __isl_give isl_union_map *isl_band_get_partial_schedule(
6600 __isl_keep isl_band *band);
6601 __isl_give isl_union_map *isl_band_get_suffix_schedule(
6602 __isl_keep isl_band *band);
6604 int isl_band_n_member(__isl_keep isl_band *band);
6605 int isl_band_member_is_coincident(
6606 __isl_keep isl_band *band, int pos);
6608 int isl_band_list_foreach_band(
6609 __isl_keep isl_band_list *list,
6610 int (*fn)(__isl_keep isl_band *band, void *user),
6613 Note that a scheduling dimension is considered to be ``coincident''
6614 if it satisfies the coincidence constraints within its band.
6615 That is, if the dependence distances of the coincidence
6616 constraints are all zero in that direction (for fixed
6617 iterations of outer bands).
6618 Like C<isl_schedule_foreach_band>,
6619 the function C<isl_band_list_foreach_band> calls C<fn> on the bands
6620 in depth-first post-order.
6622 A band can be tiled using the following function.
6624 #include <isl/band.h>
6625 int isl_band_tile(__isl_keep isl_band *band,
6626 __isl_take isl_vec *sizes);
6628 int isl_options_set_tile_scale_tile_loops(isl_ctx *ctx,
6630 int isl_options_get_tile_scale_tile_loops(isl_ctx *ctx);
6631 int isl_options_set_tile_shift_point_loops(isl_ctx *ctx,
6633 int isl_options_get_tile_shift_point_loops(isl_ctx *ctx);
6635 The C<isl_band_tile> function tiles the band using the given tile sizes
6636 inside its schedule.
6637 A new child band is created to represent the point loops and it is
6638 inserted between the modified band and its children.
6639 The C<tile_scale_tile_loops> option specifies whether the tile
6640 loops iterators should be scaled by the tile sizes.
6641 If the C<tile_shift_point_loops> option is set, then the point loops
6642 are shifted to start at zero.
6644 A band can be split into two nested bands using the following function.
6646 int isl_band_split(__isl_keep isl_band *band, int pos);
6648 The resulting outer band contains the first C<pos> dimensions of C<band>
6649 while the inner band contains the remaining dimensions.
6651 A representation of the band can be printed using
6653 #include <isl/band.h>
6654 __isl_give isl_printer *isl_printer_print_band(
6655 __isl_take isl_printer *p,
6656 __isl_keep isl_band *band);
6660 #include <isl/schedule.h>
6661 int isl_options_set_schedule_max_coefficient(
6662 isl_ctx *ctx, int val);
6663 int isl_options_get_schedule_max_coefficient(
6665 int isl_options_set_schedule_max_constant_term(
6666 isl_ctx *ctx, int val);
6667 int isl_options_get_schedule_max_constant_term(
6669 int isl_options_set_schedule_fuse(isl_ctx *ctx, int val);
6670 int isl_options_get_schedule_fuse(isl_ctx *ctx);
6671 int isl_options_set_schedule_maximize_band_depth(
6672 isl_ctx *ctx, int val);
6673 int isl_options_get_schedule_maximize_band_depth(
6675 int isl_options_set_schedule_outer_coincidence(
6676 isl_ctx *ctx, int val);
6677 int isl_options_get_schedule_outer_coincidence(
6679 int isl_options_set_schedule_split_scaled(
6680 isl_ctx *ctx, int val);
6681 int isl_options_get_schedule_split_scaled(
6683 int isl_options_set_schedule_algorithm(
6684 isl_ctx *ctx, int val);
6685 int isl_options_get_schedule_algorithm(
6687 int isl_options_set_schedule_separate_components(
6688 isl_ctx *ctx, int val);
6689 int isl_options_get_schedule_separate_components(
6694 =item * schedule_max_coefficient
6696 This option enforces that the coefficients for variable and parameter
6697 dimensions in the calculated schedule are not larger than the specified value.
6698 This option can significantly increase the speed of the scheduling calculation
6699 and may also prevent fusing of unrelated dimensions. A value of -1 means that
6700 this option does not introduce bounds on the variable or parameter
6703 =item * schedule_max_constant_term
6705 This option enforces that the constant coefficients in the calculated schedule
6706 are not larger than the maximal constant term. This option can significantly
6707 increase the speed of the scheduling calculation and may also prevent fusing of
6708 unrelated dimensions. A value of -1 means that this option does not introduce
6709 bounds on the constant coefficients.
6711 =item * schedule_fuse
6713 This option controls the level of fusion.
6714 If this option is set to C<ISL_SCHEDULE_FUSE_MIN>, then loops in the
6715 resulting schedule will be distributed as much as possible.
6716 If this option is set to C<ISL_SCHEDULE_FUSE_MAX>, then C<isl> will
6717 try to fuse loops in the resulting schedule.
6719 =item * schedule_maximize_band_depth
6721 If this option is set, we do not split bands at the point
6722 where we detect splitting is necessary. Instead, we
6723 backtrack and split bands as early as possible. This
6724 reduces the number of splits and maximizes the width of
6725 the bands. Wider bands give more possibilities for tiling.
6726 Note that if the C<schedule_fuse> option is set to C<ISL_SCHEDULE_FUSE_MIN>,
6727 then bands will be split as early as possible, even if there is no need.
6728 The C<schedule_maximize_band_depth> option therefore has no effect in this case.
6730 =item * schedule_outer_coincidence
6732 If this option is set, then we try to construct schedules
6733 where the outermost scheduling dimension in each band
6734 satisfies the coincidence constraints.
6736 =item * schedule_split_scaled
6738 If this option is set, then we try to construct schedules in which the
6739 constant term is split off from the linear part if the linear parts of
6740 the scheduling rows for all nodes in the graphs have a common non-trivial
6742 The constant term is then placed in a separate band and the linear
6745 =item * schedule_algorithm
6747 Selects the scheduling algorithm to be used.
6748 Available scheduling algorithms are C<ISL_SCHEDULE_ALGORITHM_ISL>
6749 and C<ISL_SCHEDULE_ALGORITHM_FEAUTRIER>.
6751 =item * schedule_separate_components
6753 If at any point the dependence graph contains any (weakly connected) components,
6754 then these components are scheduled separately.
6755 If this option is not set, then some iterations of the domains
6756 in these components may be scheduled together.
6757 If this option is set, then the components are given consecutive
6762 =head2 AST Generation
6764 This section describes the C<isl> functionality for generating
6765 ASTs that visit all the elements
6766 in a domain in an order specified by a schedule.
6767 In particular, given a C<isl_union_map>, an AST is generated
6768 that visits all the elements in the domain of the C<isl_union_map>
6769 according to the lexicographic order of the corresponding image
6770 element(s). If the range of the C<isl_union_map> consists of
6771 elements in more than one space, then each of these spaces is handled
6772 separately in an arbitrary order.
6773 It should be noted that the image elements only specify the I<order>
6774 in which the corresponding domain elements should be visited.
6775 No direct relation between the image elements and the loop iterators
6776 in the generated AST should be assumed.
6778 Each AST is generated within a build. The initial build
6779 simply specifies the constraints on the parameters (if any)
6780 and can be created, inspected, copied and freed using the following functions.
6782 #include <isl/ast_build.h>
6783 __isl_give isl_ast_build *isl_ast_build_from_context(
6784 __isl_take isl_set *set);
6785 __isl_give isl_ast_build *isl_ast_build_copy(
6786 __isl_keep isl_ast_build *build);
6787 __isl_null isl_ast_build *isl_ast_build_free(
6788 __isl_take isl_ast_build *build);
6790 The C<set> argument is usually a parameter set with zero or more parameters.
6791 More C<isl_ast_build> functions are described in L</"Nested AST Generation">
6792 and L</"Fine-grained Control over AST Generation">.
6793 Finally, the AST itself can be constructed using the following
6796 #include <isl/ast_build.h>
6797 __isl_give isl_ast_node *isl_ast_build_ast_from_schedule(
6798 __isl_keep isl_ast_build *build,
6799 __isl_take isl_union_map *schedule);
6801 =head3 Inspecting the AST
6803 The basic properties of an AST node can be obtained as follows.
6805 #include <isl/ast.h>
6806 enum isl_ast_node_type isl_ast_node_get_type(
6807 __isl_keep isl_ast_node *node);
6809 The type of an AST node is one of
6810 C<isl_ast_node_for>,
6812 C<isl_ast_node_block> or
6813 C<isl_ast_node_user>.
6814 An C<isl_ast_node_for> represents a for node.
6815 An C<isl_ast_node_if> represents an if node.
6816 An C<isl_ast_node_block> represents a compound node.
6817 An C<isl_ast_node_user> represents an expression statement.
6818 An expression statement typically corresponds to a domain element, i.e.,
6819 one of the elements that is visited by the AST.
6821 Each type of node has its own additional properties.
6823 #include <isl/ast.h>
6824 __isl_give isl_ast_expr *isl_ast_node_for_get_iterator(
6825 __isl_keep isl_ast_node *node);
6826 __isl_give isl_ast_expr *isl_ast_node_for_get_init(
6827 __isl_keep isl_ast_node *node);
6828 __isl_give isl_ast_expr *isl_ast_node_for_get_cond(
6829 __isl_keep isl_ast_node *node);
6830 __isl_give isl_ast_expr *isl_ast_node_for_get_inc(
6831 __isl_keep isl_ast_node *node);
6832 __isl_give isl_ast_node *isl_ast_node_for_get_body(
6833 __isl_keep isl_ast_node *node);
6834 int isl_ast_node_for_is_degenerate(
6835 __isl_keep isl_ast_node *node);
6837 An C<isl_ast_for> is considered degenerate if it is known to execute
6840 #include <isl/ast.h>
6841 __isl_give isl_ast_expr *isl_ast_node_if_get_cond(
6842 __isl_keep isl_ast_node *node);
6843 __isl_give isl_ast_node *isl_ast_node_if_get_then(
6844 __isl_keep isl_ast_node *node);
6845 int isl_ast_node_if_has_else(
6846 __isl_keep isl_ast_node *node);
6847 __isl_give isl_ast_node *isl_ast_node_if_get_else(
6848 __isl_keep isl_ast_node *node);
6850 __isl_give isl_ast_node_list *
6851 isl_ast_node_block_get_children(
6852 __isl_keep isl_ast_node *node);
6854 __isl_give isl_ast_expr *isl_ast_node_user_get_expr(
6855 __isl_keep isl_ast_node *node);
6857 Each of the returned C<isl_ast_expr>s can in turn be inspected using
6858 the following functions.
6860 #include <isl/ast.h>
6861 enum isl_ast_expr_type isl_ast_expr_get_type(
6862 __isl_keep isl_ast_expr *expr);
6864 The type of an AST expression is one of
6866 C<isl_ast_expr_id> or
6867 C<isl_ast_expr_int>.
6868 An C<isl_ast_expr_op> represents the result of an operation.
6869 An C<isl_ast_expr_id> represents an identifier.
6870 An C<isl_ast_expr_int> represents an integer value.
6872 Each type of expression has its own additional properties.
6874 #include <isl/ast.h>
6875 enum isl_ast_op_type isl_ast_expr_get_op_type(
6876 __isl_keep isl_ast_expr *expr);
6877 int isl_ast_expr_get_op_n_arg(__isl_keep isl_ast_expr *expr);
6878 __isl_give isl_ast_expr *isl_ast_expr_get_op_arg(
6879 __isl_keep isl_ast_expr *expr, int pos);
6880 int isl_ast_node_foreach_ast_op_type(
6881 __isl_keep isl_ast_node *node,
6882 int (*fn)(enum isl_ast_op_type type, void *user),
6885 C<isl_ast_expr_get_op_type> returns the type of the operation
6886 performed. C<isl_ast_expr_get_op_n_arg> returns the number of
6887 arguments. C<isl_ast_expr_get_op_arg> returns the specified
6889 C<isl_ast_node_foreach_ast_op_type> calls C<fn> for each distinct
6890 C<isl_ast_op_type> that appears in C<node>.
6891 The operation type is one of the following.
6895 =item C<isl_ast_op_and>
6897 Logical I<and> of two arguments.
6898 Both arguments can be evaluated.
6900 =item C<isl_ast_op_and_then>
6902 Logical I<and> of two arguments.
6903 The second argument can only be evaluated if the first evaluates to true.
6905 =item C<isl_ast_op_or>
6907 Logical I<or> of two arguments.
6908 Both arguments can be evaluated.
6910 =item C<isl_ast_op_or_else>
6912 Logical I<or> of two arguments.
6913 The second argument can only be evaluated if the first evaluates to false.
6915 =item C<isl_ast_op_max>
6917 Maximum of two or more arguments.
6919 =item C<isl_ast_op_min>
6921 Minimum of two or more arguments.
6923 =item C<isl_ast_op_minus>
6927 =item C<isl_ast_op_add>
6929 Sum of two arguments.
6931 =item C<isl_ast_op_sub>
6933 Difference of two arguments.
6935 =item C<isl_ast_op_mul>
6937 Product of two arguments.
6939 =item C<isl_ast_op_div>
6941 Exact division. That is, the result is known to be an integer.
6943 =item C<isl_ast_op_fdiv_q>
6945 Result of integer division, rounded towards negative
6948 =item C<isl_ast_op_pdiv_q>
6950 Result of integer division, where dividend is known to be non-negative.
6952 =item C<isl_ast_op_pdiv_r>
6954 Remainder of integer division, where dividend is known to be non-negative.
6956 =item C<isl_ast_op_zdiv_r>
6958 Equal to zero iff the remainder on integer division is zero.
6960 =item C<isl_ast_op_cond>
6962 Conditional operator defined on three arguments.
6963 If the first argument evaluates to true, then the result
6964 is equal to the second argument. Otherwise, the result
6965 is equal to the third argument.
6966 The second and third argument may only be evaluated if
6967 the first argument evaluates to true and false, respectively.
6968 Corresponds to C<a ? b : c> in C.
6970 =item C<isl_ast_op_select>
6972 Conditional operator defined on three arguments.
6973 If the first argument evaluates to true, then the result
6974 is equal to the second argument. Otherwise, the result
6975 is equal to the third argument.
6976 The second and third argument may be evaluated independently
6977 of the value of the first argument.
6978 Corresponds to C<a * b + (1 - a) * c> in C.
6980 =item C<isl_ast_op_eq>
6984 =item C<isl_ast_op_le>
6986 Less than or equal relation.
6988 =item C<isl_ast_op_lt>
6992 =item C<isl_ast_op_ge>
6994 Greater than or equal relation.
6996 =item C<isl_ast_op_gt>
6998 Greater than relation.
7000 =item C<isl_ast_op_call>
7003 The number of arguments of the C<isl_ast_expr> is one more than
7004 the number of arguments in the function call, the first argument
7005 representing the function being called.
7007 =item C<isl_ast_op_access>
7010 The number of arguments of the C<isl_ast_expr> is one more than
7011 the number of index expressions in the array access, the first argument
7012 representing the array being accessed.
7014 =item C<isl_ast_op_member>
7017 This operation has two arguments, a structure and the name of
7018 the member of the structure being accessed.
7022 #include <isl/ast.h>
7023 __isl_give isl_id *isl_ast_expr_get_id(
7024 __isl_keep isl_ast_expr *expr);
7026 Return the identifier represented by the AST expression.
7028 #include <isl/ast.h>
7029 __isl_give isl_val *isl_ast_expr_get_val(
7030 __isl_keep isl_ast_expr *expr);
7032 Return the integer represented by the AST expression.
7034 =head3 Properties of ASTs
7036 #include <isl/ast.h>
7037 int isl_ast_expr_is_equal(__isl_keep isl_ast_expr *expr1,
7038 __isl_keep isl_ast_expr *expr2);
7040 Check if two C<isl_ast_expr>s are equal to each other.
7042 =head3 Manipulating and printing the AST
7044 AST nodes can be copied and freed using the following functions.
7046 #include <isl/ast.h>
7047 __isl_give isl_ast_node *isl_ast_node_copy(
7048 __isl_keep isl_ast_node *node);
7049 __isl_null isl_ast_node *isl_ast_node_free(
7050 __isl_take isl_ast_node *node);
7052 AST expressions can be copied and freed using the following functions.
7054 #include <isl/ast.h>
7055 __isl_give isl_ast_expr *isl_ast_expr_copy(
7056 __isl_keep isl_ast_expr *expr);
7057 __isl_null isl_ast_expr *isl_ast_expr_free(
7058 __isl_take isl_ast_expr *expr);
7060 New AST expressions can be created either directly or within
7061 the context of an C<isl_ast_build>.
7063 #include <isl/ast.h>
7064 __isl_give isl_ast_expr *isl_ast_expr_from_val(
7065 __isl_take isl_val *v);
7066 __isl_give isl_ast_expr *isl_ast_expr_from_id(
7067 __isl_take isl_id *id);
7068 __isl_give isl_ast_expr *isl_ast_expr_neg(
7069 __isl_take isl_ast_expr *expr);
7070 __isl_give isl_ast_expr *isl_ast_expr_address_of(
7071 __isl_take isl_ast_expr *expr);
7072 __isl_give isl_ast_expr *isl_ast_expr_add(
7073 __isl_take isl_ast_expr *expr1,
7074 __isl_take isl_ast_expr *expr2);
7075 __isl_give isl_ast_expr *isl_ast_expr_sub(
7076 __isl_take isl_ast_expr *expr1,
7077 __isl_take isl_ast_expr *expr2);
7078 __isl_give isl_ast_expr *isl_ast_expr_mul(
7079 __isl_take isl_ast_expr *expr1,
7080 __isl_take isl_ast_expr *expr2);
7081 __isl_give isl_ast_expr *isl_ast_expr_div(
7082 __isl_take isl_ast_expr *expr1,
7083 __isl_take isl_ast_expr *expr2);
7084 __isl_give isl_ast_expr *isl_ast_expr_and(
7085 __isl_take isl_ast_expr *expr1,
7086 __isl_take isl_ast_expr *expr2)
7087 __isl_give isl_ast_expr *isl_ast_expr_or(
7088 __isl_take isl_ast_expr *expr1,
7089 __isl_take isl_ast_expr *expr2)
7090 __isl_give isl_ast_expr *isl_ast_expr_eq(
7091 __isl_take isl_ast_expr *expr1,
7092 __isl_take isl_ast_expr *expr2);
7093 __isl_give isl_ast_expr *isl_ast_expr_le(
7094 __isl_take isl_ast_expr *expr1,
7095 __isl_take isl_ast_expr *expr2);
7096 __isl_give isl_ast_expr *isl_ast_expr_lt(
7097 __isl_take isl_ast_expr *expr1,
7098 __isl_take isl_ast_expr *expr2);
7099 __isl_give isl_ast_expr *isl_ast_expr_ge(
7100 __isl_take isl_ast_expr *expr1,
7101 __isl_take isl_ast_expr *expr2);
7102 __isl_give isl_ast_expr *isl_ast_expr_gt(
7103 __isl_take isl_ast_expr *expr1,
7104 __isl_take isl_ast_expr *expr2);
7105 __isl_give isl_ast_expr *isl_ast_expr_access(
7106 __isl_take isl_ast_expr *array,
7107 __isl_take isl_ast_expr_list *indices);
7109 The function C<isl_ast_expr_address_of> can be applied to an
7110 C<isl_ast_expr> of type C<isl_ast_op_access> only. It is meant
7111 to represent the address of the C<isl_ast_expr_access>.
7113 #include <isl/ast_build.h>
7114 __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff(
7115 __isl_keep isl_ast_build *build,
7116 __isl_take isl_pw_aff *pa);
7117 __isl_give isl_ast_expr *
7118 isl_ast_build_access_from_pw_multi_aff(
7119 __isl_keep isl_ast_build *build,
7120 __isl_take isl_pw_multi_aff *pma);
7121 __isl_give isl_ast_expr *
7122 isl_ast_build_access_from_multi_pw_aff(
7123 __isl_keep isl_ast_build *build,
7124 __isl_take isl_multi_pw_aff *mpa);
7125 __isl_give isl_ast_expr *
7126 isl_ast_build_call_from_pw_multi_aff(
7127 __isl_keep isl_ast_build *build,
7128 __isl_take isl_pw_multi_aff *pma);
7129 __isl_give isl_ast_expr *
7130 isl_ast_build_call_from_multi_pw_aff(
7131 __isl_keep isl_ast_build *build,
7132 __isl_take isl_multi_pw_aff *mpa);
7134 The domains of C<pa>, C<mpa> and C<pma> should correspond
7135 to the schedule space of C<build>.
7136 The tuple id of C<mpa> or C<pma> is used as the array being accessed or
7137 the function being called.
7138 If the accessed space is a nested relation, then it is taken
7139 to represent an access of the member specified by the range
7140 of this nested relation of the structure specified by the domain
7141 of the nested relation.
7143 The following functions can be used to modify an C<isl_ast_expr>.
7145 #include <isl/ast.h>
7146 __isl_give isl_ast_expr *isl_ast_expr_set_op_arg(
7147 __isl_take isl_ast_expr *expr, int pos,
7148 __isl_take isl_ast_expr *arg);
7150 Replace the argument of C<expr> at position C<pos> by C<arg>.
7152 #include <isl/ast.h>
7153 __isl_give isl_ast_expr *isl_ast_expr_substitute_ids(
7154 __isl_take isl_ast_expr *expr,
7155 __isl_take isl_id_to_ast_expr *id2expr);
7157 The function C<isl_ast_expr_substitute_ids> replaces the
7158 subexpressions of C<expr> of type C<isl_ast_expr_id>
7159 by the corresponding expression in C<id2expr>, if there is any.
7162 User specified data can be attached to an C<isl_ast_node> and obtained
7163 from the same C<isl_ast_node> using the following functions.
7165 #include <isl/ast.h>
7166 __isl_give isl_ast_node *isl_ast_node_set_annotation(
7167 __isl_take isl_ast_node *node,
7168 __isl_take isl_id *annotation);
7169 __isl_give isl_id *isl_ast_node_get_annotation(
7170 __isl_keep isl_ast_node *node);
7172 Basic printing can be performed using the following functions.
7174 #include <isl/ast.h>
7175 __isl_give isl_printer *isl_printer_print_ast_expr(
7176 __isl_take isl_printer *p,
7177 __isl_keep isl_ast_expr *expr);
7178 __isl_give isl_printer *isl_printer_print_ast_node(
7179 __isl_take isl_printer *p,
7180 __isl_keep isl_ast_node *node);
7181 __isl_give char *isl_ast_expr_to_str(
7182 __isl_keep isl_ast_expr *expr);
7184 More advanced printing can be performed using the following functions.
7186 #include <isl/ast.h>
7187 __isl_give isl_printer *isl_ast_op_type_print_macro(
7188 enum isl_ast_op_type type,
7189 __isl_take isl_printer *p);
7190 __isl_give isl_printer *isl_ast_node_print_macros(
7191 __isl_keep isl_ast_node *node,
7192 __isl_take isl_printer *p);
7193 __isl_give isl_printer *isl_ast_node_print(
7194 __isl_keep isl_ast_node *node,
7195 __isl_take isl_printer *p,
7196 __isl_take isl_ast_print_options *options);
7197 __isl_give isl_printer *isl_ast_node_for_print(
7198 __isl_keep isl_ast_node *node,
7199 __isl_take isl_printer *p,
7200 __isl_take isl_ast_print_options *options);
7201 __isl_give isl_printer *isl_ast_node_if_print(
7202 __isl_keep isl_ast_node *node,
7203 __isl_take isl_printer *p,
7204 __isl_take isl_ast_print_options *options);
7206 While printing an C<isl_ast_node> in C<ISL_FORMAT_C>,
7207 C<isl> may print out an AST that makes use of macros such
7208 as C<floord>, C<min> and C<max>.
7209 C<isl_ast_op_type_print_macro> prints out the macro
7210 corresponding to a specific C<isl_ast_op_type>.
7211 C<isl_ast_node_print_macros> scans the C<isl_ast_node>
7212 for expressions where these macros would be used and prints
7213 out the required macro definitions.
7214 Essentially, C<isl_ast_node_print_macros> calls
7215 C<isl_ast_node_foreach_ast_op_type> with C<isl_ast_op_type_print_macro>
7216 as function argument.
7217 C<isl_ast_node_print>, C<isl_ast_node_for_print> and
7218 C<isl_ast_node_if_print> print an C<isl_ast_node>
7219 in C<ISL_FORMAT_C>, but allow for some extra control
7220 through an C<isl_ast_print_options> object.
7221 This object can be created using the following functions.
7223 #include <isl/ast.h>
7224 __isl_give isl_ast_print_options *
7225 isl_ast_print_options_alloc(isl_ctx *ctx);
7226 __isl_give isl_ast_print_options *
7227 isl_ast_print_options_copy(
7228 __isl_keep isl_ast_print_options *options);
7229 __isl_null isl_ast_print_options *
7230 isl_ast_print_options_free(
7231 __isl_take isl_ast_print_options *options);
7233 __isl_give isl_ast_print_options *
7234 isl_ast_print_options_set_print_user(
7235 __isl_take isl_ast_print_options *options,
7236 __isl_give isl_printer *(*print_user)(
7237 __isl_take isl_printer *p,
7238 __isl_take isl_ast_print_options *options,
7239 __isl_keep isl_ast_node *node, void *user),
7241 __isl_give isl_ast_print_options *
7242 isl_ast_print_options_set_print_for(
7243 __isl_take isl_ast_print_options *options,
7244 __isl_give isl_printer *(*print_for)(
7245 __isl_take isl_printer *p,
7246 __isl_take isl_ast_print_options *options,
7247 __isl_keep isl_ast_node *node, void *user),
7250 The callback set by C<isl_ast_print_options_set_print_user>
7251 is called whenever a node of type C<isl_ast_node_user> needs to
7253 The callback set by C<isl_ast_print_options_set_print_for>
7254 is called whenever a node of type C<isl_ast_node_for> needs to
7256 Note that C<isl_ast_node_for_print> will I<not> call the
7257 callback set by C<isl_ast_print_options_set_print_for> on the node
7258 on which C<isl_ast_node_for_print> is called, but only on nested
7259 nodes of type C<isl_ast_node_for>. It is therefore safe to
7260 call C<isl_ast_node_for_print> from within the callback set by
7261 C<isl_ast_print_options_set_print_for>.
7263 The following option determines the type to be used for iterators
7264 while printing the AST.
7266 int isl_options_set_ast_iterator_type(
7267 isl_ctx *ctx, const char *val);
7268 const char *isl_options_get_ast_iterator_type(
7271 The AST printer only prints body nodes as blocks if these
7272 blocks cannot be safely omitted.
7273 For example, a C<for> node with one body node will not be
7274 surrounded with braces in C<ISL_FORMAT_C>.
7275 A block will always be printed by setting the following option.
7277 int isl_options_set_ast_always_print_block(isl_ctx *ctx,
7279 int isl_options_get_ast_always_print_block(isl_ctx *ctx);
7283 #include <isl/ast_build.h>
7284 int isl_options_set_ast_build_atomic_upper_bound(
7285 isl_ctx *ctx, int val);
7286 int isl_options_get_ast_build_atomic_upper_bound(
7288 int isl_options_set_ast_build_prefer_pdiv(isl_ctx *ctx,
7290 int isl_options_get_ast_build_prefer_pdiv(isl_ctx *ctx);
7291 int isl_options_set_ast_build_exploit_nested_bounds(
7292 isl_ctx *ctx, int val);
7293 int isl_options_get_ast_build_exploit_nested_bounds(
7295 int isl_options_set_ast_build_group_coscheduled(
7296 isl_ctx *ctx, int val);
7297 int isl_options_get_ast_build_group_coscheduled(
7299 int isl_options_set_ast_build_scale_strides(
7300 isl_ctx *ctx, int val);
7301 int isl_options_get_ast_build_scale_strides(
7303 int isl_options_set_ast_build_allow_else(isl_ctx *ctx,
7305 int isl_options_get_ast_build_allow_else(isl_ctx *ctx);
7306 int isl_options_set_ast_build_allow_or(isl_ctx *ctx,
7308 int isl_options_get_ast_build_allow_or(isl_ctx *ctx);
7312 =item * ast_build_atomic_upper_bound
7314 Generate loop upper bounds that consist of the current loop iterator,
7315 an operator and an expression not involving the iterator.
7316 If this option is not set, then the current loop iterator may appear
7317 several times in the upper bound.
7318 For example, when this option is turned off, AST generation
7321 [n] -> { A[i] -> [i] : 0 <= i <= 100, n }
7325 for (int c0 = 0; c0 <= 100 && n >= c0; c0 += 1)
7328 When the option is turned on, the following AST is generated
7330 for (int c0 = 0; c0 <= min(100, n); c0 += 1)
7333 =item * ast_build_prefer_pdiv
7335 If this option is turned off, then the AST generation will
7336 produce ASTs that may only contain C<isl_ast_op_fdiv_q>
7337 operators, but no C<isl_ast_op_pdiv_q> or
7338 C<isl_ast_op_pdiv_r> operators.
7339 If this options is turned on, then C<isl> will try to convert
7340 some of the C<isl_ast_op_fdiv_q> operators to (expressions containing)
7341 C<isl_ast_op_pdiv_q> or C<isl_ast_op_pdiv_r> operators.
7343 =item * ast_build_exploit_nested_bounds
7345 Simplify conditions based on bounds of nested for loops.
7346 In particular, remove conditions that are implied by the fact
7347 that one or more nested loops have at least one iteration,
7348 meaning that the upper bound is at least as large as the lower bound.
7349 For example, when this option is turned off, AST generation
7352 [N,M] -> { A[i,j] -> [i,j] : 0 <= i <= N and
7358 for (int c0 = 0; c0 <= N; c0 += 1)
7359 for (int c1 = 0; c1 <= M; c1 += 1)
7362 When the option is turned on, the following AST is generated
7364 for (int c0 = 0; c0 <= N; c0 += 1)
7365 for (int c1 = 0; c1 <= M; c1 += 1)
7368 =item * ast_build_group_coscheduled
7370 If two domain elements are assigned the same schedule point, then
7371 they may be executed in any order and they may even appear in different
7372 loops. If this options is set, then the AST generator will make
7373 sure that coscheduled domain elements do not appear in separate parts
7374 of the AST. This is useful in case of nested AST generation
7375 if the outer AST generation is given only part of a schedule
7376 and the inner AST generation should handle the domains that are
7377 coscheduled by this initial part of the schedule together.
7378 For example if an AST is generated for a schedule
7380 { A[i] -> [0]; B[i] -> [0] }
7382 then the C<isl_ast_build_set_create_leaf> callback described
7383 below may get called twice, once for each domain.
7384 Setting this option ensures that the callback is only called once
7385 on both domains together.
7387 =item * ast_build_separation_bounds
7389 This option specifies which bounds to use during separation.
7390 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT>
7391 then all (possibly implicit) bounds on the current dimension will
7392 be used during separation.
7393 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT>
7394 then only those bounds that are explicitly available will
7395 be used during separation.
7397 =item * ast_build_scale_strides
7399 This option specifies whether the AST generator is allowed
7400 to scale down iterators of strided loops.
7402 =item * ast_build_allow_else
7404 This option specifies whether the AST generator is allowed
7405 to construct if statements with else branches.
7407 =item * ast_build_allow_or
7409 This option specifies whether the AST generator is allowed
7410 to construct if conditions with disjunctions.
7414 =head3 Fine-grained Control over AST Generation
7416 Besides specifying the constraints on the parameters,
7417 an C<isl_ast_build> object can be used to control
7418 various aspects of the AST generation process.
7419 The most prominent way of control is through ``options'',
7420 which can be set using the following function.
7422 #include <isl/ast_build.h>
7423 __isl_give isl_ast_build *
7424 isl_ast_build_set_options(
7425 __isl_take isl_ast_build *control,
7426 __isl_take isl_union_map *options);
7428 The options are encoded in an C<isl_union_map>.
7429 The domain of this union relation refers to the schedule domain,
7430 i.e., the range of the schedule passed to C<isl_ast_build_ast_from_schedule>.
7431 In the case of nested AST generation (see L</"Nested AST Generation">),
7432 the domain of C<options> should refer to the extra piece of the schedule.
7433 That is, it should be equal to the range of the wrapped relation in the
7434 range of the schedule.
7435 The range of the options can consist of elements in one or more spaces,
7436 the names of which determine the effect of the option.
7437 The values of the range typically also refer to the schedule dimension
7438 to which the option applies. In case of nested AST generation
7439 (see L</"Nested AST Generation">), these values refer to the position
7440 of the schedule dimension within the innermost AST generation.
7441 The constraints on the domain elements of
7442 the option should only refer to this dimension and earlier dimensions.
7443 We consider the following spaces.
7447 =item C<separation_class>
7449 This space is a wrapped relation between two one dimensional spaces.
7450 The input space represents the schedule dimension to which the option
7451 applies and the output space represents the separation class.
7452 While constructing a loop corresponding to the specified schedule
7453 dimension(s), the AST generator will try to generate separate loops
7454 for domain elements that are assigned different classes.
7455 If only some of the elements are assigned a class, then those elements
7456 that are not assigned any class will be treated as belonging to a class
7457 that is separate from the explicitly assigned classes.
7458 The typical use case for this option is to separate full tiles from
7460 The other options, described below, are applied after the separation
7463 As an example, consider the separation into full and partial tiles
7464 of a tiling of a triangular domain.
7465 Take, for example, the domain
7467 { A[i,j] : 0 <= i,j and i + j <= 100 }
7469 and a tiling into tiles of 10 by 10. The input to the AST generator
7470 is then the schedule
7472 { A[i,j] -> [([i/10]),[j/10],i,j] : 0 <= i,j and
7475 Without any options, the following AST is generated
7477 for (int c0 = 0; c0 <= 10; c0 += 1)
7478 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7479 for (int c2 = 10 * c0;
7480 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7482 for (int c3 = 10 * c1;
7483 c3 <= min(10 * c1 + 9, -c2 + 100);
7487 Separation into full and partial tiles can be obtained by assigning
7488 a class, say C<0>, to the full tiles. The full tiles are represented by those
7489 values of the first and second schedule dimensions for which there are
7490 values of the third and fourth dimensions to cover an entire tile.
7491 That is, we need to specify the following option
7493 { [a,b,c,d] -> separation_class[[0]->[0]] :
7494 exists b': 0 <= 10a,10b' and
7495 10a+9+10b'+9 <= 100;
7496 [a,b,c,d] -> separation_class[[1]->[0]] :
7497 0 <= 10a,10b and 10a+9+10b+9 <= 100 }
7501 { [a, b, c, d] -> separation_class[[1] -> [0]] :
7502 a >= 0 and b >= 0 and b <= 8 - a;
7503 [a, b, c, d] -> separation_class[[0] -> [0]] :
7506 With this option, the generated AST is as follows
7509 for (int c0 = 0; c0 <= 8; c0 += 1) {
7510 for (int c1 = 0; c1 <= -c0 + 8; c1 += 1)
7511 for (int c2 = 10 * c0;
7512 c2 <= 10 * c0 + 9; c2 += 1)
7513 for (int c3 = 10 * c1;
7514 c3 <= 10 * c1 + 9; c3 += 1)
7516 for (int c1 = -c0 + 9; c1 <= -c0 + 10; c1 += 1)
7517 for (int c2 = 10 * c0;
7518 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7520 for (int c3 = 10 * c1;
7521 c3 <= min(-c2 + 100, 10 * c1 + 9);
7525 for (int c0 = 9; c0 <= 10; c0 += 1)
7526 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7527 for (int c2 = 10 * c0;
7528 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7530 for (int c3 = 10 * c1;
7531 c3 <= min(10 * c1 + 9, -c2 + 100);
7538 This is a single-dimensional space representing the schedule dimension(s)
7539 to which ``separation'' should be applied. Separation tries to split
7540 a loop into several pieces if this can avoid the generation of guards
7542 See also the C<atomic> option.
7546 This is a single-dimensional space representing the schedule dimension(s)
7547 for which the domains should be considered ``atomic''. That is, the
7548 AST generator will make sure that any given domain space will only appear
7549 in a single loop at the specified level.
7551 Consider the following schedule
7553 { a[i] -> [i] : 0 <= i < 10;
7554 b[i] -> [i+1] : 0 <= i < 10 }
7556 If the following option is specified
7558 { [i] -> separate[x] }
7560 then the following AST will be generated
7564 for (int c0 = 1; c0 <= 9; c0 += 1) {
7571 If, on the other hand, the following option is specified
7573 { [i] -> atomic[x] }
7575 then the following AST will be generated
7577 for (int c0 = 0; c0 <= 10; c0 += 1) {
7584 If neither C<atomic> nor C<separate> is specified, then the AST generator
7585 may produce either of these two results or some intermediate form.
7589 This is a single-dimensional space representing the schedule dimension(s)
7590 that should be I<completely> unrolled.
7591 To obtain a partial unrolling, the user should apply an additional
7592 strip-mining to the schedule and fully unroll the inner loop.
7596 Additional control is available through the following functions.
7598 #include <isl/ast_build.h>
7599 __isl_give isl_ast_build *
7600 isl_ast_build_set_iterators(
7601 __isl_take isl_ast_build *control,
7602 __isl_take isl_id_list *iterators);
7604 The function C<isl_ast_build_set_iterators> allows the user to
7605 specify a list of iterator C<isl_id>s to be used as iterators.
7606 If the input schedule is injective, then
7607 the number of elements in this list should be as large as the dimension
7608 of the schedule space, but no direct correspondence should be assumed
7609 between dimensions and elements.
7610 If the input schedule is not injective, then an additional number
7611 of C<isl_id>s equal to the largest dimension of the input domains
7613 If the number of provided C<isl_id>s is insufficient, then additional
7614 names are automatically generated.
7616 #include <isl/ast_build.h>
7617 __isl_give isl_ast_build *
7618 isl_ast_build_set_create_leaf(
7619 __isl_take isl_ast_build *control,
7620 __isl_give isl_ast_node *(*fn)(
7621 __isl_take isl_ast_build *build,
7622 void *user), void *user);
7625 C<isl_ast_build_set_create_leaf> function allows for the
7626 specification of a callback that should be called whenever the AST
7627 generator arrives at an element of the schedule domain.
7628 The callback should return an AST node that should be inserted
7629 at the corresponding position of the AST. The default action (when
7630 the callback is not set) is to continue generating parts of the AST to scan
7631 all the domain elements associated to the schedule domain element
7632 and to insert user nodes, ``calling'' the domain element, for each of them.
7633 The C<build> argument contains the current state of the C<isl_ast_build>.
7634 To ease nested AST generation (see L</"Nested AST Generation">),
7635 all control information that is
7636 specific to the current AST generation such as the options and
7637 the callbacks has been removed from this C<isl_ast_build>.
7638 The callback would typically return the result of a nested
7640 user defined node created using the following function.
7642 #include <isl/ast.h>
7643 __isl_give isl_ast_node *isl_ast_node_alloc_user(
7644 __isl_take isl_ast_expr *expr);
7646 #include <isl/ast_build.h>
7647 __isl_give isl_ast_build *
7648 isl_ast_build_set_at_each_domain(
7649 __isl_take isl_ast_build *build,
7650 __isl_give isl_ast_node *(*fn)(
7651 __isl_take isl_ast_node *node,
7652 __isl_keep isl_ast_build *build,
7653 void *user), void *user);
7654 __isl_give isl_ast_build *
7655 isl_ast_build_set_before_each_for(
7656 __isl_take isl_ast_build *build,
7657 __isl_give isl_id *(*fn)(
7658 __isl_keep isl_ast_build *build,
7659 void *user), void *user);
7660 __isl_give isl_ast_build *
7661 isl_ast_build_set_after_each_for(
7662 __isl_take isl_ast_build *build,
7663 __isl_give isl_ast_node *(*fn)(
7664 __isl_take isl_ast_node *node,
7665 __isl_keep isl_ast_build *build,
7666 void *user), void *user);
7668 The callback set by C<isl_ast_build_set_at_each_domain> will
7669 be called for each domain AST node.
7670 The callbacks set by C<isl_ast_build_set_before_each_for>
7671 and C<isl_ast_build_set_after_each_for> will be called
7672 for each for AST node. The first will be called in depth-first
7673 pre-order, while the second will be called in depth-first post-order.
7674 Since C<isl_ast_build_set_before_each_for> is called before the for
7675 node is actually constructed, it is only passed an C<isl_ast_build>.
7676 The returned C<isl_id> will be added as an annotation (using
7677 C<isl_ast_node_set_annotation>) to the constructed for node.
7678 In particular, if the user has also specified an C<after_each_for>
7679 callback, then the annotation can be retrieved from the node passed to
7680 that callback using C<isl_ast_node_get_annotation>.
7681 All callbacks should C<NULL> on failure.
7682 The given C<isl_ast_build> can be used to create new
7683 C<isl_ast_expr> objects using C<isl_ast_build_expr_from_pw_aff>
7684 or C<isl_ast_build_call_from_pw_multi_aff>.
7686 =head3 Nested AST Generation
7688 C<isl> allows the user to create an AST within the context
7689 of another AST. These nested ASTs are created using the
7690 same C<isl_ast_build_ast_from_schedule> function that is used to create the
7691 outer AST. The C<build> argument should be an C<isl_ast_build>
7692 passed to a callback set by
7693 C<isl_ast_build_set_create_leaf>.
7694 The space of the range of the C<schedule> argument should refer
7695 to this build. In particular, the space should be a wrapped
7696 relation and the domain of this wrapped relation should be the
7697 same as that of the range of the schedule returned by
7698 C<isl_ast_build_get_schedule> below.
7699 In practice, the new schedule is typically
7700 created by calling C<isl_union_map_range_product> on the old schedule
7701 and some extra piece of the schedule.
7702 The space of the schedule domain is also available from
7703 the C<isl_ast_build>.
7705 #include <isl/ast_build.h>
7706 __isl_give isl_union_map *isl_ast_build_get_schedule(
7707 __isl_keep isl_ast_build *build);
7708 __isl_give isl_space *isl_ast_build_get_schedule_space(
7709 __isl_keep isl_ast_build *build);
7710 __isl_give isl_ast_build *isl_ast_build_restrict(
7711 __isl_take isl_ast_build *build,
7712 __isl_take isl_set *set);
7714 The C<isl_ast_build_get_schedule> function returns a (partial)
7715 schedule for the domains elements for which part of the AST still needs to
7716 be generated in the current build.
7717 In particular, the domain elements are mapped to those iterations of the loops
7718 enclosing the current point of the AST generation inside which
7719 the domain elements are executed.
7720 No direct correspondence between
7721 the input schedule and this schedule should be assumed.
7722 The space obtained from C<isl_ast_build_get_schedule_space> can be used
7723 to create a set for C<isl_ast_build_restrict> to intersect
7724 with the current build. In particular, the set passed to
7725 C<isl_ast_build_restrict> can have additional parameters.
7726 The ids of the set dimensions in the space returned by
7727 C<isl_ast_build_get_schedule_space> correspond to the
7728 iterators of the already generated loops.
7729 The user should not rely on the ids of the output dimensions
7730 of the relations in the union relation returned by
7731 C<isl_ast_build_get_schedule> having any particular value.
7735 Although C<isl> is mainly meant to be used as a library,
7736 it also contains some basic applications that use some
7737 of the functionality of C<isl>.
7738 The input may be specified in either the L<isl format>
7739 or the L<PolyLib format>.
7741 =head2 C<isl_polyhedron_sample>
7743 C<isl_polyhedron_sample> takes a polyhedron as input and prints
7744 an integer element of the polyhedron, if there is any.
7745 The first column in the output is the denominator and is always
7746 equal to 1. If the polyhedron contains no integer points,
7747 then a vector of length zero is printed.
7751 C<isl_pip> takes the same input as the C<example> program
7752 from the C<piplib> distribution, i.e., a set of constraints
7753 on the parameters, a line containing only -1 and finally a set
7754 of constraints on a parametric polyhedron.
7755 The coefficients of the parameters appear in the last columns
7756 (but before the final constant column).
7757 The output is the lexicographic minimum of the parametric polyhedron.
7758 As C<isl> currently does not have its own output format, the output
7759 is just a dump of the internal state.
7761 =head2 C<isl_polyhedron_minimize>
7763 C<isl_polyhedron_minimize> computes the minimum of some linear
7764 or affine objective function over the integer points in a polyhedron.
7765 If an affine objective function
7766 is given, then the constant should appear in the last column.
7768 =head2 C<isl_polytope_scan>
7770 Given a polytope, C<isl_polytope_scan> prints
7771 all integer points in the polytope.
7773 =head2 C<isl_codegen>
7775 Given a schedule, a context set and an options relation,
7776 C<isl_codegen> prints out an AST that scans the domain elements
7777 of the schedule in the order of their image(s) taking into account
7778 the constraints in the context set.