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/space.h>
3091 __isl_give char *isl_space_to_str(
3092 __isl_keep isl_space *space);
3094 #include <isl/val.h>
3095 __isl_give char *isl_val_to_str(__isl_keep isl_val *v);
3096 __isl_give char *isl_multi_val_to_str(
3097 __isl_keep isl_multi_val *mv);
3099 #include <isl/set.h>
3100 __isl_give char *isl_set_to_str(
3101 __isl_keep isl_set *set);
3103 #include <isl/map.h>
3104 __isl_give char *isl_map_to_str(
3105 __isl_keep isl_map *map);
3107 #include <isl/aff.h>
3108 __isl_give char *isl_union_pw_multi_aff_to_str(
3109 __isl_keep isl_union_pw_multi_aff *upma);
3113 =head3 Unary Properties
3119 The following functions test whether the given set or relation
3120 contains any integer points. The ``plain'' variants do not perform
3121 any computations, but simply check if the given set or relation
3122 is already known to be empty.
3124 int isl_basic_set_plain_is_empty(__isl_keep isl_basic_set *bset);
3125 int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
3126 int isl_set_plain_is_empty(__isl_keep isl_set *set);
3127 int isl_set_is_empty(__isl_keep isl_set *set);
3128 int isl_union_set_is_empty(__isl_keep isl_union_set *uset);
3129 int isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap);
3130 int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
3131 int isl_map_plain_is_empty(__isl_keep isl_map *map);
3132 int isl_map_is_empty(__isl_keep isl_map *map);
3133 int isl_union_map_is_empty(__isl_keep isl_union_map *umap);
3135 =item * Universality
3137 int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
3138 int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
3139 int isl_set_plain_is_universe(__isl_keep isl_set *set);
3141 =item * Single-valuedness
3143 #include <isl/set.h>
3144 int isl_set_is_singleton(__isl_keep isl_set *set);
3146 #include <isl/map.h>
3147 int isl_basic_map_is_single_valued(
3148 __isl_keep isl_basic_map *bmap);
3149 int isl_map_plain_is_single_valued(
3150 __isl_keep isl_map *map);
3151 int isl_map_is_single_valued(__isl_keep isl_map *map);
3153 #include <isl/union_map.h>
3154 int isl_union_map_is_single_valued(__isl_keep isl_union_map *umap);
3158 int isl_map_plain_is_injective(__isl_keep isl_map *map);
3159 int isl_map_is_injective(__isl_keep isl_map *map);
3160 int isl_union_map_plain_is_injective(
3161 __isl_keep isl_union_map *umap);
3162 int isl_union_map_is_injective(
3163 __isl_keep isl_union_map *umap);
3167 int isl_map_is_bijective(__isl_keep isl_map *map);
3168 int isl_union_map_is_bijective(__isl_keep isl_union_map *umap);
3172 __isl_give isl_val *
3173 isl_basic_map_plain_get_val_if_fixed(
3174 __isl_keep isl_basic_map *bmap,
3175 enum isl_dim_type type, unsigned pos);
3176 __isl_give isl_val *isl_set_plain_get_val_if_fixed(
3177 __isl_keep isl_set *set,
3178 enum isl_dim_type type, unsigned pos);
3179 __isl_give isl_val *isl_map_plain_get_val_if_fixed(
3180 __isl_keep isl_map *map,
3181 enum isl_dim_type type, unsigned pos);
3183 If the set or relation obviously lies on a hyperplane where the given dimension
3184 has a fixed value, then return that value.
3185 Otherwise return NaN.
3189 int isl_set_dim_residue_class_val(
3190 __isl_keep isl_set *set,
3191 int pos, __isl_give isl_val **modulo,
3192 __isl_give isl_val **residue);
3194 Check if the values of the given set dimension are equal to a fixed
3195 value modulo some integer value. If so, assign the modulo to C<*modulo>
3196 and the fixed value to C<*residue>. If the given dimension attains only
3197 a single value, then assign C<0> to C<*modulo> and the fixed value to
3199 If the dimension does not attain only a single value and if no modulo
3200 can be found then assign C<1> to C<*modulo> and C<1> to C<*residue>.
3204 To check whether the description of a set, relation or function depends
3205 on one or more given dimensions,
3206 the following functions can be used.
3208 #include <isl/constraint.h>
3209 int isl_constraint_involves_dims(
3210 __isl_keep isl_constraint *constraint,
3211 enum isl_dim_type type, unsigned first, unsigned n);
3213 #include <isl/set.h>
3214 int isl_basic_set_involves_dims(
3215 __isl_keep isl_basic_set *bset,
3216 enum isl_dim_type type, unsigned first, unsigned n);
3217 int isl_set_involves_dims(__isl_keep isl_set *set,
3218 enum isl_dim_type type, unsigned first, unsigned n);
3220 #include <isl/map.h>
3221 int isl_basic_map_involves_dims(
3222 __isl_keep isl_basic_map *bmap,
3223 enum isl_dim_type type, unsigned first, unsigned n);
3224 int isl_map_involves_dims(__isl_keep isl_map *map,
3225 enum isl_dim_type type, unsigned first, unsigned n);
3227 #include <isl/aff.h>
3228 int isl_aff_involves_dims(__isl_keep isl_aff *aff,
3229 enum isl_dim_type type, unsigned first, unsigned n);
3230 int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff,
3231 enum isl_dim_type type, unsigned first, unsigned n);
3232 int isl_multi_aff_involves_dims(
3233 __isl_keep isl_multi_aff *ma,
3234 enum isl_dim_type type, unsigned first, unsigned n);
3235 int isl_multi_pw_aff_involves_dims(
3236 __isl_keep isl_multi_pw_aff *mpa,
3237 enum isl_dim_type type, unsigned first, unsigned n);
3239 Similarly, the following functions can be used to check whether
3240 a given dimension is involved in any lower or upper bound.
3242 #include <isl/set.h>
3243 int isl_set_dim_has_any_lower_bound(__isl_keep isl_set *set,
3244 enum isl_dim_type type, unsigned pos);
3245 int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set,
3246 enum isl_dim_type type, unsigned pos);
3248 Note that these functions return true even if there is a bound on
3249 the dimension on only some of the basic sets of C<set>.
3250 To check if they have a bound for all of the basic sets in C<set>,
3251 use the following functions instead.
3253 #include <isl/set.h>
3254 int isl_set_dim_has_lower_bound(__isl_keep isl_set *set,
3255 enum isl_dim_type type, unsigned pos);
3256 int isl_set_dim_has_upper_bound(__isl_keep isl_set *set,
3257 enum isl_dim_type type, unsigned pos);
3261 To check whether a set is a parameter domain, use this function:
3263 int isl_set_is_params(__isl_keep isl_set *set);
3264 int isl_union_set_is_params(
3265 __isl_keep isl_union_set *uset);
3269 The following functions check whether the space of the given
3270 (basic) set or relation range is a wrapped relation.
3272 #include <isl/space.h>
3273 int isl_space_is_wrapping(
3274 __isl_keep isl_space *space);
3275 int isl_space_domain_is_wrapping(
3276 __isl_keep isl_space *space);
3277 int isl_space_range_is_wrapping(
3278 __isl_keep isl_space *space);
3280 #include <isl/set.h>
3281 int isl_basic_set_is_wrapping(
3282 __isl_keep isl_basic_set *bset);
3283 int isl_set_is_wrapping(__isl_keep isl_set *set);
3285 #include <isl/map.h>
3286 int isl_map_domain_is_wrapping(
3287 __isl_keep isl_map *map);
3288 int isl_map_range_is_wrapping(
3289 __isl_keep isl_map *map);
3291 #include <isl/val.h>
3292 int isl_multi_val_range_is_wrapping(
3293 __isl_keep isl_multi_val *mv);
3295 #include <isl/aff.h>
3296 int isl_multi_aff_range_is_wrapping(
3297 __isl_keep isl_multi_aff *ma);
3298 int isl_multi_pw_aff_range_is_wrapping(
3299 __isl_keep isl_multi_pw_aff *mpa);
3301 The input to C<isl_space_is_wrapping> should
3302 be the space of a set, while that of
3303 C<isl_space_domain_is_wrapping> and
3304 C<isl_space_range_is_wrapping> should be the space of a relation.
3306 =item * Internal Product
3308 int isl_basic_map_can_zip(
3309 __isl_keep isl_basic_map *bmap);
3310 int isl_map_can_zip(__isl_keep isl_map *map);
3312 Check whether the product of domain and range of the given relation
3314 i.e., whether both domain and range are nested relations.
3318 int isl_basic_map_can_curry(
3319 __isl_keep isl_basic_map *bmap);
3320 int isl_map_can_curry(__isl_keep isl_map *map);
3322 Check whether the domain of the (basic) relation is a wrapped relation.
3324 int isl_basic_map_can_uncurry(
3325 __isl_keep isl_basic_map *bmap);
3326 int isl_map_can_uncurry(__isl_keep isl_map *map);
3328 Check whether the range of the (basic) relation is a wrapped relation.
3330 =item * Special Values
3332 #include <isl/aff.h>
3333 int isl_aff_is_cst(__isl_keep isl_aff *aff);
3334 int isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff);
3336 Check whether the given expression is a constant.
3338 #include <isl/aff.h>
3339 int isl_aff_is_nan(__isl_keep isl_aff *aff);
3340 int isl_pw_aff_involves_nan(__isl_keep isl_pw_aff *pa);
3342 Check whether the given expression is equal to or involves NaN.
3344 #include <isl/aff.h>
3345 int isl_aff_plain_is_zero(__isl_keep isl_aff *aff);
3347 Check whether the affine expression is obviously zero.
3351 =head3 Binary Properties
3357 The following functions check whether two objects
3358 represent the same set, relation or function.
3359 The C<plain> variants only return true if the objects
3360 are obviously the same. That is, they may return false
3361 even if the objects are the same, but they will never
3362 return true if the objects are not the same.
3364 #include <isl/set.h>
3365 int isl_basic_set_plain_is_equal(
3366 __isl_keep isl_basic_set *bset1,
3367 __isl_keep isl_basic_set *bset2);
3368 int isl_set_plain_is_equal(__isl_keep isl_set *set1,
3369 __isl_keep isl_set *set2);
3370 int isl_set_is_equal(__isl_keep isl_set *set1,
3371 __isl_keep isl_set *set2);
3373 #include <isl/map.h>
3374 int isl_basic_map_is_equal(
3375 __isl_keep isl_basic_map *bmap1,
3376 __isl_keep isl_basic_map *bmap2);
3377 int isl_map_is_equal(__isl_keep isl_map *map1,
3378 __isl_keep isl_map *map2);
3379 int isl_map_plain_is_equal(__isl_keep isl_map *map1,
3380 __isl_keep isl_map *map2);
3382 #include <isl/union_set.h>
3383 int isl_union_set_is_equal(
3384 __isl_keep isl_union_set *uset1,
3385 __isl_keep isl_union_set *uset2);
3387 #include <isl/union_map.h>
3388 int isl_union_map_is_equal(
3389 __isl_keep isl_union_map *umap1,
3390 __isl_keep isl_union_map *umap2);
3392 #include <isl/aff.h>
3393 int isl_aff_plain_is_equal(__isl_keep isl_aff *aff1,
3394 __isl_keep isl_aff *aff2);
3395 int isl_multi_aff_plain_is_equal(
3396 __isl_keep isl_multi_aff *maff1,
3397 __isl_keep isl_multi_aff *maff2);
3398 int isl_pw_aff_plain_is_equal(
3399 __isl_keep isl_pw_aff *pwaff1,
3400 __isl_keep isl_pw_aff *pwaff2);
3401 int isl_pw_multi_aff_plain_is_equal(
3402 __isl_keep isl_pw_multi_aff *pma1,
3403 __isl_keep isl_pw_multi_aff *pma2);
3404 int isl_multi_pw_aff_plain_is_equal(
3405 __isl_keep isl_multi_pw_aff *mpa1,
3406 __isl_keep isl_multi_pw_aff *mpa2);
3407 int isl_multi_pw_aff_is_equal(
3408 __isl_keep isl_multi_pw_aff *mpa1,
3409 __isl_keep isl_multi_pw_aff *mpa2);
3411 #include <isl/polynomial.h>
3412 int isl_union_pw_qpolynomial_plain_is_equal(
3413 __isl_keep isl_union_pw_qpolynomial *upwqp1,
3414 __isl_keep isl_union_pw_qpolynomial *upwqp2);
3415 int isl_union_pw_qpolynomial_fold_plain_is_equal(
3416 __isl_keep isl_union_pw_qpolynomial_fold *upwf1,
3417 __isl_keep isl_union_pw_qpolynomial_fold *upwf2);
3419 =item * Disjointness
3421 int isl_basic_set_is_disjoint(
3422 __isl_keep isl_basic_set *bset1,
3423 __isl_keep isl_basic_set *bset2);
3424 int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
3425 __isl_keep isl_set *set2);
3426 int isl_set_is_disjoint(__isl_keep isl_set *set1,
3427 __isl_keep isl_set *set2);
3428 int isl_basic_map_is_disjoint(
3429 __isl_keep isl_basic_map *bmap1,
3430 __isl_keep isl_basic_map *bmap2);
3431 int isl_map_is_disjoint(__isl_keep isl_map *map1,
3432 __isl_keep isl_map *map2);
3436 int isl_basic_set_is_subset(
3437 __isl_keep isl_basic_set *bset1,
3438 __isl_keep isl_basic_set *bset2);
3439 int isl_set_is_subset(__isl_keep isl_set *set1,
3440 __isl_keep isl_set *set2);
3441 int isl_set_is_strict_subset(
3442 __isl_keep isl_set *set1,
3443 __isl_keep isl_set *set2);
3444 int isl_union_set_is_subset(
3445 __isl_keep isl_union_set *uset1,
3446 __isl_keep isl_union_set *uset2);
3447 int isl_union_set_is_strict_subset(
3448 __isl_keep isl_union_set *uset1,
3449 __isl_keep isl_union_set *uset2);
3450 int isl_basic_map_is_subset(
3451 __isl_keep isl_basic_map *bmap1,
3452 __isl_keep isl_basic_map *bmap2);
3453 int isl_basic_map_is_strict_subset(
3454 __isl_keep isl_basic_map *bmap1,
3455 __isl_keep isl_basic_map *bmap2);
3456 int isl_map_is_subset(
3457 __isl_keep isl_map *map1,
3458 __isl_keep isl_map *map2);
3459 int isl_map_is_strict_subset(
3460 __isl_keep isl_map *map1,
3461 __isl_keep isl_map *map2);
3462 int isl_union_map_is_subset(
3463 __isl_keep isl_union_map *umap1,
3464 __isl_keep isl_union_map *umap2);
3465 int isl_union_map_is_strict_subset(
3466 __isl_keep isl_union_map *umap1,
3467 __isl_keep isl_union_map *umap2);
3469 Check whether the first argument is a (strict) subset of the
3474 Every comparison function returns a negative value if the first
3475 argument is considered smaller than the second, a positive value
3476 if the first argument is considered greater and zero if the two
3477 constraints are considered the same by the comparison criterion.
3479 #include <isl/constraint.h>
3480 int isl_constraint_plain_cmp(
3481 __isl_keep isl_constraint *c1,
3482 __isl_keep isl_constraint *c2);
3484 This function is useful for sorting C<isl_constraint>s.
3485 The order depends on the internal representation of the inputs.
3486 The order is fixed over different calls to the function (assuming
3487 the internal representation of the inputs has not changed), but may
3488 change over different versions of C<isl>.
3490 #include <isl/constraint.h>
3491 int isl_constraint_cmp_last_non_zero(
3492 __isl_keep isl_constraint *c1,
3493 __isl_keep isl_constraint *c2);
3495 This function can be used to sort constraints that live in the same
3496 local space. Constraints that involve ``earlier'' dimensions or
3497 that have a smaller coefficient for the shared latest dimension
3498 are considered smaller than other constraints.
3499 This function only defines a B<partial> order.
3501 #include <isl/set.h>
3502 int isl_set_plain_cmp(__isl_keep isl_set *set1,
3503 __isl_keep isl_set *set2);
3505 This function is useful for sorting C<isl_set>s.
3506 The order depends on the internal representation of the inputs.
3507 The order is fixed over different calls to the function (assuming
3508 the internal representation of the inputs has not changed), but may
3509 change over different versions of C<isl>.
3511 #include <isl/aff.h>
3512 int isl_pw_aff_plain_cmp(__isl_keep isl_pw_aff *pa1,
3513 __isl_keep isl_pw_aff *pa2);
3515 The function C<isl_pw_aff_plain_cmp> can be used to sort
3516 C<isl_pw_aff>s. The order is not strictly defined.
3517 The current order sorts expressions that only involve
3518 earlier dimensions before those that involve later dimensions.
3522 =head2 Unary Operations
3528 __isl_give isl_set *isl_set_complement(
3529 __isl_take isl_set *set);
3530 __isl_give isl_map *isl_map_complement(
3531 __isl_take isl_map *map);
3535 #include <isl/space.h>
3536 __isl_give isl_space *isl_space_reverse(
3537 __isl_take isl_space *space);
3539 #include <isl/map.h>
3540 __isl_give isl_basic_map *isl_basic_map_reverse(
3541 __isl_take isl_basic_map *bmap);
3542 __isl_give isl_map *isl_map_reverse(
3543 __isl_take isl_map *map);
3545 #include <isl/union_map.h>
3546 __isl_give isl_union_map *isl_union_map_reverse(
3547 __isl_take isl_union_map *umap);
3551 #include <isl/space.h>
3552 __isl_give isl_space *isl_space_domain(
3553 __isl_take isl_space *space);
3554 __isl_give isl_space *isl_space_range(
3555 __isl_take isl_space *space);
3556 __isl_give isl_space *isl_space_params(
3557 __isl_take isl_space *space);
3559 #include <isl/local_space.h>
3560 __isl_give isl_local_space *isl_local_space_domain(
3561 __isl_take isl_local_space *ls);
3562 __isl_give isl_local_space *isl_local_space_range(
3563 __isl_take isl_local_space *ls);
3565 #include <isl/set.h>
3566 __isl_give isl_basic_set *isl_basic_set_project_out(
3567 __isl_take isl_basic_set *bset,
3568 enum isl_dim_type type, unsigned first, unsigned n);
3569 __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
3570 enum isl_dim_type type, unsigned first, unsigned n);
3571 __isl_give isl_basic_set *isl_basic_set_params(
3572 __isl_take isl_basic_set *bset);
3573 __isl_give isl_set *isl_set_params(__isl_take isl_set *set);
3575 #include <isl/map.h>
3576 __isl_give isl_basic_map *isl_basic_map_project_out(
3577 __isl_take isl_basic_map *bmap,
3578 enum isl_dim_type type, unsigned first, unsigned n);
3579 __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
3580 enum isl_dim_type type, unsigned first, unsigned n);
3581 __isl_give isl_basic_set *isl_basic_map_domain(
3582 __isl_take isl_basic_map *bmap);
3583 __isl_give isl_basic_set *isl_basic_map_range(
3584 __isl_take isl_basic_map *bmap);
3585 __isl_give isl_set *isl_map_params(__isl_take isl_map *map);
3586 __isl_give isl_set *isl_map_domain(
3587 __isl_take isl_map *bmap);
3588 __isl_give isl_set *isl_map_range(
3589 __isl_take isl_map *map);
3591 #include <isl/union_set.h>
3592 __isl_give isl_set *isl_union_set_params(
3593 __isl_take isl_union_set *uset);
3595 #include <isl/union_map.h>
3596 __isl_give isl_union_map *isl_union_map_project_out(
3597 __isl_take isl_union_map *umap,
3598 enum isl_dim_type type, unsigned first, unsigned n);
3599 __isl_give isl_set *isl_union_map_params(
3600 __isl_take isl_union_map *umap);
3601 __isl_give isl_union_set *isl_union_map_domain(
3602 __isl_take isl_union_map *umap);
3603 __isl_give isl_union_set *isl_union_map_range(
3604 __isl_take isl_union_map *umap);
3606 The function C<isl_union_map_project_out> can only project out
3609 #include <isl/aff.h>
3610 __isl_give isl_aff *isl_aff_project_domain_on_params(
3611 __isl_take isl_aff *aff);
3612 __isl_give isl_pw_multi_aff *
3613 isl_pw_multi_aff_project_domain_on_params(
3614 __isl_take isl_pw_multi_aff *pma);
3615 __isl_give isl_set *isl_pw_aff_domain(
3616 __isl_take isl_pw_aff *pwaff);
3617 __isl_give isl_set *isl_pw_multi_aff_domain(
3618 __isl_take isl_pw_multi_aff *pma);
3619 __isl_give isl_set *isl_multi_pw_aff_domain(
3620 __isl_take isl_multi_pw_aff *mpa);
3621 __isl_give isl_union_set *isl_union_pw_multi_aff_domain(
3622 __isl_take isl_union_pw_multi_aff *upma);
3623 __isl_give isl_set *isl_pw_aff_params(
3624 __isl_take isl_pw_aff *pwa);
3626 #include <isl/polynomial.h>
3627 __isl_give isl_qpolynomial *
3628 isl_qpolynomial_project_domain_on_params(
3629 __isl_take isl_qpolynomial *qp);
3630 __isl_give isl_pw_qpolynomial *
3631 isl_pw_qpolynomial_project_domain_on_params(
3632 __isl_take isl_pw_qpolynomial *pwqp);
3633 __isl_give isl_pw_qpolynomial_fold *
3634 isl_pw_qpolynomial_fold_project_domain_on_params(
3635 __isl_take isl_pw_qpolynomial_fold *pwf);
3636 __isl_give isl_set *isl_pw_qpolynomial_domain(
3637 __isl_take isl_pw_qpolynomial *pwqp);
3638 __isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain(
3639 __isl_take isl_union_pw_qpolynomial_fold *upwf);
3640 __isl_give isl_union_set *isl_union_pw_qpolynomial_domain(
3641 __isl_take isl_union_pw_qpolynomial *upwqp);
3643 #include <isl/space.h>
3644 __isl_give isl_space *isl_space_domain_map(
3645 __isl_take isl_space *space);
3646 __isl_give isl_space *isl_space_range_map(
3647 __isl_take isl_space *space);
3649 #include <isl/map.h>
3650 __isl_give isl_basic_map *isl_basic_map_domain_map(
3651 __isl_take isl_basic_map *bmap);
3652 __isl_give isl_basic_map *isl_basic_map_range_map(
3653 __isl_take isl_basic_map *bmap);
3654 __isl_give isl_map *isl_map_domain_map(__isl_take isl_map *map);
3655 __isl_give isl_map *isl_map_range_map(__isl_take isl_map *map);
3657 #include <isl/union_map.h>
3658 __isl_give isl_union_map *isl_union_map_domain_map(
3659 __isl_take isl_union_map *umap);
3660 __isl_give isl_union_map *isl_union_map_range_map(
3661 __isl_take isl_union_map *umap);
3663 The functions above construct a (basic, regular or union) relation
3664 that maps (a wrapped version of) the input relation to its domain or range.
3668 __isl_give isl_basic_set *isl_basic_set_eliminate(
3669 __isl_take isl_basic_set *bset,
3670 enum isl_dim_type type,
3671 unsigned first, unsigned n);
3672 __isl_give isl_set *isl_set_eliminate(
3673 __isl_take isl_set *set, enum isl_dim_type type,
3674 unsigned first, unsigned n);
3675 __isl_give isl_basic_map *isl_basic_map_eliminate(
3676 __isl_take isl_basic_map *bmap,
3677 enum isl_dim_type type,
3678 unsigned first, unsigned n);
3679 __isl_give isl_map *isl_map_eliminate(
3680 __isl_take isl_map *map, enum isl_dim_type type,
3681 unsigned first, unsigned n);
3683 Eliminate the coefficients for the given dimensions from the constraints,
3684 without removing the dimensions.
3686 =item * Constructing a set from a parameter domain
3688 A zero-dimensional space or (basic) set can be constructed
3689 on a given parameter domain using the following functions.
3691 #include <isl/space.h>
3692 __isl_give isl_space *isl_space_set_from_params(
3693 __isl_take isl_space *space);
3695 #include <isl/set.h>
3696 __isl_give isl_basic_set *isl_basic_set_from_params(
3697 __isl_take isl_basic_set *bset);
3698 __isl_give isl_set *isl_set_from_params(
3699 __isl_take isl_set *set);
3701 =item * Constructing a relation from a set
3703 Create a relation with the given set as domain or range.
3704 The range or domain of the created relation is a zero-dimensional
3705 flat anonymous space.
3707 #include <isl/space.h>
3708 __isl_give isl_space *isl_space_from_domain(
3709 __isl_take isl_space *space);
3710 __isl_give isl_space *isl_space_from_range(
3711 __isl_take isl_space *space);
3712 __isl_give isl_space *isl_space_map_from_set(
3713 __isl_take isl_space *space);
3714 __isl_give isl_space *isl_space_map_from_domain_and_range(
3715 __isl_take isl_space *domain,
3716 __isl_take isl_space *range);
3718 #include <isl/local_space.h>
3719 __isl_give isl_local_space *isl_local_space_from_domain(
3720 __isl_take isl_local_space *ls);
3722 #include <isl/map.h>
3723 __isl_give isl_map *isl_map_from_domain(
3724 __isl_take isl_set *set);
3725 __isl_give isl_map *isl_map_from_range(
3726 __isl_take isl_set *set);
3728 #include <isl/val.h>
3729 __isl_give isl_multi_val *isl_multi_val_from_range(
3730 __isl_take isl_multi_val *mv);
3732 #include <isl/aff.h>
3733 __isl_give isl_multi_aff *isl_multi_aff_from_range(
3734 __isl_take isl_multi_aff *ma);
3735 __isl_give isl_pw_aff *isl_pw_aff_from_range(
3736 __isl_take isl_pw_aff *pwa);
3737 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_range(
3738 __isl_take isl_multi_pw_aff *mpa);
3739 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_domain(
3740 __isl_take isl_set *set);
3741 __isl_give isl_union_pw_multi_aff *
3742 isl_union_pw_multi_aff_from_domain(
3743 __isl_take isl_union_set *uset);
3747 #include <isl/set.h>
3748 __isl_give isl_basic_set *isl_basic_set_fix_si(
3749 __isl_take isl_basic_set *bset,
3750 enum isl_dim_type type, unsigned pos, int value);
3751 __isl_give isl_basic_set *isl_basic_set_fix_val(
3752 __isl_take isl_basic_set *bset,
3753 enum isl_dim_type type, unsigned pos,
3754 __isl_take isl_val *v);
3755 __isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set,
3756 enum isl_dim_type type, unsigned pos, int value);
3757 __isl_give isl_set *isl_set_fix_val(
3758 __isl_take isl_set *set,
3759 enum isl_dim_type type, unsigned pos,
3760 __isl_take isl_val *v);
3762 #include <isl/map.h>
3763 __isl_give isl_basic_map *isl_basic_map_fix_si(
3764 __isl_take isl_basic_map *bmap,
3765 enum isl_dim_type type, unsigned pos, int value);
3766 __isl_give isl_basic_map *isl_basic_map_fix_val(
3767 __isl_take isl_basic_map *bmap,
3768 enum isl_dim_type type, unsigned pos,
3769 __isl_take isl_val *v);
3770 __isl_give isl_map *isl_map_fix_si(__isl_take isl_map *map,
3771 enum isl_dim_type type, unsigned pos, int value);
3772 __isl_give isl_map *isl_map_fix_val(
3773 __isl_take isl_map *map,
3774 enum isl_dim_type type, unsigned pos,
3775 __isl_take isl_val *v);
3777 #include <isl/aff.h>
3778 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_fix_si(
3779 __isl_take isl_pw_multi_aff *pma,
3780 enum isl_dim_type type, unsigned pos, int value);
3782 #include <isl/polynomial.h>
3783 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_fix_val(
3784 __isl_take isl_pw_qpolynomial *pwqp,
3785 enum isl_dim_type type, unsigned n,
3786 __isl_take isl_val *v);
3788 Intersect the set, relation or function domain
3789 with the hyperplane where the given
3790 dimension has the fixed given value.
3792 __isl_give isl_basic_map *isl_basic_map_lower_bound_si(
3793 __isl_take isl_basic_map *bmap,
3794 enum isl_dim_type type, unsigned pos, int value);
3795 __isl_give isl_basic_map *isl_basic_map_upper_bound_si(
3796 __isl_take isl_basic_map *bmap,
3797 enum isl_dim_type type, unsigned pos, int value);
3798 __isl_give isl_set *isl_set_lower_bound_si(
3799 __isl_take isl_set *set,
3800 enum isl_dim_type type, unsigned pos, int value);
3801 __isl_give isl_set *isl_set_lower_bound_val(
3802 __isl_take isl_set *set,
3803 enum isl_dim_type type, unsigned pos,
3804 __isl_take isl_val *value);
3805 __isl_give isl_map *isl_map_lower_bound_si(
3806 __isl_take isl_map *map,
3807 enum isl_dim_type type, unsigned pos, int value);
3808 __isl_give isl_set *isl_set_upper_bound_si(
3809 __isl_take isl_set *set,
3810 enum isl_dim_type type, unsigned pos, int value);
3811 __isl_give isl_set *isl_set_upper_bound_val(
3812 __isl_take isl_set *set,
3813 enum isl_dim_type type, unsigned pos,
3814 __isl_take isl_val *value);
3815 __isl_give isl_map *isl_map_upper_bound_si(
3816 __isl_take isl_map *map,
3817 enum isl_dim_type type, unsigned pos, int value);
3819 Intersect the set or relation with the half-space where the given
3820 dimension has a value bounded by the fixed given integer value.
3822 __isl_give isl_set *isl_set_equate(__isl_take isl_set *set,
3823 enum isl_dim_type type1, int pos1,
3824 enum isl_dim_type type2, int pos2);
3825 __isl_give isl_basic_map *isl_basic_map_equate(
3826 __isl_take isl_basic_map *bmap,
3827 enum isl_dim_type type1, int pos1,
3828 enum isl_dim_type type2, int pos2);
3829 __isl_give isl_map *isl_map_equate(__isl_take isl_map *map,
3830 enum isl_dim_type type1, int pos1,
3831 enum isl_dim_type type2, int pos2);
3833 Intersect the set or relation with the hyperplane where the given
3834 dimensions are equal to each other.
3836 __isl_give isl_map *isl_map_oppose(__isl_take isl_map *map,
3837 enum isl_dim_type type1, int pos1,
3838 enum isl_dim_type type2, int pos2);
3840 Intersect the relation with the hyperplane where the given
3841 dimensions have opposite values.
3843 __isl_give isl_map *isl_map_order_le(
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_basic_map *isl_basic_map_order_ge(
3848 __isl_take isl_basic_map *bmap,
3849 enum isl_dim_type type1, int pos1,
3850 enum isl_dim_type type2, int pos2);
3851 __isl_give isl_map *isl_map_order_ge(
3852 __isl_take isl_map *map,
3853 enum isl_dim_type type1, int pos1,
3854 enum isl_dim_type type2, int pos2);
3855 __isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map,
3856 enum isl_dim_type type1, int pos1,
3857 enum isl_dim_type type2, int pos2);
3858 __isl_give isl_basic_map *isl_basic_map_order_gt(
3859 __isl_take isl_basic_map *bmap,
3860 enum isl_dim_type type1, int pos1,
3861 enum isl_dim_type type2, int pos2);
3862 __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
3863 enum isl_dim_type type1, int pos1,
3864 enum isl_dim_type type2, int pos2);
3866 Intersect the relation with the half-space where the given
3867 dimensions satisfy the given ordering.
3871 #include <isl/aff.h>
3872 __isl_give isl_basic_set *isl_aff_zero_basic_set(
3873 __isl_take isl_aff *aff);
3874 __isl_give isl_basic_set *isl_aff_neg_basic_set(
3875 __isl_take isl_aff *aff);
3876 __isl_give isl_set *isl_pw_aff_nonneg_set(
3877 __isl_take isl_pw_aff *pwaff);
3878 __isl_give isl_set *isl_pw_aff_zero_set(
3879 __isl_take isl_pw_aff *pwaff);
3880 __isl_give isl_set *isl_pw_aff_non_zero_set(
3881 __isl_take isl_pw_aff *pwaff);
3883 The function C<isl_aff_neg_basic_set> returns a basic set
3884 containing those elements in the domain space
3885 of C<aff> where C<aff> is negative.
3886 The function C<isl_pw_aff_nonneg_set> returns a set
3887 containing those elements in the domain
3888 of C<pwaff> where C<pwaff> is non-negative.
3892 __isl_give isl_map *isl_set_identity(
3893 __isl_take isl_set *set);
3894 __isl_give isl_union_map *isl_union_set_identity(
3895 __isl_take isl_union_set *uset);
3897 Construct an identity relation on the given (union) set.
3899 =item * Function Extraction
3901 A piecewise quasi affine expression that is equal to 1 on a set
3902 and 0 outside the set can be created using the following function.
3904 #include <isl/aff.h>
3905 __isl_give isl_pw_aff *isl_set_indicator_function(
3906 __isl_take isl_set *set);
3908 A piecewise multiple quasi affine expression can be extracted
3909 from an C<isl_set> or C<isl_map>, provided the C<isl_set> is a singleton
3910 and the C<isl_map> is single-valued.
3911 In case of a conversion from an C<isl_union_map>
3912 to an C<isl_union_pw_multi_aff>, these properties need to hold
3913 in each domain space.
3915 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_set(
3916 __isl_take isl_set *set);
3917 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_map(
3918 __isl_take isl_map *map);
3920 __isl_give isl_union_pw_multi_aff *
3921 isl_union_pw_multi_aff_from_union_set(
3922 __isl_take isl_union_set *uset);
3923 __isl_give isl_union_pw_multi_aff *
3924 isl_union_pw_multi_aff_from_union_map(
3925 __isl_take isl_union_map *umap);
3929 __isl_give isl_basic_set *isl_basic_map_deltas(
3930 __isl_take isl_basic_map *bmap);
3931 __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
3932 __isl_give isl_union_set *isl_union_map_deltas(
3933 __isl_take isl_union_map *umap);
3935 These functions return a (basic) set containing the differences
3936 between image elements and corresponding domain elements in the input.
3938 __isl_give isl_basic_map *isl_basic_map_deltas_map(
3939 __isl_take isl_basic_map *bmap);
3940 __isl_give isl_map *isl_map_deltas_map(
3941 __isl_take isl_map *map);
3942 __isl_give isl_union_map *isl_union_map_deltas_map(
3943 __isl_take isl_union_map *umap);
3945 The functions above construct a (basic, regular or union) relation
3946 that maps (a wrapped version of) the input relation to its delta set.
3950 Simplify the representation of a set, relation or functions by trying
3951 to combine pairs of basic sets or relations into a single
3952 basic set or relation.
3954 #include <isl/set.h>
3955 __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
3957 #include <isl/map.h>
3958 __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
3960 #include <isl/union_set.h>
3961 __isl_give isl_union_set *isl_union_set_coalesce(
3962 __isl_take isl_union_set *uset);
3964 #include <isl/union_map.h>
3965 __isl_give isl_union_map *isl_union_map_coalesce(
3966 __isl_take isl_union_map *umap);
3968 #include <isl/aff.h>
3969 __isl_give isl_pw_aff *isl_pw_aff_coalesce(
3970 __isl_take isl_pw_aff *pwqp);
3971 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_coalesce(
3972 __isl_take isl_pw_multi_aff *pma);
3973 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_coalesce(
3974 __isl_take isl_multi_pw_aff *mpa);
3976 #include <isl/polynomial.h>
3977 __isl_give isl_pw_qpolynomial_fold *
3978 isl_pw_qpolynomial_fold_coalesce(
3979 __isl_take isl_pw_qpolynomial_fold *pwf);
3980 __isl_give isl_union_pw_qpolynomial *
3981 isl_union_pw_qpolynomial_coalesce(
3982 __isl_take isl_union_pw_qpolynomial *upwqp);
3983 __isl_give isl_union_pw_qpolynomial_fold *
3984 isl_union_pw_qpolynomial_fold_coalesce(
3985 __isl_take isl_union_pw_qpolynomial_fold *upwf);
3987 One of the methods for combining pairs of basic sets or relations
3988 can result in coefficients that are much larger than those that appear
3989 in the constraints of the input. By default, the coefficients are
3990 not allowed to grow larger, but this can be changed by unsetting
3991 the following option.
3993 int isl_options_set_coalesce_bounded_wrapping(
3994 isl_ctx *ctx, int val);
3995 int isl_options_get_coalesce_bounded_wrapping(
3998 =item * Detecting equalities
4000 __isl_give isl_basic_set *isl_basic_set_detect_equalities(
4001 __isl_take isl_basic_set *bset);
4002 __isl_give isl_basic_map *isl_basic_map_detect_equalities(
4003 __isl_take isl_basic_map *bmap);
4004 __isl_give isl_set *isl_set_detect_equalities(
4005 __isl_take isl_set *set);
4006 __isl_give isl_map *isl_map_detect_equalities(
4007 __isl_take isl_map *map);
4008 __isl_give isl_union_set *isl_union_set_detect_equalities(
4009 __isl_take isl_union_set *uset);
4010 __isl_give isl_union_map *isl_union_map_detect_equalities(
4011 __isl_take isl_union_map *umap);
4013 Simplify the representation of a set or relation by detecting implicit
4016 =item * Removing redundant constraints
4018 __isl_give isl_basic_set *isl_basic_set_remove_redundancies(
4019 __isl_take isl_basic_set *bset);
4020 __isl_give isl_set *isl_set_remove_redundancies(
4021 __isl_take isl_set *set);
4022 __isl_give isl_basic_map *isl_basic_map_remove_redundancies(
4023 __isl_take isl_basic_map *bmap);
4024 __isl_give isl_map *isl_map_remove_redundancies(
4025 __isl_take isl_map *map);
4029 __isl_give isl_basic_set *isl_set_convex_hull(
4030 __isl_take isl_set *set);
4031 __isl_give isl_basic_map *isl_map_convex_hull(
4032 __isl_take isl_map *map);
4034 If the input set or relation has any existentially quantified
4035 variables, then the result of these operations is currently undefined.
4039 #include <isl/set.h>
4040 __isl_give isl_basic_set *
4041 isl_set_unshifted_simple_hull(
4042 __isl_take isl_set *set);
4043 __isl_give isl_basic_set *isl_set_simple_hull(
4044 __isl_take isl_set *set);
4045 __isl_give isl_basic_set *
4046 isl_set_unshifted_simple_hull_from_set_list(
4047 __isl_take isl_set *set,
4048 __isl_take isl_set_list *list);
4050 #include <isl/map.h>
4051 __isl_give isl_basic_map *
4052 isl_map_unshifted_simple_hull(
4053 __isl_take isl_map *map);
4054 __isl_give isl_basic_map *isl_map_simple_hull(
4055 __isl_take isl_map *map);
4057 #include <isl/union_map.h>
4058 __isl_give isl_union_map *isl_union_map_simple_hull(
4059 __isl_take isl_union_map *umap);
4061 These functions compute a single basic set or relation
4062 that contains the whole input set or relation.
4063 In particular, the output is described by translates
4064 of the constraints describing the basic sets or relations in the input.
4065 In case of C<isl_set_unshifted_simple_hull>, only the original
4066 constraints are used, without any translation.
4067 In case of C<isl_set_unshifted_simple_hull_from_set_list>, the
4068 constraints are taken from the elements of the second argument.
4072 (See \autoref{s:simple hull}.)
4078 __isl_give isl_basic_set *isl_basic_set_affine_hull(
4079 __isl_take isl_basic_set *bset);
4080 __isl_give isl_basic_set *isl_set_affine_hull(
4081 __isl_take isl_set *set);
4082 __isl_give isl_union_set *isl_union_set_affine_hull(
4083 __isl_take isl_union_set *uset);
4084 __isl_give isl_basic_map *isl_basic_map_affine_hull(
4085 __isl_take isl_basic_map *bmap);
4086 __isl_give isl_basic_map *isl_map_affine_hull(
4087 __isl_take isl_map *map);
4088 __isl_give isl_union_map *isl_union_map_affine_hull(
4089 __isl_take isl_union_map *umap);
4091 In case of union sets and relations, the affine hull is computed
4094 =item * Polyhedral hull
4096 __isl_give isl_basic_set *isl_set_polyhedral_hull(
4097 __isl_take isl_set *set);
4098 __isl_give isl_basic_map *isl_map_polyhedral_hull(
4099 __isl_take isl_map *map);
4100 __isl_give isl_union_set *isl_union_set_polyhedral_hull(
4101 __isl_take isl_union_set *uset);
4102 __isl_give isl_union_map *isl_union_map_polyhedral_hull(
4103 __isl_take isl_union_map *umap);
4105 These functions compute a single basic set or relation
4106 not involving any existentially quantified variables
4107 that contains the whole input set or relation.
4108 In case of union sets and relations, the polyhedral hull is computed
4111 =item * Other approximations
4113 #include <isl/set.h>
4114 __isl_give isl_basic_set *
4115 isl_basic_set_drop_constraints_involving_dims(
4116 __isl_take isl_basic_set *bset,
4117 enum isl_dim_type type,
4118 unsigned first, unsigned n);
4119 __isl_give isl_basic_set *
4120 isl_basic_set_drop_constraints_not_involving_dims(
4121 __isl_take isl_basic_set *bset,
4122 enum isl_dim_type type,
4123 unsigned first, unsigned n);
4124 __isl_give isl_set *
4125 isl_set_drop_constraints_involving_dims(
4126 __isl_take isl_set *set,
4127 enum isl_dim_type type,
4128 unsigned first, unsigned n);
4130 #include <isl/map.h>
4131 __isl_give isl_basic_map *
4132 isl_basic_map_drop_constraints_involving_dims(
4133 __isl_take isl_basic_map *bmap,
4134 enum isl_dim_type type,
4135 unsigned first, unsigned n);
4136 __isl_give isl_map *
4137 isl_map_drop_constraints_involving_dims(
4138 __isl_take isl_map *map,
4139 enum isl_dim_type type,
4140 unsigned first, unsigned n);
4142 These functions drop any constraints (not) involving the specified dimensions.
4143 Note that the result depends on the representation of the input.
4145 #include <isl/polynomial.h>
4146 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_to_polynomial(
4147 __isl_take isl_pw_qpolynomial *pwqp, int sign);
4148 __isl_give isl_union_pw_qpolynomial *
4149 isl_union_pw_qpolynomial_to_polynomial(
4150 __isl_take isl_union_pw_qpolynomial *upwqp, int sign);
4152 Approximate each quasipolynomial by a polynomial. If C<sign> is positive,
4153 the polynomial will be an overapproximation. If C<sign> is negative,
4154 it will be an underapproximation. If C<sign> is zero, the approximation
4155 will lie somewhere in between.
4159 __isl_give isl_basic_set *isl_basic_set_sample(
4160 __isl_take isl_basic_set *bset);
4161 __isl_give isl_basic_set *isl_set_sample(
4162 __isl_take isl_set *set);
4163 __isl_give isl_basic_map *isl_basic_map_sample(
4164 __isl_take isl_basic_map *bmap);
4165 __isl_give isl_basic_map *isl_map_sample(
4166 __isl_take isl_map *map);
4168 If the input (basic) set or relation is non-empty, then return
4169 a singleton subset of the input. Otherwise, return an empty set.
4171 =item * Optimization
4173 #include <isl/ilp.h>
4174 __isl_give isl_val *isl_basic_set_max_val(
4175 __isl_keep isl_basic_set *bset,
4176 __isl_keep isl_aff *obj);
4177 __isl_give isl_val *isl_set_min_val(
4178 __isl_keep isl_set *set,
4179 __isl_keep isl_aff *obj);
4180 __isl_give isl_val *isl_set_max_val(
4181 __isl_keep isl_set *set,
4182 __isl_keep isl_aff *obj);
4184 Compute the minimum or maximum of the integer affine expression C<obj>
4185 over the points in C<set>, returning the result in C<opt>.
4186 The result is C<NULL> in case of an error, the optimal value in case
4187 there is one, negative infinity or infinity if the problem is unbounded and
4188 NaN if the problem is empty.
4190 =item * Parametric optimization
4192 __isl_give isl_pw_aff *isl_set_dim_min(
4193 __isl_take isl_set *set, int pos);
4194 __isl_give isl_pw_aff *isl_set_dim_max(
4195 __isl_take isl_set *set, int pos);
4196 __isl_give isl_pw_aff *isl_map_dim_max(
4197 __isl_take isl_map *map, int pos);
4199 Compute the minimum or maximum of the given set or output dimension
4200 as a function of the parameters (and input dimensions), but independently
4201 of the other set or output dimensions.
4202 For lexicographic optimization, see L<"Lexicographic Optimization">.
4206 The following functions compute either the set of (rational) coefficient
4207 values of valid constraints for the given set or the set of (rational)
4208 values satisfying the constraints with coefficients from the given set.
4209 Internally, these two sets of functions perform essentially the
4210 same operations, except that the set of coefficients is assumed to
4211 be a cone, while the set of values may be any polyhedron.
4212 The current implementation is based on the Farkas lemma and
4213 Fourier-Motzkin elimination, but this may change or be made optional
4214 in future. In particular, future implementations may use different
4215 dualization algorithms or skip the elimination step.
4217 __isl_give isl_basic_set *isl_basic_set_coefficients(
4218 __isl_take isl_basic_set *bset);
4219 __isl_give isl_basic_set *isl_set_coefficients(
4220 __isl_take isl_set *set);
4221 __isl_give isl_union_set *isl_union_set_coefficients(
4222 __isl_take isl_union_set *bset);
4223 __isl_give isl_basic_set *isl_basic_set_solutions(
4224 __isl_take isl_basic_set *bset);
4225 __isl_give isl_basic_set *isl_set_solutions(
4226 __isl_take isl_set *set);
4227 __isl_give isl_union_set *isl_union_set_solutions(
4228 __isl_take isl_union_set *bset);
4232 __isl_give isl_map *isl_map_fixed_power_val(
4233 __isl_take isl_map *map,
4234 __isl_take isl_val *exp);
4235 __isl_give isl_union_map *
4236 isl_union_map_fixed_power_val(
4237 __isl_take isl_union_map *umap,
4238 __isl_take isl_val *exp);
4240 Compute the given power of C<map>, where C<exp> is assumed to be non-zero.
4241 If the exponent C<exp> is negative, then the -C<exp> th power of the inverse
4242 of C<map> is computed.
4244 __isl_give isl_map *isl_map_power(__isl_take isl_map *map,
4246 __isl_give isl_union_map *isl_union_map_power(
4247 __isl_take isl_union_map *umap, int *exact);
4249 Compute a parametric representation for all positive powers I<k> of C<map>.
4250 The result maps I<k> to a nested relation corresponding to the
4251 I<k>th power of C<map>.
4252 The result may be an overapproximation. If the result is known to be exact,
4253 then C<*exact> is set to C<1>.
4255 =item * Transitive closure
4257 __isl_give isl_map *isl_map_transitive_closure(
4258 __isl_take isl_map *map, int *exact);
4259 __isl_give isl_union_map *isl_union_map_transitive_closure(
4260 __isl_take isl_union_map *umap, int *exact);
4262 Compute the transitive closure of C<map>.
4263 The result may be an overapproximation. If the result is known to be exact,
4264 then C<*exact> is set to C<1>.
4266 =item * Reaching path lengths
4268 __isl_give isl_map *isl_map_reaching_path_lengths(
4269 __isl_take isl_map *map, int *exact);
4271 Compute a relation that maps each element in the range of C<map>
4272 to the lengths of all paths composed of edges in C<map> that
4273 end up in the given element.
4274 The result may be an overapproximation. If the result is known to be exact,
4275 then C<*exact> is set to C<1>.
4276 To compute the I<maximal> path length, the resulting relation
4277 should be postprocessed by C<isl_map_lexmax>.
4278 In particular, if the input relation is a dependence relation
4279 (mapping sources to sinks), then the maximal path length corresponds
4280 to the free schedule.
4281 Note, however, that C<isl_map_lexmax> expects the maximum to be
4282 finite, so if the path lengths are unbounded (possibly due to
4283 the overapproximation), then you will get an error message.
4287 #include <isl/space.h>
4288 __isl_give isl_space *isl_space_wrap(
4289 __isl_take isl_space *space);
4290 __isl_give isl_space *isl_space_unwrap(
4291 __isl_take isl_space *space);
4293 #include <isl/set.h>
4294 __isl_give isl_basic_map *isl_basic_set_unwrap(
4295 __isl_take isl_basic_set *bset);
4296 __isl_give isl_map *isl_set_unwrap(
4297 __isl_take isl_set *set);
4299 #include <isl/map.h>
4300 __isl_give isl_basic_set *isl_basic_map_wrap(
4301 __isl_take isl_basic_map *bmap);
4302 __isl_give isl_set *isl_map_wrap(
4303 __isl_take isl_map *map);
4305 #include <isl/union_set.h>
4306 __isl_give isl_union_map *isl_union_set_unwrap(
4307 __isl_take isl_union_set *uset);
4309 #include <isl/union_map.h>
4310 __isl_give isl_union_set *isl_union_map_wrap(
4311 __isl_take isl_union_map *umap);
4313 The input to C<isl_space_unwrap> should
4314 be the space of a set, while that of
4315 C<isl_space_wrap> should be the space of a relation.
4316 Conversely, the output of C<isl_space_unwrap> is the space
4317 of a relation, while that of C<isl_space_wrap> is the space of a set.
4321 Remove any internal structure of domain (and range) of the given
4322 set or relation. If there is any such internal structure in the input,
4323 then the name of the space is also removed.
4325 #include <isl/local_space.h>
4326 __isl_give isl_local_space *
4327 isl_local_space_flatten_domain(
4328 __isl_take isl_local_space *ls);
4329 __isl_give isl_local_space *
4330 isl_local_space_flatten_range(
4331 __isl_take isl_local_space *ls);
4333 #include <isl/set.h>
4334 __isl_give isl_basic_set *isl_basic_set_flatten(
4335 __isl_take isl_basic_set *bset);
4336 __isl_give isl_set *isl_set_flatten(
4337 __isl_take isl_set *set);
4339 #include <isl/map.h>
4340 __isl_give isl_basic_map *isl_basic_map_flatten_domain(
4341 __isl_take isl_basic_map *bmap);
4342 __isl_give isl_basic_map *isl_basic_map_flatten_range(
4343 __isl_take isl_basic_map *bmap);
4344 __isl_give isl_map *isl_map_flatten_range(
4345 __isl_take isl_map *map);
4346 __isl_give isl_map *isl_map_flatten_domain(
4347 __isl_take isl_map *map);
4348 __isl_give isl_basic_map *isl_basic_map_flatten(
4349 __isl_take isl_basic_map *bmap);
4350 __isl_give isl_map *isl_map_flatten(
4351 __isl_take isl_map *map);
4353 #include <isl/aff.h>
4354 __isl_give isl_multi_aff *isl_multi_aff_flatten_domain(
4355 __isl_take isl_multi_aff *ma);
4357 #include <isl/map.h>
4358 __isl_give isl_map *isl_set_flatten_map(
4359 __isl_take isl_set *set);
4361 The function above constructs a relation
4362 that maps the input set to a flattened version of the set.
4366 Lift the input set to a space with extra dimensions corresponding
4367 to the existentially quantified variables in the input.
4368 In particular, the result lives in a wrapped map where the domain
4369 is the original space and the range corresponds to the original
4370 existentially quantified variables.
4372 #include <isl/set.h>
4373 __isl_give isl_basic_set *isl_basic_set_lift(
4374 __isl_take isl_basic_set *bset);
4375 __isl_give isl_set *isl_set_lift(
4376 __isl_take isl_set *set);
4377 __isl_give isl_union_set *isl_union_set_lift(
4378 __isl_take isl_union_set *uset);
4380 Given a local space that contains the existentially quantified
4381 variables of a set, a basic relation that, when applied to
4382 a basic set, has essentially the same effect as C<isl_basic_set_lift>,
4383 can be constructed using the following function.
4385 #include <isl/local_space.h>
4386 __isl_give isl_basic_map *isl_local_space_lifting(
4387 __isl_take isl_local_space *ls);
4389 #include <isl/aff.h>
4390 __isl_give isl_multi_aff *isl_multi_aff_lift(
4391 __isl_take isl_multi_aff *maff,
4392 __isl_give isl_local_space **ls);
4394 If the C<ls> argument of C<isl_multi_aff_lift> is not C<NULL>,
4395 then it is assigned the local space that lies at the basis of
4396 the lifting applied.
4398 =item * Internal Product
4400 #include <isl/space.h>
4401 __isl_give isl_space *isl_space_zip(
4402 __isl_take isl_space *space);
4404 #include <isl/map.h>
4405 __isl_give isl_basic_map *isl_basic_map_zip(
4406 __isl_take isl_basic_map *bmap);
4407 __isl_give isl_map *isl_map_zip(
4408 __isl_take isl_map *map);
4410 #include <isl/union_map.h>
4411 __isl_give isl_union_map *isl_union_map_zip(
4412 __isl_take isl_union_map *umap);
4414 Given a relation with nested relations for domain and range,
4415 interchange the range of the domain with the domain of the range.
4419 #include <isl/space.h>
4420 __isl_give isl_space *isl_space_curry(
4421 __isl_take isl_space *space);
4422 __isl_give isl_space *isl_space_uncurry(
4423 __isl_take isl_space *space);
4425 #include <isl/map.h>
4426 __isl_give isl_basic_map *isl_basic_map_curry(
4427 __isl_take isl_basic_map *bmap);
4428 __isl_give isl_basic_map *isl_basic_map_uncurry(
4429 __isl_take isl_basic_map *bmap);
4430 __isl_give isl_map *isl_map_curry(
4431 __isl_take isl_map *map);
4432 __isl_give isl_map *isl_map_uncurry(
4433 __isl_take isl_map *map);
4435 #include <isl/union_map.h>
4436 __isl_give isl_union_map *isl_union_map_curry(
4437 __isl_take isl_union_map *umap);
4438 __isl_give isl_union_map *isl_union_map_uncurry(
4439 __isl_take isl_union_map *umap);
4441 Given a relation with a nested relation for domain,
4442 the C<curry> functions
4443 move the range of the nested relation out of the domain
4444 and use it as the domain of a nested relation in the range,
4445 with the original range as range of this nested relation.
4446 The C<uncurry> functions perform the inverse operation.
4448 =item * Aligning parameters
4450 Change the order of the parameters of the given set, relation
4452 such that the first parameters match those of C<model>.
4453 This may involve the introduction of extra parameters.
4454 All parameters need to be named.
4456 #include <isl/space.h>
4457 __isl_give isl_space *isl_space_align_params(
4458 __isl_take isl_space *space1,
4459 __isl_take isl_space *space2)
4461 #include <isl/set.h>
4462 __isl_give isl_basic_set *isl_basic_set_align_params(
4463 __isl_take isl_basic_set *bset,
4464 __isl_take isl_space *model);
4465 __isl_give isl_set *isl_set_align_params(
4466 __isl_take isl_set *set,
4467 __isl_take isl_space *model);
4469 #include <isl/map.h>
4470 __isl_give isl_basic_map *isl_basic_map_align_params(
4471 __isl_take isl_basic_map *bmap,
4472 __isl_take isl_space *model);
4473 __isl_give isl_map *isl_map_align_params(
4474 __isl_take isl_map *map,
4475 __isl_take isl_space *model);
4477 #include <isl/val.h>
4478 __isl_give isl_multi_val *isl_multi_val_align_params(
4479 __isl_take isl_multi_val *mv,
4480 __isl_take isl_space *model);
4482 #include <isl/aff.h>
4483 __isl_give isl_aff *isl_aff_align_params(
4484 __isl_take isl_aff *aff,
4485 __isl_take isl_space *model);
4486 __isl_give isl_multi_aff *isl_multi_aff_align_params(
4487 __isl_take isl_multi_aff *multi,
4488 __isl_take isl_space *model);
4489 __isl_give isl_pw_aff *isl_pw_aff_align_params(
4490 __isl_take isl_pw_aff *pwaff,
4491 __isl_take isl_space *model);
4492 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_align_params(
4493 __isl_take isl_pw_multi_aff *pma,
4494 __isl_take isl_space *model);
4495 __isl_give isl_union_pw_multi_aff *
4496 isl_union_pw_multi_aff_align_params(
4497 __isl_take isl_union_pw_multi_aff *upma,
4498 __isl_take isl_space *model);
4500 #include <isl/polynomial.h>
4501 __isl_give isl_qpolynomial *isl_qpolynomial_align_params(
4502 __isl_take isl_qpolynomial *qp,
4503 __isl_take isl_space *model);
4505 =item * Unary Arithmethic Operations
4507 #include <isl/aff.h>
4508 __isl_give isl_aff *isl_aff_neg(
4509 __isl_take isl_aff *aff);
4510 __isl_give isl_pw_aff *isl_pw_aff_neg(
4511 __isl_take isl_pw_aff *pwaff);
4512 __isl_give isl_aff *isl_aff_ceil(
4513 __isl_take isl_aff *aff);
4514 __isl_give isl_pw_aff *isl_pw_aff_ceil(
4515 __isl_take isl_pw_aff *pwaff);
4516 __isl_give isl_aff *isl_aff_floor(
4517 __isl_take isl_aff *aff);
4518 __isl_give isl_multi_aff *isl_multi_aff_floor(
4519 __isl_take isl_multi_aff *ma);
4520 __isl_give isl_pw_aff *isl_pw_aff_floor(
4521 __isl_take isl_pw_aff *pwaff);
4523 #include <isl/aff.h>
4524 __isl_give isl_pw_aff *isl_pw_aff_list_min(
4525 __isl_take isl_pw_aff_list *list);
4526 __isl_give isl_pw_aff *isl_pw_aff_list_max(
4527 __isl_take isl_pw_aff_list *list);
4529 #include <isl/polynomial.h>
4530 __isl_give isl_qpolynomial *isl_qpolynomial_neg(
4531 __isl_take isl_qpolynomial *qp);
4532 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg(
4533 __isl_take isl_pw_qpolynomial *pwqp);
4534 __isl_give isl_qpolynomial *isl_qpolynomial_pow(
4535 __isl_take isl_qpolynomial *qp,
4537 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_pow(
4538 __isl_take isl_pw_qpolynomial *pwqp,
4543 The following functions evaluate a function in a point.
4545 #include <isl/polynomial.h>
4546 __isl_give isl_val *isl_pw_qpolynomial_eval(
4547 __isl_take isl_pw_qpolynomial *pwqp,
4548 __isl_take isl_point *pnt);
4549 __isl_give isl_val *isl_pw_qpolynomial_fold_eval(
4550 __isl_take isl_pw_qpolynomial_fold *pwf,
4551 __isl_take isl_point *pnt);
4552 __isl_give isl_val *isl_union_pw_qpolynomial_eval(
4553 __isl_take isl_union_pw_qpolynomial *upwqp,
4554 __isl_take isl_point *pnt);
4555 __isl_give isl_val *isl_union_pw_qpolynomial_fold_eval(
4556 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4557 __isl_take isl_point *pnt);
4559 =item * Dimension manipulation
4561 It is usually not advisable to directly change the (input or output)
4562 space of a set or a relation as this removes the name and the internal
4563 structure of the space. However, the functions below can be useful
4564 to add new parameters, assuming
4565 C<isl_set_align_params> and C<isl_map_align_params>
4568 #include <isl/space.h>
4569 __isl_give isl_space *isl_space_add_dims(
4570 __isl_take isl_space *space,
4571 enum isl_dim_type type, unsigned n);
4572 __isl_give isl_space *isl_space_insert_dims(
4573 __isl_take isl_space *space,
4574 enum isl_dim_type type, unsigned pos, unsigned n);
4575 __isl_give isl_space *isl_space_drop_dims(
4576 __isl_take isl_space *space,
4577 enum isl_dim_type type, unsigned first, unsigned n);
4578 __isl_give isl_space *isl_space_move_dims(
4579 __isl_take isl_space *space,
4580 enum isl_dim_type dst_type, unsigned dst_pos,
4581 enum isl_dim_type src_type, unsigned src_pos,
4584 #include <isl/local_space.h>
4585 __isl_give isl_local_space *isl_local_space_add_dims(
4586 __isl_take isl_local_space *ls,
4587 enum isl_dim_type type, unsigned n);
4588 __isl_give isl_local_space *isl_local_space_insert_dims(
4589 __isl_take isl_local_space *ls,
4590 enum isl_dim_type type, unsigned first, unsigned n);
4591 __isl_give isl_local_space *isl_local_space_drop_dims(
4592 __isl_take isl_local_space *ls,
4593 enum isl_dim_type type, unsigned first, unsigned n);
4595 #include <isl/set.h>
4596 __isl_give isl_basic_set *isl_basic_set_add_dims(
4597 __isl_take isl_basic_set *bset,
4598 enum isl_dim_type type, unsigned n);
4599 __isl_give isl_set *isl_set_add_dims(
4600 __isl_take isl_set *set,
4601 enum isl_dim_type type, unsigned n);
4602 __isl_give isl_basic_set *isl_basic_set_insert_dims(
4603 __isl_take isl_basic_set *bset,
4604 enum isl_dim_type type, unsigned pos,
4606 __isl_give isl_set *isl_set_insert_dims(
4607 __isl_take isl_set *set,
4608 enum isl_dim_type type, unsigned pos, unsigned n);
4609 __isl_give isl_basic_set *isl_basic_set_move_dims(
4610 __isl_take isl_basic_set *bset,
4611 enum isl_dim_type dst_type, unsigned dst_pos,
4612 enum isl_dim_type src_type, unsigned src_pos,
4614 __isl_give isl_set *isl_set_move_dims(
4615 __isl_take isl_set *set,
4616 enum isl_dim_type dst_type, unsigned dst_pos,
4617 enum isl_dim_type src_type, unsigned src_pos,
4620 #include <isl/map.h>
4621 __isl_give isl_map *isl_map_add_dims(
4622 __isl_take isl_map *map,
4623 enum isl_dim_type type, unsigned n);
4624 __isl_give isl_basic_map *isl_basic_map_insert_dims(
4625 __isl_take isl_basic_map *bmap,
4626 enum isl_dim_type type, unsigned pos,
4628 __isl_give isl_map *isl_map_insert_dims(
4629 __isl_take isl_map *map,
4630 enum isl_dim_type type, unsigned pos, unsigned n);
4631 __isl_give isl_basic_map *isl_basic_map_move_dims(
4632 __isl_take isl_basic_map *bmap,
4633 enum isl_dim_type dst_type, unsigned dst_pos,
4634 enum isl_dim_type src_type, unsigned src_pos,
4636 __isl_give isl_map *isl_map_move_dims(
4637 __isl_take isl_map *map,
4638 enum isl_dim_type dst_type, unsigned dst_pos,
4639 enum isl_dim_type src_type, unsigned src_pos,
4642 #include <isl/val.h>
4643 __isl_give isl_multi_val *isl_multi_val_insert_dims(
4644 __isl_take isl_multi_val *mv,
4645 enum isl_dim_type type, unsigned first, unsigned n);
4646 __isl_give isl_multi_val *isl_multi_val_add_dims(
4647 __isl_take isl_multi_val *mv,
4648 enum isl_dim_type type, unsigned n);
4649 __isl_give isl_multi_val *isl_multi_val_drop_dims(
4650 __isl_take isl_multi_val *mv,
4651 enum isl_dim_type type, unsigned first, unsigned n);
4653 #include <isl/aff.h>
4654 __isl_give isl_aff *isl_aff_insert_dims(
4655 __isl_take isl_aff *aff,
4656 enum isl_dim_type type, unsigned first, unsigned n);
4657 __isl_give isl_multi_aff *isl_multi_aff_insert_dims(
4658 __isl_take isl_multi_aff *ma,
4659 enum isl_dim_type type, unsigned first, unsigned n);
4660 __isl_give isl_pw_aff *isl_pw_aff_insert_dims(
4661 __isl_take isl_pw_aff *pwaff,
4662 enum isl_dim_type type, unsigned first, unsigned n);
4663 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_insert_dims(
4664 __isl_take isl_multi_pw_aff *mpa,
4665 enum isl_dim_type type, unsigned first, unsigned n);
4666 __isl_give isl_aff *isl_aff_add_dims(
4667 __isl_take isl_aff *aff,
4668 enum isl_dim_type type, unsigned n);
4669 __isl_give isl_multi_aff *isl_multi_aff_add_dims(
4670 __isl_take isl_multi_aff *ma,
4671 enum isl_dim_type type, unsigned n);
4672 __isl_give isl_pw_aff *isl_pw_aff_add_dims(
4673 __isl_take isl_pw_aff *pwaff,
4674 enum isl_dim_type type, unsigned n);
4675 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_add_dims(
4676 __isl_take isl_multi_pw_aff *mpa,
4677 enum isl_dim_type type, unsigned n);
4678 __isl_give isl_aff *isl_aff_drop_dims(
4679 __isl_take isl_aff *aff,
4680 enum isl_dim_type type, unsigned first, unsigned n);
4681 __isl_give isl_multi_aff *isl_multi_aff_drop_dims(
4682 __isl_take isl_multi_aff *maff,
4683 enum isl_dim_type type, unsigned first, unsigned n);
4684 __isl_give isl_pw_aff *isl_pw_aff_drop_dims(
4685 __isl_take isl_pw_aff *pwaff,
4686 enum isl_dim_type type, unsigned first, unsigned n);
4687 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_drop_dims(
4688 __isl_take isl_pw_multi_aff *pma,
4689 enum isl_dim_type type, unsigned first, unsigned n);
4690 __isl_give isl_aff *isl_aff_move_dims(
4691 __isl_take isl_aff *aff,
4692 enum isl_dim_type dst_type, unsigned dst_pos,
4693 enum isl_dim_type src_type, unsigned src_pos,
4695 __isl_give isl_pw_aff *isl_pw_aff_move_dims(
4696 __isl_take isl_pw_aff *pa,
4697 enum isl_dim_type dst_type, unsigned dst_pos,
4698 enum isl_dim_type src_type, unsigned src_pos,
4700 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_move_dims(
4701 __isl_take isl_multi_pw_aff *pma,
4702 enum isl_dim_type dst_type, unsigned dst_pos,
4703 enum isl_dim_type src_type, unsigned src_pos,
4708 =head2 Binary Operations
4710 The two arguments of a binary operation not only need to live
4711 in the same C<isl_ctx>, they currently also need to have
4712 the same (number of) parameters.
4714 =head3 Basic Operations
4718 =item * Intersection
4720 #include <isl/local_space.h>
4721 __isl_give isl_local_space *isl_local_space_intersect(
4722 __isl_take isl_local_space *ls1,
4723 __isl_take isl_local_space *ls2);
4725 #include <isl/set.h>
4726 __isl_give isl_basic_set *isl_basic_set_intersect_params(
4727 __isl_take isl_basic_set *bset1,
4728 __isl_take isl_basic_set *bset2);
4729 __isl_give isl_basic_set *isl_basic_set_intersect(
4730 __isl_take isl_basic_set *bset1,
4731 __isl_take isl_basic_set *bset2);
4732 __isl_give isl_basic_set *isl_basic_set_list_intersect(
4733 __isl_take struct isl_basic_set_list *list);
4734 __isl_give isl_set *isl_set_intersect_params(
4735 __isl_take isl_set *set,
4736 __isl_take isl_set *params);
4737 __isl_give isl_set *isl_set_intersect(
4738 __isl_take isl_set *set1,
4739 __isl_take isl_set *set2);
4741 #include <isl/map.h>
4742 __isl_give isl_basic_map *isl_basic_map_intersect_domain(
4743 __isl_take isl_basic_map *bmap,
4744 __isl_take isl_basic_set *bset);
4745 __isl_give isl_basic_map *isl_basic_map_intersect_range(
4746 __isl_take isl_basic_map *bmap,
4747 __isl_take isl_basic_set *bset);
4748 __isl_give isl_basic_map *isl_basic_map_intersect(
4749 __isl_take isl_basic_map *bmap1,
4750 __isl_take isl_basic_map *bmap2);
4751 __isl_give isl_map *isl_map_intersect_params(
4752 __isl_take isl_map *map,
4753 __isl_take isl_set *params);
4754 __isl_give isl_map *isl_map_intersect_domain(
4755 __isl_take isl_map *map,
4756 __isl_take isl_set *set);
4757 __isl_give isl_map *isl_map_intersect_range(
4758 __isl_take isl_map *map,
4759 __isl_take isl_set *set);
4760 __isl_give isl_map *isl_map_intersect(
4761 __isl_take isl_map *map1,
4762 __isl_take isl_map *map2);
4764 #include <isl/union_set.h>
4765 __isl_give isl_union_set *isl_union_set_intersect_params(
4766 __isl_take isl_union_set *uset,
4767 __isl_take isl_set *set);
4768 __isl_give isl_union_set *isl_union_set_intersect(
4769 __isl_take isl_union_set *uset1,
4770 __isl_take isl_union_set *uset2);
4772 #include <isl/union_map.h>
4773 __isl_give isl_union_map *isl_union_map_intersect_params(
4774 __isl_take isl_union_map *umap,
4775 __isl_take isl_set *set);
4776 __isl_give isl_union_map *isl_union_map_intersect_domain(
4777 __isl_take isl_union_map *umap,
4778 __isl_take isl_union_set *uset);
4779 __isl_give isl_union_map *isl_union_map_intersect_range(
4780 __isl_take isl_union_map *umap,
4781 __isl_take isl_union_set *uset);
4782 __isl_give isl_union_map *isl_union_map_intersect(
4783 __isl_take isl_union_map *umap1,
4784 __isl_take isl_union_map *umap2);
4786 #include <isl/aff.h>
4787 __isl_give isl_pw_aff *isl_pw_aff_intersect_domain(
4788 __isl_take isl_pw_aff *pa,
4789 __isl_take isl_set *set);
4790 __isl_give isl_multi_pw_aff *
4791 isl_multi_pw_aff_intersect_domain(
4792 __isl_take isl_multi_pw_aff *mpa,
4793 __isl_take isl_set *domain);
4794 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_domain(
4795 __isl_take isl_pw_multi_aff *pma,
4796 __isl_take isl_set *set);
4797 __isl_give isl_union_pw_multi_aff *
4798 isl_union_pw_multi_aff_intersect_domain(
4799 __isl_take isl_union_pw_multi_aff *upma,
4800 __isl_take isl_union_set *uset);
4801 __isl_give isl_pw_aff *isl_pw_aff_intersect_params(
4802 __isl_take isl_pw_aff *pa,
4803 __isl_take isl_set *set);
4804 __isl_give isl_multi_pw_aff *
4805 isl_multi_pw_aff_intersect_params(
4806 __isl_take isl_multi_pw_aff *mpa,
4807 __isl_take isl_set *set);
4808 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_params(
4809 __isl_take isl_pw_multi_aff *pma,
4810 __isl_take isl_set *set);
4812 #include <isl/polynomial.h>
4813 __isl_give isl_pw_qpolynomial *
4814 isl_pw_qpolynomial_intersect_domain(
4815 __isl_take isl_pw_qpolynomial *pwpq,
4816 __isl_take isl_set *set);
4817 __isl_give isl_union_pw_qpolynomial *
4818 isl_union_pw_qpolynomial_intersect_domain(
4819 __isl_take isl_union_pw_qpolynomial *upwpq,
4820 __isl_take isl_union_set *uset);
4821 __isl_give isl_union_pw_qpolynomial_fold *
4822 isl_union_pw_qpolynomial_fold_intersect_domain(
4823 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4824 __isl_take isl_union_set *uset);
4825 __isl_give isl_pw_qpolynomial *
4826 isl_pw_qpolynomial_intersect_params(
4827 __isl_take isl_pw_qpolynomial *pwpq,
4828 __isl_take isl_set *set);
4829 __isl_give isl_pw_qpolynomial_fold *
4830 isl_pw_qpolynomial_fold_intersect_params(
4831 __isl_take isl_pw_qpolynomial_fold *pwf,
4832 __isl_take isl_set *set);
4833 __isl_give isl_union_pw_qpolynomial *
4834 isl_union_pw_qpolynomial_intersect_params(
4835 __isl_take isl_union_pw_qpolynomial *upwpq,
4836 __isl_take isl_set *set);
4837 __isl_give isl_union_pw_qpolynomial_fold *
4838 isl_union_pw_qpolynomial_fold_intersect_params(
4839 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4840 __isl_take isl_set *set);
4842 The second argument to the C<_params> functions needs to be
4843 a parametric (basic) set. For the other functions, a parametric set
4844 for either argument is only allowed if the other argument is
4845 a parametric set as well.
4846 The list passed to C<isl_basic_set_list_intersect> needs to have
4847 at least one element and all elements need to live in the same space.
4851 __isl_give isl_set *isl_basic_set_union(
4852 __isl_take isl_basic_set *bset1,
4853 __isl_take isl_basic_set *bset2);
4854 __isl_give isl_map *isl_basic_map_union(
4855 __isl_take isl_basic_map *bmap1,
4856 __isl_take isl_basic_map *bmap2);
4857 __isl_give isl_set *isl_set_union(
4858 __isl_take isl_set *set1,
4859 __isl_take isl_set *set2);
4860 __isl_give isl_map *isl_map_union(
4861 __isl_take isl_map *map1,
4862 __isl_take isl_map *map2);
4863 __isl_give isl_union_set *isl_union_set_union(
4864 __isl_take isl_union_set *uset1,
4865 __isl_take isl_union_set *uset2);
4866 __isl_give isl_union_map *isl_union_map_union(
4867 __isl_take isl_union_map *umap1,
4868 __isl_take isl_union_map *umap2);
4870 =item * Set difference
4872 __isl_give isl_set *isl_set_subtract(
4873 __isl_take isl_set *set1,
4874 __isl_take isl_set *set2);
4875 __isl_give isl_map *isl_map_subtract(
4876 __isl_take isl_map *map1,
4877 __isl_take isl_map *map2);
4878 __isl_give isl_map *isl_map_subtract_domain(
4879 __isl_take isl_map *map,
4880 __isl_take isl_set *dom);
4881 __isl_give isl_map *isl_map_subtract_range(
4882 __isl_take isl_map *map,
4883 __isl_take isl_set *dom);
4884 __isl_give isl_union_set *isl_union_set_subtract(
4885 __isl_take isl_union_set *uset1,
4886 __isl_take isl_union_set *uset2);
4887 __isl_give isl_union_map *isl_union_map_subtract(
4888 __isl_take isl_union_map *umap1,
4889 __isl_take isl_union_map *umap2);
4890 __isl_give isl_union_map *isl_union_map_subtract_domain(
4891 __isl_take isl_union_map *umap,
4892 __isl_take isl_union_set *dom);
4893 __isl_give isl_union_map *isl_union_map_subtract_range(
4894 __isl_take isl_union_map *umap,
4895 __isl_take isl_union_set *dom);
4899 #include <isl/space.h>
4900 __isl_give isl_space *isl_space_join(
4901 __isl_take isl_space *left,
4902 __isl_take isl_space *right);
4904 #include <isl/map.h>
4905 __isl_give isl_basic_set *isl_basic_set_apply(
4906 __isl_take isl_basic_set *bset,
4907 __isl_take isl_basic_map *bmap);
4908 __isl_give isl_set *isl_set_apply(
4909 __isl_take isl_set *set,
4910 __isl_take isl_map *map);
4911 __isl_give isl_union_set *isl_union_set_apply(
4912 __isl_take isl_union_set *uset,
4913 __isl_take isl_union_map *umap);
4914 __isl_give isl_basic_map *isl_basic_map_apply_domain(
4915 __isl_take isl_basic_map *bmap1,
4916 __isl_take isl_basic_map *bmap2);
4917 __isl_give isl_basic_map *isl_basic_map_apply_range(
4918 __isl_take isl_basic_map *bmap1,
4919 __isl_take isl_basic_map *bmap2);
4920 __isl_give isl_map *isl_map_apply_domain(
4921 __isl_take isl_map *map1,
4922 __isl_take isl_map *map2);
4923 __isl_give isl_map *isl_map_apply_range(
4924 __isl_take isl_map *map1,
4925 __isl_take isl_map *map2);
4927 #include <isl/union_map.h>
4928 __isl_give isl_union_map *isl_union_map_apply_domain(
4929 __isl_take isl_union_map *umap1,
4930 __isl_take isl_union_map *umap2);
4931 __isl_give isl_union_map *isl_union_map_apply_range(
4932 __isl_take isl_union_map *umap1,
4933 __isl_take isl_union_map *umap2);
4935 #include <isl/polynomial.h>
4936 __isl_give isl_pw_qpolynomial_fold *
4937 isl_set_apply_pw_qpolynomial_fold(
4938 __isl_take isl_set *set,
4939 __isl_take isl_pw_qpolynomial_fold *pwf,
4941 __isl_give isl_pw_qpolynomial_fold *
4942 isl_map_apply_pw_qpolynomial_fold(
4943 __isl_take isl_map *map,
4944 __isl_take isl_pw_qpolynomial_fold *pwf,
4946 __isl_give isl_union_pw_qpolynomial_fold *
4947 isl_union_set_apply_union_pw_qpolynomial_fold(
4948 __isl_take isl_union_set *uset,
4949 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4951 __isl_give isl_union_pw_qpolynomial_fold *
4952 isl_union_map_apply_union_pw_qpolynomial_fold(
4953 __isl_take isl_union_map *umap,
4954 __isl_take isl_union_pw_qpolynomial_fold *upwf,
4957 The functions taking a map
4958 compose the given map with the given piecewise quasipolynomial reduction.
4959 That is, compute a bound (of the same type as C<pwf> or C<upwf> itself)
4960 over all elements in the intersection of the range of the map
4961 and the domain of the piecewise quasipolynomial reduction
4962 as a function of an element in the domain of the map.
4963 The functions taking a set compute a bound over all elements in the
4964 intersection of the set and the domain of the
4965 piecewise quasipolynomial reduction.
4969 #include <isl/set.h>
4970 __isl_give isl_basic_set *
4971 isl_basic_set_preimage_multi_aff(
4972 __isl_take isl_basic_set *bset,
4973 __isl_take isl_multi_aff *ma);
4974 __isl_give isl_set *isl_set_preimage_multi_aff(
4975 __isl_take isl_set *set,
4976 __isl_take isl_multi_aff *ma);
4977 __isl_give isl_set *isl_set_preimage_pw_multi_aff(
4978 __isl_take isl_set *set,
4979 __isl_take isl_pw_multi_aff *pma);
4980 __isl_give isl_set *isl_set_preimage_multi_pw_aff(
4981 __isl_take isl_set *set,
4982 __isl_take isl_multi_pw_aff *mpa);
4984 #include <isl/union_set.h>
4985 __isl_give isl_union_set *
4986 isl_union_set_preimage_multi_aff(
4987 __isl_take isl_union_set *uset,
4988 __isl_take isl_multi_aff *ma);
4989 __isl_give isl_union_set *
4990 isl_union_set_preimage_pw_multi_aff(
4991 __isl_take isl_union_set *uset,
4992 __isl_take isl_pw_multi_aff *pma);
4993 __isl_give isl_union_set *
4994 isl_union_set_preimage_union_pw_multi_aff(
4995 __isl_take isl_union_set *uset,
4996 __isl_take isl_union_pw_multi_aff *upma);
4998 #include <isl/map.h>
4999 __isl_give isl_basic_map *
5000 isl_basic_map_preimage_domain_multi_aff(
5001 __isl_take isl_basic_map *bmap,
5002 __isl_take isl_multi_aff *ma);
5003 __isl_give isl_map *isl_map_preimage_domain_multi_aff(
5004 __isl_take isl_map *map,
5005 __isl_take isl_multi_aff *ma);
5006 __isl_give isl_map *isl_map_preimage_range_multi_aff(
5007 __isl_take isl_map *map,
5008 __isl_take isl_multi_aff *ma);
5009 __isl_give isl_map *
5010 isl_map_preimage_domain_pw_multi_aff(
5011 __isl_take isl_map *map,
5012 __isl_take isl_pw_multi_aff *pma);
5013 __isl_give isl_map *
5014 isl_map_preimage_range_pw_multi_aff(
5015 __isl_take isl_map *map,
5016 __isl_take isl_pw_multi_aff *pma);
5017 __isl_give isl_map *
5018 isl_map_preimage_domain_multi_pw_aff(
5019 __isl_take isl_map *map,
5020 __isl_take isl_multi_pw_aff *mpa);
5021 __isl_give isl_basic_map *
5022 isl_basic_map_preimage_range_multi_aff(
5023 __isl_take isl_basic_map *bmap,
5024 __isl_take isl_multi_aff *ma);
5026 #include <isl/union_map.h>
5027 __isl_give isl_union_map *
5028 isl_union_map_preimage_domain_multi_aff(
5029 __isl_take isl_union_map *umap,
5030 __isl_take isl_multi_aff *ma);
5031 __isl_give isl_union_map *
5032 isl_union_map_preimage_range_multi_aff(
5033 __isl_take isl_union_map *umap,
5034 __isl_take isl_multi_aff *ma);
5035 __isl_give isl_union_map *
5036 isl_union_map_preimage_domain_pw_multi_aff(
5037 __isl_take isl_union_map *umap,
5038 __isl_take isl_pw_multi_aff *pma);
5039 __isl_give isl_union_map *
5040 isl_union_map_preimage_range_pw_multi_aff(
5041 __isl_take isl_union_map *umap,
5042 __isl_take isl_pw_multi_aff *pma);
5043 __isl_give isl_union_map *
5044 isl_union_map_preimage_domain_union_pw_multi_aff(
5045 __isl_take isl_union_map *umap,
5046 __isl_take isl_union_pw_multi_aff *upma);
5047 __isl_give isl_union_map *
5048 isl_union_map_preimage_range_union_pw_multi_aff(
5049 __isl_take isl_union_map *umap,
5050 __isl_take isl_union_pw_multi_aff *upma);
5052 These functions compute the preimage of the given set or map domain/range under
5053 the given function. In other words, the expression is plugged
5054 into the set description or into the domain/range of the map.
5058 #include <isl/aff.h>
5059 __isl_give isl_aff *isl_aff_pullback_aff(
5060 __isl_take isl_aff *aff1,
5061 __isl_take isl_aff *aff2);
5062 __isl_give isl_aff *isl_aff_pullback_multi_aff(
5063 __isl_take isl_aff *aff,
5064 __isl_take isl_multi_aff *ma);
5065 __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_aff(
5066 __isl_take isl_pw_aff *pa,
5067 __isl_take isl_multi_aff *ma);
5068 __isl_give isl_pw_aff *isl_pw_aff_pullback_pw_multi_aff(
5069 __isl_take isl_pw_aff *pa,
5070 __isl_take isl_pw_multi_aff *pma);
5071 __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_pw_aff(
5072 __isl_take isl_pw_aff *pa,
5073 __isl_take isl_multi_pw_aff *mpa);
5074 __isl_give isl_multi_aff *isl_multi_aff_pullback_multi_aff(
5075 __isl_take isl_multi_aff *ma1,
5076 __isl_take isl_multi_aff *ma2);
5077 __isl_give isl_pw_multi_aff *
5078 isl_pw_multi_aff_pullback_multi_aff(
5079 __isl_take isl_pw_multi_aff *pma,
5080 __isl_take isl_multi_aff *ma);
5081 __isl_give isl_multi_pw_aff *
5082 isl_multi_pw_aff_pullback_multi_aff(
5083 __isl_take isl_multi_pw_aff *mpa,
5084 __isl_take isl_multi_aff *ma);
5085 __isl_give isl_pw_multi_aff *
5086 isl_pw_multi_aff_pullback_pw_multi_aff(
5087 __isl_take isl_pw_multi_aff *pma1,
5088 __isl_take isl_pw_multi_aff *pma2);
5089 __isl_give isl_multi_pw_aff *
5090 isl_multi_pw_aff_pullback_pw_multi_aff(
5091 __isl_take isl_multi_pw_aff *mpa,
5092 __isl_take isl_pw_multi_aff *pma);
5093 __isl_give isl_multi_pw_aff *
5094 isl_multi_pw_aff_pullback_multi_pw_aff(
5095 __isl_take isl_multi_pw_aff *mpa1,
5096 __isl_take isl_multi_pw_aff *mpa2);
5098 These functions precompose the first expression by the second function.
5099 In other words, the second function is plugged
5100 into the first expression.
5104 #include <isl/aff.h>
5105 __isl_give isl_basic_set *isl_aff_le_basic_set(
5106 __isl_take isl_aff *aff1,
5107 __isl_take isl_aff *aff2);
5108 __isl_give isl_basic_set *isl_aff_ge_basic_set(
5109 __isl_take isl_aff *aff1,
5110 __isl_take isl_aff *aff2);
5111 __isl_give isl_set *isl_pw_aff_eq_set(
5112 __isl_take isl_pw_aff *pwaff1,
5113 __isl_take isl_pw_aff *pwaff2);
5114 __isl_give isl_set *isl_pw_aff_ne_set(
5115 __isl_take isl_pw_aff *pwaff1,
5116 __isl_take isl_pw_aff *pwaff2);
5117 __isl_give isl_set *isl_pw_aff_le_set(
5118 __isl_take isl_pw_aff *pwaff1,
5119 __isl_take isl_pw_aff *pwaff2);
5120 __isl_give isl_set *isl_pw_aff_lt_set(
5121 __isl_take isl_pw_aff *pwaff1,
5122 __isl_take isl_pw_aff *pwaff2);
5123 __isl_give isl_set *isl_pw_aff_ge_set(
5124 __isl_take isl_pw_aff *pwaff1,
5125 __isl_take isl_pw_aff *pwaff2);
5126 __isl_give isl_set *isl_pw_aff_gt_set(
5127 __isl_take isl_pw_aff *pwaff1,
5128 __isl_take isl_pw_aff *pwaff2);
5130 __isl_give isl_set *isl_multi_aff_lex_le_set(
5131 __isl_take isl_multi_aff *ma1,
5132 __isl_take isl_multi_aff *ma2);
5133 __isl_give isl_set *isl_multi_aff_lex_ge_set(
5134 __isl_take isl_multi_aff *ma1,
5135 __isl_take isl_multi_aff *ma2);
5137 __isl_give isl_set *isl_pw_aff_list_eq_set(
5138 __isl_take isl_pw_aff_list *list1,
5139 __isl_take isl_pw_aff_list *list2);
5140 __isl_give isl_set *isl_pw_aff_list_ne_set(
5141 __isl_take isl_pw_aff_list *list1,
5142 __isl_take isl_pw_aff_list *list2);
5143 __isl_give isl_set *isl_pw_aff_list_le_set(
5144 __isl_take isl_pw_aff_list *list1,
5145 __isl_take isl_pw_aff_list *list2);
5146 __isl_give isl_set *isl_pw_aff_list_lt_set(
5147 __isl_take isl_pw_aff_list *list1,
5148 __isl_take isl_pw_aff_list *list2);
5149 __isl_give isl_set *isl_pw_aff_list_ge_set(
5150 __isl_take isl_pw_aff_list *list1,
5151 __isl_take isl_pw_aff_list *list2);
5152 __isl_give isl_set *isl_pw_aff_list_gt_set(
5153 __isl_take isl_pw_aff_list *list1,
5154 __isl_take isl_pw_aff_list *list2);
5156 The function C<isl_aff_ge_basic_set> returns a basic set
5157 containing those elements in the shared space
5158 of C<aff1> and C<aff2> where C<aff1> is greater than or equal to C<aff2>.
5159 The function C<isl_pw_aff_ge_set> returns a set
5160 containing those elements in the shared domain
5161 of C<pwaff1> and C<pwaff2> where C<pwaff1> is
5162 greater than or equal to C<pwaff2>.
5163 The function C<isl_multi_aff_lex_le_set> returns a set
5164 containing those elements in the shared domain space
5165 where C<ma1> is lexicographically smaller than or
5167 The functions operating on C<isl_pw_aff_list> apply the corresponding
5168 C<isl_pw_aff> function to each pair of elements in the two lists.
5170 =item * Cartesian Product
5172 #include <isl/space.h>
5173 __isl_give isl_space *isl_space_product(
5174 __isl_take isl_space *space1,
5175 __isl_take isl_space *space2);
5176 __isl_give isl_space *isl_space_domain_product(
5177 __isl_take isl_space *space1,
5178 __isl_take isl_space *space2);
5179 __isl_give isl_space *isl_space_range_product(
5180 __isl_take isl_space *space1,
5181 __isl_take isl_space *space2);
5184 C<isl_space_product>, C<isl_space_domain_product>
5185 and C<isl_space_range_product> take pairs or relation spaces and
5186 produce a single relations space, where either the domain, the range
5187 or both domain and range are wrapped spaces of relations between
5188 the domains and/or ranges of the input spaces.
5189 If the product is only constructed over the domain or the range
5190 then the ranges or the domains of the inputs should be the same.
5191 The function C<isl_space_product> also accepts a pair of set spaces,
5192 in which case it returns a wrapped space of a relation between the
5195 #include <isl/set.h>
5196 __isl_give isl_set *isl_set_product(
5197 __isl_take isl_set *set1,
5198 __isl_take isl_set *set2);
5200 #include <isl/map.h>
5201 __isl_give isl_basic_map *isl_basic_map_domain_product(
5202 __isl_take isl_basic_map *bmap1,
5203 __isl_take isl_basic_map *bmap2);
5204 __isl_give isl_basic_map *isl_basic_map_range_product(
5205 __isl_take isl_basic_map *bmap1,
5206 __isl_take isl_basic_map *bmap2);
5207 __isl_give isl_basic_map *isl_basic_map_product(
5208 __isl_take isl_basic_map *bmap1,
5209 __isl_take isl_basic_map *bmap2);
5210 __isl_give isl_map *isl_map_domain_product(
5211 __isl_take isl_map *map1,
5212 __isl_take isl_map *map2);
5213 __isl_give isl_map *isl_map_range_product(
5214 __isl_take isl_map *map1,
5215 __isl_take isl_map *map2);
5216 __isl_give isl_map *isl_map_product(
5217 __isl_take isl_map *map1,
5218 __isl_take isl_map *map2);
5220 #include <isl/union_set.h>
5221 __isl_give isl_union_set *isl_union_set_product(
5222 __isl_take isl_union_set *uset1,
5223 __isl_take isl_union_set *uset2);
5225 #include <isl/union_map.h>
5226 __isl_give isl_union_map *isl_union_map_domain_product(
5227 __isl_take isl_union_map *umap1,
5228 __isl_take isl_union_map *umap2);
5229 __isl_give isl_union_map *isl_union_map_range_product(
5230 __isl_take isl_union_map *umap1,
5231 __isl_take isl_union_map *umap2);
5232 __isl_give isl_union_map *isl_union_map_product(
5233 __isl_take isl_union_map *umap1,
5234 __isl_take isl_union_map *umap2);
5236 #include <isl/val.h>
5237 __isl_give isl_multi_val *isl_multi_val_range_product(
5238 __isl_take isl_multi_val *mv1,
5239 __isl_take isl_multi_val *mv2);
5240 __isl_give isl_multi_val *isl_multi_val_product(
5241 __isl_take isl_multi_val *mv1,
5242 __isl_take isl_multi_val *mv2);
5244 #include <isl/aff.h>
5245 __isl_give isl_multi_aff *isl_multi_aff_range_product(
5246 __isl_take isl_multi_aff *ma1,
5247 __isl_take isl_multi_aff *ma2);
5248 __isl_give isl_multi_aff *isl_multi_aff_product(
5249 __isl_take isl_multi_aff *ma1,
5250 __isl_take isl_multi_aff *ma2);
5251 __isl_give isl_multi_pw_aff *
5252 isl_multi_pw_aff_range_product(
5253 __isl_take isl_multi_pw_aff *mpa1,
5254 __isl_take isl_multi_pw_aff *mpa2);
5255 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_product(
5256 __isl_take isl_multi_pw_aff *mpa1,
5257 __isl_take isl_multi_pw_aff *mpa2);
5258 __isl_give isl_pw_multi_aff *
5259 isl_pw_multi_aff_range_product(
5260 __isl_take isl_pw_multi_aff *pma1,
5261 __isl_take isl_pw_multi_aff *pma2);
5262 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_product(
5263 __isl_take isl_pw_multi_aff *pma1,
5264 __isl_take isl_pw_multi_aff *pma2);
5266 The above functions compute the cross product of the given
5267 sets, relations or functions. The domains and ranges of the results
5268 are wrapped maps between domains and ranges of the inputs.
5269 To obtain a ``flat'' product, use the following functions
5272 #include <isl/set.h>
5273 __isl_give isl_basic_set *isl_basic_set_flat_product(
5274 __isl_take isl_basic_set *bset1,
5275 __isl_take isl_basic_set *bset2);
5276 __isl_give isl_set *isl_set_flat_product(
5277 __isl_take isl_set *set1,
5278 __isl_take isl_set *set2);
5280 #include <isl/map.h>
5281 __isl_give isl_basic_map *isl_basic_map_flat_range_product(
5282 __isl_take isl_basic_map *bmap1,
5283 __isl_take isl_basic_map *bmap2);
5284 __isl_give isl_map *isl_map_flat_domain_product(
5285 __isl_take isl_map *map1,
5286 __isl_take isl_map *map2);
5287 __isl_give isl_map *isl_map_flat_range_product(
5288 __isl_take isl_map *map1,
5289 __isl_take isl_map *map2);
5290 __isl_give isl_basic_map *isl_basic_map_flat_product(
5291 __isl_take isl_basic_map *bmap1,
5292 __isl_take isl_basic_map *bmap2);
5293 __isl_give isl_map *isl_map_flat_product(
5294 __isl_take isl_map *map1,
5295 __isl_take isl_map *map2);
5297 #include <isl/union_map.h>
5298 __isl_give isl_union_map *
5299 isl_union_map_flat_range_product(
5300 __isl_take isl_union_map *umap1,
5301 __isl_take isl_union_map *umap2);
5303 #include <isl/val.h>
5304 __isl_give isl_multi_val *isl_multi_val_flat_range_product(
5305 __isl_take isl_multi_val *mv1,
5306 __isl_take isl_multi_aff *mv2);
5308 #include <isl/aff.h>
5309 __isl_give isl_multi_aff *isl_multi_aff_flat_range_product(
5310 __isl_take isl_multi_aff *ma1,
5311 __isl_take isl_multi_aff *ma2);
5312 __isl_give isl_pw_multi_aff *
5313 isl_pw_multi_aff_flat_range_product(
5314 __isl_take isl_pw_multi_aff *pma1,
5315 __isl_take isl_pw_multi_aff *pma2);
5316 __isl_give isl_multi_pw_aff *
5317 isl_multi_pw_aff_flat_range_product(
5318 __isl_take isl_multi_pw_aff *mpa1,
5319 __isl_take isl_multi_pw_aff *mpa2);
5320 __isl_give isl_union_pw_multi_aff *
5321 isl_union_pw_multi_aff_flat_range_product(
5322 __isl_take isl_union_pw_multi_aff *upma1,
5323 __isl_take isl_union_pw_multi_aff *upma2);
5325 #include <isl/space.h>
5326 __isl_give isl_space *isl_space_domain_factor_domain(
5327 __isl_take isl_space *space);
5328 __isl_give isl_space *isl_space_range_factor_domain(
5329 __isl_take isl_space *space);
5330 __isl_give isl_space *isl_space_range_factor_range(
5331 __isl_take isl_space *space);
5333 The functions C<isl_space_range_factor_domain> and
5334 C<isl_space_range_factor_range> extract the two arguments from
5335 the result of a call to C<isl_space_range_product>.
5337 The arguments of a call to C<isl_map_range_product> can be extracted
5338 from the result using the following two functions.
5340 #include <isl/map.h>
5341 __isl_give isl_map *isl_map_range_factor_domain(
5342 __isl_take isl_map *map);
5343 __isl_give isl_map *isl_map_range_factor_range(
5344 __isl_take isl_map *map);
5346 #include <isl/val.h>
5347 __isl_give isl_multi_val *
5348 isl_multi_val_range_factor_domain(
5349 __isl_take isl_multi_val *mv);
5350 __isl_give isl_multi_val *
5351 isl_multi_val_range_factor_range(
5352 __isl_take isl_multi_val *mv);
5354 #include <isl/aff.h>
5355 __isl_give isl_multi_aff *
5356 isl_multi_aff_range_factor_domain(
5357 __isl_take isl_multi_aff *ma);
5358 __isl_give isl_multi_aff *
5359 isl_multi_aff_range_factor_range(
5360 __isl_take isl_multi_aff *ma);
5361 __isl_give isl_multi_pw_aff *
5362 isl_multi_pw_aff_range_factor_domain(
5363 __isl_take isl_multi_pw_aff *mpa);
5364 __isl_give isl_multi_pw_aff *
5365 isl_multi_pw_aff_range_factor_range(
5366 __isl_take isl_multi_pw_aff *mpa);
5368 The splice functions are a generalization of the flat product functions,
5369 where the second argument may be inserted at any position inside
5370 the first argument rather than being placed at the end.
5372 #include <isl/val.h>
5373 __isl_give isl_multi_val *isl_multi_val_range_splice(
5374 __isl_take isl_multi_val *mv1, unsigned pos,
5375 __isl_take isl_multi_val *mv2);
5377 #include <isl/aff.h>
5378 __isl_give isl_multi_aff *isl_multi_aff_range_splice(
5379 __isl_take isl_multi_aff *ma1, unsigned pos,
5380 __isl_take isl_multi_aff *ma2);
5381 __isl_give isl_multi_aff *isl_multi_aff_splice(
5382 __isl_take isl_multi_aff *ma1,
5383 unsigned in_pos, unsigned out_pos,
5384 __isl_take isl_multi_aff *ma2);
5385 __isl_give isl_multi_pw_aff *
5386 isl_multi_pw_aff_range_splice(
5387 __isl_take isl_multi_pw_aff *mpa1, unsigned pos,
5388 __isl_take isl_multi_pw_aff *mpa2);
5389 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_splice(
5390 __isl_take isl_multi_pw_aff *mpa1,
5391 unsigned in_pos, unsigned out_pos,
5392 __isl_take isl_multi_pw_aff *mpa2);
5394 =item * Simplification
5396 When applied to a set or relation,
5397 the gist operation returns a set or relation that has the
5398 same intersection with the context as the input set or relation.
5399 Any implicit equality in the intersection is made explicit in the result,
5400 while all inequalities that are redundant with respect to the intersection
5402 In case of union sets and relations, the gist operation is performed
5405 When applied to a function,
5406 the gist operation applies the set gist operation to each of
5407 the cells in the domain of the input piecewise expression.
5408 The context is also exploited
5409 to simplify the expression associated to each cell.
5411 #include <isl/set.h>
5412 __isl_give isl_basic_set *isl_basic_set_gist(
5413 __isl_take isl_basic_set *bset,
5414 __isl_take isl_basic_set *context);
5415 __isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
5416 __isl_take isl_set *context);
5417 __isl_give isl_set *isl_set_gist_params(
5418 __isl_take isl_set *set,
5419 __isl_take isl_set *context);
5421 #include <isl/map.h>
5422 __isl_give isl_basic_map *isl_basic_map_gist(
5423 __isl_take isl_basic_map *bmap,
5424 __isl_take isl_basic_map *context);
5425 __isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
5426 __isl_take isl_map *context);
5427 __isl_give isl_map *isl_map_gist_params(
5428 __isl_take isl_map *map,
5429 __isl_take isl_set *context);
5430 __isl_give isl_map *isl_map_gist_domain(
5431 __isl_take isl_map *map,
5432 __isl_take isl_set *context);
5433 __isl_give isl_map *isl_map_gist_range(
5434 __isl_take isl_map *map,
5435 __isl_take isl_set *context);
5437 #include <isl/union_set.h>
5438 __isl_give isl_union_set *isl_union_set_gist(
5439 __isl_take isl_union_set *uset,
5440 __isl_take isl_union_set *context);
5441 __isl_give isl_union_set *isl_union_set_gist_params(
5442 __isl_take isl_union_set *uset,
5443 __isl_take isl_set *set);
5445 #include <isl/union_map.h>
5446 __isl_give isl_union_map *isl_union_map_gist(
5447 __isl_take isl_union_map *umap,
5448 __isl_take isl_union_map *context);
5449 __isl_give isl_union_map *isl_union_map_gist_params(
5450 __isl_take isl_union_map *umap,
5451 __isl_take isl_set *set);
5452 __isl_give isl_union_map *isl_union_map_gist_domain(
5453 __isl_take isl_union_map *umap,
5454 __isl_take isl_union_set *uset);
5455 __isl_give isl_union_map *isl_union_map_gist_range(
5456 __isl_take isl_union_map *umap,
5457 __isl_take isl_union_set *uset);
5459 #include <isl/aff.h>
5460 __isl_give isl_aff *isl_aff_gist_params(
5461 __isl_take isl_aff *aff,
5462 __isl_take isl_set *context);
5463 __isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff,
5464 __isl_take isl_set *context);
5465 __isl_give isl_multi_aff *isl_multi_aff_gist_params(
5466 __isl_take isl_multi_aff *maff,
5467 __isl_take isl_set *context);
5468 __isl_give isl_multi_aff *isl_multi_aff_gist(
5469 __isl_take isl_multi_aff *maff,
5470 __isl_take isl_set *context);
5471 __isl_give isl_pw_aff *isl_pw_aff_gist_params(
5472 __isl_take isl_pw_aff *pwaff,
5473 __isl_take isl_set *context);
5474 __isl_give isl_pw_aff *isl_pw_aff_gist(
5475 __isl_take isl_pw_aff *pwaff,
5476 __isl_take isl_set *context);
5477 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist_params(
5478 __isl_take isl_pw_multi_aff *pma,
5479 __isl_take isl_set *set);
5480 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist(
5481 __isl_take isl_pw_multi_aff *pma,
5482 __isl_take isl_set *set);
5483 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist_params(
5484 __isl_take isl_multi_pw_aff *mpa,
5485 __isl_take isl_set *set);
5486 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist(
5487 __isl_take isl_multi_pw_aff *mpa,
5488 __isl_take isl_set *set);
5490 #include <isl/polynomial.h>
5491 __isl_give isl_qpolynomial *isl_qpolynomial_gist_params(
5492 __isl_take isl_qpolynomial *qp,
5493 __isl_take isl_set *context);
5494 __isl_give isl_qpolynomial *isl_qpolynomial_gist(
5495 __isl_take isl_qpolynomial *qp,
5496 __isl_take isl_set *context);
5497 __isl_give isl_qpolynomial_fold *
5498 isl_qpolynomial_fold_gist_params(
5499 __isl_take isl_qpolynomial_fold *fold,
5500 __isl_take isl_set *context);
5501 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist(
5502 __isl_take isl_qpolynomial_fold *fold,
5503 __isl_take isl_set *context);
5504 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist_params(
5505 __isl_take isl_pw_qpolynomial *pwqp,
5506 __isl_take isl_set *context);
5507 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist(
5508 __isl_take isl_pw_qpolynomial *pwqp,
5509 __isl_take isl_set *context);
5510 __isl_give isl_pw_qpolynomial_fold *
5511 isl_pw_qpolynomial_fold_gist(
5512 __isl_take isl_pw_qpolynomial_fold *pwf,
5513 __isl_take isl_set *context);
5514 __isl_give isl_pw_qpolynomial_fold *
5515 isl_pw_qpolynomial_fold_gist_params(
5516 __isl_take isl_pw_qpolynomial_fold *pwf,
5517 __isl_take isl_set *context);
5518 __isl_give isl_union_pw_qpolynomial *
5519 isl_union_pw_qpolynomial_gist_params(
5520 __isl_take isl_union_pw_qpolynomial *upwqp,
5521 __isl_take isl_set *context);
5522 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist(
5523 __isl_take isl_union_pw_qpolynomial *upwqp,
5524 __isl_take isl_union_set *context);
5525 __isl_give isl_union_pw_qpolynomial_fold *
5526 isl_union_pw_qpolynomial_fold_gist(
5527 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5528 __isl_take isl_union_set *context);
5529 __isl_give isl_union_pw_qpolynomial_fold *
5530 isl_union_pw_qpolynomial_fold_gist_params(
5531 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5532 __isl_take isl_set *context);
5534 =item * Binary Arithmethic Operations
5536 #include <isl/aff.h>
5537 __isl_give isl_aff *isl_aff_add(
5538 __isl_take isl_aff *aff1,
5539 __isl_take isl_aff *aff2);
5540 __isl_give isl_multi_aff *isl_multi_aff_add(
5541 __isl_take isl_multi_aff *maff1,
5542 __isl_take isl_multi_aff *maff2);
5543 __isl_give isl_pw_aff *isl_pw_aff_add(
5544 __isl_take isl_pw_aff *pwaff1,
5545 __isl_take isl_pw_aff *pwaff2);
5546 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_add(
5547 __isl_take isl_pw_multi_aff *pma1,
5548 __isl_take isl_pw_multi_aff *pma2);
5549 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_add(
5550 __isl_take isl_union_pw_multi_aff *upma1,
5551 __isl_take isl_union_pw_multi_aff *upma2);
5552 __isl_give isl_pw_aff *isl_pw_aff_min(
5553 __isl_take isl_pw_aff *pwaff1,
5554 __isl_take isl_pw_aff *pwaff2);
5555 __isl_give isl_pw_aff *isl_pw_aff_max(
5556 __isl_take isl_pw_aff *pwaff1,
5557 __isl_take isl_pw_aff *pwaff2);
5558 __isl_give isl_aff *isl_aff_sub(
5559 __isl_take isl_aff *aff1,
5560 __isl_take isl_aff *aff2);
5561 __isl_give isl_multi_aff *isl_multi_aff_sub(
5562 __isl_take isl_multi_aff *ma1,
5563 __isl_take isl_multi_aff *ma2);
5564 __isl_give isl_pw_aff *isl_pw_aff_sub(
5565 __isl_take isl_pw_aff *pwaff1,
5566 __isl_take isl_pw_aff *pwaff2);
5567 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_sub(
5568 __isl_take isl_pw_multi_aff *pma1,
5569 __isl_take isl_pw_multi_aff *pma2);
5570 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_sub(
5571 __isl_take isl_union_pw_multi_aff *upma1,
5572 __isl_take isl_union_pw_multi_aff *upma2);
5574 C<isl_aff_sub> subtracts the second argument from the first.
5576 #include <isl/polynomial.h>
5577 __isl_give isl_qpolynomial *isl_qpolynomial_add(
5578 __isl_take isl_qpolynomial *qp1,
5579 __isl_take isl_qpolynomial *qp2);
5580 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
5581 __isl_take isl_pw_qpolynomial *pwqp1,
5582 __isl_take isl_pw_qpolynomial *pwqp2);
5583 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint(
5584 __isl_take isl_pw_qpolynomial *pwqp1,
5585 __isl_take isl_pw_qpolynomial *pwqp2);
5586 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
5587 __isl_take isl_pw_qpolynomial_fold *pwf1,
5588 __isl_take isl_pw_qpolynomial_fold *pwf2);
5589 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add(
5590 __isl_take isl_union_pw_qpolynomial *upwqp1,
5591 __isl_take isl_union_pw_qpolynomial *upwqp2);
5592 __isl_give isl_qpolynomial *isl_qpolynomial_sub(
5593 __isl_take isl_qpolynomial *qp1,
5594 __isl_take isl_qpolynomial *qp2);
5595 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub(
5596 __isl_take isl_pw_qpolynomial *pwqp1,
5597 __isl_take isl_pw_qpolynomial *pwqp2);
5598 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
5599 __isl_take isl_union_pw_qpolynomial *upwqp1,
5600 __isl_take isl_union_pw_qpolynomial *upwqp2);
5601 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_fold(
5602 __isl_take isl_pw_qpolynomial_fold *pwf1,
5603 __isl_take isl_pw_qpolynomial_fold *pwf2);
5604 __isl_give isl_union_pw_qpolynomial_fold *
5605 isl_union_pw_qpolynomial_fold_fold(
5606 __isl_take isl_union_pw_qpolynomial_fold *upwf1,
5607 __isl_take isl_union_pw_qpolynomial_fold *upwf2);
5609 #include <isl/aff.h>
5610 __isl_give isl_pw_aff *isl_pw_aff_union_add(
5611 __isl_take isl_pw_aff *pwaff1,
5612 __isl_take isl_pw_aff *pwaff2);
5613 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_add(
5614 __isl_take isl_pw_multi_aff *pma1,
5615 __isl_take isl_pw_multi_aff *pma2);
5616 __isl_give isl_pw_aff *isl_pw_aff_union_min(
5617 __isl_take isl_pw_aff *pwaff1,
5618 __isl_take isl_pw_aff *pwaff2);
5619 __isl_give isl_pw_aff *isl_pw_aff_union_max(
5620 __isl_take isl_pw_aff *pwaff1,
5621 __isl_take isl_pw_aff *pwaff2);
5623 The function C<isl_pw_aff_union_max> computes a piecewise quasi-affine
5624 expression with a domain that is the union of those of C<pwaff1> and
5625 C<pwaff2> and such that on each cell, the quasi-affine expression is
5626 the maximum of those of C<pwaff1> and C<pwaff2>. If only one of
5627 C<pwaff1> or C<pwaff2> is defined on a given cell, then the
5628 associated expression is the defined one.
5629 This in contrast to the C<isl_pw_aff_max> function, which is
5630 only defined on the shared definition domain of the arguments.
5632 #include <isl/val.h>
5633 __isl_give isl_multi_val *isl_multi_val_add_val(
5634 __isl_take isl_multi_val *mv,
5635 __isl_take isl_val *v);
5636 __isl_give isl_multi_val *isl_multi_val_mod_val(
5637 __isl_take isl_multi_val *mv,
5638 __isl_take isl_val *v);
5639 __isl_give isl_multi_val *isl_multi_val_scale_val(
5640 __isl_take isl_multi_val *mv,
5641 __isl_take isl_val *v);
5643 #include <isl/aff.h>
5644 __isl_give isl_aff *isl_aff_mod_val(__isl_take isl_aff *aff,
5645 __isl_take isl_val *mod);
5646 __isl_give isl_pw_aff *isl_pw_aff_mod_val(
5647 __isl_take isl_pw_aff *pa,
5648 __isl_take isl_val *mod);
5649 __isl_give isl_aff *isl_aff_scale_val(__isl_take isl_aff *aff,
5650 __isl_take isl_val *v);
5651 __isl_give isl_multi_aff *isl_multi_aff_scale_val(
5652 __isl_take isl_multi_aff *ma,
5653 __isl_take isl_val *v);
5654 __isl_give isl_pw_aff *isl_pw_aff_scale_val(
5655 __isl_take isl_pw_aff *pa, __isl_take isl_val *v);
5656 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_scale_val(
5657 __isl_take isl_multi_pw_aff *mpa,
5658 __isl_take isl_val *v);
5659 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_val(
5660 __isl_take isl_pw_multi_aff *pma,
5661 __isl_take isl_val *v);
5662 __isl_give isl_aff *isl_aff_scale_down_ui(
5663 __isl_take isl_aff *aff, unsigned f);
5664 __isl_give isl_aff *isl_aff_scale_down_val(
5665 __isl_take isl_aff *aff, __isl_take isl_val *v);
5666 __isl_give isl_pw_aff *isl_pw_aff_scale_down_val(
5667 __isl_take isl_pw_aff *pa,
5668 __isl_take isl_val *f);
5670 #include <isl/polynomial.h>
5671 __isl_give isl_qpolynomial *isl_qpolynomial_scale_val(
5672 __isl_take isl_qpolynomial *qp,
5673 __isl_take isl_val *v);
5674 __isl_give isl_qpolynomial_fold *
5675 isl_qpolynomial_fold_scale_val(
5676 __isl_take isl_qpolynomial_fold *fold,
5677 __isl_take isl_val *v);
5678 __isl_give isl_pw_qpolynomial *
5679 isl_pw_qpolynomial_scale_val(
5680 __isl_take isl_pw_qpolynomial *pwqp,
5681 __isl_take isl_val *v);
5682 __isl_give isl_pw_qpolynomial_fold *
5683 isl_pw_qpolynomial_fold_scale_val(
5684 __isl_take isl_pw_qpolynomial_fold *pwf,
5685 __isl_take isl_val *v);
5686 __isl_give isl_union_pw_qpolynomial *
5687 isl_union_pw_qpolynomial_scale_val(
5688 __isl_take isl_union_pw_qpolynomial *upwqp,
5689 __isl_take isl_val *v);
5690 __isl_give isl_union_pw_qpolynomial_fold *
5691 isl_union_pw_qpolynomial_fold_scale_val(
5692 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5693 __isl_take isl_val *v);
5695 #include <isl/val.h>
5696 __isl_give isl_multi_val *isl_multi_val_scale_multi_val(
5697 __isl_take isl_multi_val *mv1,
5698 __isl_take isl_multi_val *mv2);
5699 __isl_give isl_multi_val *
5700 isl_multi_val_scale_down_multi_val(
5701 __isl_take isl_multi_val *mv1,
5702 __isl_take isl_multi_val *mv2);
5704 #include <isl/aff.h>
5705 __isl_give isl_multi_aff *isl_multi_aff_scale_multi_val(
5706 __isl_take isl_multi_aff *ma,
5707 __isl_take isl_multi_val *mv);
5708 __isl_give isl_pw_multi_aff *
5709 isl_pw_multi_aff_scale_multi_val(
5710 __isl_take isl_pw_multi_aff *pma,
5711 __isl_take isl_multi_val *mv);
5712 __isl_give isl_multi_pw_aff *
5713 isl_multi_pw_aff_scale_multi_val(
5714 __isl_take isl_multi_pw_aff *mpa,
5715 __isl_take isl_multi_val *mv);
5716 __isl_give isl_union_pw_multi_aff *
5717 isl_union_pw_multi_aff_scale_multi_val(
5718 __isl_take isl_union_pw_multi_aff *upma,
5719 __isl_take isl_multi_val *mv);
5720 __isl_give isl_multi_aff *
5721 isl_multi_aff_scale_down_multi_val(
5722 __isl_take isl_multi_aff *ma,
5723 __isl_take isl_multi_val *mv);
5724 __isl_give isl_multi_pw_aff *
5725 isl_multi_pw_aff_scale_down_multi_val(
5726 __isl_take isl_multi_pw_aff *mpa,
5727 __isl_take isl_multi_val *mv);
5729 C<isl_multi_aff_scale_multi_val> scales the elements of C<ma>
5730 by the corresponding elements of C<mv>.
5732 #include <isl/aff.h>
5733 __isl_give isl_aff *isl_aff_mul(
5734 __isl_take isl_aff *aff1,
5735 __isl_take isl_aff *aff2);
5736 __isl_give isl_aff *isl_aff_div(
5737 __isl_take isl_aff *aff1,
5738 __isl_take isl_aff *aff2);
5739 __isl_give isl_pw_aff *isl_pw_aff_mul(
5740 __isl_take isl_pw_aff *pwaff1,
5741 __isl_take isl_pw_aff *pwaff2);
5742 __isl_give isl_pw_aff *isl_pw_aff_div(
5743 __isl_take isl_pw_aff *pa1,
5744 __isl_take isl_pw_aff *pa2);
5745 __isl_give isl_pw_aff *isl_pw_aff_tdiv_q(
5746 __isl_take isl_pw_aff *pa1,
5747 __isl_take isl_pw_aff *pa2);
5748 __isl_give isl_pw_aff *isl_pw_aff_tdiv_r(
5749 __isl_take isl_pw_aff *pa1,
5750 __isl_take isl_pw_aff *pa2);
5752 When multiplying two affine expressions, at least one of the two needs
5753 to be a constant. Similarly, when dividing an affine expression by another,
5754 the second expression needs to be a constant.
5755 C<isl_pw_aff_tdiv_q> computes the quotient of an integer division with
5756 rounding towards zero. C<isl_pw_aff_tdiv_r> computes the corresponding
5759 #include <isl/polynomial.h>
5760 __isl_give isl_qpolynomial *isl_qpolynomial_mul(
5761 __isl_take isl_qpolynomial *qp1,
5762 __isl_take isl_qpolynomial *qp2);
5763 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
5764 __isl_take isl_pw_qpolynomial *pwqp1,
5765 __isl_take isl_pw_qpolynomial *pwqp2);
5766 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
5767 __isl_take isl_union_pw_qpolynomial *upwqp1,
5768 __isl_take isl_union_pw_qpolynomial *upwqp2);
5772 =head3 Lexicographic Optimization
5774 Given a (basic) set C<set> (or C<bset>) and a zero-dimensional domain C<dom>,
5775 the following functions
5776 compute a set that contains the lexicographic minimum or maximum
5777 of the elements in C<set> (or C<bset>) for those values of the parameters
5778 that satisfy C<dom>.
5779 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
5780 that contains the parameter values in C<dom> for which C<set> (or C<bset>)
5782 In other words, the union of the parameter values
5783 for which the result is non-empty and of C<*empty>
5786 #include <isl/set.h>
5787 __isl_give isl_set *isl_basic_set_partial_lexmin(
5788 __isl_take isl_basic_set *bset,
5789 __isl_take isl_basic_set *dom,
5790 __isl_give isl_set **empty);
5791 __isl_give isl_set *isl_basic_set_partial_lexmax(
5792 __isl_take isl_basic_set *bset,
5793 __isl_take isl_basic_set *dom,
5794 __isl_give isl_set **empty);
5795 __isl_give isl_set *isl_set_partial_lexmin(
5796 __isl_take isl_set *set, __isl_take isl_set *dom,
5797 __isl_give isl_set **empty);
5798 __isl_give isl_set *isl_set_partial_lexmax(
5799 __isl_take isl_set *set, __isl_take isl_set *dom,
5800 __isl_give isl_set **empty);
5802 Given a (basic) set C<set> (or C<bset>), the following functions simply
5803 return a set containing the lexicographic minimum or maximum
5804 of the elements in C<set> (or C<bset>).
5805 In case of union sets, the optimum is computed per space.
5807 #include <isl/set.h>
5808 __isl_give isl_set *isl_basic_set_lexmin(
5809 __isl_take isl_basic_set *bset);
5810 __isl_give isl_set *isl_basic_set_lexmax(
5811 __isl_take isl_basic_set *bset);
5812 __isl_give isl_set *isl_set_lexmin(
5813 __isl_take isl_set *set);
5814 __isl_give isl_set *isl_set_lexmax(
5815 __isl_take isl_set *set);
5816 __isl_give isl_union_set *isl_union_set_lexmin(
5817 __isl_take isl_union_set *uset);
5818 __isl_give isl_union_set *isl_union_set_lexmax(
5819 __isl_take isl_union_set *uset);
5821 Given a (basic) relation C<map> (or C<bmap>) and a domain C<dom>,
5822 the following functions
5823 compute a relation that maps each element of C<dom>
5824 to the single lexicographic minimum or maximum
5825 of the elements that are associated to that same
5826 element in C<map> (or C<bmap>).
5827 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
5828 that contains the elements in C<dom> that do not map
5829 to any elements in C<map> (or C<bmap>).
5830 In other words, the union of the domain of the result and of C<*empty>
5833 #include <isl/map.h>
5834 __isl_give isl_map *isl_basic_map_partial_lexmax(
5835 __isl_take isl_basic_map *bmap,
5836 __isl_take isl_basic_set *dom,
5837 __isl_give isl_set **empty);
5838 __isl_give isl_map *isl_basic_map_partial_lexmin(
5839 __isl_take isl_basic_map *bmap,
5840 __isl_take isl_basic_set *dom,
5841 __isl_give isl_set **empty);
5842 __isl_give isl_map *isl_map_partial_lexmax(
5843 __isl_take isl_map *map, __isl_take isl_set *dom,
5844 __isl_give isl_set **empty);
5845 __isl_give isl_map *isl_map_partial_lexmin(
5846 __isl_take isl_map *map, __isl_take isl_set *dom,
5847 __isl_give isl_set **empty);
5849 Given a (basic) map C<map> (or C<bmap>), the following functions simply
5850 return a map mapping each element in the domain of
5851 C<map> (or C<bmap>) to the lexicographic minimum or maximum
5852 of all elements associated to that element.
5853 In case of union relations, the optimum is computed per space.
5855 #include <isl/map.h>
5856 __isl_give isl_map *isl_basic_map_lexmin(
5857 __isl_take isl_basic_map *bmap);
5858 __isl_give isl_map *isl_basic_map_lexmax(
5859 __isl_take isl_basic_map *bmap);
5860 __isl_give isl_map *isl_map_lexmin(
5861 __isl_take isl_map *map);
5862 __isl_give isl_map *isl_map_lexmax(
5863 __isl_take isl_map *map);
5864 __isl_give isl_union_map *isl_union_map_lexmin(
5865 __isl_take isl_union_map *umap);
5866 __isl_give isl_union_map *isl_union_map_lexmax(
5867 __isl_take isl_union_map *umap);
5869 The following functions return their result in the form of
5870 a piecewise multi-affine expression,
5871 but are otherwise equivalent to the corresponding functions
5872 returning a basic set or relation.
5874 #include <isl/set.h>
5875 __isl_give isl_pw_multi_aff *
5876 isl_basic_set_partial_lexmin_pw_multi_aff(
5877 __isl_take isl_basic_set *bset,
5878 __isl_take isl_basic_set *dom,
5879 __isl_give isl_set **empty);
5880 __isl_give isl_pw_multi_aff *
5881 isl_basic_set_partial_lexmax_pw_multi_aff(
5882 __isl_take isl_basic_set *bset,
5883 __isl_take isl_basic_set *dom,
5884 __isl_give isl_set **empty);
5885 __isl_give isl_pw_multi_aff *isl_set_lexmin_pw_multi_aff(
5886 __isl_take isl_set *set);
5887 __isl_give isl_pw_multi_aff *isl_set_lexmax_pw_multi_aff(
5888 __isl_take isl_set *set);
5890 #include <isl/map.h>
5891 __isl_give isl_pw_multi_aff *
5892 isl_basic_map_lexmin_pw_multi_aff(
5893 __isl_take isl_basic_map *bmap);
5894 __isl_give isl_pw_multi_aff *
5895 isl_basic_map_partial_lexmin_pw_multi_aff(
5896 __isl_take isl_basic_map *bmap,
5897 __isl_take isl_basic_set *dom,
5898 __isl_give isl_set **empty);
5899 __isl_give isl_pw_multi_aff *
5900 isl_basic_map_partial_lexmax_pw_multi_aff(
5901 __isl_take isl_basic_map *bmap,
5902 __isl_take isl_basic_set *dom,
5903 __isl_give isl_set **empty);
5904 __isl_give isl_pw_multi_aff *isl_map_lexmin_pw_multi_aff(
5905 __isl_take isl_map *map);
5906 __isl_give isl_pw_multi_aff *isl_map_lexmax_pw_multi_aff(
5907 __isl_take isl_map *map);
5909 The following functions return the lexicographic minimum or maximum
5910 on the shared domain of the inputs and the single defined function
5911 on those parts of the domain where only a single function is defined.
5913 #include <isl/aff.h>
5914 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmin(
5915 __isl_take isl_pw_multi_aff *pma1,
5916 __isl_take isl_pw_multi_aff *pma2);
5917 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmax(
5918 __isl_take isl_pw_multi_aff *pma1,
5919 __isl_take isl_pw_multi_aff *pma2);
5921 =head2 Ternary Operations
5923 #include <isl/aff.h>
5924 __isl_give isl_pw_aff *isl_pw_aff_cond(
5925 __isl_take isl_pw_aff *cond,
5926 __isl_take isl_pw_aff *pwaff_true,
5927 __isl_take isl_pw_aff *pwaff_false);
5929 The function C<isl_pw_aff_cond> performs a conditional operator
5930 and returns an expression that is equal to C<pwaff_true>
5931 for elements where C<cond> is non-zero and equal to C<pwaff_false> for elements
5932 where C<cond> is zero.
5936 Lists are defined over several element types, including
5937 C<isl_val>, C<isl_id>, C<isl_aff>, C<isl_pw_aff>, C<isl_constraint>,
5938 C<isl_basic_set>, C<isl_set>, C<isl_ast_expr> and C<isl_ast_node>.
5939 Here we take lists of C<isl_set>s as an example.
5940 Lists can be created, copied, modified and freed using the following functions.
5942 #include <isl/set.h>
5943 __isl_give isl_set_list *isl_set_list_from_set(
5944 __isl_take isl_set *el);
5945 __isl_give isl_set_list *isl_set_list_alloc(
5946 isl_ctx *ctx, int n);
5947 __isl_give isl_set_list *isl_set_list_copy(
5948 __isl_keep isl_set_list *list);
5949 __isl_give isl_set_list *isl_set_list_insert(
5950 __isl_take isl_set_list *list, unsigned pos,
5951 __isl_take isl_set *el);
5952 __isl_give isl_set_list *isl_set_list_add(
5953 __isl_take isl_set_list *list,
5954 __isl_take isl_set *el);
5955 __isl_give isl_set_list *isl_set_list_drop(
5956 __isl_take isl_set_list *list,
5957 unsigned first, unsigned n);
5958 __isl_give isl_set_list *isl_set_list_set_set(
5959 __isl_take isl_set_list *list, int index,
5960 __isl_take isl_set *set);
5961 __isl_give isl_set_list *isl_set_list_concat(
5962 __isl_take isl_set_list *list1,
5963 __isl_take isl_set_list *list2);
5964 __isl_give isl_set_list *isl_set_list_sort(
5965 __isl_take isl_set_list *list,
5966 int (*cmp)(__isl_keep isl_set *a,
5967 __isl_keep isl_set *b, void *user),
5969 __isl_null isl_set_list *isl_set_list_free(
5970 __isl_take isl_set_list *list);
5972 C<isl_set_list_alloc> creates an empty list with a capacity for
5973 C<n> elements. C<isl_set_list_from_set> creates a list with a single
5976 Lists can be inspected using the following functions.
5978 #include <isl/set.h>
5979 int isl_set_list_n_set(__isl_keep isl_set_list *list);
5980 __isl_give isl_set *isl_set_list_get_set(
5981 __isl_keep isl_set_list *list, int index);
5982 int isl_set_list_foreach(__isl_keep isl_set_list *list,
5983 int (*fn)(__isl_take isl_set *el, void *user),
5985 int isl_set_list_foreach_scc(__isl_keep isl_set_list *list,
5986 int (*follows)(__isl_keep isl_set *a,
5987 __isl_keep isl_set *b, void *user),
5989 int (*fn)(__isl_take isl_set *el, void *user),
5992 The function C<isl_set_list_foreach_scc> calls C<fn> on each of the
5993 strongly connected components of the graph with as vertices the elements
5994 of C<list> and a directed edge from vertex C<b> to vertex C<a>
5995 iff C<follows(a, b)> returns C<1>. The callbacks C<follows> and C<fn>
5996 should return C<-1> on error.
5998 Lists can be printed using
6000 #include <isl/set.h>
6001 __isl_give isl_printer *isl_printer_print_set_list(
6002 __isl_take isl_printer *p,
6003 __isl_keep isl_set_list *list);
6005 =head2 Associative arrays
6007 Associative arrays map isl objects of a specific type to isl objects
6008 of some (other) specific type. They are defined for several pairs
6009 of types, including (C<isl_map>, C<isl_basic_set>),
6010 (C<isl_id>, C<isl_ast_expr>) and.
6011 (C<isl_id>, C<isl_pw_aff>).
6012 Here, we take associative arrays that map C<isl_id>s to C<isl_ast_expr>s
6015 Associative arrays can be created, copied and freed using
6016 the following functions.
6018 #include <isl/id_to_ast_expr.h>
6019 __isl_give id_to_ast_expr *isl_id_to_ast_expr_alloc(
6020 isl_ctx *ctx, int min_size);
6021 __isl_give id_to_ast_expr *isl_id_to_ast_expr_copy(
6022 __isl_keep id_to_ast_expr *id2expr);
6023 __isl_null id_to_ast_expr *isl_id_to_ast_expr_free(
6024 __isl_take id_to_ast_expr *id2expr);
6026 The C<min_size> argument to C<isl_id_to_ast_expr_alloc> can be used
6027 to specify the expected size of the associative array.
6028 The associative array will be grown automatically as needed.
6030 Associative arrays can be inspected using the following functions.
6032 #include <isl/id_to_ast_expr.h>
6033 int isl_id_to_ast_expr_has(
6034 __isl_keep id_to_ast_expr *id2expr,
6035 __isl_keep isl_id *key);
6036 __isl_give isl_ast_expr *isl_id_to_ast_expr_get(
6037 __isl_keep id_to_ast_expr *id2expr,
6038 __isl_take isl_id *key);
6039 int isl_id_to_ast_expr_foreach(
6040 __isl_keep id_to_ast_expr *id2expr,
6041 int (*fn)(__isl_take isl_id *key,
6042 __isl_take isl_ast_expr *val, void *user),
6045 They can be modified using the following function.
6047 #include <isl/id_to_ast_expr.h>
6048 __isl_give id_to_ast_expr *isl_id_to_ast_expr_set(
6049 __isl_take id_to_ast_expr *id2expr,
6050 __isl_take isl_id *key,
6051 __isl_take isl_ast_expr *val);
6052 __isl_give id_to_ast_expr *isl_id_to_ast_expr_drop(
6053 __isl_take id_to_ast_expr *id2expr,
6054 __isl_take isl_id *key);
6056 Associative arrays can be printed using the following function.
6058 #include <isl/id_to_ast_expr.h>
6059 __isl_give isl_printer *isl_printer_print_id_to_ast_expr(
6060 __isl_take isl_printer *p,
6061 __isl_keep id_to_ast_expr *id2expr);
6065 Vectors can be created, copied and freed using the following functions.
6067 #include <isl/vec.h>
6068 __isl_give isl_vec *isl_vec_alloc(isl_ctx *ctx,
6070 __isl_give isl_vec *isl_vec_copy(__isl_keep isl_vec *vec);
6071 __isl_null isl_vec *isl_vec_free(__isl_take isl_vec *vec);
6073 Note that the elements of a newly created vector may have arbitrary values.
6074 The elements can be changed and inspected using the following functions.
6076 int isl_vec_size(__isl_keep isl_vec *vec);
6077 __isl_give isl_val *isl_vec_get_element_val(
6078 __isl_keep isl_vec *vec, int pos);
6079 __isl_give isl_vec *isl_vec_set_element_si(
6080 __isl_take isl_vec *vec, int pos, int v);
6081 __isl_give isl_vec *isl_vec_set_element_val(
6082 __isl_take isl_vec *vec, int pos,
6083 __isl_take isl_val *v);
6084 __isl_give isl_vec *isl_vec_set_si(__isl_take isl_vec *vec,
6086 __isl_give isl_vec *isl_vec_set_val(
6087 __isl_take isl_vec *vec, __isl_take isl_val *v);
6088 int isl_vec_cmp_element(__isl_keep isl_vec *vec1,
6089 __isl_keep isl_vec *vec2, int pos);
6091 C<isl_vec_get_element> will return a negative value if anything went wrong.
6092 In that case, the value of C<*v> is undefined.
6094 The following function can be used to concatenate two vectors.
6096 __isl_give isl_vec *isl_vec_concat(__isl_take isl_vec *vec1,
6097 __isl_take isl_vec *vec2);
6101 Matrices can be created, copied and freed using the following functions.
6103 #include <isl/mat.h>
6104 __isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx,
6105 unsigned n_row, unsigned n_col);
6106 __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat);
6107 __isl_null isl_mat *isl_mat_free(__isl_take isl_mat *mat);
6109 Note that the elements of a newly created matrix may have arbitrary values.
6110 The elements can be changed and inspected using the following functions.
6112 int isl_mat_rows(__isl_keep isl_mat *mat);
6113 int isl_mat_cols(__isl_keep isl_mat *mat);
6114 __isl_give isl_val *isl_mat_get_element_val(
6115 __isl_keep isl_mat *mat, int row, int col);
6116 __isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat,
6117 int row, int col, int v);
6118 __isl_give isl_mat *isl_mat_set_element_val(
6119 __isl_take isl_mat *mat, int row, int col,
6120 __isl_take isl_val *v);
6122 C<isl_mat_get_element> will return a negative value if anything went wrong.
6123 In that case, the value of C<*v> is undefined.
6125 The following function can be used to compute the (right) inverse
6126 of a matrix, i.e., a matrix such that the product of the original
6127 and the inverse (in that order) is a multiple of the identity matrix.
6128 The input matrix is assumed to be of full row-rank.
6130 __isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat);
6132 The following function can be used to compute the (right) kernel
6133 (or null space) of a matrix, i.e., a matrix such that the product of
6134 the original and the kernel (in that order) is the zero matrix.
6136 __isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat);
6138 =head2 Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions
6140 The following functions determine
6141 an upper or lower bound on a quasipolynomial over its domain.
6143 __isl_give isl_pw_qpolynomial_fold *
6144 isl_pw_qpolynomial_bound(
6145 __isl_take isl_pw_qpolynomial *pwqp,
6146 enum isl_fold type, int *tight);
6148 __isl_give isl_union_pw_qpolynomial_fold *
6149 isl_union_pw_qpolynomial_bound(
6150 __isl_take isl_union_pw_qpolynomial *upwqp,
6151 enum isl_fold type, int *tight);
6153 The C<type> argument may be either C<isl_fold_min> or C<isl_fold_max>.
6154 If C<tight> is not C<NULL>, then C<*tight> is set to C<1>
6155 is the returned bound is known be tight, i.e., for each value
6156 of the parameters there is at least
6157 one element in the domain that reaches the bound.
6158 If the domain of C<pwqp> is not wrapping, then the bound is computed
6159 over all elements in that domain and the result has a purely parametric
6160 domain. If the domain of C<pwqp> is wrapping, then the bound is
6161 computed over the range of the wrapped relation. The domain of the
6162 wrapped relation becomes the domain of the result.
6164 =head2 Parametric Vertex Enumeration
6166 The parametric vertex enumeration described in this section
6167 is mainly intended to be used internally and by the C<barvinok>
6170 #include <isl/vertices.h>
6171 __isl_give isl_vertices *isl_basic_set_compute_vertices(
6172 __isl_keep isl_basic_set *bset);
6174 The function C<isl_basic_set_compute_vertices> performs the
6175 actual computation of the parametric vertices and the chamber
6176 decomposition and store the result in an C<isl_vertices> object.
6177 This information can be queried by either iterating over all
6178 the vertices or iterating over all the chambers or cells
6179 and then iterating over all vertices that are active on the chamber.
6181 int isl_vertices_foreach_vertex(
6182 __isl_keep isl_vertices *vertices,
6183 int (*fn)(__isl_take isl_vertex *vertex, void *user),
6186 int isl_vertices_foreach_cell(
6187 __isl_keep isl_vertices *vertices,
6188 int (*fn)(__isl_take isl_cell *cell, void *user),
6190 int isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
6191 int (*fn)(__isl_take isl_vertex *vertex, void *user),
6194 Other operations that can be performed on an C<isl_vertices> object are
6197 int isl_vertices_get_n_vertices(
6198 __isl_keep isl_vertices *vertices);
6199 void isl_vertices_free(__isl_take isl_vertices *vertices);
6201 Vertices can be inspected and destroyed using the following functions.
6203 int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
6204 __isl_give isl_basic_set *isl_vertex_get_domain(
6205 __isl_keep isl_vertex *vertex);
6206 __isl_give isl_multi_aff *isl_vertex_get_expr(
6207 __isl_keep isl_vertex *vertex);
6208 void isl_vertex_free(__isl_take isl_vertex *vertex);
6210 C<isl_vertex_get_expr> returns a multiple quasi-affine expression
6211 describing the vertex in terms of the parameters,
6212 while C<isl_vertex_get_domain> returns the activity domain
6215 Chambers can be inspected and destroyed using the following functions.
6217 __isl_give isl_basic_set *isl_cell_get_domain(
6218 __isl_keep isl_cell *cell);
6219 void isl_cell_free(__isl_take isl_cell *cell);
6221 =head1 Polyhedral Compilation Library
6223 This section collects functionality in C<isl> that has been specifically
6224 designed for use during polyhedral compilation.
6226 =head2 Dependence Analysis
6228 C<isl> contains specialized functionality for performing
6229 array dataflow analysis. That is, given a I<sink> access relation
6230 and a collection of possible I<source> access relations,
6231 C<isl> can compute relations that describe
6232 for each iteration of the sink access, which iteration
6233 of which of the source access relations was the last
6234 to access the same data element before the given iteration
6236 The resulting dependence relations map source iterations
6237 to the corresponding sink iterations.
6238 To compute standard flow dependences, the sink should be
6239 a read, while the sources should be writes.
6240 If any of the source accesses are marked as being I<may>
6241 accesses, then there will be a dependence from the last
6242 I<must> access B<and> from any I<may> access that follows
6243 this last I<must> access.
6244 In particular, if I<all> sources are I<may> accesses,
6245 then memory based dependence analysis is performed.
6246 If, on the other hand, all sources are I<must> accesses,
6247 then value based dependence analysis is performed.
6249 #include <isl/flow.h>
6251 typedef int (*isl_access_level_before)(void *first, void *second);
6253 __isl_give isl_access_info *isl_access_info_alloc(
6254 __isl_take isl_map *sink,
6255 void *sink_user, isl_access_level_before fn,
6257 __isl_give isl_access_info *isl_access_info_add_source(
6258 __isl_take isl_access_info *acc,
6259 __isl_take isl_map *source, int must,
6261 __isl_null isl_access_info *isl_access_info_free(
6262 __isl_take isl_access_info *acc);
6264 __isl_give isl_flow *isl_access_info_compute_flow(
6265 __isl_take isl_access_info *acc);
6267 int isl_flow_foreach(__isl_keep isl_flow *deps,
6268 int (*fn)(__isl_take isl_map *dep, int must,
6269 void *dep_user, void *user),
6271 __isl_give isl_map *isl_flow_get_no_source(
6272 __isl_keep isl_flow *deps, int must);
6273 void isl_flow_free(__isl_take isl_flow *deps);
6275 The function C<isl_access_info_compute_flow> performs the actual
6276 dependence analysis. The other functions are used to construct
6277 the input for this function or to read off the output.
6279 The input is collected in an C<isl_access_info>, which can
6280 be created through a call to C<isl_access_info_alloc>.
6281 The arguments to this functions are the sink access relation
6282 C<sink>, a token C<sink_user> used to identify the sink
6283 access to the user, a callback function for specifying the
6284 relative order of source and sink accesses, and the number
6285 of source access relations that will be added.
6286 The callback function has type C<int (*)(void *first, void *second)>.
6287 The function is called with two user supplied tokens identifying
6288 either a source or the sink and it should return the shared nesting
6289 level and the relative order of the two accesses.
6290 In particular, let I<n> be the number of loops shared by
6291 the two accesses. If C<first> precedes C<second> textually,
6292 then the function should return I<2 * n + 1>; otherwise,
6293 it should return I<2 * n>.
6294 The sources can be added to the C<isl_access_info> by performing
6295 (at most) C<max_source> calls to C<isl_access_info_add_source>.
6296 C<must> indicates whether the source is a I<must> access
6297 or a I<may> access. Note that a multi-valued access relation
6298 should only be marked I<must> if every iteration in the domain
6299 of the relation accesses I<all> elements in its image.
6300 The C<source_user> token is again used to identify
6301 the source access. The range of the source access relation
6302 C<source> should have the same dimension as the range
6303 of the sink access relation.
6304 The C<isl_access_info_free> function should usually not be
6305 called explicitly, because it is called implicitly by
6306 C<isl_access_info_compute_flow>.
6308 The result of the dependence analysis is collected in an
6309 C<isl_flow>. There may be elements of
6310 the sink access for which no preceding source access could be
6311 found or for which all preceding sources are I<may> accesses.
6312 The relations containing these elements can be obtained through
6313 calls to C<isl_flow_get_no_source>, the first with C<must> set
6314 and the second with C<must> unset.
6315 In the case of standard flow dependence analysis,
6316 with the sink a read and the sources I<must> writes,
6317 the first relation corresponds to the reads from uninitialized
6318 array elements and the second relation is empty.
6319 The actual flow dependences can be extracted using
6320 C<isl_flow_foreach>. This function will call the user-specified
6321 callback function C<fn> for each B<non-empty> dependence between
6322 a source and the sink. The callback function is called
6323 with four arguments, the actual flow dependence relation
6324 mapping source iterations to sink iterations, a boolean that
6325 indicates whether it is a I<must> or I<may> dependence, a token
6326 identifying the source and an additional C<void *> with value
6327 equal to the third argument of the C<isl_flow_foreach> call.
6328 A dependence is marked I<must> if it originates from a I<must>
6329 source and if it is not followed by any I<may> sources.
6331 After finishing with an C<isl_flow>, the user should call
6332 C<isl_flow_free> to free all associated memory.
6334 A higher-level interface to dependence analysis is provided
6335 by the following function.
6337 #include <isl/flow.h>
6339 int isl_union_map_compute_flow(__isl_take isl_union_map *sink,
6340 __isl_take isl_union_map *must_source,
6341 __isl_take isl_union_map *may_source,
6342 __isl_take isl_union_map *schedule,
6343 __isl_give isl_union_map **must_dep,
6344 __isl_give isl_union_map **may_dep,
6345 __isl_give isl_union_map **must_no_source,
6346 __isl_give isl_union_map **may_no_source);
6348 The arrays are identified by the tuple names of the ranges
6349 of the accesses. The iteration domains by the tuple names
6350 of the domains of the accesses and of the schedule.
6351 The relative order of the iteration domains is given by the
6352 schedule. The relations returned through C<must_no_source>
6353 and C<may_no_source> are subsets of C<sink>.
6354 Any of C<must_dep>, C<may_dep>, C<must_no_source>
6355 or C<may_no_source> may be C<NULL>, but a C<NULL> value for
6356 any of the other arguments is treated as an error.
6358 =head3 Interaction with Dependence Analysis
6360 During the dependence analysis, we frequently need to perform
6361 the following operation. Given a relation between sink iterations
6362 and potential source iterations from a particular source domain,
6363 what is the last potential source iteration corresponding to each
6364 sink iteration. It can sometimes be convenient to adjust
6365 the set of potential source iterations before or after each such operation.
6366 The prototypical example is fuzzy array dataflow analysis,
6367 where we need to analyze if, based on data-dependent constraints,
6368 the sink iteration can ever be executed without one or more of
6369 the corresponding potential source iterations being executed.
6370 If so, we can introduce extra parameters and select an unknown
6371 but fixed source iteration from the potential source iterations.
6372 To be able to perform such manipulations, C<isl> provides the following
6375 #include <isl/flow.h>
6377 typedef __isl_give isl_restriction *(*isl_access_restrict)(
6378 __isl_keep isl_map *source_map,
6379 __isl_keep isl_set *sink, void *source_user,
6381 __isl_give isl_access_info *isl_access_info_set_restrict(
6382 __isl_take isl_access_info *acc,
6383 isl_access_restrict fn, void *user);
6385 The function C<isl_access_info_set_restrict> should be called
6386 before calling C<isl_access_info_compute_flow> and registers a callback function
6387 that will be called any time C<isl> is about to compute the last
6388 potential source. The first argument is the (reverse) proto-dependence,
6389 mapping sink iterations to potential source iterations.
6390 The second argument represents the sink iterations for which
6391 we want to compute the last source iteration.
6392 The third argument is the token corresponding to the source
6393 and the final argument is the token passed to C<isl_access_info_set_restrict>.
6394 The callback is expected to return a restriction on either the input or
6395 the output of the operation computing the last potential source.
6396 If the input needs to be restricted then restrictions are needed
6397 for both the source and the sink iterations. The sink iterations
6398 and the potential source iterations will be intersected with these sets.
6399 If the output needs to be restricted then only a restriction on the source
6400 iterations is required.
6401 If any error occurs, the callback should return C<NULL>.
6402 An C<isl_restriction> object can be created, freed and inspected
6403 using the following functions.
6405 #include <isl/flow.h>
6407 __isl_give isl_restriction *isl_restriction_input(
6408 __isl_take isl_set *source_restr,
6409 __isl_take isl_set *sink_restr);
6410 __isl_give isl_restriction *isl_restriction_output(
6411 __isl_take isl_set *source_restr);
6412 __isl_give isl_restriction *isl_restriction_none(
6413 __isl_take isl_map *source_map);
6414 __isl_give isl_restriction *isl_restriction_empty(
6415 __isl_take isl_map *source_map);
6416 __isl_null isl_restriction *isl_restriction_free(
6417 __isl_take isl_restriction *restr);
6419 C<isl_restriction_none> and C<isl_restriction_empty> are special
6420 cases of C<isl_restriction_input>. C<isl_restriction_none>
6421 is essentially equivalent to
6423 isl_restriction_input(isl_set_universe(
6424 isl_space_range(isl_map_get_space(source_map))),
6426 isl_space_domain(isl_map_get_space(source_map))));
6428 whereas C<isl_restriction_empty> is essentially equivalent to
6430 isl_restriction_input(isl_set_empty(
6431 isl_space_range(isl_map_get_space(source_map))),
6433 isl_space_domain(isl_map_get_space(source_map))));
6437 B<The functionality described in this section is fairly new
6438 and may be subject to change.>
6440 #include <isl/schedule.h>
6441 __isl_give isl_schedule *
6442 isl_schedule_constraints_compute_schedule(
6443 __isl_take isl_schedule_constraints *sc);
6444 __isl_null isl_schedule *isl_schedule_free(
6445 __isl_take isl_schedule *sched);
6447 The function C<isl_schedule_constraints_compute_schedule> can be
6448 used to compute a schedule that satisfies the given schedule constraints.
6449 These schedule constraints include the iteration domain for which
6450 a schedule should be computed and dependences between pairs of
6451 iterations. In particular, these dependences include
6452 I<validity> dependences and I<proximity> dependences.
6453 By default, the algorithm used to construct the schedule is similar
6454 to that of C<Pluto>.
6455 Alternatively, Feautrier's multi-dimensional scheduling algorithm can
6457 The generated schedule respects all validity dependences.
6458 That is, all dependence distances over these dependences in the
6459 scheduled space are lexicographically positive.
6460 The default algorithm tries to ensure that the dependence distances
6461 over coincidence constraints are zero and to minimize the
6462 dependence distances over proximity dependences.
6463 Moreover, it tries to obtain sequences (bands) of schedule dimensions
6464 for groups of domains where the dependence distances over validity
6465 dependences have only non-negative values.
6466 When using Feautrier's algorithm, the coincidence and proximity constraints
6467 are only taken into account during the extension to a
6468 full-dimensional schedule.
6470 An C<isl_schedule_constraints> object can be constructed
6471 and manipulated using the following functions.
6473 #include <isl/schedule.h>
6474 __isl_give isl_schedule_constraints *
6475 isl_schedule_constraints_copy(
6476 __isl_keep isl_schedule_constraints *sc);
6477 __isl_give isl_schedule_constraints *
6478 isl_schedule_constraints_on_domain(
6479 __isl_take isl_union_set *domain);
6480 __isl_give isl_schedule_constraints *
6481 isl_schedule_constraints_set_validity(
6482 __isl_take isl_schedule_constraints *sc,
6483 __isl_take isl_union_map *validity);
6484 __isl_give isl_schedule_constraints *
6485 isl_schedule_constraints_set_coincidence(
6486 __isl_take isl_schedule_constraints *sc,
6487 __isl_take isl_union_map *coincidence);
6488 __isl_give isl_schedule_constraints *
6489 isl_schedule_constraints_set_proximity(
6490 __isl_take isl_schedule_constraints *sc,
6491 __isl_take isl_union_map *proximity);
6492 __isl_give isl_schedule_constraints *
6493 isl_schedule_constraints_set_conditional_validity(
6494 __isl_take isl_schedule_constraints *sc,
6495 __isl_take isl_union_map *condition,
6496 __isl_take isl_union_map *validity);
6497 __isl_null isl_schedule_constraints *
6498 isl_schedule_constraints_free(
6499 __isl_take isl_schedule_constraints *sc);
6501 The initial C<isl_schedule_constraints> object created by
6502 C<isl_schedule_constraints_on_domain> does not impose any constraints.
6503 That is, it has an empty set of dependences.
6504 The function C<isl_schedule_constraints_set_validity> replaces the
6505 validity dependences, mapping domain elements I<i> to domain
6506 elements that should be scheduled after I<i>.
6507 The function C<isl_schedule_constraints_set_coincidence> replaces the
6508 coincidence dependences, mapping domain elements I<i> to domain
6509 elements that should be scheduled together with I<I>, if possible.
6510 The function C<isl_schedule_constraints_set_proximity> replaces the
6511 proximity dependences, mapping domain elements I<i> to domain
6512 elements that should be scheduled either before I<I>
6513 or as early as possible after I<i>.
6515 The function C<isl_schedule_constraints_set_conditional_validity>
6516 replaces the conditional validity constraints.
6517 A conditional validity constraint is only imposed when any of the corresponding
6518 conditions is satisfied, i.e., when any of them is non-zero.
6519 That is, the scheduler ensures that within each band if the dependence
6520 distances over the condition constraints are not all zero
6521 then all corresponding conditional validity constraints are respected.
6522 A conditional validity constraint corresponds to a condition
6523 if the two are adjacent, i.e., if the domain of one relation intersect
6524 the range of the other relation.
6525 The typical use case of conditional validity constraints is
6526 to allow order constraints between live ranges to be violated
6527 as long as the live ranges themselves are local to the band.
6528 To allow more fine-grained control over which conditions correspond
6529 to which conditional validity constraints, the domains and ranges
6530 of these relations may include I<tags>. That is, the domains and
6531 ranges of those relation may themselves be wrapped relations
6532 where the iteration domain appears in the domain of those wrapped relations
6533 and the range of the wrapped relations can be arbitrarily chosen
6534 by the user. Conditions and conditional validity constraints are only
6535 considered adjacent to each other if the entire wrapped relation matches.
6536 In particular, a relation with a tag will never be considered adjacent
6537 to a relation without a tag.
6539 The following function computes a schedule directly from
6540 an iteration domain and validity and proximity dependences
6541 and is implemented in terms of the functions described above.
6542 The use of C<isl_union_set_compute_schedule> is discouraged.
6544 #include <isl/schedule.h>
6545 __isl_give isl_schedule *isl_union_set_compute_schedule(
6546 __isl_take isl_union_set *domain,
6547 __isl_take isl_union_map *validity,
6548 __isl_take isl_union_map *proximity);
6550 A mapping from the domains to the scheduled space can be obtained
6551 from an C<isl_schedule> using the following function.
6553 __isl_give isl_union_map *isl_schedule_get_map(
6554 __isl_keep isl_schedule *sched);
6556 A representation of the schedule can be printed using
6558 __isl_give isl_printer *isl_printer_print_schedule(
6559 __isl_take isl_printer *p,
6560 __isl_keep isl_schedule *schedule);
6562 A representation of the schedule as a forest of bands can be obtained
6563 using the following function.
6565 __isl_give isl_band_list *isl_schedule_get_band_forest(
6566 __isl_keep isl_schedule *schedule);
6568 The individual bands can be visited in depth-first post-order
6569 using the following function.
6571 #include <isl/schedule.h>
6572 int isl_schedule_foreach_band(
6573 __isl_keep isl_schedule *sched,
6574 int (*fn)(__isl_keep isl_band *band, void *user),
6577 The list can be manipulated as explained in L<"Lists">.
6578 The bands inside the list can be copied and freed using the following
6581 #include <isl/band.h>
6582 __isl_give isl_band *isl_band_copy(
6583 __isl_keep isl_band *band);
6584 __isl_null isl_band *isl_band_free(
6585 __isl_take isl_band *band);
6587 Each band contains zero or more scheduling dimensions.
6588 These are referred to as the members of the band.
6589 The section of the schedule that corresponds to the band is
6590 referred to as the partial schedule of the band.
6591 For those nodes that participate in a band, the outer scheduling
6592 dimensions form the prefix schedule, while the inner scheduling
6593 dimensions form the suffix schedule.
6594 That is, if we take a cut of the band forest, then the union of
6595 the concatenations of the prefix, partial and suffix schedules of
6596 each band in the cut is equal to the entire schedule (modulo
6597 some possible padding at the end with zero scheduling dimensions).
6598 The properties of a band can be inspected using the following functions.
6600 #include <isl/band.h>
6601 int isl_band_has_children(__isl_keep isl_band *band);
6602 __isl_give isl_band_list *isl_band_get_children(
6603 __isl_keep isl_band *band);
6605 __isl_give isl_union_map *isl_band_get_prefix_schedule(
6606 __isl_keep isl_band *band);
6607 __isl_give isl_union_map *isl_band_get_partial_schedule(
6608 __isl_keep isl_band *band);
6609 __isl_give isl_union_map *isl_band_get_suffix_schedule(
6610 __isl_keep isl_band *band);
6612 int isl_band_n_member(__isl_keep isl_band *band);
6613 int isl_band_member_is_coincident(
6614 __isl_keep isl_band *band, int pos);
6616 int isl_band_list_foreach_band(
6617 __isl_keep isl_band_list *list,
6618 int (*fn)(__isl_keep isl_band *band, void *user),
6621 Note that a scheduling dimension is considered to be ``coincident''
6622 if it satisfies the coincidence constraints within its band.
6623 That is, if the dependence distances of the coincidence
6624 constraints are all zero in that direction (for fixed
6625 iterations of outer bands).
6626 Like C<isl_schedule_foreach_band>,
6627 the function C<isl_band_list_foreach_band> calls C<fn> on the bands
6628 in depth-first post-order.
6630 A band can be tiled using the following function.
6632 #include <isl/band.h>
6633 int isl_band_tile(__isl_keep isl_band *band,
6634 __isl_take isl_vec *sizes);
6636 int isl_options_set_tile_scale_tile_loops(isl_ctx *ctx,
6638 int isl_options_get_tile_scale_tile_loops(isl_ctx *ctx);
6639 int isl_options_set_tile_shift_point_loops(isl_ctx *ctx,
6641 int isl_options_get_tile_shift_point_loops(isl_ctx *ctx);
6643 The C<isl_band_tile> function tiles the band using the given tile sizes
6644 inside its schedule.
6645 A new child band is created to represent the point loops and it is
6646 inserted between the modified band and its children.
6647 The C<tile_scale_tile_loops> option specifies whether the tile
6648 loops iterators should be scaled by the tile sizes.
6649 If the C<tile_shift_point_loops> option is set, then the point loops
6650 are shifted to start at zero.
6652 A band can be split into two nested bands using the following function.
6654 int isl_band_split(__isl_keep isl_band *band, int pos);
6656 The resulting outer band contains the first C<pos> dimensions of C<band>
6657 while the inner band contains the remaining dimensions.
6659 A representation of the band can be printed using
6661 #include <isl/band.h>
6662 __isl_give isl_printer *isl_printer_print_band(
6663 __isl_take isl_printer *p,
6664 __isl_keep isl_band *band);
6668 #include <isl/schedule.h>
6669 int isl_options_set_schedule_max_coefficient(
6670 isl_ctx *ctx, int val);
6671 int isl_options_get_schedule_max_coefficient(
6673 int isl_options_set_schedule_max_constant_term(
6674 isl_ctx *ctx, int val);
6675 int isl_options_get_schedule_max_constant_term(
6677 int isl_options_set_schedule_fuse(isl_ctx *ctx, int val);
6678 int isl_options_get_schedule_fuse(isl_ctx *ctx);
6679 int isl_options_set_schedule_maximize_band_depth(
6680 isl_ctx *ctx, int val);
6681 int isl_options_get_schedule_maximize_band_depth(
6683 int isl_options_set_schedule_outer_coincidence(
6684 isl_ctx *ctx, int val);
6685 int isl_options_get_schedule_outer_coincidence(
6687 int isl_options_set_schedule_split_scaled(
6688 isl_ctx *ctx, int val);
6689 int isl_options_get_schedule_split_scaled(
6691 int isl_options_set_schedule_algorithm(
6692 isl_ctx *ctx, int val);
6693 int isl_options_get_schedule_algorithm(
6695 int isl_options_set_schedule_separate_components(
6696 isl_ctx *ctx, int val);
6697 int isl_options_get_schedule_separate_components(
6702 =item * schedule_max_coefficient
6704 This option enforces that the coefficients for variable and parameter
6705 dimensions in the calculated schedule are not larger than the specified value.
6706 This option can significantly increase the speed of the scheduling calculation
6707 and may also prevent fusing of unrelated dimensions. A value of -1 means that
6708 this option does not introduce bounds on the variable or parameter
6711 =item * schedule_max_constant_term
6713 This option enforces that the constant coefficients in the calculated schedule
6714 are not larger than the maximal constant term. This option can significantly
6715 increase the speed of the scheduling calculation and may also prevent fusing of
6716 unrelated dimensions. A value of -1 means that this option does not introduce
6717 bounds on the constant coefficients.
6719 =item * schedule_fuse
6721 This option controls the level of fusion.
6722 If this option is set to C<ISL_SCHEDULE_FUSE_MIN>, then loops in the
6723 resulting schedule will be distributed as much as possible.
6724 If this option is set to C<ISL_SCHEDULE_FUSE_MAX>, then C<isl> will
6725 try to fuse loops in the resulting schedule.
6727 =item * schedule_maximize_band_depth
6729 If this option is set, we do not split bands at the point
6730 where we detect splitting is necessary. Instead, we
6731 backtrack and split bands as early as possible. This
6732 reduces the number of splits and maximizes the width of
6733 the bands. Wider bands give more possibilities for tiling.
6734 Note that if the C<schedule_fuse> option is set to C<ISL_SCHEDULE_FUSE_MIN>,
6735 then bands will be split as early as possible, even if there is no need.
6736 The C<schedule_maximize_band_depth> option therefore has no effect in this case.
6738 =item * schedule_outer_coincidence
6740 If this option is set, then we try to construct schedules
6741 where the outermost scheduling dimension in each band
6742 satisfies the coincidence constraints.
6744 =item * schedule_split_scaled
6746 If this option is set, then we try to construct schedules in which the
6747 constant term is split off from the linear part if the linear parts of
6748 the scheduling rows for all nodes in the graphs have a common non-trivial
6750 The constant term is then placed in a separate band and the linear
6753 =item * schedule_algorithm
6755 Selects the scheduling algorithm to be used.
6756 Available scheduling algorithms are C<ISL_SCHEDULE_ALGORITHM_ISL>
6757 and C<ISL_SCHEDULE_ALGORITHM_FEAUTRIER>.
6759 =item * schedule_separate_components
6761 If at any point the dependence graph contains any (weakly connected) components,
6762 then these components are scheduled separately.
6763 If this option is not set, then some iterations of the domains
6764 in these components may be scheduled together.
6765 If this option is set, then the components are given consecutive
6770 =head2 AST Generation
6772 This section describes the C<isl> functionality for generating
6773 ASTs that visit all the elements
6774 in a domain in an order specified by a schedule.
6775 In particular, given a C<isl_union_map>, an AST is generated
6776 that visits all the elements in the domain of the C<isl_union_map>
6777 according to the lexicographic order of the corresponding image
6778 element(s). If the range of the C<isl_union_map> consists of
6779 elements in more than one space, then each of these spaces is handled
6780 separately in an arbitrary order.
6781 It should be noted that the image elements only specify the I<order>
6782 in which the corresponding domain elements should be visited.
6783 No direct relation between the image elements and the loop iterators
6784 in the generated AST should be assumed.
6786 Each AST is generated within a build. The initial build
6787 simply specifies the constraints on the parameters (if any)
6788 and can be created, inspected, copied and freed using the following functions.
6790 #include <isl/ast_build.h>
6791 __isl_give isl_ast_build *isl_ast_build_from_context(
6792 __isl_take isl_set *set);
6793 __isl_give isl_ast_build *isl_ast_build_copy(
6794 __isl_keep isl_ast_build *build);
6795 __isl_null isl_ast_build *isl_ast_build_free(
6796 __isl_take isl_ast_build *build);
6798 The C<set> argument is usually a parameter set with zero or more parameters.
6799 More C<isl_ast_build> functions are described in L</"Nested AST Generation">
6800 and L</"Fine-grained Control over AST Generation">.
6801 Finally, the AST itself can be constructed using the following
6804 #include <isl/ast_build.h>
6805 __isl_give isl_ast_node *isl_ast_build_ast_from_schedule(
6806 __isl_keep isl_ast_build *build,
6807 __isl_take isl_union_map *schedule);
6809 =head3 Inspecting the AST
6811 The basic properties of an AST node can be obtained as follows.
6813 #include <isl/ast.h>
6814 enum isl_ast_node_type isl_ast_node_get_type(
6815 __isl_keep isl_ast_node *node);
6817 The type of an AST node is one of
6818 C<isl_ast_node_for>,
6820 C<isl_ast_node_block> or
6821 C<isl_ast_node_user>.
6822 An C<isl_ast_node_for> represents a for node.
6823 An C<isl_ast_node_if> represents an if node.
6824 An C<isl_ast_node_block> represents a compound node.
6825 An C<isl_ast_node_user> represents an expression statement.
6826 An expression statement typically corresponds to a domain element, i.e.,
6827 one of the elements that is visited by the AST.
6829 Each type of node has its own additional properties.
6831 #include <isl/ast.h>
6832 __isl_give isl_ast_expr *isl_ast_node_for_get_iterator(
6833 __isl_keep isl_ast_node *node);
6834 __isl_give isl_ast_expr *isl_ast_node_for_get_init(
6835 __isl_keep isl_ast_node *node);
6836 __isl_give isl_ast_expr *isl_ast_node_for_get_cond(
6837 __isl_keep isl_ast_node *node);
6838 __isl_give isl_ast_expr *isl_ast_node_for_get_inc(
6839 __isl_keep isl_ast_node *node);
6840 __isl_give isl_ast_node *isl_ast_node_for_get_body(
6841 __isl_keep isl_ast_node *node);
6842 int isl_ast_node_for_is_degenerate(
6843 __isl_keep isl_ast_node *node);
6845 An C<isl_ast_for> is considered degenerate if it is known to execute
6848 #include <isl/ast.h>
6849 __isl_give isl_ast_expr *isl_ast_node_if_get_cond(
6850 __isl_keep isl_ast_node *node);
6851 __isl_give isl_ast_node *isl_ast_node_if_get_then(
6852 __isl_keep isl_ast_node *node);
6853 int isl_ast_node_if_has_else(
6854 __isl_keep isl_ast_node *node);
6855 __isl_give isl_ast_node *isl_ast_node_if_get_else(
6856 __isl_keep isl_ast_node *node);
6858 __isl_give isl_ast_node_list *
6859 isl_ast_node_block_get_children(
6860 __isl_keep isl_ast_node *node);
6862 __isl_give isl_ast_expr *isl_ast_node_user_get_expr(
6863 __isl_keep isl_ast_node *node);
6865 Each of the returned C<isl_ast_expr>s can in turn be inspected using
6866 the following functions.
6868 #include <isl/ast.h>
6869 enum isl_ast_expr_type isl_ast_expr_get_type(
6870 __isl_keep isl_ast_expr *expr);
6872 The type of an AST expression is one of
6874 C<isl_ast_expr_id> or
6875 C<isl_ast_expr_int>.
6876 An C<isl_ast_expr_op> represents the result of an operation.
6877 An C<isl_ast_expr_id> represents an identifier.
6878 An C<isl_ast_expr_int> represents an integer value.
6880 Each type of expression has its own additional properties.
6882 #include <isl/ast.h>
6883 enum isl_ast_op_type isl_ast_expr_get_op_type(
6884 __isl_keep isl_ast_expr *expr);
6885 int isl_ast_expr_get_op_n_arg(__isl_keep isl_ast_expr *expr);
6886 __isl_give isl_ast_expr *isl_ast_expr_get_op_arg(
6887 __isl_keep isl_ast_expr *expr, int pos);
6888 int isl_ast_node_foreach_ast_op_type(
6889 __isl_keep isl_ast_node *node,
6890 int (*fn)(enum isl_ast_op_type type, void *user),
6893 C<isl_ast_expr_get_op_type> returns the type of the operation
6894 performed. C<isl_ast_expr_get_op_n_arg> returns the number of
6895 arguments. C<isl_ast_expr_get_op_arg> returns the specified
6897 C<isl_ast_node_foreach_ast_op_type> calls C<fn> for each distinct
6898 C<isl_ast_op_type> that appears in C<node>.
6899 The operation type is one of the following.
6903 =item C<isl_ast_op_and>
6905 Logical I<and> of two arguments.
6906 Both arguments can be evaluated.
6908 =item C<isl_ast_op_and_then>
6910 Logical I<and> of two arguments.
6911 The second argument can only be evaluated if the first evaluates to true.
6913 =item C<isl_ast_op_or>
6915 Logical I<or> of two arguments.
6916 Both arguments can be evaluated.
6918 =item C<isl_ast_op_or_else>
6920 Logical I<or> of two arguments.
6921 The second argument can only be evaluated if the first evaluates to false.
6923 =item C<isl_ast_op_max>
6925 Maximum of two or more arguments.
6927 =item C<isl_ast_op_min>
6929 Minimum of two or more arguments.
6931 =item C<isl_ast_op_minus>
6935 =item C<isl_ast_op_add>
6937 Sum of two arguments.
6939 =item C<isl_ast_op_sub>
6941 Difference of two arguments.
6943 =item C<isl_ast_op_mul>
6945 Product of two arguments.
6947 =item C<isl_ast_op_div>
6949 Exact division. That is, the result is known to be an integer.
6951 =item C<isl_ast_op_fdiv_q>
6953 Result of integer division, rounded towards negative
6956 =item C<isl_ast_op_pdiv_q>
6958 Result of integer division, where dividend is known to be non-negative.
6960 =item C<isl_ast_op_pdiv_r>
6962 Remainder of integer division, where dividend is known to be non-negative.
6964 =item C<isl_ast_op_zdiv_r>
6966 Equal to zero iff the remainder on integer division is zero.
6968 =item C<isl_ast_op_cond>
6970 Conditional operator defined on three arguments.
6971 If the first argument evaluates to true, then the result
6972 is equal to the second argument. Otherwise, the result
6973 is equal to the third argument.
6974 The second and third argument may only be evaluated if
6975 the first argument evaluates to true and false, respectively.
6976 Corresponds to C<a ? b : c> in C.
6978 =item C<isl_ast_op_select>
6980 Conditional operator defined on three arguments.
6981 If the first argument evaluates to true, then the result
6982 is equal to the second argument. Otherwise, the result
6983 is equal to the third argument.
6984 The second and third argument may be evaluated independently
6985 of the value of the first argument.
6986 Corresponds to C<a * b + (1 - a) * c> in C.
6988 =item C<isl_ast_op_eq>
6992 =item C<isl_ast_op_le>
6994 Less than or equal relation.
6996 =item C<isl_ast_op_lt>
7000 =item C<isl_ast_op_ge>
7002 Greater than or equal relation.
7004 =item C<isl_ast_op_gt>
7006 Greater than relation.
7008 =item C<isl_ast_op_call>
7011 The number of arguments of the C<isl_ast_expr> is one more than
7012 the number of arguments in the function call, the first argument
7013 representing the function being called.
7015 =item C<isl_ast_op_access>
7018 The number of arguments of the C<isl_ast_expr> is one more than
7019 the number of index expressions in the array access, the first argument
7020 representing the array being accessed.
7022 =item C<isl_ast_op_member>
7025 This operation has two arguments, a structure and the name of
7026 the member of the structure being accessed.
7030 #include <isl/ast.h>
7031 __isl_give isl_id *isl_ast_expr_get_id(
7032 __isl_keep isl_ast_expr *expr);
7034 Return the identifier represented by the AST expression.
7036 #include <isl/ast.h>
7037 __isl_give isl_val *isl_ast_expr_get_val(
7038 __isl_keep isl_ast_expr *expr);
7040 Return the integer represented by the AST expression.
7042 =head3 Properties of ASTs
7044 #include <isl/ast.h>
7045 int isl_ast_expr_is_equal(__isl_keep isl_ast_expr *expr1,
7046 __isl_keep isl_ast_expr *expr2);
7048 Check if two C<isl_ast_expr>s are equal to each other.
7050 =head3 Manipulating and printing the AST
7052 AST nodes can be copied and freed using the following functions.
7054 #include <isl/ast.h>
7055 __isl_give isl_ast_node *isl_ast_node_copy(
7056 __isl_keep isl_ast_node *node);
7057 __isl_null isl_ast_node *isl_ast_node_free(
7058 __isl_take isl_ast_node *node);
7060 AST expressions can be copied and freed using the following functions.
7062 #include <isl/ast.h>
7063 __isl_give isl_ast_expr *isl_ast_expr_copy(
7064 __isl_keep isl_ast_expr *expr);
7065 __isl_null isl_ast_expr *isl_ast_expr_free(
7066 __isl_take isl_ast_expr *expr);
7068 New AST expressions can be created either directly or within
7069 the context of an C<isl_ast_build>.
7071 #include <isl/ast.h>
7072 __isl_give isl_ast_expr *isl_ast_expr_from_val(
7073 __isl_take isl_val *v);
7074 __isl_give isl_ast_expr *isl_ast_expr_from_id(
7075 __isl_take isl_id *id);
7076 __isl_give isl_ast_expr *isl_ast_expr_neg(
7077 __isl_take isl_ast_expr *expr);
7078 __isl_give isl_ast_expr *isl_ast_expr_address_of(
7079 __isl_take isl_ast_expr *expr);
7080 __isl_give isl_ast_expr *isl_ast_expr_add(
7081 __isl_take isl_ast_expr *expr1,
7082 __isl_take isl_ast_expr *expr2);
7083 __isl_give isl_ast_expr *isl_ast_expr_sub(
7084 __isl_take isl_ast_expr *expr1,
7085 __isl_take isl_ast_expr *expr2);
7086 __isl_give isl_ast_expr *isl_ast_expr_mul(
7087 __isl_take isl_ast_expr *expr1,
7088 __isl_take isl_ast_expr *expr2);
7089 __isl_give isl_ast_expr *isl_ast_expr_div(
7090 __isl_take isl_ast_expr *expr1,
7091 __isl_take isl_ast_expr *expr2);
7092 __isl_give isl_ast_expr *isl_ast_expr_and(
7093 __isl_take isl_ast_expr *expr1,
7094 __isl_take isl_ast_expr *expr2)
7095 __isl_give isl_ast_expr *isl_ast_expr_or(
7096 __isl_take isl_ast_expr *expr1,
7097 __isl_take isl_ast_expr *expr2)
7098 __isl_give isl_ast_expr *isl_ast_expr_eq(
7099 __isl_take isl_ast_expr *expr1,
7100 __isl_take isl_ast_expr *expr2);
7101 __isl_give isl_ast_expr *isl_ast_expr_le(
7102 __isl_take isl_ast_expr *expr1,
7103 __isl_take isl_ast_expr *expr2);
7104 __isl_give isl_ast_expr *isl_ast_expr_lt(
7105 __isl_take isl_ast_expr *expr1,
7106 __isl_take isl_ast_expr *expr2);
7107 __isl_give isl_ast_expr *isl_ast_expr_ge(
7108 __isl_take isl_ast_expr *expr1,
7109 __isl_take isl_ast_expr *expr2);
7110 __isl_give isl_ast_expr *isl_ast_expr_gt(
7111 __isl_take isl_ast_expr *expr1,
7112 __isl_take isl_ast_expr *expr2);
7113 __isl_give isl_ast_expr *isl_ast_expr_access(
7114 __isl_take isl_ast_expr *array,
7115 __isl_take isl_ast_expr_list *indices);
7117 The function C<isl_ast_expr_address_of> can be applied to an
7118 C<isl_ast_expr> of type C<isl_ast_op_access> only. It is meant
7119 to represent the address of the C<isl_ast_expr_access>.
7121 #include <isl/ast_build.h>
7122 __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff(
7123 __isl_keep isl_ast_build *build,
7124 __isl_take isl_pw_aff *pa);
7125 __isl_give isl_ast_expr *
7126 isl_ast_build_access_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_access_from_multi_pw_aff(
7131 __isl_keep isl_ast_build *build,
7132 __isl_take isl_multi_pw_aff *mpa);
7133 __isl_give isl_ast_expr *
7134 isl_ast_build_call_from_pw_multi_aff(
7135 __isl_keep isl_ast_build *build,
7136 __isl_take isl_pw_multi_aff *pma);
7137 __isl_give isl_ast_expr *
7138 isl_ast_build_call_from_multi_pw_aff(
7139 __isl_keep isl_ast_build *build,
7140 __isl_take isl_multi_pw_aff *mpa);
7142 The domains of C<pa>, C<mpa> and C<pma> should correspond
7143 to the schedule space of C<build>.
7144 The tuple id of C<mpa> or C<pma> is used as the array being accessed or
7145 the function being called.
7146 If the accessed space is a nested relation, then it is taken
7147 to represent an access of the member specified by the range
7148 of this nested relation of the structure specified by the domain
7149 of the nested relation.
7151 The following functions can be used to modify an C<isl_ast_expr>.
7153 #include <isl/ast.h>
7154 __isl_give isl_ast_expr *isl_ast_expr_set_op_arg(
7155 __isl_take isl_ast_expr *expr, int pos,
7156 __isl_take isl_ast_expr *arg);
7158 Replace the argument of C<expr> at position C<pos> by C<arg>.
7160 #include <isl/ast.h>
7161 __isl_give isl_ast_expr *isl_ast_expr_substitute_ids(
7162 __isl_take isl_ast_expr *expr,
7163 __isl_take isl_id_to_ast_expr *id2expr);
7165 The function C<isl_ast_expr_substitute_ids> replaces the
7166 subexpressions of C<expr> of type C<isl_ast_expr_id>
7167 by the corresponding expression in C<id2expr>, if there is any.
7170 User specified data can be attached to an C<isl_ast_node> and obtained
7171 from the same C<isl_ast_node> using the following functions.
7173 #include <isl/ast.h>
7174 __isl_give isl_ast_node *isl_ast_node_set_annotation(
7175 __isl_take isl_ast_node *node,
7176 __isl_take isl_id *annotation);
7177 __isl_give isl_id *isl_ast_node_get_annotation(
7178 __isl_keep isl_ast_node *node);
7180 Basic printing can be performed using the following functions.
7182 #include <isl/ast.h>
7183 __isl_give isl_printer *isl_printer_print_ast_expr(
7184 __isl_take isl_printer *p,
7185 __isl_keep isl_ast_expr *expr);
7186 __isl_give isl_printer *isl_printer_print_ast_node(
7187 __isl_take isl_printer *p,
7188 __isl_keep isl_ast_node *node);
7189 __isl_give char *isl_ast_expr_to_str(
7190 __isl_keep isl_ast_expr *expr);
7192 More advanced printing can be performed using the following functions.
7194 #include <isl/ast.h>
7195 __isl_give isl_printer *isl_ast_op_type_print_macro(
7196 enum isl_ast_op_type type,
7197 __isl_take isl_printer *p);
7198 __isl_give isl_printer *isl_ast_node_print_macros(
7199 __isl_keep isl_ast_node *node,
7200 __isl_take isl_printer *p);
7201 __isl_give isl_printer *isl_ast_node_print(
7202 __isl_keep isl_ast_node *node,
7203 __isl_take isl_printer *p,
7204 __isl_take isl_ast_print_options *options);
7205 __isl_give isl_printer *isl_ast_node_for_print(
7206 __isl_keep isl_ast_node *node,
7207 __isl_take isl_printer *p,
7208 __isl_take isl_ast_print_options *options);
7209 __isl_give isl_printer *isl_ast_node_if_print(
7210 __isl_keep isl_ast_node *node,
7211 __isl_take isl_printer *p,
7212 __isl_take isl_ast_print_options *options);
7214 While printing an C<isl_ast_node> in C<ISL_FORMAT_C>,
7215 C<isl> may print out an AST that makes use of macros such
7216 as C<floord>, C<min> and C<max>.
7217 C<isl_ast_op_type_print_macro> prints out the macro
7218 corresponding to a specific C<isl_ast_op_type>.
7219 C<isl_ast_node_print_macros> scans the C<isl_ast_node>
7220 for expressions where these macros would be used and prints
7221 out the required macro definitions.
7222 Essentially, C<isl_ast_node_print_macros> calls
7223 C<isl_ast_node_foreach_ast_op_type> with C<isl_ast_op_type_print_macro>
7224 as function argument.
7225 C<isl_ast_node_print>, C<isl_ast_node_for_print> and
7226 C<isl_ast_node_if_print> print an C<isl_ast_node>
7227 in C<ISL_FORMAT_C>, but allow for some extra control
7228 through an C<isl_ast_print_options> object.
7229 This object can be created using the following functions.
7231 #include <isl/ast.h>
7232 __isl_give isl_ast_print_options *
7233 isl_ast_print_options_alloc(isl_ctx *ctx);
7234 __isl_give isl_ast_print_options *
7235 isl_ast_print_options_copy(
7236 __isl_keep isl_ast_print_options *options);
7237 __isl_null isl_ast_print_options *
7238 isl_ast_print_options_free(
7239 __isl_take isl_ast_print_options *options);
7241 __isl_give isl_ast_print_options *
7242 isl_ast_print_options_set_print_user(
7243 __isl_take isl_ast_print_options *options,
7244 __isl_give isl_printer *(*print_user)(
7245 __isl_take isl_printer *p,
7246 __isl_take isl_ast_print_options *options,
7247 __isl_keep isl_ast_node *node, void *user),
7249 __isl_give isl_ast_print_options *
7250 isl_ast_print_options_set_print_for(
7251 __isl_take isl_ast_print_options *options,
7252 __isl_give isl_printer *(*print_for)(
7253 __isl_take isl_printer *p,
7254 __isl_take isl_ast_print_options *options,
7255 __isl_keep isl_ast_node *node, void *user),
7258 The callback set by C<isl_ast_print_options_set_print_user>
7259 is called whenever a node of type C<isl_ast_node_user> needs to
7261 The callback set by C<isl_ast_print_options_set_print_for>
7262 is called whenever a node of type C<isl_ast_node_for> needs to
7264 Note that C<isl_ast_node_for_print> will I<not> call the
7265 callback set by C<isl_ast_print_options_set_print_for> on the node
7266 on which C<isl_ast_node_for_print> is called, but only on nested
7267 nodes of type C<isl_ast_node_for>. It is therefore safe to
7268 call C<isl_ast_node_for_print> from within the callback set by
7269 C<isl_ast_print_options_set_print_for>.
7271 The following option determines the type to be used for iterators
7272 while printing the AST.
7274 int isl_options_set_ast_iterator_type(
7275 isl_ctx *ctx, const char *val);
7276 const char *isl_options_get_ast_iterator_type(
7279 The AST printer only prints body nodes as blocks if these
7280 blocks cannot be safely omitted.
7281 For example, a C<for> node with one body node will not be
7282 surrounded with braces in C<ISL_FORMAT_C>.
7283 A block will always be printed by setting the following option.
7285 int isl_options_set_ast_always_print_block(isl_ctx *ctx,
7287 int isl_options_get_ast_always_print_block(isl_ctx *ctx);
7291 #include <isl/ast_build.h>
7292 int isl_options_set_ast_build_atomic_upper_bound(
7293 isl_ctx *ctx, int val);
7294 int isl_options_get_ast_build_atomic_upper_bound(
7296 int isl_options_set_ast_build_prefer_pdiv(isl_ctx *ctx,
7298 int isl_options_get_ast_build_prefer_pdiv(isl_ctx *ctx);
7299 int isl_options_set_ast_build_exploit_nested_bounds(
7300 isl_ctx *ctx, int val);
7301 int isl_options_get_ast_build_exploit_nested_bounds(
7303 int isl_options_set_ast_build_group_coscheduled(
7304 isl_ctx *ctx, int val);
7305 int isl_options_get_ast_build_group_coscheduled(
7307 int isl_options_set_ast_build_scale_strides(
7308 isl_ctx *ctx, int val);
7309 int isl_options_get_ast_build_scale_strides(
7311 int isl_options_set_ast_build_allow_else(isl_ctx *ctx,
7313 int isl_options_get_ast_build_allow_else(isl_ctx *ctx);
7314 int isl_options_set_ast_build_allow_or(isl_ctx *ctx,
7316 int isl_options_get_ast_build_allow_or(isl_ctx *ctx);
7320 =item * ast_build_atomic_upper_bound
7322 Generate loop upper bounds that consist of the current loop iterator,
7323 an operator and an expression not involving the iterator.
7324 If this option is not set, then the current loop iterator may appear
7325 several times in the upper bound.
7326 For example, when this option is turned off, AST generation
7329 [n] -> { A[i] -> [i] : 0 <= i <= 100, n }
7333 for (int c0 = 0; c0 <= 100 && n >= c0; c0 += 1)
7336 When the option is turned on, the following AST is generated
7338 for (int c0 = 0; c0 <= min(100, n); c0 += 1)
7341 =item * ast_build_prefer_pdiv
7343 If this option is turned off, then the AST generation will
7344 produce ASTs that may only contain C<isl_ast_op_fdiv_q>
7345 operators, but no C<isl_ast_op_pdiv_q> or
7346 C<isl_ast_op_pdiv_r> operators.
7347 If this options is turned on, then C<isl> will try to convert
7348 some of the C<isl_ast_op_fdiv_q> operators to (expressions containing)
7349 C<isl_ast_op_pdiv_q> or C<isl_ast_op_pdiv_r> operators.
7351 =item * ast_build_exploit_nested_bounds
7353 Simplify conditions based on bounds of nested for loops.
7354 In particular, remove conditions that are implied by the fact
7355 that one or more nested loops have at least one iteration,
7356 meaning that the upper bound is at least as large as the lower bound.
7357 For example, when this option is turned off, AST generation
7360 [N,M] -> { A[i,j] -> [i,j] : 0 <= i <= N and
7366 for (int c0 = 0; c0 <= N; c0 += 1)
7367 for (int c1 = 0; c1 <= M; c1 += 1)
7370 When the option is turned on, the following AST is generated
7372 for (int c0 = 0; c0 <= N; c0 += 1)
7373 for (int c1 = 0; c1 <= M; c1 += 1)
7376 =item * ast_build_group_coscheduled
7378 If two domain elements are assigned the same schedule point, then
7379 they may be executed in any order and they may even appear in different
7380 loops. If this options is set, then the AST generator will make
7381 sure that coscheduled domain elements do not appear in separate parts
7382 of the AST. This is useful in case of nested AST generation
7383 if the outer AST generation is given only part of a schedule
7384 and the inner AST generation should handle the domains that are
7385 coscheduled by this initial part of the schedule together.
7386 For example if an AST is generated for a schedule
7388 { A[i] -> [0]; B[i] -> [0] }
7390 then the C<isl_ast_build_set_create_leaf> callback described
7391 below may get called twice, once for each domain.
7392 Setting this option ensures that the callback is only called once
7393 on both domains together.
7395 =item * ast_build_separation_bounds
7397 This option specifies which bounds to use during separation.
7398 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT>
7399 then all (possibly implicit) bounds on the current dimension will
7400 be used during separation.
7401 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT>
7402 then only those bounds that are explicitly available will
7403 be used during separation.
7405 =item * ast_build_scale_strides
7407 This option specifies whether the AST generator is allowed
7408 to scale down iterators of strided loops.
7410 =item * ast_build_allow_else
7412 This option specifies whether the AST generator is allowed
7413 to construct if statements with else branches.
7415 =item * ast_build_allow_or
7417 This option specifies whether the AST generator is allowed
7418 to construct if conditions with disjunctions.
7422 =head3 Fine-grained Control over AST Generation
7424 Besides specifying the constraints on the parameters,
7425 an C<isl_ast_build> object can be used to control
7426 various aspects of the AST generation process.
7427 The most prominent way of control is through ``options'',
7428 which can be set using the following function.
7430 #include <isl/ast_build.h>
7431 __isl_give isl_ast_build *
7432 isl_ast_build_set_options(
7433 __isl_take isl_ast_build *control,
7434 __isl_take isl_union_map *options);
7436 The options are encoded in an C<isl_union_map>.
7437 The domain of this union relation refers to the schedule domain,
7438 i.e., the range of the schedule passed to C<isl_ast_build_ast_from_schedule>.
7439 In the case of nested AST generation (see L</"Nested AST Generation">),
7440 the domain of C<options> should refer to the extra piece of the schedule.
7441 That is, it should be equal to the range of the wrapped relation in the
7442 range of the schedule.
7443 The range of the options can consist of elements in one or more spaces,
7444 the names of which determine the effect of the option.
7445 The values of the range typically also refer to the schedule dimension
7446 to which the option applies. In case of nested AST generation
7447 (see L</"Nested AST Generation">), these values refer to the position
7448 of the schedule dimension within the innermost AST generation.
7449 The constraints on the domain elements of
7450 the option should only refer to this dimension and earlier dimensions.
7451 We consider the following spaces.
7455 =item C<separation_class>
7457 This space is a wrapped relation between two one dimensional spaces.
7458 The input space represents the schedule dimension to which the option
7459 applies and the output space represents the separation class.
7460 While constructing a loop corresponding to the specified schedule
7461 dimension(s), the AST generator will try to generate separate loops
7462 for domain elements that are assigned different classes.
7463 If only some of the elements are assigned a class, then those elements
7464 that are not assigned any class will be treated as belonging to a class
7465 that is separate from the explicitly assigned classes.
7466 The typical use case for this option is to separate full tiles from
7468 The other options, described below, are applied after the separation
7471 As an example, consider the separation into full and partial tiles
7472 of a tiling of a triangular domain.
7473 Take, for example, the domain
7475 { A[i,j] : 0 <= i,j and i + j <= 100 }
7477 and a tiling into tiles of 10 by 10. The input to the AST generator
7478 is then the schedule
7480 { A[i,j] -> [([i/10]),[j/10],i,j] : 0 <= i,j and
7483 Without any options, the following AST is generated
7485 for (int c0 = 0; c0 <= 10; c0 += 1)
7486 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7487 for (int c2 = 10 * c0;
7488 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7490 for (int c3 = 10 * c1;
7491 c3 <= min(10 * c1 + 9, -c2 + 100);
7495 Separation into full and partial tiles can be obtained by assigning
7496 a class, say C<0>, to the full tiles. The full tiles are represented by those
7497 values of the first and second schedule dimensions for which there are
7498 values of the third and fourth dimensions to cover an entire tile.
7499 That is, we need to specify the following option
7501 { [a,b,c,d] -> separation_class[[0]->[0]] :
7502 exists b': 0 <= 10a,10b' and
7503 10a+9+10b'+9 <= 100;
7504 [a,b,c,d] -> separation_class[[1]->[0]] :
7505 0 <= 10a,10b and 10a+9+10b+9 <= 100 }
7509 { [a, b, c, d] -> separation_class[[1] -> [0]] :
7510 a >= 0 and b >= 0 and b <= 8 - a;
7511 [a, b, c, d] -> separation_class[[0] -> [0]] :
7514 With this option, the generated AST is as follows
7517 for (int c0 = 0; c0 <= 8; c0 += 1) {
7518 for (int c1 = 0; c1 <= -c0 + 8; c1 += 1)
7519 for (int c2 = 10 * c0;
7520 c2 <= 10 * c0 + 9; c2 += 1)
7521 for (int c3 = 10 * c1;
7522 c3 <= 10 * c1 + 9; c3 += 1)
7524 for (int c1 = -c0 + 9; c1 <= -c0 + 10; c1 += 1)
7525 for (int c2 = 10 * c0;
7526 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7528 for (int c3 = 10 * c1;
7529 c3 <= min(-c2 + 100, 10 * c1 + 9);
7533 for (int c0 = 9; c0 <= 10; c0 += 1)
7534 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7535 for (int c2 = 10 * c0;
7536 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7538 for (int c3 = 10 * c1;
7539 c3 <= min(10 * c1 + 9, -c2 + 100);
7546 This is a single-dimensional space representing the schedule dimension(s)
7547 to which ``separation'' should be applied. Separation tries to split
7548 a loop into several pieces if this can avoid the generation of guards
7550 See also the C<atomic> option.
7554 This is a single-dimensional space representing the schedule dimension(s)
7555 for which the domains should be considered ``atomic''. That is, the
7556 AST generator will make sure that any given domain space will only appear
7557 in a single loop at the specified level.
7559 Consider the following schedule
7561 { a[i] -> [i] : 0 <= i < 10;
7562 b[i] -> [i+1] : 0 <= i < 10 }
7564 If the following option is specified
7566 { [i] -> separate[x] }
7568 then the following AST will be generated
7572 for (int c0 = 1; c0 <= 9; c0 += 1) {
7579 If, on the other hand, the following option is specified
7581 { [i] -> atomic[x] }
7583 then the following AST will be generated
7585 for (int c0 = 0; c0 <= 10; c0 += 1) {
7592 If neither C<atomic> nor C<separate> is specified, then the AST generator
7593 may produce either of these two results or some intermediate form.
7597 This is a single-dimensional space representing the schedule dimension(s)
7598 that should be I<completely> unrolled.
7599 To obtain a partial unrolling, the user should apply an additional
7600 strip-mining to the schedule and fully unroll the inner loop.
7604 Additional control is available through the following functions.
7606 #include <isl/ast_build.h>
7607 __isl_give isl_ast_build *
7608 isl_ast_build_set_iterators(
7609 __isl_take isl_ast_build *control,
7610 __isl_take isl_id_list *iterators);
7612 The function C<isl_ast_build_set_iterators> allows the user to
7613 specify a list of iterator C<isl_id>s to be used as iterators.
7614 If the input schedule is injective, then
7615 the number of elements in this list should be as large as the dimension
7616 of the schedule space, but no direct correspondence should be assumed
7617 between dimensions and elements.
7618 If the input schedule is not injective, then an additional number
7619 of C<isl_id>s equal to the largest dimension of the input domains
7621 If the number of provided C<isl_id>s is insufficient, then additional
7622 names are automatically generated.
7624 #include <isl/ast_build.h>
7625 __isl_give isl_ast_build *
7626 isl_ast_build_set_create_leaf(
7627 __isl_take isl_ast_build *control,
7628 __isl_give isl_ast_node *(*fn)(
7629 __isl_take isl_ast_build *build,
7630 void *user), void *user);
7633 C<isl_ast_build_set_create_leaf> function allows for the
7634 specification of a callback that should be called whenever the AST
7635 generator arrives at an element of the schedule domain.
7636 The callback should return an AST node that should be inserted
7637 at the corresponding position of the AST. The default action (when
7638 the callback is not set) is to continue generating parts of the AST to scan
7639 all the domain elements associated to the schedule domain element
7640 and to insert user nodes, ``calling'' the domain element, for each of them.
7641 The C<build> argument contains the current state of the C<isl_ast_build>.
7642 To ease nested AST generation (see L</"Nested AST Generation">),
7643 all control information that is
7644 specific to the current AST generation such as the options and
7645 the callbacks has been removed from this C<isl_ast_build>.
7646 The callback would typically return the result of a nested
7648 user defined node created using the following function.
7650 #include <isl/ast.h>
7651 __isl_give isl_ast_node *isl_ast_node_alloc_user(
7652 __isl_take isl_ast_expr *expr);
7654 #include <isl/ast_build.h>
7655 __isl_give isl_ast_build *
7656 isl_ast_build_set_at_each_domain(
7657 __isl_take isl_ast_build *build,
7658 __isl_give isl_ast_node *(*fn)(
7659 __isl_take isl_ast_node *node,
7660 __isl_keep isl_ast_build *build,
7661 void *user), void *user);
7662 __isl_give isl_ast_build *
7663 isl_ast_build_set_before_each_for(
7664 __isl_take isl_ast_build *build,
7665 __isl_give isl_id *(*fn)(
7666 __isl_keep isl_ast_build *build,
7667 void *user), void *user);
7668 __isl_give isl_ast_build *
7669 isl_ast_build_set_after_each_for(
7670 __isl_take isl_ast_build *build,
7671 __isl_give isl_ast_node *(*fn)(
7672 __isl_take isl_ast_node *node,
7673 __isl_keep isl_ast_build *build,
7674 void *user), void *user);
7676 The callback set by C<isl_ast_build_set_at_each_domain> will
7677 be called for each domain AST node.
7678 The callbacks set by C<isl_ast_build_set_before_each_for>
7679 and C<isl_ast_build_set_after_each_for> will be called
7680 for each for AST node. The first will be called in depth-first
7681 pre-order, while the second will be called in depth-first post-order.
7682 Since C<isl_ast_build_set_before_each_for> is called before the for
7683 node is actually constructed, it is only passed an C<isl_ast_build>.
7684 The returned C<isl_id> will be added as an annotation (using
7685 C<isl_ast_node_set_annotation>) to the constructed for node.
7686 In particular, if the user has also specified an C<after_each_for>
7687 callback, then the annotation can be retrieved from the node passed to
7688 that callback using C<isl_ast_node_get_annotation>.
7689 All callbacks should C<NULL> on failure.
7690 The given C<isl_ast_build> can be used to create new
7691 C<isl_ast_expr> objects using C<isl_ast_build_expr_from_pw_aff>
7692 or C<isl_ast_build_call_from_pw_multi_aff>.
7694 =head3 Nested AST Generation
7696 C<isl> allows the user to create an AST within the context
7697 of another AST. These nested ASTs are created using the
7698 same C<isl_ast_build_ast_from_schedule> function that is used to create the
7699 outer AST. The C<build> argument should be an C<isl_ast_build>
7700 passed to a callback set by
7701 C<isl_ast_build_set_create_leaf>.
7702 The space of the range of the C<schedule> argument should refer
7703 to this build. In particular, the space should be a wrapped
7704 relation and the domain of this wrapped relation should be the
7705 same as that of the range of the schedule returned by
7706 C<isl_ast_build_get_schedule> below.
7707 In practice, the new schedule is typically
7708 created by calling C<isl_union_map_range_product> on the old schedule
7709 and some extra piece of the schedule.
7710 The space of the schedule domain is also available from
7711 the C<isl_ast_build>.
7713 #include <isl/ast_build.h>
7714 __isl_give isl_union_map *isl_ast_build_get_schedule(
7715 __isl_keep isl_ast_build *build);
7716 __isl_give isl_space *isl_ast_build_get_schedule_space(
7717 __isl_keep isl_ast_build *build);
7718 __isl_give isl_ast_build *isl_ast_build_restrict(
7719 __isl_take isl_ast_build *build,
7720 __isl_take isl_set *set);
7722 The C<isl_ast_build_get_schedule> function returns a (partial)
7723 schedule for the domains elements for which part of the AST still needs to
7724 be generated in the current build.
7725 In particular, the domain elements are mapped to those iterations of the loops
7726 enclosing the current point of the AST generation inside which
7727 the domain elements are executed.
7728 No direct correspondence between
7729 the input schedule and this schedule should be assumed.
7730 The space obtained from C<isl_ast_build_get_schedule_space> can be used
7731 to create a set for C<isl_ast_build_restrict> to intersect
7732 with the current build. In particular, the set passed to
7733 C<isl_ast_build_restrict> can have additional parameters.
7734 The ids of the set dimensions in the space returned by
7735 C<isl_ast_build_get_schedule_space> correspond to the
7736 iterators of the already generated loops.
7737 The user should not rely on the ids of the output dimensions
7738 of the relations in the union relation returned by
7739 C<isl_ast_build_get_schedule> having any particular value.
7743 Although C<isl> is mainly meant to be used as a library,
7744 it also contains some basic applications that use some
7745 of the functionality of C<isl>.
7746 The input may be specified in either the L<isl format>
7747 or the L<PolyLib format>.
7749 =head2 C<isl_polyhedron_sample>
7751 C<isl_polyhedron_sample> takes a polyhedron as input and prints
7752 an integer element of the polyhedron, if there is any.
7753 The first column in the output is the denominator and is always
7754 equal to 1. If the polyhedron contains no integer points,
7755 then a vector of length zero is printed.
7759 C<isl_pip> takes the same input as the C<example> program
7760 from the C<piplib> distribution, i.e., a set of constraints
7761 on the parameters, a line containing only -1 and finally a set
7762 of constraints on a parametric polyhedron.
7763 The coefficients of the parameters appear in the last columns
7764 (but before the final constant column).
7765 The output is the lexicographic minimum of the parametric polyhedron.
7766 As C<isl> currently does not have its own output format, the output
7767 is just a dump of the internal state.
7769 =head2 C<isl_polyhedron_minimize>
7771 C<isl_polyhedron_minimize> computes the minimum of some linear
7772 or affine objective function over the integer points in a polyhedron.
7773 If an affine objective function
7774 is given, then the constant should appear in the last column.
7776 =head2 C<isl_polytope_scan>
7778 Given a polytope, C<isl_polytope_scan> prints
7779 all integer points in the polytope.
7781 =head2 C<isl_codegen>
7783 Given a schedule, a context set and an options relation,
7784 C<isl_codegen> prints out an AST that scans the domain elements
7785 of the schedule in the order of their image(s) taking into account
7786 the constraints in the context set.