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 Initialization
357 All manipulations of integer sets and relations occur within
358 the context of an C<isl_ctx>.
359 A given C<isl_ctx> can only be used within a single thread.
360 All arguments of a function are required to have been allocated
361 within the same context.
362 There are currently no functions available for moving an object
363 from one C<isl_ctx> to another C<isl_ctx>. This means that
364 there is currently no way of safely moving an object from one
365 thread to another, unless the whole C<isl_ctx> is moved.
367 An C<isl_ctx> can be allocated using C<isl_ctx_alloc> and
368 freed using C<isl_ctx_free>.
369 All objects allocated within an C<isl_ctx> should be freed
370 before the C<isl_ctx> itself is freed.
372 isl_ctx *isl_ctx_alloc();
373 void isl_ctx_free(isl_ctx *ctx);
375 The user can impose a bound on the number of low-level I<operations>
376 that can be performed by an C<isl_ctx>. This bound can be set and
377 retrieved using the following functions. A bound of zero means that
378 no bound is imposed. The number of operations performed can be
379 reset using C<isl_ctx_reset_operations>. Note that the number
380 of low-level operations needed to perform a high-level computation
381 may differ significantly across different versions
382 of C<isl>, but it should be the same across different platforms
383 for the same version of C<isl>.
385 Warning: This feature is experimental. C<isl> has good support to abort and
386 bail out during the computation, but this feature may exercise error code paths
387 that are normally not used that much. Consequently, it is not unlikely that
388 hidden bugs will be exposed.
390 void isl_ctx_set_max_operations(isl_ctx *ctx,
391 unsigned long max_operations);
392 unsigned long isl_ctx_get_max_operations(isl_ctx *ctx);
393 void isl_ctx_reset_operations(isl_ctx *ctx);
395 =head2 Memory Management
397 Since a high-level operation on isl objects usually involves
398 several substeps and since the user is usually not interested in
399 the intermediate results, most functions that return a new object
400 will also release all the objects passed as arguments.
401 If the user still wants to use one or more of these arguments
402 after the function call, she should pass along a copy of the
403 object rather than the object itself.
404 The user is then responsible for making sure that the original
405 object gets used somewhere else or is explicitly freed.
407 The arguments and return values of all documented functions are
408 annotated to make clear which arguments are released and which
409 arguments are preserved. In particular, the following annotations
416 C<__isl_give> means that a new object is returned.
417 The user should make sure that the returned pointer is
418 used exactly once as a value for an C<__isl_take> argument.
419 In between, it can be used as a value for as many
420 C<__isl_keep> arguments as the user likes.
421 There is one exception, and that is the case where the
422 pointer returned is C<NULL>. Is this case, the user
423 is free to use it as an C<__isl_take> argument or not.
427 C<__isl_null> means that a C<NULL> value is returned.
431 C<__isl_take> means that the object the argument points to
432 is taken over by the function and may no longer be used
433 by the user as an argument to any other function.
434 The pointer value must be one returned by a function
435 returning an C<__isl_give> pointer.
436 If the user passes in a C<NULL> value, then this will
437 be treated as an error in the sense that the function will
438 not perform its usual operation. However, it will still
439 make sure that all the other C<__isl_take> arguments
444 C<__isl_keep> means that the function will only use the object
445 temporarily. After the function has finished, the user
446 can still use it as an argument to other functions.
447 A C<NULL> value will be treated in the same way as
448 a C<NULL> value for an C<__isl_take> argument.
454 An C<isl_val> represents an integer value, a rational value
455 or one of three special values, infinity, negative infinity and NaN.
456 Some predefined values can be created using the following functions.
459 __isl_give isl_val *isl_val_zero(isl_ctx *ctx);
460 __isl_give isl_val *isl_val_one(isl_ctx *ctx);
461 __isl_give isl_val *isl_val_negone(isl_ctx *ctx);
462 __isl_give isl_val *isl_val_nan(isl_ctx *ctx);
463 __isl_give isl_val *isl_val_infty(isl_ctx *ctx);
464 __isl_give isl_val *isl_val_neginfty(isl_ctx *ctx);
466 Specific integer values can be created using the following functions.
469 __isl_give isl_val *isl_val_int_from_si(isl_ctx *ctx,
471 __isl_give isl_val *isl_val_int_from_ui(isl_ctx *ctx,
473 __isl_give isl_val *isl_val_int_from_chunks(isl_ctx *ctx,
474 size_t n, size_t size, const void *chunks);
476 The function C<isl_val_int_from_chunks> constructs an C<isl_val>
477 from the C<n> I<digits>, each consisting of C<size> bytes, stored at C<chunks>.
478 The least significant digit is assumed to be stored first.
480 Value objects can be copied and freed using the following functions.
483 __isl_give isl_val *isl_val_copy(__isl_keep isl_val *v);
484 __isl_null isl_val *isl_val_free(__isl_take isl_val *v);
486 They can be inspected using the following functions.
489 isl_ctx *isl_val_get_ctx(__isl_keep isl_val *val);
490 long isl_val_get_num_si(__isl_keep isl_val *v);
491 long isl_val_get_den_si(__isl_keep isl_val *v);
492 double isl_val_get_d(__isl_keep isl_val *v);
493 size_t isl_val_n_abs_num_chunks(__isl_keep isl_val *v,
495 int isl_val_get_abs_num_chunks(__isl_keep isl_val *v,
496 size_t size, void *chunks);
498 C<isl_val_n_abs_num_chunks> returns the number of I<digits>
499 of C<size> bytes needed to store the absolute value of the
501 C<isl_val_get_abs_num_chunks> stores these digits at C<chunks>,
502 which is assumed to have been preallocated by the caller.
503 The least significant digit is stored first.
504 Note that C<isl_val_get_num_si>, C<isl_val_get_den_si>,
505 C<isl_val_get_d>, C<isl_val_n_abs_num_chunks>
506 and C<isl_val_get_abs_num_chunks> can only be applied to rational values.
508 An C<isl_val> can be modified using the following function.
511 __isl_give isl_val *isl_val_set_si(__isl_take isl_val *v,
514 The following unary properties are defined on C<isl_val>s.
517 int isl_val_sgn(__isl_keep isl_val *v);
518 int isl_val_is_zero(__isl_keep isl_val *v);
519 int isl_val_is_one(__isl_keep isl_val *v);
520 int isl_val_is_negone(__isl_keep isl_val *v);
521 int isl_val_is_nonneg(__isl_keep isl_val *v);
522 int isl_val_is_nonpos(__isl_keep isl_val *v);
523 int isl_val_is_pos(__isl_keep isl_val *v);
524 int isl_val_is_neg(__isl_keep isl_val *v);
525 int isl_val_is_int(__isl_keep isl_val *v);
526 int isl_val_is_rat(__isl_keep isl_val *v);
527 int isl_val_is_nan(__isl_keep isl_val *v);
528 int isl_val_is_infty(__isl_keep isl_val *v);
529 int isl_val_is_neginfty(__isl_keep isl_val *v);
531 Note that the sign of NaN is undefined.
533 The following binary properties are defined on pairs of C<isl_val>s.
536 int isl_val_lt(__isl_keep isl_val *v1,
537 __isl_keep isl_val *v2);
538 int isl_val_le(__isl_keep isl_val *v1,
539 __isl_keep isl_val *v2);
540 int isl_val_gt(__isl_keep isl_val *v1,
541 __isl_keep isl_val *v2);
542 int isl_val_ge(__isl_keep isl_val *v1,
543 __isl_keep isl_val *v2);
544 int isl_val_eq(__isl_keep isl_val *v1,
545 __isl_keep isl_val *v2);
546 int isl_val_ne(__isl_keep isl_val *v1,
547 __isl_keep isl_val *v2);
548 int isl_val_abs_eq(__isl_keep isl_val *v1,
549 __isl_keep isl_val *v2);
551 The function C<isl_val_abs_eq> checks whether its two arguments
552 are equal in absolute value.
554 For integer C<isl_val>s we additionally have the following binary property.
557 int isl_val_is_divisible_by(__isl_keep isl_val *v1,
558 __isl_keep isl_val *v2);
560 An C<isl_val> can also be compared to an integer using the following
561 function. The result is undefined for NaN.
564 int isl_val_cmp_si(__isl_keep isl_val *v, long i);
566 The following unary operations are available on C<isl_val>s.
569 __isl_give isl_val *isl_val_abs(__isl_take isl_val *v);
570 __isl_give isl_val *isl_val_neg(__isl_take isl_val *v);
571 __isl_give isl_val *isl_val_floor(__isl_take isl_val *v);
572 __isl_give isl_val *isl_val_ceil(__isl_take isl_val *v);
573 __isl_give isl_val *isl_val_trunc(__isl_take isl_val *v);
574 __isl_give isl_val *isl_val_2exp(__isl_take isl_val *v);
576 The following binary operations are available on C<isl_val>s.
579 __isl_give isl_val *isl_val_min(__isl_take isl_val *v1,
580 __isl_take isl_val *v2);
581 __isl_give isl_val *isl_val_max(__isl_take isl_val *v1,
582 __isl_take isl_val *v2);
583 __isl_give isl_val *isl_val_add(__isl_take isl_val *v1,
584 __isl_take isl_val *v2);
585 __isl_give isl_val *isl_val_add_ui(__isl_take isl_val *v1,
587 __isl_give isl_val *isl_val_sub(__isl_take isl_val *v1,
588 __isl_take isl_val *v2);
589 __isl_give isl_val *isl_val_sub_ui(__isl_take isl_val *v1,
591 __isl_give isl_val *isl_val_mul(__isl_take isl_val *v1,
592 __isl_take isl_val *v2);
593 __isl_give isl_val *isl_val_mul_ui(__isl_take isl_val *v1,
595 __isl_give isl_val *isl_val_div(__isl_take isl_val *v1,
596 __isl_take isl_val *v2);
598 On integer values, we additionally have the following operations.
601 __isl_give isl_val *isl_val_2exp(__isl_take isl_val *v);
602 __isl_give isl_val *isl_val_mod(__isl_take isl_val *v1,
603 __isl_take isl_val *v2);
604 __isl_give isl_val *isl_val_gcd(__isl_take isl_val *v1,
605 __isl_take isl_val *v2);
606 __isl_give isl_val *isl_val_gcdext(__isl_take isl_val *v1,
607 __isl_take isl_val *v2, __isl_give isl_val **x,
608 __isl_give isl_val **y);
610 The function C<isl_val_gcdext> returns the greatest common divisor g
611 of C<v1> and C<v2> as well as two integers C<*x> and C<*y> such
612 that C<*x> * C<v1> + C<*y> * C<v2> = g.
614 A value can be read from input using
617 __isl_give isl_val *isl_val_read_from_str(isl_ctx *ctx,
620 A value can be printed using
623 __isl_give isl_printer *isl_printer_print_val(
624 __isl_take isl_printer *p, __isl_keep isl_val *v);
626 =head3 GMP specific functions
628 These functions are only available if C<isl> has been compiled with C<GMP>
631 Specific integer and rational values can be created from C<GMP> values using
632 the following functions.
634 #include <isl/val_gmp.h>
635 __isl_give isl_val *isl_val_int_from_gmp(isl_ctx *ctx,
637 __isl_give isl_val *isl_val_from_gmp(isl_ctx *ctx,
638 const mpz_t n, const mpz_t d);
640 The numerator and denominator of a rational value can be extracted as
641 C<GMP> values using the following functions.
643 #include <isl/val_gmp.h>
644 int isl_val_get_num_gmp(__isl_keep isl_val *v, mpz_t z);
645 int isl_val_get_den_gmp(__isl_keep isl_val *v, mpz_t z);
647 =head2 Sets and Relations
649 C<isl> uses six types of objects for representing sets and relations,
650 C<isl_basic_set>, C<isl_basic_map>, C<isl_set>, C<isl_map>,
651 C<isl_union_set> and C<isl_union_map>.
652 C<isl_basic_set> and C<isl_basic_map> represent sets and relations that
653 can be described as a conjunction of affine constraints, while
654 C<isl_set> and C<isl_map> represent unions of
655 C<isl_basic_set>s and C<isl_basic_map>s, respectively.
656 However, all C<isl_basic_set>s or C<isl_basic_map>s in the union need
657 to live in the same space. C<isl_union_set>s and C<isl_union_map>s
658 represent unions of C<isl_set>s or C<isl_map>s in I<different> spaces,
659 where spaces are considered different if they have a different number
660 of dimensions and/or different names (see L<"Spaces">).
661 The difference between sets and relations (maps) is that sets have
662 one set of variables, while relations have two sets of variables,
663 input variables and output variables.
665 =head2 Error Handling
667 C<isl> supports different ways to react in case a runtime error is triggered.
668 Runtime errors arise, e.g., if a function such as C<isl_map_intersect> is called
669 with two maps that have incompatible spaces. There are three possible ways
670 to react on error: to warn, to continue or to abort.
672 The default behavior is to warn. In this mode, C<isl> prints a warning, stores
673 the last error in the corresponding C<isl_ctx> and the function in which the
674 error was triggered returns C<NULL>. An error does not corrupt internal state,
675 such that isl can continue to be used. C<isl> also provides functions to
676 read the last error and to reset the memory that stores the last error. The
677 last error is only stored for information purposes. Its presence does not
678 change the behavior of C<isl>. Hence, resetting an error is not required to
679 continue to use isl, but only to observe new errors.
682 enum isl_error isl_ctx_last_error(isl_ctx *ctx);
683 void isl_ctx_reset_error(isl_ctx *ctx);
685 Another option is to continue on error. This is similar to warn on error mode,
686 except that C<isl> does not print any warning. This allows a program to
687 implement its own error reporting.
689 The last option is to directly abort the execution of the program from within
690 the isl library. This makes it obviously impossible to recover from an error,
691 but it allows to directly spot the error location. By aborting on error,
692 debuggers break at the location the error occurred and can provide a stack
693 trace. Other tools that automatically provide stack traces on abort or that do
694 not want to continue execution after an error was triggered may also prefer to
697 The on error behavior of isl can be specified by calling
698 C<isl_options_set_on_error> or by setting the command line option
699 C<--isl-on-error>. Valid arguments for the function call are
700 C<ISL_ON_ERROR_WARN>, C<ISL_ON_ERROR_CONTINUE> and C<ISL_ON_ERROR_ABORT>. The
701 choices for the command line option are C<warn>, C<continue> and C<abort>.
702 It is also possible to query the current error mode.
704 #include <isl/options.h>
705 int isl_options_set_on_error(isl_ctx *ctx, int val);
706 int isl_options_get_on_error(isl_ctx *ctx);
710 Identifiers are used to identify both individual dimensions
711 and tuples of dimensions. They consist of an optional name and an optional
712 user pointer. The name and the user pointer cannot both be C<NULL>, however.
713 Identifiers with the same name but different pointer values
714 are considered to be distinct.
715 Similarly, identifiers with different names but the same pointer value
716 are also considered to be distinct.
717 Equal identifiers are represented using the same object.
718 Pairs of identifiers can therefore be tested for equality using the
720 Identifiers can be constructed, copied, freed, inspected and printed
721 using the following functions.
724 __isl_give isl_id *isl_id_alloc(isl_ctx *ctx,
725 __isl_keep const char *name, void *user);
726 __isl_give isl_id *isl_id_set_free_user(
727 __isl_take isl_id *id,
728 __isl_give void (*free_user)(void *user));
729 __isl_give isl_id *isl_id_copy(isl_id *id);
730 __isl_null isl_id *isl_id_free(__isl_take isl_id *id);
732 isl_ctx *isl_id_get_ctx(__isl_keep isl_id *id);
733 void *isl_id_get_user(__isl_keep isl_id *id);
734 __isl_keep const char *isl_id_get_name(__isl_keep isl_id *id);
736 __isl_give isl_printer *isl_printer_print_id(
737 __isl_take isl_printer *p, __isl_keep isl_id *id);
739 The callback set by C<isl_id_set_free_user> is called on the user
740 pointer when the last reference to the C<isl_id> is freed.
741 Note that C<isl_id_get_name> returns a pointer to some internal
742 data structure, so the result can only be used while the
743 corresponding C<isl_id> is alive.
747 Whenever a new set, relation or similar object is created from scratch,
748 the space in which it lives needs to be specified using an C<isl_space>.
749 Each space involves zero or more parameters and zero, one or two
750 tuples of set or input/output dimensions. The parameters and dimensions
751 are identified by an C<isl_dim_type> and a position.
752 The type C<isl_dim_param> refers to parameters,
753 the type C<isl_dim_set> refers to set dimensions (for spaces
754 with a single tuple of dimensions) and the types C<isl_dim_in>
755 and C<isl_dim_out> refer to input and output dimensions
756 (for spaces with two tuples of dimensions).
757 Local spaces (see L</"Local Spaces">) also contain dimensions
758 of type C<isl_dim_div>.
759 Note that parameters are only identified by their position within
760 a given object. Across different objects, parameters are (usually)
761 identified by their names or identifiers. Only unnamed parameters
762 are identified by their positions across objects. The use of unnamed
763 parameters is discouraged.
765 #include <isl/space.h>
766 __isl_give isl_space *isl_space_alloc(isl_ctx *ctx,
767 unsigned nparam, unsigned n_in, unsigned n_out);
768 __isl_give isl_space *isl_space_params_alloc(isl_ctx *ctx,
770 __isl_give isl_space *isl_space_set_alloc(isl_ctx *ctx,
771 unsigned nparam, unsigned dim);
772 __isl_give isl_space *isl_space_copy(__isl_keep isl_space *space);
773 __isl_null isl_space *isl_space_free(__isl_take isl_space *space);
775 The space used for creating a parameter domain
776 needs to be created using C<isl_space_params_alloc>.
777 For other sets, the space
778 needs to be created using C<isl_space_set_alloc>, while
779 for a relation, the space
780 needs to be created using C<isl_space_alloc>.
782 To check whether a given space is that of a set or a map
783 or whether it is a parameter space, use these functions:
785 #include <isl/space.h>
786 int isl_space_is_params(__isl_keep isl_space *space);
787 int isl_space_is_set(__isl_keep isl_space *space);
788 int isl_space_is_map(__isl_keep isl_space *space);
790 Spaces can be compared using the following functions:
792 #include <isl/space.h>
793 int isl_space_is_equal(__isl_keep isl_space *space1,
794 __isl_keep isl_space *space2);
795 int isl_space_is_domain(__isl_keep isl_space *space1,
796 __isl_keep isl_space *space2);
797 int isl_space_is_range(__isl_keep isl_space *space1,
798 __isl_keep isl_space *space2);
799 int isl_space_tuple_is_equal(
800 __isl_keep isl_space *space1,
801 enum isl_dim_type type1,
802 __isl_keep isl_space *space2,
803 enum isl_dim_type type2);
805 C<isl_space_is_domain> checks whether the first argument is equal
806 to the domain of the second argument. This requires in particular that
807 the first argument is a set space and that the second argument
808 is a map space. C<isl_space_tuple_is_equal> checks whether the given
809 tuples (C<isl_dim_in>, C<isl_dim_out> or C<isl_dim_set>) of the given
810 spaces are the same. That is, it checks if they have the same
811 identifier (if any), the same dimension and the same internal structure
814 It is often useful to create objects that live in the
815 same space as some other object. This can be accomplished
816 by creating the new objects
817 (see L</"Creating New Sets and Relations"> or
818 L</"Creating New (Piecewise) Quasipolynomials">) based on the space
819 of the original object.
822 __isl_give isl_space *isl_basic_set_get_space(
823 __isl_keep isl_basic_set *bset);
824 __isl_give isl_space *isl_set_get_space(__isl_keep isl_set *set);
826 #include <isl/union_set.h>
827 __isl_give isl_space *isl_union_set_get_space(
828 __isl_keep isl_union_set *uset);
831 __isl_give isl_space *isl_basic_map_get_space(
832 __isl_keep isl_basic_map *bmap);
833 __isl_give isl_space *isl_map_get_space(__isl_keep isl_map *map);
835 #include <isl/union_map.h>
836 __isl_give isl_space *isl_union_map_get_space(
837 __isl_keep isl_union_map *umap);
839 #include <isl/constraint.h>
840 __isl_give isl_space *isl_constraint_get_space(
841 __isl_keep isl_constraint *constraint);
843 #include <isl/polynomial.h>
844 __isl_give isl_space *isl_qpolynomial_get_domain_space(
845 __isl_keep isl_qpolynomial *qp);
846 __isl_give isl_space *isl_qpolynomial_get_space(
847 __isl_keep isl_qpolynomial *qp);
848 __isl_give isl_space *isl_qpolynomial_fold_get_space(
849 __isl_keep isl_qpolynomial_fold *fold);
850 __isl_give isl_space *isl_pw_qpolynomial_get_domain_space(
851 __isl_keep isl_pw_qpolynomial *pwqp);
852 __isl_give isl_space *isl_pw_qpolynomial_get_space(
853 __isl_keep isl_pw_qpolynomial *pwqp);
854 __isl_give isl_space *isl_pw_qpolynomial_fold_get_domain_space(
855 __isl_keep isl_pw_qpolynomial_fold *pwf);
856 __isl_give isl_space *isl_pw_qpolynomial_fold_get_space(
857 __isl_keep isl_pw_qpolynomial_fold *pwf);
858 __isl_give isl_space *isl_union_pw_qpolynomial_get_space(
859 __isl_keep isl_union_pw_qpolynomial *upwqp);
860 __isl_give isl_space *isl_union_pw_qpolynomial_fold_get_space(
861 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
864 __isl_give isl_space *isl_multi_val_get_space(
865 __isl_keep isl_multi_val *mv);
868 __isl_give isl_space *isl_aff_get_domain_space(
869 __isl_keep isl_aff *aff);
870 __isl_give isl_space *isl_aff_get_space(
871 __isl_keep isl_aff *aff);
872 __isl_give isl_space *isl_pw_aff_get_domain_space(
873 __isl_keep isl_pw_aff *pwaff);
874 __isl_give isl_space *isl_pw_aff_get_space(
875 __isl_keep isl_pw_aff *pwaff);
876 __isl_give isl_space *isl_multi_aff_get_domain_space(
877 __isl_keep isl_multi_aff *maff);
878 __isl_give isl_space *isl_multi_aff_get_space(
879 __isl_keep isl_multi_aff *maff);
880 __isl_give isl_space *isl_pw_multi_aff_get_domain_space(
881 __isl_keep isl_pw_multi_aff *pma);
882 __isl_give isl_space *isl_pw_multi_aff_get_space(
883 __isl_keep isl_pw_multi_aff *pma);
884 __isl_give isl_space *isl_union_pw_multi_aff_get_space(
885 __isl_keep isl_union_pw_multi_aff *upma);
886 __isl_give isl_space *isl_multi_pw_aff_get_domain_space(
887 __isl_keep isl_multi_pw_aff *mpa);
888 __isl_give isl_space *isl_multi_pw_aff_get_space(
889 __isl_keep isl_multi_pw_aff *mpa);
891 #include <isl/point.h>
892 __isl_give isl_space *isl_point_get_space(
893 __isl_keep isl_point *pnt);
895 The number of dimensions of a given type of space
896 may be read off from a space or an object that lives
897 in a space using the following functions.
898 In case of C<isl_space_dim>, type may be
899 C<isl_dim_param>, C<isl_dim_in> (only for relations),
900 C<isl_dim_out> (only for relations), C<isl_dim_set>
901 (only for sets) or C<isl_dim_all>.
903 #include <isl/space.h>
904 unsigned isl_space_dim(__isl_keep isl_space *space,
905 enum isl_dim_type type);
907 #include <isl/local_space.h>
908 int isl_local_space_dim(__isl_keep isl_local_space *ls,
909 enum isl_dim_type type);
912 unsigned isl_basic_set_dim(__isl_keep isl_basic_set *bset,
913 enum isl_dim_type type);
914 unsigned isl_set_dim(__isl_keep isl_set *set,
915 enum isl_dim_type type);
918 unsigned isl_basic_map_dim(__isl_keep isl_basic_map *bmap,
919 enum isl_dim_type type);
920 unsigned isl_map_dim(__isl_keep isl_map *map,
921 enum isl_dim_type type);
923 #include <isl/union_map.h>
924 unsigned isl_union_map_dim(__isl_keep isl_union_map *umap,
925 enum isl_dim_type type);
928 unsigned isl_multi_val_dim(__isl_keep isl_multi_val *mv,
929 enum isl_dim_type type);
932 int isl_aff_dim(__isl_keep isl_aff *aff,
933 enum isl_dim_type type);
934 unsigned isl_multi_aff_dim(__isl_keep isl_multi_aff *maff,
935 enum isl_dim_type type);
936 unsigned isl_pw_aff_dim(__isl_keep isl_pw_aff *pwaff,
937 enum isl_dim_type type);
938 unsigned isl_pw_multi_aff_dim(
939 __isl_keep isl_pw_multi_aff *pma,
940 enum isl_dim_type type);
941 unsigned isl_multi_pw_aff_dim(
942 __isl_keep isl_multi_pw_aff *mpa,
943 enum isl_dim_type type);
945 Note that an C<isl_union_map> only has parameters.
947 The identifiers or names of the individual dimensions of spaces
948 may be set or read off using the following functions on spaces
949 or objects that live in spaces.
950 These functions are mostly useful to obtain the identifiers, positions
951 or names of the parameters. Identifiers of individual dimensions are
952 essentially only useful for printing. They are ignored by all other
953 operations and may not be preserved across those operations.
955 #include <isl/space.h>
956 __isl_give isl_space *isl_space_set_dim_id(
957 __isl_take isl_space *space,
958 enum isl_dim_type type, unsigned pos,
959 __isl_take isl_id *id);
960 int isl_space_has_dim_id(__isl_keep isl_space *space,
961 enum isl_dim_type type, unsigned pos);
962 __isl_give isl_id *isl_space_get_dim_id(
963 __isl_keep isl_space *space,
964 enum isl_dim_type type, unsigned pos);
965 __isl_give isl_space *isl_space_set_dim_name(
966 __isl_take isl_space *space,
967 enum isl_dim_type type, unsigned pos,
968 __isl_keep const char *name);
969 int isl_space_has_dim_name(__isl_keep isl_space *space,
970 enum isl_dim_type type, unsigned pos);
971 __isl_keep const char *isl_space_get_dim_name(
972 __isl_keep isl_space *space,
973 enum isl_dim_type type, unsigned pos);
975 #include <isl/local_space.h>
976 __isl_give isl_local_space *isl_local_space_set_dim_id(
977 __isl_take isl_local_space *ls,
978 enum isl_dim_type type, unsigned pos,
979 __isl_take isl_id *id);
980 int isl_local_space_has_dim_id(
981 __isl_keep isl_local_space *ls,
982 enum isl_dim_type type, unsigned pos);
983 __isl_give isl_id *isl_local_space_get_dim_id(
984 __isl_keep isl_local_space *ls,
985 enum isl_dim_type type, unsigned pos);
986 __isl_give isl_local_space *isl_local_space_set_dim_name(
987 __isl_take isl_local_space *ls,
988 enum isl_dim_type type, unsigned pos, const char *s);
989 int isl_local_space_has_dim_name(
990 __isl_keep isl_local_space *ls,
991 enum isl_dim_type type, unsigned pos)
992 const char *isl_local_space_get_dim_name(
993 __isl_keep isl_local_space *ls,
994 enum isl_dim_type type, unsigned pos);
996 #include <isl/constraint.h>
997 const char *isl_constraint_get_dim_name(
998 __isl_keep isl_constraint *constraint,
999 enum isl_dim_type type, unsigned pos);
1001 #include <isl/set.h>
1002 __isl_give isl_id *isl_basic_set_get_dim_id(
1003 __isl_keep isl_basic_set *bset,
1004 enum isl_dim_type type, unsigned pos);
1005 __isl_give isl_set *isl_set_set_dim_id(
1006 __isl_take isl_set *set, enum isl_dim_type type,
1007 unsigned pos, __isl_take isl_id *id);
1008 int isl_set_has_dim_id(__isl_keep isl_set *set,
1009 enum isl_dim_type type, unsigned pos);
1010 __isl_give isl_id *isl_set_get_dim_id(
1011 __isl_keep isl_set *set, enum isl_dim_type type,
1013 const char *isl_basic_set_get_dim_name(
1014 __isl_keep isl_basic_set *bset,
1015 enum isl_dim_type type, unsigned pos);
1016 int isl_set_has_dim_name(__isl_keep isl_set *set,
1017 enum isl_dim_type type, unsigned pos);
1018 const char *isl_set_get_dim_name(
1019 __isl_keep isl_set *set,
1020 enum isl_dim_type type, unsigned pos);
1022 #include <isl/map.h>
1023 __isl_give isl_map *isl_map_set_dim_id(
1024 __isl_take isl_map *map, enum isl_dim_type type,
1025 unsigned pos, __isl_take isl_id *id);
1026 int isl_basic_map_has_dim_id(
1027 __isl_keep isl_basic_map *bmap,
1028 enum isl_dim_type type, unsigned pos);
1029 int isl_map_has_dim_id(__isl_keep isl_map *map,
1030 enum isl_dim_type type, unsigned pos);
1031 __isl_give isl_id *isl_map_get_dim_id(
1032 __isl_keep isl_map *map, enum isl_dim_type type,
1034 __isl_give isl_id *isl_union_map_get_dim_id(
1035 __isl_keep isl_union_map *umap,
1036 enum isl_dim_type type, unsigned pos);
1037 const char *isl_basic_map_get_dim_name(
1038 __isl_keep isl_basic_map *bmap,
1039 enum isl_dim_type type, unsigned pos);
1040 int isl_map_has_dim_name(__isl_keep isl_map *map,
1041 enum isl_dim_type type, unsigned pos);
1042 const char *isl_map_get_dim_name(
1043 __isl_keep isl_map *map,
1044 enum isl_dim_type type, unsigned pos);
1046 #include <isl/val.h>
1047 __isl_give isl_multi_val *isl_multi_val_set_dim_id(
1048 __isl_take isl_multi_val *mv,
1049 enum isl_dim_type type, unsigned pos,
1050 __isl_take isl_id *id);
1051 __isl_give isl_id *isl_multi_val_get_dim_id(
1052 __isl_keep isl_multi_val *mv,
1053 enum isl_dim_type type, unsigned pos);
1054 __isl_give isl_multi_val *isl_multi_val_set_dim_name(
1055 __isl_take isl_multi_val *mv,
1056 enum isl_dim_type type, unsigned pos, const char *s);
1058 #include <isl/aff.h>
1059 __isl_give isl_aff *isl_aff_set_dim_id(
1060 __isl_take isl_aff *aff, enum isl_dim_type type,
1061 unsigned pos, __isl_take isl_id *id);
1062 __isl_give isl_multi_aff *isl_multi_aff_set_dim_id(
1063 __isl_take isl_multi_aff *maff,
1064 enum isl_dim_type type, unsigned pos,
1065 __isl_take isl_id *id);
1066 __isl_give isl_pw_aff *isl_pw_aff_set_dim_id(
1067 __isl_take isl_pw_aff *pma,
1068 enum isl_dim_type type, unsigned pos,
1069 __isl_take isl_id *id);
1070 __isl_give isl_multi_pw_aff *
1071 isl_multi_pw_aff_set_dim_id(
1072 __isl_take isl_multi_pw_aff *mpa,
1073 enum isl_dim_type type, unsigned pos,
1074 __isl_take isl_id *id);
1075 __isl_give isl_id *isl_multi_aff_get_dim_id(
1076 __isl_keep isl_multi_aff *ma,
1077 enum isl_dim_type type, unsigned pos);
1078 int isl_pw_aff_has_dim_id(__isl_keep isl_pw_aff *pa,
1079 enum isl_dim_type type, unsigned pos);
1080 __isl_give isl_id *isl_pw_aff_get_dim_id(
1081 __isl_keep isl_pw_aff *pa,
1082 enum isl_dim_type type, unsigned pos);
1083 __isl_give isl_id *isl_pw_multi_aff_get_dim_id(
1084 __isl_keep isl_pw_multi_aff *pma,
1085 enum isl_dim_type type, unsigned pos);
1086 __isl_give isl_id *isl_multi_pw_aff_get_dim_id(
1087 __isl_keep isl_multi_pw_aff *mpa,
1088 enum isl_dim_type type, unsigned pos);
1089 __isl_give isl_aff *isl_aff_set_dim_name(
1090 __isl_take isl_aff *aff, enum isl_dim_type type,
1091 unsigned pos, const char *s);
1092 __isl_give isl_multi_aff *isl_multi_aff_set_dim_name(
1093 __isl_take isl_multi_aff *maff,
1094 enum isl_dim_type type, unsigned pos, const char *s);
1095 __isl_give isl_multi_pw_aff *
1096 isl_multi_pw_aff_set_dim_name(
1097 __isl_take isl_multi_pw_aff *mpa,
1098 enum isl_dim_type type, unsigned pos, const char *s);
1099 const char *isl_aff_get_dim_name(__isl_keep isl_aff *aff,
1100 enum isl_dim_type type, unsigned pos);
1101 const char *isl_pw_aff_get_dim_name(
1102 __isl_keep isl_pw_aff *pa,
1103 enum isl_dim_type type, unsigned pos);
1104 const char *isl_pw_multi_aff_get_dim_name(
1105 __isl_keep isl_pw_multi_aff *pma,
1106 enum isl_dim_type type, unsigned pos);
1108 #include <isl/polynomial.h>
1109 __isl_give isl_qpolynomial *isl_qpolynomial_set_dim_name(
1110 __isl_take isl_qpolynomial *qp,
1111 enum isl_dim_type type, unsigned pos,
1113 __isl_give isl_pw_qpolynomial *
1114 isl_pw_qpolynomial_set_dim_name(
1115 __isl_take isl_pw_qpolynomial *pwqp,
1116 enum isl_dim_type type, unsigned pos,
1118 __isl_give isl_pw_qpolynomial_fold *
1119 isl_pw_qpolynomial_fold_set_dim_name(
1120 __isl_take isl_pw_qpolynomial_fold *pwf,
1121 enum isl_dim_type type, unsigned pos,
1124 Note that C<isl_space_get_name> returns a pointer to some internal
1125 data structure, so the result can only be used while the
1126 corresponding C<isl_space> is alive.
1127 Also note that every function that operates on two sets or relations
1128 requires that both arguments have the same parameters. This also
1129 means that if one of the arguments has named parameters, then the
1130 other needs to have named parameters too and the names need to match.
1131 Pairs of C<isl_set>, C<isl_map>, C<isl_union_set> and/or C<isl_union_map>
1132 arguments may have different parameters (as long as they are named),
1133 in which case the result will have as parameters the union of the parameters of
1136 Given the identifier or name of a dimension (typically a parameter),
1137 its position can be obtained from the following functions.
1139 #include <isl/space.h>
1140 int isl_space_find_dim_by_id(__isl_keep isl_space *space,
1141 enum isl_dim_type type, __isl_keep isl_id *id);
1142 int isl_space_find_dim_by_name(__isl_keep isl_space *space,
1143 enum isl_dim_type type, const char *name);
1145 #include <isl/val.h>
1146 int isl_multi_val_find_dim_by_id(
1147 __isl_keep isl_multi_val *mv,
1148 enum isl_dim_type type, __isl_keep isl_id *id);
1150 #include <isl/set.h>
1151 int isl_set_find_dim_by_id(__isl_keep isl_set *set,
1152 enum isl_dim_type type, __isl_keep isl_id *id);
1153 int isl_set_find_dim_by_name(__isl_keep isl_set *set,
1154 enum isl_dim_type type, const char *name);
1156 #include <isl/map.h>
1157 int isl_map_find_dim_by_id(__isl_keep isl_map *map,
1158 enum isl_dim_type type, __isl_keep isl_id *id);
1159 int isl_map_find_dim_by_name(__isl_keep isl_map *map,
1160 enum isl_dim_type type, const char *name);
1162 #include <isl/aff.h>
1163 int isl_multi_aff_find_dim_by_id(
1164 __isl_keep isl_multi_aff *ma,
1165 enum isl_dim_type type, __isl_keep isl_id *id);
1166 int isl_multi_pw_aff_find_dim_by_id(
1167 __isl_keep isl_multi_pw_aff *mpa,
1168 enum isl_dim_type type, __isl_keep isl_id *id);
1170 The identifiers or names of entire spaces may be set or read off
1171 using the following functions.
1173 #include <isl/space.h>
1174 __isl_give isl_space *isl_space_set_tuple_id(
1175 __isl_take isl_space *space,
1176 enum isl_dim_type type, __isl_take isl_id *id);
1177 __isl_give isl_space *isl_space_reset_tuple_id(
1178 __isl_take isl_space *space, enum isl_dim_type type);
1179 int isl_space_has_tuple_id(__isl_keep isl_space *space,
1180 enum isl_dim_type type);
1181 __isl_give isl_id *isl_space_get_tuple_id(
1182 __isl_keep isl_space *space, enum isl_dim_type type);
1183 __isl_give isl_space *isl_space_set_tuple_name(
1184 __isl_take isl_space *space,
1185 enum isl_dim_type type, const char *s);
1186 int isl_space_has_tuple_name(__isl_keep isl_space *space,
1187 enum isl_dim_type type);
1188 const char *isl_space_get_tuple_name(__isl_keep isl_space *space,
1189 enum isl_dim_type type);
1191 #include <isl/local_space.h>
1192 __isl_give isl_local_space *isl_local_space_set_tuple_id(
1193 __isl_take isl_local_space *ls,
1194 enum isl_dim_type type, __isl_take isl_id *id);
1196 #include <isl/set.h>
1197 __isl_give isl_basic_set *isl_basic_set_set_tuple_id(
1198 __isl_take isl_basic_set *bset,
1199 __isl_take isl_id *id);
1200 __isl_give isl_set *isl_set_set_tuple_id(
1201 __isl_take isl_set *set, __isl_take isl_id *id);
1202 __isl_give isl_set *isl_set_reset_tuple_id(
1203 __isl_take isl_set *set);
1204 int isl_set_has_tuple_id(__isl_keep isl_set *set);
1205 __isl_give isl_id *isl_set_get_tuple_id(
1206 __isl_keep isl_set *set);
1207 __isl_give isl_basic_set *isl_basic_set_set_tuple_name(
1208 __isl_take isl_basic_set *set, const char *s);
1209 __isl_give isl_set *isl_set_set_tuple_name(
1210 __isl_take isl_set *set, const char *s);
1211 const char *isl_basic_set_get_tuple_name(
1212 __isl_keep isl_basic_set *bset);
1213 int isl_set_has_tuple_name(__isl_keep isl_set *set);
1214 const char *isl_set_get_tuple_name(
1215 __isl_keep isl_set *set);
1217 #include <isl/map.h>
1218 __isl_give isl_basic_map *isl_basic_map_set_tuple_id(
1219 __isl_take isl_basic_map *bmap,
1220 enum isl_dim_type type, __isl_take isl_id *id);
1221 __isl_give isl_map *isl_map_set_tuple_id(
1222 __isl_take isl_map *map, enum isl_dim_type type,
1223 __isl_take isl_id *id);
1224 __isl_give isl_map *isl_map_reset_tuple_id(
1225 __isl_take isl_map *map, enum isl_dim_type type);
1226 int isl_map_has_tuple_id(__isl_keep isl_map *map,
1227 enum isl_dim_type type);
1228 __isl_give isl_id *isl_map_get_tuple_id(
1229 __isl_keep isl_map *map, enum isl_dim_type type);
1230 __isl_give isl_map *isl_map_set_tuple_name(
1231 __isl_take isl_map *map,
1232 enum isl_dim_type type, const char *s);
1233 const char *isl_basic_map_get_tuple_name(
1234 __isl_keep isl_basic_map *bmap,
1235 enum isl_dim_type type);
1236 __isl_give isl_basic_map *isl_basic_map_set_tuple_name(
1237 __isl_take isl_basic_map *bmap,
1238 enum isl_dim_type type, const char *s);
1239 int isl_map_has_tuple_name(__isl_keep isl_map *map,
1240 enum isl_dim_type type);
1241 const char *isl_map_get_tuple_name(
1242 __isl_keep isl_map *map,
1243 enum isl_dim_type type);
1245 #include <isl/val.h>
1246 __isl_give isl_multi_val *isl_multi_val_set_tuple_id(
1247 __isl_take isl_multi_val *mv,
1248 enum isl_dim_type type, __isl_take isl_id *id);
1249 __isl_give isl_multi_val *isl_multi_val_reset_tuple_id(
1250 __isl_take isl_multi_val *mv,
1251 enum isl_dim_type type);
1252 int isl_multi_val_has_tuple_id(__isl_keep isl_multi_val *mv,
1253 enum isl_dim_type type);
1254 __isl_give isl_id *isl_multi_val_get_tuple_id(
1255 __isl_keep isl_multi_val *mv,
1256 enum isl_dim_type type);
1257 __isl_give isl_multi_val *isl_multi_val_set_tuple_name(
1258 __isl_take isl_multi_val *mv,
1259 enum isl_dim_type type, const char *s);
1260 const char *isl_multi_val_get_tuple_name(
1261 __isl_keep isl_multi_val *mv,
1262 enum isl_dim_type type);
1264 #include <isl/aff.h>
1265 __isl_give isl_aff *isl_aff_set_tuple_id(
1266 __isl_take isl_aff *aff,
1267 enum isl_dim_type type, __isl_take isl_id *id);
1268 __isl_give isl_multi_aff *isl_multi_aff_set_tuple_id(
1269 __isl_take isl_multi_aff *maff,
1270 enum isl_dim_type type, __isl_take isl_id *id);
1271 __isl_give isl_pw_aff *isl_pw_aff_set_tuple_id(
1272 __isl_take isl_pw_aff *pwaff,
1273 enum isl_dim_type type, __isl_take isl_id *id);
1274 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_tuple_id(
1275 __isl_take isl_pw_multi_aff *pma,
1276 enum isl_dim_type type, __isl_take isl_id *id);
1277 __isl_give isl_multi_aff *isl_multi_aff_reset_tuple_id(
1278 __isl_take isl_multi_aff *ma,
1279 enum isl_dim_type type);
1280 __isl_give isl_pw_aff *isl_pw_aff_reset_tuple_id(
1281 __isl_take isl_pw_aff *pa,
1282 enum isl_dim_type type);
1283 __isl_give isl_multi_pw_aff *
1284 isl_multi_pw_aff_reset_tuple_id(
1285 __isl_take isl_multi_pw_aff *mpa,
1286 enum isl_dim_type type);
1287 int isl_multi_aff_has_tuple_id(__isl_keep isl_multi_aff *ma,
1288 enum isl_dim_type type);
1289 __isl_give isl_id *isl_multi_aff_get_tuple_id(
1290 __isl_keep isl_multi_aff *ma,
1291 enum isl_dim_type type);
1292 int isl_pw_aff_has_tuple_id(__isl_keep isl_pw_aff *pa,
1293 enum isl_dim_type type);
1294 __isl_give isl_id *isl_pw_aff_get_tuple_id(
1295 __isl_keep isl_pw_aff *pa,
1296 enum isl_dim_type type);
1297 int isl_pw_multi_aff_has_tuple_id(
1298 __isl_keep isl_pw_multi_aff *pma,
1299 enum isl_dim_type type);
1300 __isl_give isl_id *isl_pw_multi_aff_get_tuple_id(
1301 __isl_keep isl_pw_multi_aff *pma,
1302 enum isl_dim_type type);
1303 int isl_multi_pw_aff_has_tuple_id(
1304 __isl_keep isl_multi_pw_aff *mpa,
1305 enum isl_dim_type type);
1306 __isl_give isl_id *isl_multi_pw_aff_get_tuple_id(
1307 __isl_keep isl_multi_pw_aff *mpa,
1308 enum isl_dim_type type);
1309 __isl_give isl_multi_aff *isl_multi_aff_set_tuple_name(
1310 __isl_take isl_multi_aff *maff,
1311 enum isl_dim_type type, const char *s);
1312 __isl_give isl_multi_pw_aff *
1313 isl_multi_pw_aff_set_tuple_name(
1314 __isl_take isl_multi_pw_aff *mpa,
1315 enum isl_dim_type type, const char *s);
1316 const char *isl_multi_aff_get_tuple_name(
1317 __isl_keep isl_multi_aff *multi,
1318 enum isl_dim_type type);
1319 int isl_pw_multi_aff_has_tuple_name(
1320 __isl_keep isl_pw_multi_aff *pma,
1321 enum isl_dim_type type);
1322 const char *isl_pw_multi_aff_get_tuple_name(
1323 __isl_keep isl_pw_multi_aff *pma,
1324 enum isl_dim_type type);
1326 The C<type> argument needs to be one of C<isl_dim_in>, C<isl_dim_out>
1327 or C<isl_dim_set>. As with C<isl_space_get_name>,
1328 the C<isl_space_get_tuple_name> function returns a pointer to some internal
1330 Binary operations require the corresponding spaces of their arguments
1331 to have the same name.
1333 To keep the names of all parameters and tuples, but reset the user pointers
1334 of all the corresponding identifiers, use the following function.
1336 #include <isl/space.h>
1337 __isl_give isl_space *isl_space_reset_user(
1338 __isl_take isl_space *space);
1340 #include <isl/set.h>
1341 __isl_give isl_set *isl_set_reset_user(
1342 __isl_take isl_set *set);
1344 #include <isl/map.h>
1345 __isl_give isl_map *isl_map_reset_user(
1346 __isl_take isl_map *map);
1348 #include <isl/union_set.h>
1349 __isl_give isl_union_set *isl_union_set_reset_user(
1350 __isl_take isl_union_set *uset);
1352 #include <isl/union_map.h>
1353 __isl_give isl_union_map *isl_union_map_reset_user(
1354 __isl_take isl_union_map *umap);
1356 #include <isl/val.h>
1357 __isl_give isl_multi_val *isl_multi_val_reset_user(
1358 __isl_take isl_multi_val *mv);
1360 #include <isl/aff.h>
1361 __isl_give isl_multi_aff *isl_multi_aff_reset_user(
1362 __isl_take isl_multi_aff *ma);
1363 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_reset_user(
1364 __isl_take isl_multi_pw_aff *mpa);
1366 Spaces can be nested. In particular, the domain of a set or
1367 the domain or range of a relation can be a nested relation.
1368 This process is also called I<wrapping>.
1369 The functions for detecting, constructing and deconstructing
1370 such nested spaces can be found in the wrapping properties
1371 of L</"Unary Properties">, the wrapping operations
1372 of L</"Unary Operations"> and the Cartesian product operations
1373 of L</"Basic Operations">.
1375 Spaces can be created from other spaces
1376 using the functions described in L</"Unary Operations">
1377 and L</"Binary Operations">.
1381 A local space is essentially a space with
1382 zero or more existentially quantified variables.
1383 The local space of a (constraint of a) basic set or relation can be obtained
1384 using the following functions.
1386 #include <isl/constraint.h>
1387 __isl_give isl_local_space *isl_constraint_get_local_space(
1388 __isl_keep isl_constraint *constraint);
1390 #include <isl/set.h>
1391 __isl_give isl_local_space *isl_basic_set_get_local_space(
1392 __isl_keep isl_basic_set *bset);
1394 #include <isl/map.h>
1395 __isl_give isl_local_space *isl_basic_map_get_local_space(
1396 __isl_keep isl_basic_map *bmap);
1398 A new local space can be created from a space using
1400 #include <isl/local_space.h>
1401 __isl_give isl_local_space *isl_local_space_from_space(
1402 __isl_take isl_space *space);
1404 They can be inspected, modified, copied and freed using the following functions.
1406 #include <isl/local_space.h>
1407 isl_ctx *isl_local_space_get_ctx(
1408 __isl_keep isl_local_space *ls);
1409 int isl_local_space_is_set(__isl_keep isl_local_space *ls);
1410 __isl_give isl_space *isl_local_space_get_space(
1411 __isl_keep isl_local_space *ls);
1412 __isl_give isl_aff *isl_local_space_get_div(
1413 __isl_keep isl_local_space *ls, int pos);
1414 __isl_give isl_local_space *isl_local_space_copy(
1415 __isl_keep isl_local_space *ls);
1416 __isl_null isl_local_space *isl_local_space_free(
1417 __isl_take isl_local_space *ls);
1419 Note that C<isl_local_space_get_div> can only be used on local spaces
1422 Two local spaces can be compared using
1424 int isl_local_space_is_equal(__isl_keep isl_local_space *ls1,
1425 __isl_keep isl_local_space *ls2);
1427 Local spaces can be created from other local spaces
1428 using the functions described in L</"Unary Operations">
1429 and L</"Binary Operations">.
1431 =head2 Input and Output
1433 C<isl> supports its own input/output format, which is similar
1434 to the C<Omega> format, but also supports the C<PolyLib> format
1437 =head3 C<isl> format
1439 The C<isl> format is similar to that of C<Omega>, but has a different
1440 syntax for describing the parameters and allows for the definition
1441 of an existentially quantified variable as the integer division
1442 of an affine expression.
1443 For example, the set of integers C<i> between C<0> and C<n>
1444 such that C<i % 10 <= 6> can be described as
1446 [n] -> { [i] : exists (a = [i/10] : 0 <= i and i <= n and
1449 A set or relation can have several disjuncts, separated
1450 by the keyword C<or>. Each disjunct is either a conjunction
1451 of constraints or a projection (C<exists>) of a conjunction
1452 of constraints. The constraints are separated by the keyword
1455 =head3 C<PolyLib> format
1457 If the represented set is a union, then the first line
1458 contains a single number representing the number of disjuncts.
1459 Otherwise, a line containing the number C<1> is optional.
1461 Each disjunct is represented by a matrix of constraints.
1462 The first line contains two numbers representing
1463 the number of rows and columns,
1464 where the number of rows is equal to the number of constraints
1465 and the number of columns is equal to two plus the number of variables.
1466 The following lines contain the actual rows of the constraint matrix.
1467 In each row, the first column indicates whether the constraint
1468 is an equality (C<0>) or inequality (C<1>). The final column
1469 corresponds to the constant term.
1471 If the set is parametric, then the coefficients of the parameters
1472 appear in the last columns before the constant column.
1473 The coefficients of any existentially quantified variables appear
1474 between those of the set variables and those of the parameters.
1476 =head3 Extended C<PolyLib> format
1478 The extended C<PolyLib> format is nearly identical to the
1479 C<PolyLib> format. The only difference is that the line
1480 containing the number of rows and columns of a constraint matrix
1481 also contains four additional numbers:
1482 the number of output dimensions, the number of input dimensions,
1483 the number of local dimensions (i.e., the number of existentially
1484 quantified variables) and the number of parameters.
1485 For sets, the number of ``output'' dimensions is equal
1486 to the number of set dimensions, while the number of ``input''
1491 #include <isl/set.h>
1492 __isl_give isl_basic_set *isl_basic_set_read_from_file(
1493 isl_ctx *ctx, FILE *input);
1494 __isl_give isl_basic_set *isl_basic_set_read_from_str(
1495 isl_ctx *ctx, const char *str);
1496 __isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx,
1498 __isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx,
1501 #include <isl/map.h>
1502 __isl_give isl_basic_map *isl_basic_map_read_from_file(
1503 isl_ctx *ctx, FILE *input);
1504 __isl_give isl_basic_map *isl_basic_map_read_from_str(
1505 isl_ctx *ctx, const char *str);
1506 __isl_give isl_map *isl_map_read_from_file(
1507 isl_ctx *ctx, FILE *input);
1508 __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx,
1511 #include <isl/union_set.h>
1512 __isl_give isl_union_set *isl_union_set_read_from_file(
1513 isl_ctx *ctx, FILE *input);
1514 __isl_give isl_union_set *isl_union_set_read_from_str(
1515 isl_ctx *ctx, const char *str);
1517 #include <isl/union_map.h>
1518 __isl_give isl_union_map *isl_union_map_read_from_file(
1519 isl_ctx *ctx, FILE *input);
1520 __isl_give isl_union_map *isl_union_map_read_from_str(
1521 isl_ctx *ctx, const char *str);
1523 The input format is autodetected and may be either the C<PolyLib> format
1524 or the C<isl> format.
1528 Before anything can be printed, an C<isl_printer> needs to
1531 __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx,
1533 __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx);
1534 __isl_null isl_printer *isl_printer_free(
1535 __isl_take isl_printer *printer);
1536 __isl_give char *isl_printer_get_str(
1537 __isl_keep isl_printer *printer);
1539 The printer can be inspected using the following functions.
1541 FILE *isl_printer_get_file(
1542 __isl_keep isl_printer *printer);
1543 int isl_printer_get_output_format(
1544 __isl_keep isl_printer *p);
1546 The behavior of the printer can be modified in various ways
1548 __isl_give isl_printer *isl_printer_set_output_format(
1549 __isl_take isl_printer *p, int output_format);
1550 __isl_give isl_printer *isl_printer_set_indent(
1551 __isl_take isl_printer *p, int indent);
1552 __isl_give isl_printer *isl_printer_set_indent_prefix(
1553 __isl_take isl_printer *p, const char *prefix);
1554 __isl_give isl_printer *isl_printer_indent(
1555 __isl_take isl_printer *p, int indent);
1556 __isl_give isl_printer *isl_printer_set_prefix(
1557 __isl_take isl_printer *p, const char *prefix);
1558 __isl_give isl_printer *isl_printer_set_suffix(
1559 __isl_take isl_printer *p, const char *suffix);
1561 The C<output_format> may be either C<ISL_FORMAT_ISL>, C<ISL_FORMAT_OMEGA>,
1562 C<ISL_FORMAT_POLYLIB>, C<ISL_FORMAT_EXT_POLYLIB> or C<ISL_FORMAT_LATEX>
1563 and defaults to C<ISL_FORMAT_ISL>.
1564 Each line in the output is prefixed by C<indent_prefix>,
1565 indented by C<indent> (set by C<isl_printer_set_indent>) spaces
1566 (default: 0), prefixed by C<prefix> and suffixed by C<suffix>.
1567 In the C<PolyLib> format output,
1568 the coefficients of the existentially quantified variables
1569 appear between those of the set variables and those
1571 The function C<isl_printer_indent> increases the indentation
1572 by the specified amount (which may be negative).
1574 To actually print something, use
1576 #include <isl/printer.h>
1577 __isl_give isl_printer *isl_printer_print_double(
1578 __isl_take isl_printer *p, double d);
1580 #include <isl/set.h>
1581 __isl_give isl_printer *isl_printer_print_basic_set(
1582 __isl_take isl_printer *printer,
1583 __isl_keep isl_basic_set *bset);
1584 __isl_give isl_printer *isl_printer_print_set(
1585 __isl_take isl_printer *printer,
1586 __isl_keep isl_set *set);
1588 #include <isl/map.h>
1589 __isl_give isl_printer *isl_printer_print_basic_map(
1590 __isl_take isl_printer *printer,
1591 __isl_keep isl_basic_map *bmap);
1592 __isl_give isl_printer *isl_printer_print_map(
1593 __isl_take isl_printer *printer,
1594 __isl_keep isl_map *map);
1596 #include <isl/union_set.h>
1597 __isl_give isl_printer *isl_printer_print_union_set(
1598 __isl_take isl_printer *p,
1599 __isl_keep isl_union_set *uset);
1601 #include <isl/union_map.h>
1602 __isl_give isl_printer *isl_printer_print_union_map(
1603 __isl_take isl_printer *p,
1604 __isl_keep isl_union_map *umap);
1606 When called on a file printer, the following function flushes
1607 the file. When called on a string printer, the buffer is cleared.
1609 __isl_give isl_printer *isl_printer_flush(
1610 __isl_take isl_printer *p);
1612 =head2 Creating New Sets and Relations
1614 C<isl> has functions for creating some standard sets and relations.
1618 =item * Empty sets and relations
1620 __isl_give isl_basic_set *isl_basic_set_empty(
1621 __isl_take isl_space *space);
1622 __isl_give isl_basic_map *isl_basic_map_empty(
1623 __isl_take isl_space *space);
1624 __isl_give isl_set *isl_set_empty(
1625 __isl_take isl_space *space);
1626 __isl_give isl_map *isl_map_empty(
1627 __isl_take isl_space *space);
1628 __isl_give isl_union_set *isl_union_set_empty(
1629 __isl_take isl_space *space);
1630 __isl_give isl_union_map *isl_union_map_empty(
1631 __isl_take isl_space *space);
1633 For C<isl_union_set>s and C<isl_union_map>s, the space
1634 is only used to specify the parameters.
1636 =item * Universe sets and relations
1638 __isl_give isl_basic_set *isl_basic_set_universe(
1639 __isl_take isl_space *space);
1640 __isl_give isl_basic_map *isl_basic_map_universe(
1641 __isl_take isl_space *space);
1642 __isl_give isl_set *isl_set_universe(
1643 __isl_take isl_space *space);
1644 __isl_give isl_map *isl_map_universe(
1645 __isl_take isl_space *space);
1646 __isl_give isl_union_set *isl_union_set_universe(
1647 __isl_take isl_union_set *uset);
1648 __isl_give isl_union_map *isl_union_map_universe(
1649 __isl_take isl_union_map *umap);
1651 The sets and relations constructed by the functions above
1652 contain all integer values, while those constructed by the
1653 functions below only contain non-negative values.
1655 __isl_give isl_basic_set *isl_basic_set_nat_universe(
1656 __isl_take isl_space *space);
1657 __isl_give isl_basic_map *isl_basic_map_nat_universe(
1658 __isl_take isl_space *space);
1659 __isl_give isl_set *isl_set_nat_universe(
1660 __isl_take isl_space *space);
1661 __isl_give isl_map *isl_map_nat_universe(
1662 __isl_take isl_space *space);
1664 =item * Identity relations
1666 __isl_give isl_basic_map *isl_basic_map_identity(
1667 __isl_take isl_space *space);
1668 __isl_give isl_map *isl_map_identity(
1669 __isl_take isl_space *space);
1671 The number of input and output dimensions in C<space> needs
1674 =item * Lexicographic order
1676 __isl_give isl_map *isl_map_lex_lt(
1677 __isl_take isl_space *set_space);
1678 __isl_give isl_map *isl_map_lex_le(
1679 __isl_take isl_space *set_space);
1680 __isl_give isl_map *isl_map_lex_gt(
1681 __isl_take isl_space *set_space);
1682 __isl_give isl_map *isl_map_lex_ge(
1683 __isl_take isl_space *set_space);
1684 __isl_give isl_map *isl_map_lex_lt_first(
1685 __isl_take isl_space *space, unsigned n);
1686 __isl_give isl_map *isl_map_lex_le_first(
1687 __isl_take isl_space *space, unsigned n);
1688 __isl_give isl_map *isl_map_lex_gt_first(
1689 __isl_take isl_space *space, unsigned n);
1690 __isl_give isl_map *isl_map_lex_ge_first(
1691 __isl_take isl_space *space, unsigned n);
1693 The first four functions take a space for a B<set>
1694 and return relations that express that the elements in the domain
1695 are lexicographically less
1696 (C<isl_map_lex_lt>), less or equal (C<isl_map_lex_le>),
1697 greater (C<isl_map_lex_gt>) or greater or equal (C<isl_map_lex_ge>)
1698 than the elements in the range.
1699 The last four functions take a space for a map
1700 and return relations that express that the first C<n> dimensions
1701 in the domain are lexicographically less
1702 (C<isl_map_lex_lt_first>), less or equal (C<isl_map_lex_le_first>),
1703 greater (C<isl_map_lex_gt_first>) or greater or equal (C<isl_map_lex_ge_first>)
1704 than the first C<n> dimensions in the range.
1708 A basic set or relation can be converted to a set or relation
1709 using the following functions.
1711 __isl_give isl_set *isl_set_from_basic_set(
1712 __isl_take isl_basic_set *bset);
1713 __isl_give isl_map *isl_map_from_basic_map(
1714 __isl_take isl_basic_map *bmap);
1716 Sets and relations can be converted to union sets and relations
1717 using the following functions.
1719 __isl_give isl_union_set *isl_union_set_from_basic_set(
1720 __isl_take isl_basic_set *bset);
1721 __isl_give isl_union_map *isl_union_map_from_basic_map(
1722 __isl_take isl_basic_map *bmap);
1723 __isl_give isl_union_set *isl_union_set_from_set(
1724 __isl_take isl_set *set);
1725 __isl_give isl_union_map *isl_union_map_from_map(
1726 __isl_take isl_map *map);
1728 The inverse conversions below can only be used if the input
1729 union set or relation is known to contain elements in exactly one
1732 __isl_give isl_set *isl_set_from_union_set(
1733 __isl_take isl_union_set *uset);
1734 __isl_give isl_map *isl_map_from_union_map(
1735 __isl_take isl_union_map *umap);
1737 Sets and relations can be copied and freed again using the following
1740 __isl_give isl_basic_set *isl_basic_set_copy(
1741 __isl_keep isl_basic_set *bset);
1742 __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set);
1743 __isl_give isl_union_set *isl_union_set_copy(
1744 __isl_keep isl_union_set *uset);
1745 __isl_give isl_basic_map *isl_basic_map_copy(
1746 __isl_keep isl_basic_map *bmap);
1747 __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
1748 __isl_give isl_union_map *isl_union_map_copy(
1749 __isl_keep isl_union_map *umap);
1750 __isl_null isl_basic_set *isl_basic_set_free(
1751 __isl_take isl_basic_set *bset);
1752 __isl_null isl_set *isl_set_free(__isl_take isl_set *set);
1753 __isl_null isl_union_set *isl_union_set_free(
1754 __isl_take isl_union_set *uset);
1755 __isl_null isl_basic_map *isl_basic_map_free(
1756 __isl_take isl_basic_map *bmap);
1757 __isl_null isl_map *isl_map_free(__isl_take isl_map *map);
1758 __isl_null isl_union_map *isl_union_map_free(
1759 __isl_take isl_union_map *umap);
1761 Other sets and relations can be constructed by starting
1762 from a universe set or relation, adding equality and/or
1763 inequality constraints and then projecting out the
1764 existentially quantified variables, if any.
1765 Constraints can be constructed, manipulated and
1766 added to (or removed from) (basic) sets and relations
1767 using the following functions.
1769 #include <isl/constraint.h>
1770 __isl_give isl_constraint *isl_equality_alloc(
1771 __isl_take isl_local_space *ls);
1772 __isl_give isl_constraint *isl_inequality_alloc(
1773 __isl_take isl_local_space *ls);
1774 __isl_give isl_constraint *isl_constraint_set_constant_si(
1775 __isl_take isl_constraint *constraint, int v);
1776 __isl_give isl_constraint *isl_constraint_set_constant_val(
1777 __isl_take isl_constraint *constraint,
1778 __isl_take isl_val *v);
1779 __isl_give isl_constraint *isl_constraint_set_coefficient_si(
1780 __isl_take isl_constraint *constraint,
1781 enum isl_dim_type type, int pos, int v);
1782 __isl_give isl_constraint *
1783 isl_constraint_set_coefficient_val(
1784 __isl_take isl_constraint *constraint,
1785 enum isl_dim_type type, int pos,
1786 __isl_take isl_val *v);
1787 __isl_give isl_basic_map *isl_basic_map_add_constraint(
1788 __isl_take isl_basic_map *bmap,
1789 __isl_take isl_constraint *constraint);
1790 __isl_give isl_basic_set *isl_basic_set_add_constraint(
1791 __isl_take isl_basic_set *bset,
1792 __isl_take isl_constraint *constraint);
1793 __isl_give isl_map *isl_map_add_constraint(
1794 __isl_take isl_map *map,
1795 __isl_take isl_constraint *constraint);
1796 __isl_give isl_set *isl_set_add_constraint(
1797 __isl_take isl_set *set,
1798 __isl_take isl_constraint *constraint);
1799 __isl_give isl_basic_set *isl_basic_set_drop_constraint(
1800 __isl_take isl_basic_set *bset,
1801 __isl_take isl_constraint *constraint);
1803 For example, to create a set containing the even integers
1804 between 10 and 42, you would use the following code.
1807 isl_local_space *ls;
1809 isl_basic_set *bset;
1811 space = isl_space_set_alloc(ctx, 0, 2);
1812 bset = isl_basic_set_universe(isl_space_copy(space));
1813 ls = isl_local_space_from_space(space);
1815 c = isl_equality_alloc(isl_local_space_copy(ls));
1816 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1817 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 1, 2);
1818 bset = isl_basic_set_add_constraint(bset, c);
1820 c = isl_inequality_alloc(isl_local_space_copy(ls));
1821 c = isl_constraint_set_constant_si(c, -10);
1822 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, 1);
1823 bset = isl_basic_set_add_constraint(bset, c);
1825 c = isl_inequality_alloc(ls);
1826 c = isl_constraint_set_constant_si(c, 42);
1827 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1828 bset = isl_basic_set_add_constraint(bset, c);
1830 bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 1);
1834 isl_basic_set *bset;
1835 bset = isl_basic_set_read_from_str(ctx,
1836 "{[i] : exists (a : i = 2a and i >= 10 and i <= 42)}");
1838 A basic set or relation can also be constructed from two matrices
1839 describing the equalities and the inequalities.
1841 __isl_give isl_basic_set *isl_basic_set_from_constraint_matrices(
1842 __isl_take isl_space *space,
1843 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1844 enum isl_dim_type c1,
1845 enum isl_dim_type c2, enum isl_dim_type c3,
1846 enum isl_dim_type c4);
1847 __isl_give isl_basic_map *isl_basic_map_from_constraint_matrices(
1848 __isl_take isl_space *space,
1849 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1850 enum isl_dim_type c1,
1851 enum isl_dim_type c2, enum isl_dim_type c3,
1852 enum isl_dim_type c4, enum isl_dim_type c5);
1854 The C<isl_dim_type> arguments indicate the order in which
1855 different kinds of variables appear in the input matrices
1856 and should be a permutation of C<isl_dim_cst>, C<isl_dim_param>,
1857 C<isl_dim_set> and C<isl_dim_div> for sets and
1858 of C<isl_dim_cst>, C<isl_dim_param>,
1859 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div> for relations.
1861 A (basic or union) set or relation can also be constructed from a
1862 (union) (piecewise) (multiple) affine expression
1863 or a list of affine expressions
1864 (See L<"Piecewise Quasi Affine Expressions"> and
1865 L<"Piecewise Multiple Quasi Affine Expressions">).
1867 __isl_give isl_basic_map *isl_basic_map_from_aff(
1868 __isl_take isl_aff *aff);
1869 __isl_give isl_map *isl_map_from_aff(
1870 __isl_take isl_aff *aff);
1871 __isl_give isl_set *isl_set_from_pw_aff(
1872 __isl_take isl_pw_aff *pwaff);
1873 __isl_give isl_map *isl_map_from_pw_aff(
1874 __isl_take isl_pw_aff *pwaff);
1875 __isl_give isl_basic_map *isl_basic_map_from_aff_list(
1876 __isl_take isl_space *domain_space,
1877 __isl_take isl_aff_list *list);
1878 __isl_give isl_basic_map *isl_basic_map_from_multi_aff(
1879 __isl_take isl_multi_aff *maff)
1880 __isl_give isl_map *isl_map_from_multi_aff(
1881 __isl_take isl_multi_aff *maff)
1882 __isl_give isl_set *isl_set_from_pw_multi_aff(
1883 __isl_take isl_pw_multi_aff *pma);
1884 __isl_give isl_map *isl_map_from_pw_multi_aff(
1885 __isl_take isl_pw_multi_aff *pma);
1886 __isl_give isl_set *isl_set_from_multi_pw_aff(
1887 __isl_take isl_multi_pw_aff *mpa);
1888 __isl_give isl_map *isl_map_from_multi_pw_aff(
1889 __isl_take isl_multi_pw_aff *mpa);
1890 __isl_give isl_union_map *
1891 isl_union_map_from_union_pw_multi_aff(
1892 __isl_take isl_union_pw_multi_aff *upma);
1894 The C<domain_space> argument describes the domain of the resulting
1895 basic relation. It is required because the C<list> may consist
1896 of zero affine expressions.
1898 =head2 Inspecting Sets and Relations
1900 Usually, the user should not have to care about the actual constraints
1901 of the sets and maps, but should instead apply the abstract operations
1902 explained in the following sections.
1903 Occasionally, however, it may be required to inspect the individual
1904 coefficients of the constraints. This section explains how to do so.
1905 In these cases, it may also be useful to have C<isl> compute
1906 an explicit representation of the existentially quantified variables.
1908 __isl_give isl_set *isl_set_compute_divs(
1909 __isl_take isl_set *set);
1910 __isl_give isl_map *isl_map_compute_divs(
1911 __isl_take isl_map *map);
1912 __isl_give isl_union_set *isl_union_set_compute_divs(
1913 __isl_take isl_union_set *uset);
1914 __isl_give isl_union_map *isl_union_map_compute_divs(
1915 __isl_take isl_union_map *umap);
1917 This explicit representation defines the existentially quantified
1918 variables as integer divisions of the other variables, possibly
1919 including earlier existentially quantified variables.
1920 An explicitly represented existentially quantified variable therefore
1921 has a unique value when the values of the other variables are known.
1922 If, furthermore, the same existentials, i.e., existentials
1923 with the same explicit representations, should appear in the
1924 same order in each of the disjuncts of a set or map, then the user should call
1925 either of the following functions.
1927 __isl_give isl_set *isl_set_align_divs(
1928 __isl_take isl_set *set);
1929 __isl_give isl_map *isl_map_align_divs(
1930 __isl_take isl_map *map);
1932 Alternatively, the existentially quantified variables can be removed
1933 using the following functions, which compute an overapproximation.
1935 __isl_give isl_basic_set *isl_basic_set_remove_divs(
1936 __isl_take isl_basic_set *bset);
1937 __isl_give isl_basic_map *isl_basic_map_remove_divs(
1938 __isl_take isl_basic_map *bmap);
1939 __isl_give isl_set *isl_set_remove_divs(
1940 __isl_take isl_set *set);
1941 __isl_give isl_map *isl_map_remove_divs(
1942 __isl_take isl_map *map);
1944 It is also possible to only remove those divs that are defined
1945 in terms of a given range of dimensions or only those for which
1946 no explicit representation is known.
1948 __isl_give isl_basic_set *
1949 isl_basic_set_remove_divs_involving_dims(
1950 __isl_take isl_basic_set *bset,
1951 enum isl_dim_type type,
1952 unsigned first, unsigned n);
1953 __isl_give isl_basic_map *
1954 isl_basic_map_remove_divs_involving_dims(
1955 __isl_take isl_basic_map *bmap,
1956 enum isl_dim_type type,
1957 unsigned first, unsigned n);
1958 __isl_give isl_set *isl_set_remove_divs_involving_dims(
1959 __isl_take isl_set *set, enum isl_dim_type type,
1960 unsigned first, unsigned n);
1961 __isl_give isl_map *isl_map_remove_divs_involving_dims(
1962 __isl_take isl_map *map, enum isl_dim_type type,
1963 unsigned first, unsigned n);
1965 __isl_give isl_basic_set *
1966 isl_basic_set_remove_unknown_divs(
1967 __isl_take isl_basic_set *bset);
1968 __isl_give isl_set *isl_set_remove_unknown_divs(
1969 __isl_take isl_set *set);
1970 __isl_give isl_map *isl_map_remove_unknown_divs(
1971 __isl_take isl_map *map);
1973 To iterate over all the sets or maps in a union set or map, use
1975 int isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
1976 int (*fn)(__isl_take isl_set *set, void *user),
1978 int isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
1979 int (*fn)(__isl_take isl_map *map, void *user),
1982 The number of sets or maps in a union set or map can be obtained
1985 int isl_union_set_n_set(__isl_keep isl_union_set *uset);
1986 int isl_union_map_n_map(__isl_keep isl_union_map *umap);
1988 To extract the set or map in a given space from a union, use
1990 __isl_give isl_set *isl_union_set_extract_set(
1991 __isl_keep isl_union_set *uset,
1992 __isl_take isl_space *space);
1993 __isl_give isl_map *isl_union_map_extract_map(
1994 __isl_keep isl_union_map *umap,
1995 __isl_take isl_space *space);
1997 To iterate over all the basic sets or maps in a set or map, use
1999 int isl_set_foreach_basic_set(__isl_keep isl_set *set,
2000 int (*fn)(__isl_take isl_basic_set *bset, void *user),
2002 int isl_map_foreach_basic_map(__isl_keep isl_map *map,
2003 int (*fn)(__isl_take isl_basic_map *bmap, void *user),
2006 The callback function C<fn> should return 0 if successful and
2007 -1 if an error occurs. In the latter case, or if any other error
2008 occurs, the above functions will return -1.
2010 It should be noted that C<isl> does not guarantee that
2011 the basic sets or maps passed to C<fn> are disjoint.
2012 If this is required, then the user should call one of
2013 the following functions first.
2015 __isl_give isl_set *isl_set_make_disjoint(
2016 __isl_take isl_set *set);
2017 __isl_give isl_map *isl_map_make_disjoint(
2018 __isl_take isl_map *map);
2020 The number of basic sets in a set can be obtained
2021 or the number of basic maps in a map can be obtained
2024 #include <isl/set.h>
2025 int isl_set_n_basic_set(__isl_keep isl_set *set);
2027 #include <isl/map.h>
2028 int isl_map_n_basic_map(__isl_keep isl_map *map);
2030 To iterate over the constraints of a basic set or map, use
2032 #include <isl/constraint.h>
2034 int isl_basic_set_n_constraint(
2035 __isl_keep isl_basic_set *bset);
2036 int isl_basic_set_foreach_constraint(
2037 __isl_keep isl_basic_set *bset,
2038 int (*fn)(__isl_take isl_constraint *c, void *user),
2040 int isl_basic_map_n_constraint(
2041 __isl_keep isl_basic_map *bmap);
2042 int isl_basic_map_foreach_constraint(
2043 __isl_keep isl_basic_map *bmap,
2044 int (*fn)(__isl_take isl_constraint *c, void *user),
2046 __isl_null isl_constraint *isl_constraint_free(
2047 __isl_take isl_constraint *c);
2049 Again, the callback function C<fn> should return 0 if successful and
2050 -1 if an error occurs. In the latter case, or if any other error
2051 occurs, the above functions will return -1.
2052 The constraint C<c> represents either an equality or an inequality.
2053 Use the following function to find out whether a constraint
2054 represents an equality. If not, it represents an inequality.
2056 int isl_constraint_is_equality(
2057 __isl_keep isl_constraint *constraint);
2059 It is also possible to obtain a list of constraints from a basic
2062 #include <isl/constraint.h>
2063 __isl_give isl_constraint_list *
2064 isl_basic_map_get_constraint_list(
2065 __isl_keep isl_basic_map *bmap);
2066 __isl_give isl_constraint_list *
2067 isl_basic_set_get_constraint_list(
2068 __isl_keep isl_basic_set *bset);
2070 These functions require that all existentially quantified variables
2071 have an explicit representation.
2072 The returned list can be manipulated using the functions in L<"Lists">.
2074 The coefficients of the constraints can be inspected using
2075 the following functions.
2077 int isl_constraint_is_lower_bound(
2078 __isl_keep isl_constraint *constraint,
2079 enum isl_dim_type type, unsigned pos);
2080 int isl_constraint_is_upper_bound(
2081 __isl_keep isl_constraint *constraint,
2082 enum isl_dim_type type, unsigned pos);
2083 __isl_give isl_val *isl_constraint_get_constant_val(
2084 __isl_keep isl_constraint *constraint);
2085 __isl_give isl_val *isl_constraint_get_coefficient_val(
2086 __isl_keep isl_constraint *constraint,
2087 enum isl_dim_type type, int pos);
2088 int isl_constraint_involves_dims(
2089 __isl_keep isl_constraint *constraint,
2090 enum isl_dim_type type, unsigned first, unsigned n);
2092 The explicit representations of the existentially quantified
2093 variables can be inspected using the following function.
2094 Note that the user is only allowed to use this function
2095 if the inspected set or map is the result of a call
2096 to C<isl_set_compute_divs> or C<isl_map_compute_divs>.
2097 The existentially quantified variable is equal to the floor
2098 of the returned affine expression. The affine expression
2099 itself can be inspected using the functions in
2100 L<"Piecewise Quasi Affine Expressions">.
2102 __isl_give isl_aff *isl_constraint_get_div(
2103 __isl_keep isl_constraint *constraint, int pos);
2105 To obtain the constraints of a basic set or map in matrix
2106 form, use the following functions.
2108 __isl_give isl_mat *isl_basic_set_equalities_matrix(
2109 __isl_keep isl_basic_set *bset,
2110 enum isl_dim_type c1, enum isl_dim_type c2,
2111 enum isl_dim_type c3, enum isl_dim_type c4);
2112 __isl_give isl_mat *isl_basic_set_inequalities_matrix(
2113 __isl_keep isl_basic_set *bset,
2114 enum isl_dim_type c1, enum isl_dim_type c2,
2115 enum isl_dim_type c3, enum isl_dim_type c4);
2116 __isl_give isl_mat *isl_basic_map_equalities_matrix(
2117 __isl_keep isl_basic_map *bmap,
2118 enum isl_dim_type c1,
2119 enum isl_dim_type c2, enum isl_dim_type c3,
2120 enum isl_dim_type c4, enum isl_dim_type c5);
2121 __isl_give isl_mat *isl_basic_map_inequalities_matrix(
2122 __isl_keep isl_basic_map *bmap,
2123 enum isl_dim_type c1,
2124 enum isl_dim_type c2, enum isl_dim_type c3,
2125 enum isl_dim_type c4, enum isl_dim_type c5);
2127 The C<isl_dim_type> arguments dictate the order in which
2128 different kinds of variables appear in the resulting matrix.
2129 For set inputs, they should be a permutation of
2130 C<isl_dim_cst>, C<isl_dim_param>, C<isl_dim_set> and C<isl_dim_div>.
2131 For map inputs, they should be a permutation of
2132 C<isl_dim_cst>, C<isl_dim_param>,
2133 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div>.
2135 To check whether the description of a set or relation depends
2136 on one or more given dimensions, it is not necessary to iterate over all
2137 constraints. Instead the following functions can be used.
2139 int isl_basic_set_involves_dims(
2140 __isl_keep isl_basic_set *bset,
2141 enum isl_dim_type type, unsigned first, unsigned n);
2142 int isl_set_involves_dims(__isl_keep isl_set *set,
2143 enum isl_dim_type type, unsigned first, unsigned n);
2144 int isl_basic_map_involves_dims(
2145 __isl_keep isl_basic_map *bmap,
2146 enum isl_dim_type type, unsigned first, unsigned n);
2147 int isl_map_involves_dims(__isl_keep isl_map *map,
2148 enum isl_dim_type type, unsigned first, unsigned n);
2150 Similarly, the following functions can be used to check whether
2151 a given dimension is involved in any lower or upper bound.
2153 int isl_set_dim_has_any_lower_bound(__isl_keep isl_set *set,
2154 enum isl_dim_type type, unsigned pos);
2155 int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set,
2156 enum isl_dim_type type, unsigned pos);
2158 Note that these functions return true even if there is a bound on
2159 the dimension on only some of the basic sets of C<set>.
2160 To check if they have a bound for all of the basic sets in C<set>,
2161 use the following functions instead.
2163 int isl_set_dim_has_lower_bound(__isl_keep isl_set *set,
2164 enum isl_dim_type type, unsigned pos);
2165 int isl_set_dim_has_upper_bound(__isl_keep isl_set *set,
2166 enum isl_dim_type type, unsigned pos);
2170 =head3 Unary Properties
2176 The following functions test whether the given set or relation
2177 contains any integer points. The ``plain'' variants do not perform
2178 any computations, but simply check if the given set or relation
2179 is already known to be empty.
2181 int isl_basic_set_plain_is_empty(__isl_keep isl_basic_set *bset);
2182 int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
2183 int isl_set_plain_is_empty(__isl_keep isl_set *set);
2184 int isl_set_is_empty(__isl_keep isl_set *set);
2185 int isl_union_set_is_empty(__isl_keep isl_union_set *uset);
2186 int isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap);
2187 int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
2188 int isl_map_plain_is_empty(__isl_keep isl_map *map);
2189 int isl_map_is_empty(__isl_keep isl_map *map);
2190 int isl_union_map_is_empty(__isl_keep isl_union_map *umap);
2192 =item * Universality
2194 int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
2195 int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
2196 int isl_set_plain_is_universe(__isl_keep isl_set *set);
2198 =item * Single-valuedness
2200 #include <isl/set.h>
2201 int isl_set_is_singleton(__isl_keep isl_set *set);
2203 #include <isl/map.h>
2204 int isl_basic_map_is_single_valued(
2205 __isl_keep isl_basic_map *bmap);
2206 int isl_map_plain_is_single_valued(
2207 __isl_keep isl_map *map);
2208 int isl_map_is_single_valued(__isl_keep isl_map *map);
2210 #include <isl/union_map.h>
2211 int isl_union_map_is_single_valued(__isl_keep isl_union_map *umap);
2215 int isl_map_plain_is_injective(__isl_keep isl_map *map);
2216 int isl_map_is_injective(__isl_keep isl_map *map);
2217 int isl_union_map_plain_is_injective(
2218 __isl_keep isl_union_map *umap);
2219 int isl_union_map_is_injective(
2220 __isl_keep isl_union_map *umap);
2224 int isl_map_is_bijective(__isl_keep isl_map *map);
2225 int isl_union_map_is_bijective(__isl_keep isl_union_map *umap);
2229 __isl_give isl_val *
2230 isl_basic_map_plain_get_val_if_fixed(
2231 __isl_keep isl_basic_map *bmap,
2232 enum isl_dim_type type, unsigned pos);
2233 __isl_give isl_val *isl_set_plain_get_val_if_fixed(
2234 __isl_keep isl_set *set,
2235 enum isl_dim_type type, unsigned pos);
2236 __isl_give isl_val *isl_map_plain_get_val_if_fixed(
2237 __isl_keep isl_map *map,
2238 enum isl_dim_type type, unsigned pos);
2240 If the set or relation obviously lies on a hyperplane where the given dimension
2241 has a fixed value, then return that value.
2242 Otherwise return NaN.
2246 int isl_set_dim_residue_class_val(
2247 __isl_keep isl_set *set,
2248 int pos, __isl_give isl_val **modulo,
2249 __isl_give isl_val **residue);
2251 Check if the values of the given set dimension are equal to a fixed
2252 value modulo some integer value. If so, assign the modulo to C<*modulo>
2253 and the fixed value to C<*residue>. If the given dimension attains only
2254 a single value, then assign C<0> to C<*modulo> and the fixed value to
2256 If the dimension does not attain only a single value and if no modulo
2257 can be found then assign C<1> to C<*modulo> and C<1> to C<*residue>.
2261 To check whether a set is a parameter domain, use this function:
2263 int isl_set_is_params(__isl_keep isl_set *set);
2264 int isl_union_set_is_params(
2265 __isl_keep isl_union_set *uset);
2269 The following functions check whether the space of the given
2270 (basic) set or relation range is a wrapped relation.
2272 #include <isl/space.h>
2273 int isl_space_is_wrapping(
2274 __isl_keep isl_space *space);
2275 int isl_space_domain_is_wrapping(
2276 __isl_keep isl_space *space);
2277 int isl_space_range_is_wrapping(
2278 __isl_keep isl_space *space);
2280 #include <isl/set.h>
2281 int isl_basic_set_is_wrapping(
2282 __isl_keep isl_basic_set *bset);
2283 int isl_set_is_wrapping(__isl_keep isl_set *set);
2285 #include <isl/map.h>
2286 int isl_map_domain_is_wrapping(
2287 __isl_keep isl_map *map);
2288 int isl_map_range_is_wrapping(
2289 __isl_keep isl_map *map);
2291 The input to C<isl_space_is_wrapping> should
2292 be the space of a set, while that of
2293 C<isl_space_domain_is_wrapping> and
2294 C<isl_space_range_is_wrapping> should be the space of a relation.
2296 =item * Internal Product
2298 int isl_basic_map_can_zip(
2299 __isl_keep isl_basic_map *bmap);
2300 int isl_map_can_zip(__isl_keep isl_map *map);
2302 Check whether the product of domain and range of the given relation
2304 i.e., whether both domain and range are nested relations.
2308 int isl_basic_map_can_curry(
2309 __isl_keep isl_basic_map *bmap);
2310 int isl_map_can_curry(__isl_keep isl_map *map);
2312 Check whether the domain of the (basic) relation is a wrapped relation.
2314 int isl_basic_map_can_uncurry(
2315 __isl_keep isl_basic_map *bmap);
2316 int isl_map_can_uncurry(__isl_keep isl_map *map);
2318 Check whether the range of the (basic) relation is a wrapped relation.
2322 =head3 Binary Properties
2328 int isl_basic_set_plain_is_equal(
2329 __isl_keep isl_basic_set *bset1,
2330 __isl_keep isl_basic_set *bset2);
2331 int isl_set_plain_is_equal(__isl_keep isl_set *set1,
2332 __isl_keep isl_set *set2);
2333 int isl_set_is_equal(__isl_keep isl_set *set1,
2334 __isl_keep isl_set *set2);
2335 int isl_union_set_is_equal(
2336 __isl_keep isl_union_set *uset1,
2337 __isl_keep isl_union_set *uset2);
2338 int isl_basic_map_is_equal(
2339 __isl_keep isl_basic_map *bmap1,
2340 __isl_keep isl_basic_map *bmap2);
2341 int isl_map_is_equal(__isl_keep isl_map *map1,
2342 __isl_keep isl_map *map2);
2343 int isl_map_plain_is_equal(__isl_keep isl_map *map1,
2344 __isl_keep isl_map *map2);
2345 int isl_union_map_is_equal(
2346 __isl_keep isl_union_map *umap1,
2347 __isl_keep isl_union_map *umap2);
2349 =item * Disjointness
2351 int isl_basic_set_is_disjoint(
2352 __isl_keep isl_basic_set *bset1,
2353 __isl_keep isl_basic_set *bset2);
2354 int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
2355 __isl_keep isl_set *set2);
2356 int isl_set_is_disjoint(__isl_keep isl_set *set1,
2357 __isl_keep isl_set *set2);
2358 int isl_basic_map_is_disjoint(
2359 __isl_keep isl_basic_map *bmap1,
2360 __isl_keep isl_basic_map *bmap2);
2361 int isl_map_is_disjoint(__isl_keep isl_map *map1,
2362 __isl_keep isl_map *map2);
2366 int isl_basic_set_is_subset(
2367 __isl_keep isl_basic_set *bset1,
2368 __isl_keep isl_basic_set *bset2);
2369 int isl_set_is_subset(__isl_keep isl_set *set1,
2370 __isl_keep isl_set *set2);
2371 int isl_set_is_strict_subset(
2372 __isl_keep isl_set *set1,
2373 __isl_keep isl_set *set2);
2374 int isl_union_set_is_subset(
2375 __isl_keep isl_union_set *uset1,
2376 __isl_keep isl_union_set *uset2);
2377 int isl_union_set_is_strict_subset(
2378 __isl_keep isl_union_set *uset1,
2379 __isl_keep isl_union_set *uset2);
2380 int isl_basic_map_is_subset(
2381 __isl_keep isl_basic_map *bmap1,
2382 __isl_keep isl_basic_map *bmap2);
2383 int isl_basic_map_is_strict_subset(
2384 __isl_keep isl_basic_map *bmap1,
2385 __isl_keep isl_basic_map *bmap2);
2386 int isl_map_is_subset(
2387 __isl_keep isl_map *map1,
2388 __isl_keep isl_map *map2);
2389 int isl_map_is_strict_subset(
2390 __isl_keep isl_map *map1,
2391 __isl_keep isl_map *map2);
2392 int isl_union_map_is_subset(
2393 __isl_keep isl_union_map *umap1,
2394 __isl_keep isl_union_map *umap2);
2395 int isl_union_map_is_strict_subset(
2396 __isl_keep isl_union_map *umap1,
2397 __isl_keep isl_union_map *umap2);
2399 Check whether the first argument is a (strict) subset of the
2404 Every comparison function returns a negative value if the first
2405 argument is considered smaller than the second, a positive value
2406 if the first argument is considered greater and zero if the two
2407 constraints are considered the same by the comparison criterion.
2409 #include <isl/constraint.h>
2410 int isl_constraint_plain_cmp(
2411 __isl_keep isl_constraint *c1,
2412 __isl_keep isl_constraint *c2);
2414 This function is useful for sorting C<isl_constraint>s.
2415 The order depends on the internal representation of the inputs.
2416 The order is fixed over different calls to the function (assuming
2417 the internal representation of the inputs has not changed), but may
2418 change over different versions of C<isl>.
2420 #include <isl/constraint.h>
2421 int isl_constraint_cmp_last_non_zero(
2422 __isl_keep isl_constraint *c1,
2423 __isl_keep isl_constraint *c2);
2425 This function can be used to sort constraints that live in the same
2426 local space. Constraints that involve ``earlier'' dimensions or
2427 that have a smaller coefficient for the shared latest dimension
2428 are considered smaller than other constraints.
2429 This function only defines a B<partial> order.
2431 #include <isl/set.h>
2432 int isl_set_plain_cmp(__isl_keep isl_set *set1,
2433 __isl_keep isl_set *set2);
2435 This function is useful for sorting C<isl_set>s.
2436 The order depends on the internal representation of the inputs.
2437 The order is fixed over different calls to the function (assuming
2438 the internal representation of the inputs has not changed), but may
2439 change over different versions of C<isl>.
2443 =head2 Unary Operations
2449 __isl_give isl_set *isl_set_complement(
2450 __isl_take isl_set *set);
2451 __isl_give isl_map *isl_map_complement(
2452 __isl_take isl_map *map);
2456 #include <isl/space.h>
2457 __isl_give isl_space *isl_space_reverse(
2458 __isl_take isl_space *space);
2460 #include <isl/map.h>
2461 __isl_give isl_basic_map *isl_basic_map_reverse(
2462 __isl_take isl_basic_map *bmap);
2463 __isl_give isl_map *isl_map_reverse(
2464 __isl_take isl_map *map);
2465 __isl_give isl_union_map *isl_union_map_reverse(
2466 __isl_take isl_union_map *umap);
2470 #include <isl/space.h>
2471 __isl_give isl_space *isl_space_domain(
2472 __isl_take isl_space *space);
2473 __isl_give isl_space *isl_space_range(
2474 __isl_take isl_space *space);
2475 __isl_give isl_space *isl_space_params(
2476 __isl_take isl_space *space);
2478 #include <isl/local_space.h>
2479 __isl_give isl_local_space *isl_local_space_domain(
2480 __isl_take isl_local_space *ls);
2481 __isl_give isl_local_space *isl_local_space_range(
2482 __isl_take isl_local_space *ls);
2484 #include <isl/set.h>
2485 __isl_give isl_basic_set *isl_basic_set_project_out(
2486 __isl_take isl_basic_set *bset,
2487 enum isl_dim_type type, unsigned first, unsigned n);
2488 __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
2489 enum isl_dim_type type, unsigned first, unsigned n);
2490 __isl_give isl_basic_set *isl_basic_set_params(
2491 __isl_take isl_basic_set *bset);
2492 __isl_give isl_set *isl_set_params(__isl_take isl_set *set);
2494 #include <isl/map.h>
2495 __isl_give isl_basic_map *isl_basic_map_project_out(
2496 __isl_take isl_basic_map *bmap,
2497 enum isl_dim_type type, unsigned first, unsigned n);
2498 __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
2499 enum isl_dim_type type, unsigned first, unsigned n);
2500 __isl_give isl_basic_set *isl_basic_map_domain(
2501 __isl_take isl_basic_map *bmap);
2502 __isl_give isl_basic_set *isl_basic_map_range(
2503 __isl_take isl_basic_map *bmap);
2504 __isl_give isl_set *isl_map_params(__isl_take isl_map *map);
2505 __isl_give isl_set *isl_map_domain(
2506 __isl_take isl_map *bmap);
2507 __isl_give isl_set *isl_map_range(
2508 __isl_take isl_map *map);
2510 #include <isl/union_set.h>
2511 __isl_give isl_set *isl_union_set_params(
2512 __isl_take isl_union_set *uset);
2514 #include <isl/union_map.h>
2515 __isl_give isl_union_map *isl_union_map_project_out(
2516 __isl_take isl_union_map *umap,
2517 enum isl_dim_type type, unsigned first, unsigned n);
2518 __isl_give isl_set *isl_union_map_params(
2519 __isl_take isl_union_map *umap);
2520 __isl_give isl_union_set *isl_union_map_domain(
2521 __isl_take isl_union_map *umap);
2522 __isl_give isl_union_set *isl_union_map_range(
2523 __isl_take isl_union_map *umap);
2525 The function C<isl_union_map_project_out> can only project out
2528 #include <isl/space.h>
2529 __isl_give isl_space *isl_space_domain_map(
2530 __isl_take isl_space *space);
2531 __isl_give isl_space *isl_space_range_map(
2532 __isl_take isl_space *space);
2534 #include <isl/map.h>
2535 __isl_give isl_basic_map *isl_basic_map_domain_map(
2536 __isl_take isl_basic_map *bmap);
2537 __isl_give isl_basic_map *isl_basic_map_range_map(
2538 __isl_take isl_basic_map *bmap);
2539 __isl_give isl_map *isl_map_domain_map(__isl_take isl_map *map);
2540 __isl_give isl_map *isl_map_range_map(__isl_take isl_map *map);
2542 #include <isl/union_map.h>
2543 __isl_give isl_union_map *isl_union_map_domain_map(
2544 __isl_take isl_union_map *umap);
2545 __isl_give isl_union_map *isl_union_map_range_map(
2546 __isl_take isl_union_map *umap);
2548 The functions above construct a (basic, regular or union) relation
2549 that maps (a wrapped version of) the input relation to its domain or range.
2553 __isl_give isl_basic_set *isl_basic_set_eliminate(
2554 __isl_take isl_basic_set *bset,
2555 enum isl_dim_type type,
2556 unsigned first, unsigned n);
2557 __isl_give isl_set *isl_set_eliminate(
2558 __isl_take isl_set *set, enum isl_dim_type type,
2559 unsigned first, unsigned n);
2560 __isl_give isl_basic_map *isl_basic_map_eliminate(
2561 __isl_take isl_basic_map *bmap,
2562 enum isl_dim_type type,
2563 unsigned first, unsigned n);
2564 __isl_give isl_map *isl_map_eliminate(
2565 __isl_take isl_map *map, enum isl_dim_type type,
2566 unsigned first, unsigned n);
2568 Eliminate the coefficients for the given dimensions from the constraints,
2569 without removing the dimensions.
2571 =item * Constructing a set from a parameter domain
2573 A zero-dimensional space or (basic) set can be constructed
2574 on a given parameter domain using the following functions.
2576 #include <isl/space.h>
2577 __isl_give isl_space *isl_space_set_from_params(
2578 __isl_take isl_space *space);
2580 #include <isl/set.h>
2581 __isl_give isl_basic_set *isl_basic_set_from_params(
2582 __isl_take isl_basic_set *bset);
2583 __isl_give isl_set *isl_set_from_params(
2584 __isl_take isl_set *set);
2586 =item * Constructing a relation from a set
2588 #include <isl/space.h>
2589 __isl_give isl_space *isl_space_from_domain(
2590 __isl_take isl_space *space);
2591 __isl_give isl_space *isl_space_from_range(
2592 __isl_take isl_space *space);
2593 __isl_give isl_space *isl_space_map_from_set(
2594 __isl_take isl_space *space);
2595 __isl_give isl_space *isl_space_map_from_domain_and_range(
2596 __isl_take isl_space *domain,
2597 __isl_take isl_space *range);
2599 #include <isl/local_space.h>
2600 __isl_give isl_local_space *isl_local_space_from_domain(
2601 __isl_take isl_local_space *ls);
2603 #include <isl/map.h>
2604 __isl_give isl_map *isl_map_from_domain(
2605 __isl_take isl_set *set);
2606 __isl_give isl_map *isl_map_from_range(
2607 __isl_take isl_set *set);
2609 Create a relation with the given set as domain or range.
2610 The range or domain of the created relation is a zero-dimensional
2611 flat anonymous space.
2615 __isl_give isl_basic_set *isl_basic_set_fix_si(
2616 __isl_take isl_basic_set *bset,
2617 enum isl_dim_type type, unsigned pos, int value);
2618 __isl_give isl_basic_set *isl_basic_set_fix_val(
2619 __isl_take isl_basic_set *bset,
2620 enum isl_dim_type type, unsigned pos,
2621 __isl_take isl_val *v);
2622 __isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set,
2623 enum isl_dim_type type, unsigned pos, int value);
2624 __isl_give isl_set *isl_set_fix_val(
2625 __isl_take isl_set *set,
2626 enum isl_dim_type type, unsigned pos,
2627 __isl_take isl_val *v);
2628 __isl_give isl_basic_map *isl_basic_map_fix_si(
2629 __isl_take isl_basic_map *bmap,
2630 enum isl_dim_type type, unsigned pos, int value);
2631 __isl_give isl_basic_map *isl_basic_map_fix_val(
2632 __isl_take isl_basic_map *bmap,
2633 enum isl_dim_type type, unsigned pos,
2634 __isl_take isl_val *v);
2635 __isl_give isl_map *isl_map_fix_si(__isl_take isl_map *map,
2636 enum isl_dim_type type, unsigned pos, int value);
2637 __isl_give isl_map *isl_map_fix_val(
2638 __isl_take isl_map *map,
2639 enum isl_dim_type type, unsigned pos,
2640 __isl_take isl_val *v);
2642 Intersect the set or relation with the hyperplane where the given
2643 dimension has the fixed given value.
2645 __isl_give isl_basic_map *isl_basic_map_lower_bound_si(
2646 __isl_take isl_basic_map *bmap,
2647 enum isl_dim_type type, unsigned pos, int value);
2648 __isl_give isl_basic_map *isl_basic_map_upper_bound_si(
2649 __isl_take isl_basic_map *bmap,
2650 enum isl_dim_type type, unsigned pos, int value);
2651 __isl_give isl_set *isl_set_lower_bound_si(
2652 __isl_take isl_set *set,
2653 enum isl_dim_type type, unsigned pos, int value);
2654 __isl_give isl_set *isl_set_lower_bound_val(
2655 __isl_take isl_set *set,
2656 enum isl_dim_type type, unsigned pos,
2657 __isl_take isl_val *value);
2658 __isl_give isl_map *isl_map_lower_bound_si(
2659 __isl_take isl_map *map,
2660 enum isl_dim_type type, unsigned pos, int value);
2661 __isl_give isl_set *isl_set_upper_bound_si(
2662 __isl_take isl_set *set,
2663 enum isl_dim_type type, unsigned pos, int value);
2664 __isl_give isl_set *isl_set_upper_bound_val(
2665 __isl_take isl_set *set,
2666 enum isl_dim_type type, unsigned pos,
2667 __isl_take isl_val *value);
2668 __isl_give isl_map *isl_map_upper_bound_si(
2669 __isl_take isl_map *map,
2670 enum isl_dim_type type, unsigned pos, int value);
2672 Intersect the set or relation with the half-space where the given
2673 dimension has a value bounded by the fixed given integer value.
2675 __isl_give isl_set *isl_set_equate(__isl_take isl_set *set,
2676 enum isl_dim_type type1, int pos1,
2677 enum isl_dim_type type2, int pos2);
2678 __isl_give isl_basic_map *isl_basic_map_equate(
2679 __isl_take isl_basic_map *bmap,
2680 enum isl_dim_type type1, int pos1,
2681 enum isl_dim_type type2, int pos2);
2682 __isl_give isl_map *isl_map_equate(__isl_take isl_map *map,
2683 enum isl_dim_type type1, int pos1,
2684 enum isl_dim_type type2, int pos2);
2686 Intersect the set or relation with the hyperplane where the given
2687 dimensions are equal to each other.
2689 __isl_give isl_map *isl_map_oppose(__isl_take isl_map *map,
2690 enum isl_dim_type type1, int pos1,
2691 enum isl_dim_type type2, int pos2);
2693 Intersect the relation with the hyperplane where the given
2694 dimensions have opposite values.
2696 __isl_give isl_map *isl_map_order_le(
2697 __isl_take isl_map *map,
2698 enum isl_dim_type type1, int pos1,
2699 enum isl_dim_type type2, int pos2);
2700 __isl_give isl_basic_map *isl_basic_map_order_ge(
2701 __isl_take isl_basic_map *bmap,
2702 enum isl_dim_type type1, int pos1,
2703 enum isl_dim_type type2, int pos2);
2704 __isl_give isl_map *isl_map_order_ge(
2705 __isl_take isl_map *map,
2706 enum isl_dim_type type1, int pos1,
2707 enum isl_dim_type type2, int pos2);
2708 __isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map,
2709 enum isl_dim_type type1, int pos1,
2710 enum isl_dim_type type2, int pos2);
2711 __isl_give isl_basic_map *isl_basic_map_order_gt(
2712 __isl_take isl_basic_map *bmap,
2713 enum isl_dim_type type1, int pos1,
2714 enum isl_dim_type type2, int pos2);
2715 __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
2716 enum isl_dim_type type1, int pos1,
2717 enum isl_dim_type type2, int pos2);
2719 Intersect the relation with the half-space where the given
2720 dimensions satisfy the given ordering.
2724 __isl_give isl_map *isl_set_identity(
2725 __isl_take isl_set *set);
2726 __isl_give isl_union_map *isl_union_set_identity(
2727 __isl_take isl_union_set *uset);
2729 Construct an identity relation on the given (union) set.
2733 __isl_give isl_basic_set *isl_basic_map_deltas(
2734 __isl_take isl_basic_map *bmap);
2735 __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
2736 __isl_give isl_union_set *isl_union_map_deltas(
2737 __isl_take isl_union_map *umap);
2739 These functions return a (basic) set containing the differences
2740 between image elements and corresponding domain elements in the input.
2742 __isl_give isl_basic_map *isl_basic_map_deltas_map(
2743 __isl_take isl_basic_map *bmap);
2744 __isl_give isl_map *isl_map_deltas_map(
2745 __isl_take isl_map *map);
2746 __isl_give isl_union_map *isl_union_map_deltas_map(
2747 __isl_take isl_union_map *umap);
2749 The functions above construct a (basic, regular or union) relation
2750 that maps (a wrapped version of) the input relation to its delta set.
2754 Simplify the representation of a set or relation by trying
2755 to combine pairs of basic sets or relations into a single
2756 basic set or relation.
2758 __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
2759 __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
2760 __isl_give isl_union_set *isl_union_set_coalesce(
2761 __isl_take isl_union_set *uset);
2762 __isl_give isl_union_map *isl_union_map_coalesce(
2763 __isl_take isl_union_map *umap);
2765 One of the methods for combining pairs of basic sets or relations
2766 can result in coefficients that are much larger than those that appear
2767 in the constraints of the input. By default, the coefficients are
2768 not allowed to grow larger, but this can be changed by unsetting
2769 the following option.
2771 int isl_options_set_coalesce_bounded_wrapping(
2772 isl_ctx *ctx, int val);
2773 int isl_options_get_coalesce_bounded_wrapping(
2776 =item * Detecting equalities
2778 __isl_give isl_basic_set *isl_basic_set_detect_equalities(
2779 __isl_take isl_basic_set *bset);
2780 __isl_give isl_basic_map *isl_basic_map_detect_equalities(
2781 __isl_take isl_basic_map *bmap);
2782 __isl_give isl_set *isl_set_detect_equalities(
2783 __isl_take isl_set *set);
2784 __isl_give isl_map *isl_map_detect_equalities(
2785 __isl_take isl_map *map);
2786 __isl_give isl_union_set *isl_union_set_detect_equalities(
2787 __isl_take isl_union_set *uset);
2788 __isl_give isl_union_map *isl_union_map_detect_equalities(
2789 __isl_take isl_union_map *umap);
2791 Simplify the representation of a set or relation by detecting implicit
2794 =item * Removing redundant constraints
2796 __isl_give isl_basic_set *isl_basic_set_remove_redundancies(
2797 __isl_take isl_basic_set *bset);
2798 __isl_give isl_set *isl_set_remove_redundancies(
2799 __isl_take isl_set *set);
2800 __isl_give isl_basic_map *isl_basic_map_remove_redundancies(
2801 __isl_take isl_basic_map *bmap);
2802 __isl_give isl_map *isl_map_remove_redundancies(
2803 __isl_take isl_map *map);
2807 __isl_give isl_basic_set *isl_set_convex_hull(
2808 __isl_take isl_set *set);
2809 __isl_give isl_basic_map *isl_map_convex_hull(
2810 __isl_take isl_map *map);
2812 If the input set or relation has any existentially quantified
2813 variables, then the result of these operations is currently undefined.
2817 #include <isl/set.h>
2818 __isl_give isl_basic_set *
2819 isl_set_unshifted_simple_hull(
2820 __isl_take isl_set *set);
2821 __isl_give isl_basic_set *isl_set_simple_hull(
2822 __isl_take isl_set *set);
2823 __isl_give isl_basic_set *
2824 isl_set_unshifted_simple_hull_from_set_list(
2825 __isl_take isl_set *set,
2826 __isl_take isl_set_list *list);
2828 #include <isl/map.h>
2829 __isl_give isl_basic_map *
2830 isl_map_unshifted_simple_hull(
2831 __isl_take isl_map *map);
2832 __isl_give isl_basic_map *isl_map_simple_hull(
2833 __isl_take isl_map *map);
2835 #include <isl/union_map.h>
2836 __isl_give isl_union_map *isl_union_map_simple_hull(
2837 __isl_take isl_union_map *umap);
2839 These functions compute a single basic set or relation
2840 that contains the whole input set or relation.
2841 In particular, the output is described by translates
2842 of the constraints describing the basic sets or relations in the input.
2843 In case of C<isl_set_unshifted_simple_hull>, only the original
2844 constraints are used, without any translation.
2845 In case of C<isl_set_unshifted_simple_hull_from_set_list>, the
2846 constraints are taken from the elements of the second argument.
2850 (See \autoref{s:simple hull}.)
2856 __isl_give isl_basic_set *isl_basic_set_affine_hull(
2857 __isl_take isl_basic_set *bset);
2858 __isl_give isl_basic_set *isl_set_affine_hull(
2859 __isl_take isl_set *set);
2860 __isl_give isl_union_set *isl_union_set_affine_hull(
2861 __isl_take isl_union_set *uset);
2862 __isl_give isl_basic_map *isl_basic_map_affine_hull(
2863 __isl_take isl_basic_map *bmap);
2864 __isl_give isl_basic_map *isl_map_affine_hull(
2865 __isl_take isl_map *map);
2866 __isl_give isl_union_map *isl_union_map_affine_hull(
2867 __isl_take isl_union_map *umap);
2869 In case of union sets and relations, the affine hull is computed
2872 =item * Polyhedral hull
2874 __isl_give isl_basic_set *isl_set_polyhedral_hull(
2875 __isl_take isl_set *set);
2876 __isl_give isl_basic_map *isl_map_polyhedral_hull(
2877 __isl_take isl_map *map);
2878 __isl_give isl_union_set *isl_union_set_polyhedral_hull(
2879 __isl_take isl_union_set *uset);
2880 __isl_give isl_union_map *isl_union_map_polyhedral_hull(
2881 __isl_take isl_union_map *umap);
2883 These functions compute a single basic set or relation
2884 not involving any existentially quantified variables
2885 that contains the whole input set or relation.
2886 In case of union sets and relations, the polyhedral hull is computed
2889 =item * Other approximations
2891 __isl_give isl_basic_set *
2892 isl_basic_set_drop_constraints_involving_dims(
2893 __isl_take isl_basic_set *bset,
2894 enum isl_dim_type type,
2895 unsigned first, unsigned n);
2896 __isl_give isl_basic_map *
2897 isl_basic_map_drop_constraints_involving_dims(
2898 __isl_take isl_basic_map *bmap,
2899 enum isl_dim_type type,
2900 unsigned first, unsigned n);
2901 __isl_give isl_basic_set *
2902 isl_basic_set_drop_constraints_not_involving_dims(
2903 __isl_take isl_basic_set *bset,
2904 enum isl_dim_type type,
2905 unsigned first, unsigned n);
2906 __isl_give isl_set *
2907 isl_set_drop_constraints_involving_dims(
2908 __isl_take isl_set *set,
2909 enum isl_dim_type type,
2910 unsigned first, unsigned n);
2911 __isl_give isl_map *
2912 isl_map_drop_constraints_involving_dims(
2913 __isl_take isl_map *map,
2914 enum isl_dim_type type,
2915 unsigned first, unsigned n);
2917 These functions drop any constraints (not) involving the specified dimensions.
2918 Note that the result depends on the representation of the input.
2922 __isl_give isl_basic_set *isl_basic_set_sample(
2923 __isl_take isl_basic_set *bset);
2924 __isl_give isl_basic_set *isl_set_sample(
2925 __isl_take isl_set *set);
2926 __isl_give isl_basic_map *isl_basic_map_sample(
2927 __isl_take isl_basic_map *bmap);
2928 __isl_give isl_basic_map *isl_map_sample(
2929 __isl_take isl_map *map);
2931 If the input (basic) set or relation is non-empty, then return
2932 a singleton subset of the input. Otherwise, return an empty set.
2934 =item * Optimization
2936 #include <isl/ilp.h>
2937 __isl_give isl_val *isl_basic_set_max_val(
2938 __isl_keep isl_basic_set *bset,
2939 __isl_keep isl_aff *obj);
2940 __isl_give isl_val *isl_set_min_val(
2941 __isl_keep isl_set *set,
2942 __isl_keep isl_aff *obj);
2943 __isl_give isl_val *isl_set_max_val(
2944 __isl_keep isl_set *set,
2945 __isl_keep isl_aff *obj);
2947 Compute the minimum or maximum of the integer affine expression C<obj>
2948 over the points in C<set>, returning the result in C<opt>.
2949 The result is C<NULL> in case of an error, the optimal value in case
2950 there is one, negative infinity or infinity if the problem is unbounded and
2951 NaN if the problem is empty.
2953 =item * Parametric optimization
2955 __isl_give isl_pw_aff *isl_set_dim_min(
2956 __isl_take isl_set *set, int pos);
2957 __isl_give isl_pw_aff *isl_set_dim_max(
2958 __isl_take isl_set *set, int pos);
2959 __isl_give isl_pw_aff *isl_map_dim_max(
2960 __isl_take isl_map *map, int pos);
2962 Compute the minimum or maximum of the given set or output dimension
2963 as a function of the parameters (and input dimensions), but independently
2964 of the other set or output dimensions.
2965 For lexicographic optimization, see L<"Lexicographic Optimization">.
2969 The following functions compute either the set of (rational) coefficient
2970 values of valid constraints for the given set or the set of (rational)
2971 values satisfying the constraints with coefficients from the given set.
2972 Internally, these two sets of functions perform essentially the
2973 same operations, except that the set of coefficients is assumed to
2974 be a cone, while the set of values may be any polyhedron.
2975 The current implementation is based on the Farkas lemma and
2976 Fourier-Motzkin elimination, but this may change or be made optional
2977 in future. In particular, future implementations may use different
2978 dualization algorithms or skip the elimination step.
2980 __isl_give isl_basic_set *isl_basic_set_coefficients(
2981 __isl_take isl_basic_set *bset);
2982 __isl_give isl_basic_set *isl_set_coefficients(
2983 __isl_take isl_set *set);
2984 __isl_give isl_union_set *isl_union_set_coefficients(
2985 __isl_take isl_union_set *bset);
2986 __isl_give isl_basic_set *isl_basic_set_solutions(
2987 __isl_take isl_basic_set *bset);
2988 __isl_give isl_basic_set *isl_set_solutions(
2989 __isl_take isl_set *set);
2990 __isl_give isl_union_set *isl_union_set_solutions(
2991 __isl_take isl_union_set *bset);
2995 __isl_give isl_map *isl_map_fixed_power_val(
2996 __isl_take isl_map *map,
2997 __isl_take isl_val *exp);
2998 __isl_give isl_union_map *
2999 isl_union_map_fixed_power_val(
3000 __isl_take isl_union_map *umap,
3001 __isl_take isl_val *exp);
3003 Compute the given power of C<map>, where C<exp> is assumed to be non-zero.
3004 If the exponent C<exp> is negative, then the -C<exp> th power of the inverse
3005 of C<map> is computed.
3007 __isl_give isl_map *isl_map_power(__isl_take isl_map *map,
3009 __isl_give isl_union_map *isl_union_map_power(
3010 __isl_take isl_union_map *umap, int *exact);
3012 Compute a parametric representation for all positive powers I<k> of C<map>.
3013 The result maps I<k> to a nested relation corresponding to the
3014 I<k>th power of C<map>.
3015 The result may be an overapproximation. If the result is known to be exact,
3016 then C<*exact> is set to C<1>.
3018 =item * Transitive closure
3020 __isl_give isl_map *isl_map_transitive_closure(
3021 __isl_take isl_map *map, int *exact);
3022 __isl_give isl_union_map *isl_union_map_transitive_closure(
3023 __isl_take isl_union_map *umap, int *exact);
3025 Compute the transitive closure of C<map>.
3026 The result may be an overapproximation. If the result is known to be exact,
3027 then C<*exact> is set to C<1>.
3029 =item * Reaching path lengths
3031 __isl_give isl_map *isl_map_reaching_path_lengths(
3032 __isl_take isl_map *map, int *exact);
3034 Compute a relation that maps each element in the range of C<map>
3035 to the lengths of all paths composed of edges in C<map> that
3036 end up in the given element.
3037 The result may be an overapproximation. If the result is known to be exact,
3038 then C<*exact> is set to C<1>.
3039 To compute the I<maximal> path length, the resulting relation
3040 should be postprocessed by C<isl_map_lexmax>.
3041 In particular, if the input relation is a dependence relation
3042 (mapping sources to sinks), then the maximal path length corresponds
3043 to the free schedule.
3044 Note, however, that C<isl_map_lexmax> expects the maximum to be
3045 finite, so if the path lengths are unbounded (possibly due to
3046 the overapproximation), then you will get an error message.
3050 #include <isl/space.h>
3051 __isl_give isl_space *isl_space_wrap(
3052 __isl_take isl_space *space);
3053 __isl_give isl_space *isl_space_unwrap(
3054 __isl_take isl_space *space);
3056 #include <isl/set.h>
3057 __isl_give isl_basic_map *isl_basic_set_unwrap(
3058 __isl_take isl_basic_set *bset);
3059 __isl_give isl_map *isl_set_unwrap(
3060 __isl_take isl_set *set);
3062 #include <isl/map.h>
3063 __isl_give isl_basic_set *isl_basic_map_wrap(
3064 __isl_take isl_basic_map *bmap);
3065 __isl_give isl_set *isl_map_wrap(
3066 __isl_take isl_map *map);
3068 #include <isl/union_set.h>
3069 __isl_give isl_union_map *isl_union_set_unwrap(
3070 __isl_take isl_union_set *uset);
3072 #include <isl/union_map.h>
3073 __isl_give isl_union_set *isl_union_map_wrap(
3074 __isl_take isl_union_map *umap);
3076 The input to C<isl_space_unwrap> should
3077 be the space of a set, while that of
3078 C<isl_space_wrap> should be the space of a relation.
3079 Conversely, the output of C<isl_space_unwrap> is the space
3080 of a relation, while that of C<isl_space_wrap> is the space of a set.
3084 Remove any internal structure of domain (and range) of the given
3085 set or relation. If there is any such internal structure in the input,
3086 then the name of the space is also removed.
3088 #include <isl/local_space.h>
3089 __isl_give isl_local_space *
3090 isl_local_space_flatten_domain(
3091 __isl_take isl_local_space *ls);
3092 __isl_give isl_local_space *
3093 isl_local_space_flatten_range(
3094 __isl_take isl_local_space *ls);
3096 #include <isl/set.h>
3097 __isl_give isl_basic_set *isl_basic_set_flatten(
3098 __isl_take isl_basic_set *bset);
3099 __isl_give isl_set *isl_set_flatten(
3100 __isl_take isl_set *set);
3102 #include <isl/map.h>
3103 __isl_give isl_basic_map *isl_basic_map_flatten_domain(
3104 __isl_take isl_basic_map *bmap);
3105 __isl_give isl_basic_map *isl_basic_map_flatten_range(
3106 __isl_take isl_basic_map *bmap);
3107 __isl_give isl_map *isl_map_flatten_range(
3108 __isl_take isl_map *map);
3109 __isl_give isl_map *isl_map_flatten_domain(
3110 __isl_take isl_map *map);
3111 __isl_give isl_basic_map *isl_basic_map_flatten(
3112 __isl_take isl_basic_map *bmap);
3113 __isl_give isl_map *isl_map_flatten(
3114 __isl_take isl_map *map);
3116 #include <isl/map.h>
3117 __isl_give isl_map *isl_set_flatten_map(
3118 __isl_take isl_set *set);
3120 The function above constructs a relation
3121 that maps the input set to a flattened version of the set.
3125 Lift the input set to a space with extra dimensions corresponding
3126 to the existentially quantified variables in the input.
3127 In particular, the result lives in a wrapped map where the domain
3128 is the original space and the range corresponds to the original
3129 existentially quantified variables.
3131 __isl_give isl_basic_set *isl_basic_set_lift(
3132 __isl_take isl_basic_set *bset);
3133 __isl_give isl_set *isl_set_lift(
3134 __isl_take isl_set *set);
3135 __isl_give isl_union_set *isl_union_set_lift(
3136 __isl_take isl_union_set *uset);
3138 Given a local space that contains the existentially quantified
3139 variables of a set, a basic relation that, when applied to
3140 a basic set, has essentially the same effect as C<isl_basic_set_lift>,
3141 can be constructed using the following function.
3143 #include <isl/local_space.h>
3144 __isl_give isl_basic_map *isl_local_space_lifting(
3145 __isl_take isl_local_space *ls);
3147 =item * Internal Product
3149 #include <isl/space.h>
3150 __isl_give isl_space *isl_space_zip(
3151 __isl_take isl_space *space);
3153 #include <isl/map.h>
3154 __isl_give isl_basic_map *isl_basic_map_zip(
3155 __isl_take isl_basic_map *bmap);
3156 __isl_give isl_map *isl_map_zip(
3157 __isl_take isl_map *map);
3158 __isl_give isl_union_map *isl_union_map_zip(
3159 __isl_take isl_union_map *umap);
3161 Given a relation with nested relations for domain and range,
3162 interchange the range of the domain with the domain of the range.
3166 #include <isl/space.h>
3167 __isl_give isl_space *isl_space_curry(
3168 __isl_take isl_space *space);
3169 __isl_give isl_space *isl_space_uncurry(
3170 __isl_take isl_space *space);
3172 #include <isl/map.h>
3173 __isl_give isl_basic_map *isl_basic_map_curry(
3174 __isl_take isl_basic_map *bmap);
3175 __isl_give isl_basic_map *isl_basic_map_uncurry(
3176 __isl_take isl_basic_map *bmap);
3177 __isl_give isl_map *isl_map_curry(
3178 __isl_take isl_map *map);
3179 __isl_give isl_map *isl_map_uncurry(
3180 __isl_take isl_map *map);
3182 #include <isl/union_map.h>
3183 __isl_give isl_union_map *isl_union_map_curry(
3184 __isl_take isl_union_map *umap);
3185 __isl_give isl_union_map *isl_union_map_uncurry(
3186 __isl_take isl_union_map *umap);
3188 Given a relation with a nested relation for domain,
3189 the C<curry> functions
3190 move the range of the nested relation out of the domain
3191 and use it as the domain of a nested relation in the range,
3192 with the original range as range of this nested relation.
3193 The C<uncurry> functions perform the inverse operation.
3195 =item * Aligning parameters
3197 #include <isl/space.h>
3198 __isl_give isl_space *isl_space_align_params(
3199 __isl_take isl_space *space1,
3200 __isl_take isl_space *space2)
3202 #include <isl/set.h>
3203 __isl_give isl_basic_set *isl_basic_set_align_params(
3204 __isl_take isl_basic_set *bset,
3205 __isl_take isl_space *model);
3206 __isl_give isl_set *isl_set_align_params(
3207 __isl_take isl_set *set,
3208 __isl_take isl_space *model);
3210 #include <isl/map.h>
3211 __isl_give isl_basic_map *isl_basic_map_align_params(
3212 __isl_take isl_basic_map *bmap,
3213 __isl_take isl_space *model);
3214 __isl_give isl_map *isl_map_align_params(
3215 __isl_take isl_map *map,
3216 __isl_take isl_space *model);
3218 Change the order of the parameters of the given set or relation
3219 such that the first parameters match those of C<model>.
3220 This may involve the introduction of extra parameters.
3221 All parameters need to be named.
3223 =item * Dimension manipulation
3225 #include <isl/space.h>
3226 __isl_give isl_space *isl_space_add_dims(
3227 __isl_take isl_space *space,
3228 enum isl_dim_type type, unsigned n);
3229 __isl_give isl_space *isl_space_insert_dims(
3230 __isl_take isl_space *space,
3231 enum isl_dim_type type, unsigned pos, unsigned n);
3232 __isl_give isl_space *isl_space_drop_dims(
3233 __isl_take isl_space *space,
3234 enum isl_dim_type type, unsigned first, unsigned n);
3235 __isl_give isl_space *isl_space_move_dims(
3236 __isl_take isl_space *space,
3237 enum isl_dim_type dst_type, unsigned dst_pos,
3238 enum isl_dim_type src_type, unsigned src_pos,
3241 #include <isl/local_space.h>
3242 __isl_give isl_local_space *isl_local_space_add_dims(
3243 __isl_take isl_local_space *ls,
3244 enum isl_dim_type type, unsigned n);
3245 __isl_give isl_local_space *isl_local_space_insert_dims(
3246 __isl_take isl_local_space *ls,
3247 enum isl_dim_type type, unsigned first, unsigned n);
3248 __isl_give isl_local_space *isl_local_space_drop_dims(
3249 __isl_take isl_local_space *ls,
3250 enum isl_dim_type type, unsigned first, unsigned n);
3252 #include <isl/set.h>
3253 __isl_give isl_basic_set *isl_basic_set_add_dims(
3254 __isl_take isl_basic_set *bset,
3255 enum isl_dim_type type, unsigned n);
3256 __isl_give isl_set *isl_set_add_dims(
3257 __isl_take isl_set *set,
3258 enum isl_dim_type type, unsigned n);
3259 __isl_give isl_basic_set *isl_basic_set_insert_dims(
3260 __isl_take isl_basic_set *bset,
3261 enum isl_dim_type type, unsigned pos,
3263 __isl_give isl_set *isl_set_insert_dims(
3264 __isl_take isl_set *set,
3265 enum isl_dim_type type, unsigned pos, unsigned n);
3266 __isl_give isl_basic_set *isl_basic_set_move_dims(
3267 __isl_take isl_basic_set *bset,
3268 enum isl_dim_type dst_type, unsigned dst_pos,
3269 enum isl_dim_type src_type, unsigned src_pos,
3271 __isl_give isl_set *isl_set_move_dims(
3272 __isl_take isl_set *set,
3273 enum isl_dim_type dst_type, unsigned dst_pos,
3274 enum isl_dim_type src_type, unsigned src_pos,
3277 #include <isl/map.h>
3278 __isl_give isl_map *isl_map_add_dims(
3279 __isl_take isl_map *map,
3280 enum isl_dim_type type, unsigned n);
3281 __isl_give isl_basic_map *isl_basic_map_insert_dims(
3282 __isl_take isl_basic_map *bmap,
3283 enum isl_dim_type type, unsigned pos,
3285 __isl_give isl_map *isl_map_insert_dims(
3286 __isl_take isl_map *map,
3287 enum isl_dim_type type, unsigned pos, unsigned n);
3288 __isl_give isl_basic_map *isl_basic_map_move_dims(
3289 __isl_take isl_basic_map *bmap,
3290 enum isl_dim_type dst_type, unsigned dst_pos,
3291 enum isl_dim_type src_type, unsigned src_pos,
3293 __isl_give isl_map *isl_map_move_dims(
3294 __isl_take isl_map *map,
3295 enum isl_dim_type dst_type, unsigned dst_pos,
3296 enum isl_dim_type src_type, unsigned src_pos,
3299 It is usually not advisable to directly change the (input or output)
3300 space of a set or a relation as this removes the name and the internal
3301 structure of the space. However, the above functions can be useful
3302 to add new parameters, assuming
3303 C<isl_set_align_params> and C<isl_map_align_params>
3308 =head2 Binary Operations
3310 The two arguments of a binary operation not only need to live
3311 in the same C<isl_ctx>, they currently also need to have
3312 the same (number of) parameters.
3314 =head3 Basic Operations
3318 =item * Intersection
3320 #include <isl/local_space.h>
3321 __isl_give isl_local_space *isl_local_space_intersect(
3322 __isl_take isl_local_space *ls1,
3323 __isl_take isl_local_space *ls2);
3325 #include <isl/set.h>
3326 __isl_give isl_basic_set *isl_basic_set_intersect_params(
3327 __isl_take isl_basic_set *bset1,
3328 __isl_take isl_basic_set *bset2);
3329 __isl_give isl_basic_set *isl_basic_set_intersect(
3330 __isl_take isl_basic_set *bset1,
3331 __isl_take isl_basic_set *bset2);
3332 __isl_give isl_basic_set *isl_basic_set_list_intersect(
3333 __isl_take struct isl_basic_set_list *list);
3334 __isl_give isl_set *isl_set_intersect_params(
3335 __isl_take isl_set *set,
3336 __isl_take isl_set *params);
3337 __isl_give isl_set *isl_set_intersect(
3338 __isl_take isl_set *set1,
3339 __isl_take isl_set *set2);
3341 #include <isl/map.h>
3342 __isl_give isl_basic_map *isl_basic_map_intersect_domain(
3343 __isl_take isl_basic_map *bmap,
3344 __isl_take isl_basic_set *bset);
3345 __isl_give isl_basic_map *isl_basic_map_intersect_range(
3346 __isl_take isl_basic_map *bmap,
3347 __isl_take isl_basic_set *bset);
3348 __isl_give isl_basic_map *isl_basic_map_intersect(
3349 __isl_take isl_basic_map *bmap1,
3350 __isl_take isl_basic_map *bmap2);
3351 __isl_give isl_map *isl_map_intersect_params(
3352 __isl_take isl_map *map,
3353 __isl_take isl_set *params);
3354 __isl_give isl_map *isl_map_intersect_domain(
3355 __isl_take isl_map *map,
3356 __isl_take isl_set *set);
3357 __isl_give isl_map *isl_map_intersect_range(
3358 __isl_take isl_map *map,
3359 __isl_take isl_set *set);
3360 __isl_give isl_map *isl_map_intersect(
3361 __isl_take isl_map *map1,
3362 __isl_take isl_map *map2);
3364 #include <isl/union_set.h>
3365 __isl_give isl_union_set *isl_union_set_intersect_params(
3366 __isl_take isl_union_set *uset,
3367 __isl_take isl_set *set);
3368 __isl_give isl_union_set *isl_union_set_intersect(
3369 __isl_take isl_union_set *uset1,
3370 __isl_take isl_union_set *uset2);
3372 #include <isl/union_map.h>
3373 __isl_give isl_union_map *isl_union_map_intersect_params(
3374 __isl_take isl_union_map *umap,
3375 __isl_take isl_set *set);
3376 __isl_give isl_union_map *isl_union_map_intersect_domain(
3377 __isl_take isl_union_map *umap,
3378 __isl_take isl_union_set *uset);
3379 __isl_give isl_union_map *isl_union_map_intersect_range(
3380 __isl_take isl_union_map *umap,
3381 __isl_take isl_union_set *uset);
3382 __isl_give isl_union_map *isl_union_map_intersect(
3383 __isl_take isl_union_map *umap1,
3384 __isl_take isl_union_map *umap2);
3386 The second argument to the C<_params> functions needs to be
3387 a parametric (basic) set. For the other functions, a parametric set
3388 for either argument is only allowed if the other argument is
3389 a parametric set as well.
3390 The list passed to C<isl_basic_set_list_intersect> needs to have
3391 at least one element and all elements need to live in the same space.
3395 __isl_give isl_set *isl_basic_set_union(
3396 __isl_take isl_basic_set *bset1,
3397 __isl_take isl_basic_set *bset2);
3398 __isl_give isl_map *isl_basic_map_union(
3399 __isl_take isl_basic_map *bmap1,
3400 __isl_take isl_basic_map *bmap2);
3401 __isl_give isl_set *isl_set_union(
3402 __isl_take isl_set *set1,
3403 __isl_take isl_set *set2);
3404 __isl_give isl_map *isl_map_union(
3405 __isl_take isl_map *map1,
3406 __isl_take isl_map *map2);
3407 __isl_give isl_union_set *isl_union_set_union(
3408 __isl_take isl_union_set *uset1,
3409 __isl_take isl_union_set *uset2);
3410 __isl_give isl_union_map *isl_union_map_union(
3411 __isl_take isl_union_map *umap1,
3412 __isl_take isl_union_map *umap2);
3414 =item * Set difference
3416 __isl_give isl_set *isl_set_subtract(
3417 __isl_take isl_set *set1,
3418 __isl_take isl_set *set2);
3419 __isl_give isl_map *isl_map_subtract(
3420 __isl_take isl_map *map1,
3421 __isl_take isl_map *map2);
3422 __isl_give isl_map *isl_map_subtract_domain(
3423 __isl_take isl_map *map,
3424 __isl_take isl_set *dom);
3425 __isl_give isl_map *isl_map_subtract_range(
3426 __isl_take isl_map *map,
3427 __isl_take isl_set *dom);
3428 __isl_give isl_union_set *isl_union_set_subtract(
3429 __isl_take isl_union_set *uset1,
3430 __isl_take isl_union_set *uset2);
3431 __isl_give isl_union_map *isl_union_map_subtract(
3432 __isl_take isl_union_map *umap1,
3433 __isl_take isl_union_map *umap2);
3434 __isl_give isl_union_map *isl_union_map_subtract_domain(
3435 __isl_take isl_union_map *umap,
3436 __isl_take isl_union_set *dom);
3437 __isl_give isl_union_map *isl_union_map_subtract_range(
3438 __isl_take isl_union_map *umap,
3439 __isl_take isl_union_set *dom);
3443 #include <isl/space.h>
3444 __isl_give isl_space *isl_space_join(
3445 __isl_take isl_space *left,
3446 __isl_take isl_space *right);
3448 #include <isl/set.h>
3449 __isl_give isl_basic_set *isl_basic_set_apply(
3450 __isl_take isl_basic_set *bset,
3451 __isl_take isl_basic_map *bmap);
3452 __isl_give isl_set *isl_set_apply(
3453 __isl_take isl_set *set,
3454 __isl_take isl_map *map);
3456 #include <isl/union_set.h>
3457 __isl_give isl_union_set *isl_union_set_apply(
3458 __isl_take isl_union_set *uset,
3459 __isl_take isl_union_map *umap);
3461 #include <isl/map.h>
3462 __isl_give isl_basic_map *isl_basic_map_apply_domain(
3463 __isl_take isl_basic_map *bmap1,
3464 __isl_take isl_basic_map *bmap2);
3465 __isl_give isl_basic_map *isl_basic_map_apply_range(
3466 __isl_take isl_basic_map *bmap1,
3467 __isl_take isl_basic_map *bmap2);
3468 __isl_give isl_map *isl_map_apply_domain(
3469 __isl_take isl_map *map1,
3470 __isl_take isl_map *map2);
3471 __isl_give isl_map *isl_map_apply_range(
3472 __isl_take isl_map *map1,
3473 __isl_take isl_map *map2);
3475 #include <isl/union_map.h>
3476 __isl_give isl_union_map *isl_union_map_apply_domain(
3477 __isl_take isl_union_map *umap1,
3478 __isl_take isl_union_map *umap2);
3479 __isl_give isl_union_map *isl_union_map_apply_range(
3480 __isl_take isl_union_map *umap1,
3481 __isl_take isl_union_map *umap2);
3485 #include <isl/set.h>
3486 __isl_give isl_basic_set *
3487 isl_basic_set_preimage_multi_aff(
3488 __isl_take isl_basic_set *bset,
3489 __isl_take isl_multi_aff *ma);
3490 __isl_give isl_set *isl_set_preimage_multi_aff(
3491 __isl_take isl_set *set,
3492 __isl_take isl_multi_aff *ma);
3493 __isl_give isl_set *isl_set_preimage_pw_multi_aff(
3494 __isl_take isl_set *set,
3495 __isl_take isl_pw_multi_aff *pma);
3496 __isl_give isl_set *isl_set_preimage_multi_pw_aff(
3497 __isl_take isl_set *set,
3498 __isl_take isl_multi_pw_aff *mpa);
3500 #include <isl/union_set.h>
3501 __isl_give isl_union_set *
3502 isl_union_set_preimage_multi_aff(
3503 __isl_take isl_union_set *uset,
3504 __isl_take isl_multi_aff *ma);
3505 __isl_give isl_union_set *
3506 isl_union_set_preimage_pw_multi_aff(
3507 __isl_take isl_union_set *uset,
3508 __isl_take isl_pw_multi_aff *pma);
3509 __isl_give isl_union_set *
3510 isl_union_set_preimage_union_pw_multi_aff(
3511 __isl_take isl_union_set *uset,
3512 __isl_take isl_union_pw_multi_aff *upma);
3514 #include <isl/map.h>
3515 __isl_give isl_basic_map *
3516 isl_basic_map_preimage_domain_multi_aff(
3517 __isl_take isl_basic_map *bmap,
3518 __isl_take isl_multi_aff *ma);
3519 __isl_give isl_map *isl_map_preimage_domain_multi_aff(
3520 __isl_take isl_map *map,
3521 __isl_take isl_multi_aff *ma);
3522 __isl_give isl_map *isl_map_preimage_range_multi_aff(
3523 __isl_take isl_map *map,
3524 __isl_take isl_multi_aff *ma);
3525 __isl_give isl_map *
3526 isl_map_preimage_domain_pw_multi_aff(
3527 __isl_take isl_map *map,
3528 __isl_take isl_pw_multi_aff *pma);
3529 __isl_give isl_map *
3530 isl_map_preimage_range_pw_multi_aff(
3531 __isl_take isl_map *map,
3532 __isl_take isl_pw_multi_aff *pma);
3533 __isl_give isl_map *
3534 isl_map_preimage_domain_multi_pw_aff(
3535 __isl_take isl_map *map,
3536 __isl_take isl_multi_pw_aff *mpa);
3537 __isl_give isl_basic_map *
3538 isl_basic_map_preimage_range_multi_aff(
3539 __isl_take isl_basic_map *bmap,
3540 __isl_take isl_multi_aff *ma);
3542 #include <isl/union_map.h>
3543 __isl_give isl_union_map *
3544 isl_union_map_preimage_domain_multi_aff(
3545 __isl_take isl_union_map *umap,
3546 __isl_take isl_multi_aff *ma);
3547 __isl_give isl_union_map *
3548 isl_union_map_preimage_range_multi_aff(
3549 __isl_take isl_union_map *umap,
3550 __isl_take isl_multi_aff *ma);
3551 __isl_give isl_union_map *
3552 isl_union_map_preimage_domain_pw_multi_aff(
3553 __isl_take isl_union_map *umap,
3554 __isl_take isl_pw_multi_aff *pma);
3555 __isl_give isl_union_map *
3556 isl_union_map_preimage_range_pw_multi_aff(
3557 __isl_take isl_union_map *umap,
3558 __isl_take isl_pw_multi_aff *pma);
3559 __isl_give isl_union_map *
3560 isl_union_map_preimage_domain_union_pw_multi_aff(
3561 __isl_take isl_union_map *umap,
3562 __isl_take isl_union_pw_multi_aff *upma);
3563 __isl_give isl_union_map *
3564 isl_union_map_preimage_range_union_pw_multi_aff(
3565 __isl_take isl_union_map *umap,
3566 __isl_take isl_union_pw_multi_aff *upma);
3568 These functions compute the preimage of the given set or map domain/range under
3569 the given function. In other words, the expression is plugged
3570 into the set description or into the domain/range of the map.
3571 Objects of types C<isl_multi_aff> and C<isl_pw_multi_aff> are described in
3572 L</"Piecewise Multiple Quasi Affine Expressions">.
3574 =item * Cartesian Product
3576 #include <isl/space.h>
3577 __isl_give isl_space *isl_space_product(
3578 __isl_take isl_space *space1,
3579 __isl_take isl_space *space2);
3580 __isl_give isl_space *isl_space_domain_product(
3581 __isl_take isl_space *space1,
3582 __isl_take isl_space *space2);
3583 __isl_give isl_space *isl_space_range_product(
3584 __isl_take isl_space *space1,
3585 __isl_take isl_space *space2);
3588 C<isl_space_product>, C<isl_space_domain_product>
3589 and C<isl_space_range_product> take pairs or relation spaces and
3590 produce a single relations space, where either the domain, the range
3591 or both domain and range are wrapped spaces of relations between
3592 the domains and/or ranges of the input spaces.
3593 If the product is only constructed over the domain or the range
3594 then the ranges or the domains of the inputs should be the same.
3595 The function C<isl_space_product> also accepts a pair of set spaces,
3596 in which case it returns a wrapped space of a relation between the
3599 #include <isl/set.h>
3600 __isl_give isl_set *isl_set_product(
3601 __isl_take isl_set *set1,
3602 __isl_take isl_set *set2);
3604 #include <isl/map.h>
3605 __isl_give isl_basic_map *isl_basic_map_domain_product(
3606 __isl_take isl_basic_map *bmap1,
3607 __isl_take isl_basic_map *bmap2);
3608 __isl_give isl_basic_map *isl_basic_map_range_product(
3609 __isl_take isl_basic_map *bmap1,
3610 __isl_take isl_basic_map *bmap2);
3611 __isl_give isl_basic_map *isl_basic_map_product(
3612 __isl_take isl_basic_map *bmap1,
3613 __isl_take isl_basic_map *bmap2);
3614 __isl_give isl_map *isl_map_domain_product(
3615 __isl_take isl_map *map1,
3616 __isl_take isl_map *map2);
3617 __isl_give isl_map *isl_map_range_product(
3618 __isl_take isl_map *map1,
3619 __isl_take isl_map *map2);
3620 __isl_give isl_map *isl_map_product(
3621 __isl_take isl_map *map1,
3622 __isl_take isl_map *map2);
3624 #include <isl/union_set.h>
3625 __isl_give isl_union_set *isl_union_set_product(
3626 __isl_take isl_union_set *uset1,
3627 __isl_take isl_union_set *uset2);
3629 #include <isl/union_map.h>
3630 __isl_give isl_union_map *isl_union_map_domain_product(
3631 __isl_take isl_union_map *umap1,
3632 __isl_take isl_union_map *umap2);
3633 __isl_give isl_union_map *isl_union_map_range_product(
3634 __isl_take isl_union_map *umap1,
3635 __isl_take isl_union_map *umap2);
3636 __isl_give isl_union_map *isl_union_map_product(
3637 __isl_take isl_union_map *umap1,
3638 __isl_take isl_union_map *umap2);
3640 The above functions compute the cross product of the given
3641 sets or relations. The domains and ranges of the results
3642 are wrapped maps between domains and ranges of the inputs.
3643 To obtain a ``flat'' product, use the following functions
3646 __isl_give isl_basic_set *isl_basic_set_flat_product(
3647 __isl_take isl_basic_set *bset1,
3648 __isl_take isl_basic_set *bset2);
3649 __isl_give isl_set *isl_set_flat_product(
3650 __isl_take isl_set *set1,
3651 __isl_take isl_set *set2);
3652 __isl_give isl_basic_map *isl_basic_map_flat_range_product(
3653 __isl_take isl_basic_map *bmap1,
3654 __isl_take isl_basic_map *bmap2);
3655 __isl_give isl_map *isl_map_flat_domain_product(
3656 __isl_take isl_map *map1,
3657 __isl_take isl_map *map2);
3658 __isl_give isl_map *isl_map_flat_range_product(
3659 __isl_take isl_map *map1,
3660 __isl_take isl_map *map2);
3661 __isl_give isl_union_map *isl_union_map_flat_range_product(
3662 __isl_take isl_union_map *umap1,
3663 __isl_take isl_union_map *umap2);
3664 __isl_give isl_basic_map *isl_basic_map_flat_product(
3665 __isl_take isl_basic_map *bmap1,
3666 __isl_take isl_basic_map *bmap2);
3667 __isl_give isl_map *isl_map_flat_product(
3668 __isl_take isl_map *map1,
3669 __isl_take isl_map *map2);
3671 #include <isl/space.h>
3672 __isl_give isl_space *isl_space_domain_factor_domain(
3673 __isl_take isl_space *space);
3674 __isl_give isl_space *isl_space_range_factor_domain(
3675 __isl_take isl_space *space);
3676 __isl_give isl_space *isl_space_range_factor_range(
3677 __isl_take isl_space *space);
3679 The functions C<isl_space_range_factor_domain> and
3680 C<isl_space_range_factor_range> extract the two arguments from
3681 the result of a call to C<isl_space_range_product>.
3683 The arguments of a call to C<isl_map_range_product> can be extracted
3684 from the result using the following two functions.
3686 #include <isl/map.h>
3687 __isl_give isl_map *isl_map_range_factor_domain(
3688 __isl_take isl_map *map);
3689 __isl_give isl_map *isl_map_range_factor_range(
3690 __isl_take isl_map *map);
3692 =item * Simplification
3694 __isl_give isl_basic_set *isl_basic_set_gist(
3695 __isl_take isl_basic_set *bset,
3696 __isl_take isl_basic_set *context);
3697 __isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
3698 __isl_take isl_set *context);
3699 __isl_give isl_set *isl_set_gist_params(
3700 __isl_take isl_set *set,
3701 __isl_take isl_set *context);
3702 __isl_give isl_union_set *isl_union_set_gist(
3703 __isl_take isl_union_set *uset,
3704 __isl_take isl_union_set *context);
3705 __isl_give isl_union_set *isl_union_set_gist_params(
3706 __isl_take isl_union_set *uset,
3707 __isl_take isl_set *set);
3708 __isl_give isl_basic_map *isl_basic_map_gist(
3709 __isl_take isl_basic_map *bmap,
3710 __isl_take isl_basic_map *context);
3711 __isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
3712 __isl_take isl_map *context);
3713 __isl_give isl_map *isl_map_gist_params(
3714 __isl_take isl_map *map,
3715 __isl_take isl_set *context);
3716 __isl_give isl_map *isl_map_gist_domain(
3717 __isl_take isl_map *map,
3718 __isl_take isl_set *context);
3719 __isl_give isl_map *isl_map_gist_range(
3720 __isl_take isl_map *map,
3721 __isl_take isl_set *context);
3722 __isl_give isl_union_map *isl_union_map_gist(
3723 __isl_take isl_union_map *umap,
3724 __isl_take isl_union_map *context);
3725 __isl_give isl_union_map *isl_union_map_gist_params(
3726 __isl_take isl_union_map *umap,
3727 __isl_take isl_set *set);
3728 __isl_give isl_union_map *isl_union_map_gist_domain(
3729 __isl_take isl_union_map *umap,
3730 __isl_take isl_union_set *uset);
3731 __isl_give isl_union_map *isl_union_map_gist_range(
3732 __isl_take isl_union_map *umap,
3733 __isl_take isl_union_set *uset);
3735 The gist operation returns a set or relation that has the
3736 same intersection with the context as the input set or relation.
3737 Any implicit equality in the intersection is made explicit in the result,
3738 while all inequalities that are redundant with respect to the intersection
3740 In case of union sets and relations, the gist operation is performed
3745 =head3 Lexicographic Optimization
3747 Given a (basic) set C<set> (or C<bset>) and a zero-dimensional domain C<dom>,
3748 the following functions
3749 compute a set that contains the lexicographic minimum or maximum
3750 of the elements in C<set> (or C<bset>) for those values of the parameters
3751 that satisfy C<dom>.
3752 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
3753 that contains the parameter values in C<dom> for which C<set> (or C<bset>)
3755 In other words, the union of the parameter values
3756 for which the result is non-empty and of C<*empty>
3759 __isl_give isl_set *isl_basic_set_partial_lexmin(
3760 __isl_take isl_basic_set *bset,
3761 __isl_take isl_basic_set *dom,
3762 __isl_give isl_set **empty);
3763 __isl_give isl_set *isl_basic_set_partial_lexmax(
3764 __isl_take isl_basic_set *bset,
3765 __isl_take isl_basic_set *dom,
3766 __isl_give isl_set **empty);
3767 __isl_give isl_set *isl_set_partial_lexmin(
3768 __isl_take isl_set *set, __isl_take isl_set *dom,
3769 __isl_give isl_set **empty);
3770 __isl_give isl_set *isl_set_partial_lexmax(
3771 __isl_take isl_set *set, __isl_take isl_set *dom,
3772 __isl_give isl_set **empty);
3774 Given a (basic) set C<set> (or C<bset>), the following functions simply
3775 return a set containing the lexicographic minimum or maximum
3776 of the elements in C<set> (or C<bset>).
3777 In case of union sets, the optimum is computed per space.
3779 __isl_give isl_set *isl_basic_set_lexmin(
3780 __isl_take isl_basic_set *bset);
3781 __isl_give isl_set *isl_basic_set_lexmax(
3782 __isl_take isl_basic_set *bset);
3783 __isl_give isl_set *isl_set_lexmin(
3784 __isl_take isl_set *set);
3785 __isl_give isl_set *isl_set_lexmax(
3786 __isl_take isl_set *set);
3787 __isl_give isl_union_set *isl_union_set_lexmin(
3788 __isl_take isl_union_set *uset);
3789 __isl_give isl_union_set *isl_union_set_lexmax(
3790 __isl_take isl_union_set *uset);
3792 Given a (basic) relation C<map> (or C<bmap>) and a domain C<dom>,
3793 the following functions
3794 compute a relation that maps each element of C<dom>
3795 to the single lexicographic minimum or maximum
3796 of the elements that are associated to that same
3797 element in C<map> (or C<bmap>).
3798 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
3799 that contains the elements in C<dom> that do not map
3800 to any elements in C<map> (or C<bmap>).
3801 In other words, the union of the domain of the result and of C<*empty>
3804 __isl_give isl_map *isl_basic_map_partial_lexmax(
3805 __isl_take isl_basic_map *bmap,
3806 __isl_take isl_basic_set *dom,
3807 __isl_give isl_set **empty);
3808 __isl_give isl_map *isl_basic_map_partial_lexmin(
3809 __isl_take isl_basic_map *bmap,
3810 __isl_take isl_basic_set *dom,
3811 __isl_give isl_set **empty);
3812 __isl_give isl_map *isl_map_partial_lexmax(
3813 __isl_take isl_map *map, __isl_take isl_set *dom,
3814 __isl_give isl_set **empty);
3815 __isl_give isl_map *isl_map_partial_lexmin(
3816 __isl_take isl_map *map, __isl_take isl_set *dom,
3817 __isl_give isl_set **empty);
3819 Given a (basic) map C<map> (or C<bmap>), the following functions simply
3820 return a map mapping each element in the domain of
3821 C<map> (or C<bmap>) to the lexicographic minimum or maximum
3822 of all elements associated to that element.
3823 In case of union relations, the optimum is computed per space.
3825 __isl_give isl_map *isl_basic_map_lexmin(
3826 __isl_take isl_basic_map *bmap);
3827 __isl_give isl_map *isl_basic_map_lexmax(
3828 __isl_take isl_basic_map *bmap);
3829 __isl_give isl_map *isl_map_lexmin(
3830 __isl_take isl_map *map);
3831 __isl_give isl_map *isl_map_lexmax(
3832 __isl_take isl_map *map);
3833 __isl_give isl_union_map *isl_union_map_lexmin(
3834 __isl_take isl_union_map *umap);
3835 __isl_give isl_union_map *isl_union_map_lexmax(
3836 __isl_take isl_union_map *umap);
3838 The following functions return their result in the form of
3839 a piecewise multi-affine expression
3840 (See L<"Piecewise Multiple Quasi Affine Expressions">),
3841 but are otherwise equivalent to the corresponding functions
3842 returning a basic set or relation.
3844 __isl_give isl_pw_multi_aff *
3845 isl_basic_map_lexmin_pw_multi_aff(
3846 __isl_take isl_basic_map *bmap);
3847 __isl_give isl_pw_multi_aff *
3848 isl_basic_set_partial_lexmin_pw_multi_aff(
3849 __isl_take isl_basic_set *bset,
3850 __isl_take isl_basic_set *dom,
3851 __isl_give isl_set **empty);
3852 __isl_give isl_pw_multi_aff *
3853 isl_basic_set_partial_lexmax_pw_multi_aff(
3854 __isl_take isl_basic_set *bset,
3855 __isl_take isl_basic_set *dom,
3856 __isl_give isl_set **empty);
3857 __isl_give isl_pw_multi_aff *
3858 isl_basic_map_partial_lexmin_pw_multi_aff(
3859 __isl_take isl_basic_map *bmap,
3860 __isl_take isl_basic_set *dom,
3861 __isl_give isl_set **empty);
3862 __isl_give isl_pw_multi_aff *
3863 isl_basic_map_partial_lexmax_pw_multi_aff(
3864 __isl_take isl_basic_map *bmap,
3865 __isl_take isl_basic_set *dom,
3866 __isl_give isl_set **empty);
3867 __isl_give isl_pw_multi_aff *isl_set_lexmin_pw_multi_aff(
3868 __isl_take isl_set *set);
3869 __isl_give isl_pw_multi_aff *isl_set_lexmax_pw_multi_aff(
3870 __isl_take isl_set *set);
3871 __isl_give isl_pw_multi_aff *isl_map_lexmin_pw_multi_aff(
3872 __isl_take isl_map *map);
3873 __isl_give isl_pw_multi_aff *isl_map_lexmax_pw_multi_aff(
3874 __isl_take isl_map *map);
3878 Lists are defined over several element types, including
3879 C<isl_val>, C<isl_id>, C<isl_aff>, C<isl_pw_aff>, C<isl_constraint>,
3880 C<isl_basic_set>, C<isl_set>, C<isl_ast_expr> and C<isl_ast_node>.
3881 Here we take lists of C<isl_set>s as an example.
3882 Lists can be created, copied, modified and freed using the following functions.
3884 #include <isl/set.h>
3885 __isl_give isl_set_list *isl_set_list_from_set(
3886 __isl_take isl_set *el);
3887 __isl_give isl_set_list *isl_set_list_alloc(
3888 isl_ctx *ctx, int n);
3889 __isl_give isl_set_list *isl_set_list_copy(
3890 __isl_keep isl_set_list *list);
3891 __isl_give isl_set_list *isl_set_list_insert(
3892 __isl_take isl_set_list *list, unsigned pos,
3893 __isl_take isl_set *el);
3894 __isl_give isl_set_list *isl_set_list_add(
3895 __isl_take isl_set_list *list,
3896 __isl_take isl_set *el);
3897 __isl_give isl_set_list *isl_set_list_drop(
3898 __isl_take isl_set_list *list,
3899 unsigned first, unsigned n);
3900 __isl_give isl_set_list *isl_set_list_set_set(
3901 __isl_take isl_set_list *list, int index,
3902 __isl_take isl_set *set);
3903 __isl_give isl_set_list *isl_set_list_concat(
3904 __isl_take isl_set_list *list1,
3905 __isl_take isl_set_list *list2);
3906 __isl_give isl_set_list *isl_set_list_sort(
3907 __isl_take isl_set_list *list,
3908 int (*cmp)(__isl_keep isl_set *a,
3909 __isl_keep isl_set *b, void *user),
3911 __isl_null isl_set_list *isl_set_list_free(
3912 __isl_take isl_set_list *list);
3914 C<isl_set_list_alloc> creates an empty list with a capacity for
3915 C<n> elements. C<isl_set_list_from_set> creates a list with a single
3918 Lists can be inspected using the following functions.
3920 #include <isl/set.h>
3921 isl_ctx *isl_set_list_get_ctx(__isl_keep isl_set_list *list);
3922 int isl_set_list_n_set(__isl_keep isl_set_list *list);
3923 __isl_give isl_set *isl_set_list_get_set(
3924 __isl_keep isl_set_list *list, int index);
3925 int isl_set_list_foreach(__isl_keep isl_set_list *list,
3926 int (*fn)(__isl_take isl_set *el, void *user),
3928 int isl_set_list_foreach_scc(__isl_keep isl_set_list *list,
3929 int (*follows)(__isl_keep isl_set *a,
3930 __isl_keep isl_set *b, void *user),
3932 int (*fn)(__isl_take isl_set *el, void *user),
3935 The function C<isl_set_list_foreach_scc> calls C<fn> on each of the
3936 strongly connected components of the graph with as vertices the elements
3937 of C<list> and a directed edge from vertex C<b> to vertex C<a>
3938 iff C<follows(a, b)> returns C<1>. The callbacks C<follows> and C<fn>
3939 should return C<-1> on error.
3941 Lists can be printed using
3943 #include <isl/set.h>
3944 __isl_give isl_printer *isl_printer_print_set_list(
3945 __isl_take isl_printer *p,
3946 __isl_keep isl_set_list *list);
3948 =head2 Associative arrays
3950 Associative arrays map isl objects of a specific type to isl objects
3951 of some (other) specific type. They are defined for several pairs
3952 of types, including (C<isl_map>, C<isl_basic_set>),
3953 (C<isl_id>, C<isl_ast_expr>) and.
3954 (C<isl_id>, C<isl_pw_aff>).
3955 Here, we take associative arrays that map C<isl_id>s to C<isl_ast_expr>s
3958 Associative arrays can be created, copied and freed using
3959 the following functions.
3961 #include <isl/id_to_ast_expr.h>
3962 __isl_give id_to_ast_expr *isl_id_to_ast_expr_alloc(
3963 isl_ctx *ctx, int min_size);
3964 __isl_give id_to_ast_expr *isl_id_to_ast_expr_copy(
3965 __isl_keep id_to_ast_expr *id2expr);
3966 __isl_null id_to_ast_expr *isl_id_to_ast_expr_free(
3967 __isl_take id_to_ast_expr *id2expr);
3969 The C<min_size> argument to C<isl_id_to_ast_expr_alloc> can be used
3970 to specify the expected size of the associative array.
3971 The associative array will be grown automatically as needed.
3973 Associative arrays can be inspected using the following functions.
3975 #include <isl/id_to_ast_expr.h>
3976 isl_ctx *isl_id_to_ast_expr_get_ctx(
3977 __isl_keep id_to_ast_expr *id2expr);
3978 int isl_id_to_ast_expr_has(
3979 __isl_keep id_to_ast_expr *id2expr,
3980 __isl_keep isl_id *key);
3981 __isl_give isl_ast_expr *isl_id_to_ast_expr_get(
3982 __isl_keep id_to_ast_expr *id2expr,
3983 __isl_take isl_id *key);
3984 int isl_id_to_ast_expr_foreach(
3985 __isl_keep id_to_ast_expr *id2expr,
3986 int (*fn)(__isl_take isl_id *key,
3987 __isl_take isl_ast_expr *val, void *user),
3990 They can be modified using the following function.
3992 #include <isl/id_to_ast_expr.h>
3993 __isl_give id_to_ast_expr *isl_id_to_ast_expr_set(
3994 __isl_take id_to_ast_expr *id2expr,
3995 __isl_take isl_id *key,
3996 __isl_take isl_ast_expr *val);
3997 __isl_give id_to_ast_expr *isl_id_to_ast_expr_drop(
3998 __isl_take id_to_ast_expr *id2expr,
3999 __isl_take isl_id *key);
4001 Associative arrays can be printed using the following function.
4003 #include <isl/id_to_ast_expr.h>
4004 __isl_give isl_printer *isl_printer_print_id_to_ast_expr(
4005 __isl_take isl_printer *p,
4006 __isl_keep id_to_ast_expr *id2expr);
4008 =head2 Multiple Values
4010 An C<isl_multi_val> object represents a sequence of zero or more values,
4011 living in a set space.
4013 An C<isl_multi_val> can be constructed from an C<isl_val_list>
4014 using the following function
4016 #include <isl/val.h>
4017 __isl_give isl_multi_val *isl_multi_val_from_val_list(
4018 __isl_take isl_space *space,
4019 __isl_take isl_val_list *list);
4021 The zero multiple value (with value zero for each set dimension)
4022 can be created using the following function.
4024 #include <isl/val.h>
4025 __isl_give isl_multi_val *isl_multi_val_zero(
4026 __isl_take isl_space *space);
4028 Multiple values can be copied and freed using
4030 #include <isl/val.h>
4031 __isl_give isl_multi_val *isl_multi_val_copy(
4032 __isl_keep isl_multi_val *mv);
4033 __isl_null isl_multi_val *isl_multi_val_free(
4034 __isl_take isl_multi_val *mv);
4036 They can be inspected using
4038 #include <isl/val.h>
4039 isl_ctx *isl_multi_val_get_ctx(
4040 __isl_keep isl_multi_val *mv);
4041 __isl_give isl_val *isl_multi_val_get_val(
4042 __isl_keep isl_multi_val *mv, int pos);
4043 int isl_multi_val_range_is_wrapping(
4044 __isl_keep isl_multi_val *mv);
4046 They can be modified using
4048 #include <isl/val.h>
4049 __isl_give isl_multi_val *isl_multi_val_set_val(
4050 __isl_take isl_multi_val *mv, int pos,
4051 __isl_take isl_val *val);
4053 __isl_give isl_multi_val *isl_multi_val_insert_dims(
4054 __isl_take isl_multi_val *mv,
4055 enum isl_dim_type type, unsigned first, unsigned n);
4056 __isl_give isl_multi_val *isl_multi_val_add_dims(
4057 __isl_take isl_multi_val *mv,
4058 enum isl_dim_type type, unsigned n);
4059 __isl_give isl_multi_val *isl_multi_val_drop_dims(
4060 __isl_take isl_multi_val *mv,
4061 enum isl_dim_type type, unsigned first, unsigned n);
4065 #include <isl/val.h>
4066 __isl_give isl_multi_val *isl_multi_val_align_params(
4067 __isl_take isl_multi_val *mv,
4068 __isl_take isl_space *model);
4069 __isl_give isl_multi_val *isl_multi_val_from_range(
4070 __isl_take isl_multi_val *mv);
4071 __isl_give isl_multi_val *isl_multi_val_range_splice(
4072 __isl_take isl_multi_val *mv1, unsigned pos,
4073 __isl_take isl_multi_val *mv2);
4074 __isl_give isl_multi_val *isl_multi_val_range_product(
4075 __isl_take isl_multi_val *mv1,
4076 __isl_take isl_multi_val *mv2);
4077 __isl_give isl_multi_val *
4078 isl_multi_val_range_factor_domain(
4079 __isl_take isl_multi_val *mv);
4080 __isl_give isl_multi_val *
4081 isl_multi_val_range_factor_range(
4082 __isl_take isl_multi_val *mv);
4083 __isl_give isl_multi_val *isl_multi_val_flat_range_product(
4084 __isl_take isl_multi_val *mv1,
4085 __isl_take isl_multi_aff *mv2);
4086 __isl_give isl_multi_val *isl_multi_val_product(
4087 __isl_take isl_multi_val *mv1,
4088 __isl_take isl_multi_val *mv2);
4089 __isl_give isl_multi_val *isl_multi_val_add_val(
4090 __isl_take isl_multi_val *mv,
4091 __isl_take isl_val *v);
4092 __isl_give isl_multi_val *isl_multi_val_mod_val(
4093 __isl_take isl_multi_val *mv,
4094 __isl_take isl_val *v);
4095 __isl_give isl_multi_val *isl_multi_val_scale_val(
4096 __isl_take isl_multi_val *mv,
4097 __isl_take isl_val *v);
4098 __isl_give isl_multi_val *isl_multi_val_scale_multi_val(
4099 __isl_take isl_multi_val *mv1,
4100 __isl_take isl_multi_val *mv2);
4101 __isl_give isl_multi_val *
4102 isl_multi_val_scale_down_multi_val(
4103 __isl_take isl_multi_val *mv1,
4104 __isl_take isl_multi_val *mv2);
4106 A multiple value can be printed using
4108 __isl_give isl_printer *isl_printer_print_multi_val(
4109 __isl_take isl_printer *p,
4110 __isl_keep isl_multi_val *mv);
4114 Vectors can be created, copied and freed using the following functions.
4116 #include <isl/vec.h>
4117 __isl_give isl_vec *isl_vec_alloc(isl_ctx *ctx,
4119 __isl_give isl_vec *isl_vec_copy(__isl_keep isl_vec *vec);
4120 __isl_null isl_vec *isl_vec_free(__isl_take isl_vec *vec);
4122 Note that the elements of a newly created vector may have arbitrary values.
4123 The elements can be changed and inspected using the following functions.
4125 isl_ctx *isl_vec_get_ctx(__isl_keep isl_vec *vec);
4126 int isl_vec_size(__isl_keep isl_vec *vec);
4127 __isl_give isl_val *isl_vec_get_element_val(
4128 __isl_keep isl_vec *vec, int pos);
4129 __isl_give isl_vec *isl_vec_set_element_si(
4130 __isl_take isl_vec *vec, int pos, int v);
4131 __isl_give isl_vec *isl_vec_set_element_val(
4132 __isl_take isl_vec *vec, int pos,
4133 __isl_take isl_val *v);
4134 __isl_give isl_vec *isl_vec_set_si(__isl_take isl_vec *vec,
4136 __isl_give isl_vec *isl_vec_set_val(
4137 __isl_take isl_vec *vec, __isl_take isl_val *v);
4138 int isl_vec_cmp_element(__isl_keep isl_vec *vec1,
4139 __isl_keep isl_vec *vec2, int pos);
4141 C<isl_vec_get_element> will return a negative value if anything went wrong.
4142 In that case, the value of C<*v> is undefined.
4144 The following function can be used to concatenate two vectors.
4146 __isl_give isl_vec *isl_vec_concat(__isl_take isl_vec *vec1,
4147 __isl_take isl_vec *vec2);
4151 Matrices can be created, copied and freed using the following functions.
4153 #include <isl/mat.h>
4154 __isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx,
4155 unsigned n_row, unsigned n_col);
4156 __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat);
4157 __isl_null isl_mat *isl_mat_free(__isl_take isl_mat *mat);
4159 Note that the elements of a newly created matrix may have arbitrary values.
4160 The elements can be changed and inspected using the following functions.
4162 isl_ctx *isl_mat_get_ctx(__isl_keep isl_mat *mat);
4163 int isl_mat_rows(__isl_keep isl_mat *mat);
4164 int isl_mat_cols(__isl_keep isl_mat *mat);
4165 __isl_give isl_val *isl_mat_get_element_val(
4166 __isl_keep isl_mat *mat, int row, int col);
4167 __isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat,
4168 int row, int col, int v);
4169 __isl_give isl_mat *isl_mat_set_element_val(
4170 __isl_take isl_mat *mat, int row, int col,
4171 __isl_take isl_val *v);
4173 C<isl_mat_get_element> will return a negative value if anything went wrong.
4174 In that case, the value of C<*v> is undefined.
4176 The following function can be used to compute the (right) inverse
4177 of a matrix, i.e., a matrix such that the product of the original
4178 and the inverse (in that order) is a multiple of the identity matrix.
4179 The input matrix is assumed to be of full row-rank.
4181 __isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat);
4183 The following function can be used to compute the (right) kernel
4184 (or null space) of a matrix, i.e., a matrix such that the product of
4185 the original and the kernel (in that order) is the zero matrix.
4187 __isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat);
4189 =head2 Piecewise Quasi Affine Expressions
4191 The zero quasi affine expression or the quasi affine expression
4192 that is equal to a given value or
4193 a specified dimension on a given domain can be created using
4195 __isl_give isl_aff *isl_aff_zero_on_domain(
4196 __isl_take isl_local_space *ls);
4197 __isl_give isl_pw_aff *isl_pw_aff_zero_on_domain(
4198 __isl_take isl_local_space *ls);
4199 __isl_give isl_aff *isl_aff_val_on_domain(
4200 __isl_take isl_local_space *ls,
4201 __isl_take isl_val *val);
4202 __isl_give isl_aff *isl_aff_var_on_domain(
4203 __isl_take isl_local_space *ls,
4204 enum isl_dim_type type, unsigned pos);
4205 __isl_give isl_pw_aff *isl_pw_aff_var_on_domain(
4206 __isl_take isl_local_space *ls,
4207 enum isl_dim_type type, unsigned pos);
4208 __isl_give isl_aff *isl_aff_nan_on_domain(
4209 __isl_take isl_local_space *ls);
4210 __isl_give isl_pw_aff *isl_pw_aff_nan_on_domain(
4211 __isl_take isl_local_space *ls);
4213 Note that the space in which the resulting objects live is a map space
4214 with the given space as domain and a one-dimensional range.
4216 An empty piecewise quasi affine expression (one with no cells)
4217 or a piecewise quasi affine expression with a single cell can
4218 be created using the following functions.
4220 #include <isl/aff.h>
4221 __isl_give isl_pw_aff *isl_pw_aff_empty(
4222 __isl_take isl_space *space);
4223 __isl_give isl_pw_aff *isl_pw_aff_alloc(
4224 __isl_take isl_set *set, __isl_take isl_aff *aff);
4225 __isl_give isl_pw_aff *isl_pw_aff_from_aff(
4226 __isl_take isl_aff *aff);
4228 A piecewise quasi affine expression that is equal to 1 on a set
4229 and 0 outside the set can be created using the following function.
4231 #include <isl/aff.h>
4232 __isl_give isl_pw_aff *isl_set_indicator_function(
4233 __isl_take isl_set *set);
4235 Quasi affine expressions can be copied and freed using
4237 #include <isl/aff.h>
4238 __isl_give isl_aff *isl_aff_copy(__isl_keep isl_aff *aff);
4239 __isl_null isl_aff *isl_aff_free(__isl_take isl_aff *aff);
4241 __isl_give isl_pw_aff *isl_pw_aff_copy(
4242 __isl_keep isl_pw_aff *pwaff);
4243 __isl_null isl_pw_aff *isl_pw_aff_free(
4244 __isl_take isl_pw_aff *pwaff);
4246 A (rational) bound on a dimension can be extracted from an C<isl_constraint>
4247 using the following function. The constraint is required to have
4248 a non-zero coefficient for the specified dimension.
4250 #include <isl/constraint.h>
4251 __isl_give isl_aff *isl_constraint_get_bound(
4252 __isl_keep isl_constraint *constraint,
4253 enum isl_dim_type type, int pos);
4255 The entire affine expression of the constraint can also be extracted
4256 using the following function.
4258 #include <isl/constraint.h>
4259 __isl_give isl_aff *isl_constraint_get_aff(
4260 __isl_keep isl_constraint *constraint);
4262 Conversely, an equality constraint equating
4263 the affine expression to zero or an inequality constraint enforcing
4264 the affine expression to be non-negative, can be constructed using
4266 __isl_give isl_constraint *isl_equality_from_aff(
4267 __isl_take isl_aff *aff);
4268 __isl_give isl_constraint *isl_inequality_from_aff(
4269 __isl_take isl_aff *aff);
4271 The expression can be inspected using
4273 #include <isl/aff.h>
4274 isl_ctx *isl_aff_get_ctx(__isl_keep isl_aff *aff);
4275 __isl_give isl_local_space *isl_aff_get_domain_local_space(
4276 __isl_keep isl_aff *aff);
4277 __isl_give isl_local_space *isl_aff_get_local_space(
4278 __isl_keep isl_aff *aff);
4279 __isl_give isl_val *isl_aff_get_constant_val(
4280 __isl_keep isl_aff *aff);
4281 __isl_give isl_val *isl_aff_get_coefficient_val(
4282 __isl_keep isl_aff *aff,
4283 enum isl_dim_type type, int pos);
4284 int isl_aff_coefficient_sgn(__isl_keep isl_aff *aff,
4285 enum isl_dim_type type, int pos);
4286 __isl_give isl_val *isl_aff_get_denominator_val(
4287 __isl_keep isl_aff *aff);
4288 __isl_give isl_aff *isl_aff_get_div(
4289 __isl_keep isl_aff *aff, int pos);
4291 int isl_pw_aff_n_piece(__isl_keep isl_pw_aff *pwaff);
4292 int isl_pw_aff_foreach_piece(__isl_keep isl_pw_aff *pwaff,
4293 int (*fn)(__isl_take isl_set *set,
4294 __isl_take isl_aff *aff,
4295 void *user), void *user);
4297 int isl_aff_is_cst(__isl_keep isl_aff *aff);
4298 int isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff);
4300 int isl_aff_is_nan(__isl_keep isl_aff *aff);
4301 int isl_pw_aff_involves_nan(__isl_keep isl_pw_aff *pa);
4303 int isl_aff_involves_dims(__isl_keep isl_aff *aff,
4304 enum isl_dim_type type, unsigned first, unsigned n);
4305 int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff,
4306 enum isl_dim_type type, unsigned first, unsigned n);
4308 isl_ctx *isl_pw_aff_get_ctx(__isl_keep isl_pw_aff *pwaff);
4309 int isl_pw_aff_is_empty(__isl_keep isl_pw_aff *pwaff);
4311 It can be modified using
4313 #include <isl/aff.h>
4314 __isl_give isl_aff *isl_aff_set_constant_si(
4315 __isl_take isl_aff *aff, int v);
4316 __isl_give isl_aff *isl_aff_set_constant_val(
4317 __isl_take isl_aff *aff, __isl_take isl_val *v);
4318 __isl_give isl_aff *isl_aff_set_coefficient_si(
4319 __isl_take isl_aff *aff,
4320 enum isl_dim_type type, int pos, int v);
4321 __isl_give isl_aff *isl_aff_set_coefficient_val(
4322 __isl_take isl_aff *aff,
4323 enum isl_dim_type type, int pos,
4324 __isl_take isl_val *v);
4326 __isl_give isl_aff *isl_aff_add_constant_si(
4327 __isl_take isl_aff *aff, int v);
4328 __isl_give isl_aff *isl_aff_add_constant_val(
4329 __isl_take isl_aff *aff, __isl_take isl_val *v);
4330 __isl_give isl_aff *isl_aff_add_constant_num_si(
4331 __isl_take isl_aff *aff, int v);
4332 __isl_give isl_aff *isl_aff_add_coefficient_si(
4333 __isl_take isl_aff *aff,
4334 enum isl_dim_type type, int pos, int v);
4335 __isl_give isl_aff *isl_aff_add_coefficient_val(
4336 __isl_take isl_aff *aff,
4337 enum isl_dim_type type, int pos,
4338 __isl_take isl_val *v);
4340 __isl_give isl_aff *isl_aff_insert_dims(
4341 __isl_take isl_aff *aff,
4342 enum isl_dim_type type, unsigned first, unsigned n);
4343 __isl_give isl_pw_aff *isl_pw_aff_insert_dims(
4344 __isl_take isl_pw_aff *pwaff,
4345 enum isl_dim_type type, unsigned first, unsigned n);
4346 __isl_give isl_aff *isl_aff_add_dims(
4347 __isl_take isl_aff *aff,
4348 enum isl_dim_type type, unsigned n);
4349 __isl_give isl_pw_aff *isl_pw_aff_add_dims(
4350 __isl_take isl_pw_aff *pwaff,
4351 enum isl_dim_type type, unsigned n);
4352 __isl_give isl_aff *isl_aff_drop_dims(
4353 __isl_take isl_aff *aff,
4354 enum isl_dim_type type, unsigned first, unsigned n);
4355 __isl_give isl_pw_aff *isl_pw_aff_drop_dims(
4356 __isl_take isl_pw_aff *pwaff,
4357 enum isl_dim_type type, unsigned first, unsigned n);
4358 __isl_give isl_aff *isl_aff_move_dims(
4359 __isl_take isl_aff *aff,
4360 enum isl_dim_type dst_type, unsigned dst_pos,
4361 enum isl_dim_type src_type, unsigned src_pos,
4363 __isl_give isl_pw_aff *isl_pw_aff_move_dims(
4364 __isl_take isl_pw_aff *pa,
4365 enum isl_dim_type dst_type, unsigned dst_pos,
4366 enum isl_dim_type src_type, unsigned src_pos,
4369 Note that C<isl_aff_set_constant_si> and C<isl_aff_set_coefficient_si>
4370 set the I<numerator> of the constant or coefficient, while
4371 C<isl_aff_set_constant_val> and C<isl_aff_set_coefficient_val> set
4372 the constant or coefficient as a whole.
4373 The C<add_constant> and C<add_coefficient> functions add an integer
4374 or rational value to
4375 the possibly rational constant or coefficient.
4376 The C<add_constant_num> functions add an integer value to
4379 To check whether an affine expressions is obviously zero
4380 or (obviously) equal to some other affine expression, use
4382 #include <isl/aff.h>
4383 int isl_aff_plain_is_zero(__isl_keep isl_aff *aff);
4384 int isl_aff_plain_is_equal(__isl_keep isl_aff *aff1,
4385 __isl_keep isl_aff *aff2);
4386 int isl_pw_aff_plain_is_equal(
4387 __isl_keep isl_pw_aff *pwaff1,
4388 __isl_keep isl_pw_aff *pwaff2);
4389 int isl_pw_aff_is_equal(__isl_keep isl_pw_aff *pa1,
4390 __isl_keep isl_pw_aff *pa2);
4391 int isl_pw_aff_plain_cmp(__isl_keep isl_pw_aff *pa1,
4392 __isl_keep isl_pw_aff *pa2);
4394 The function C<isl_pw_aff_plain_cmp> can be used to sort
4395 C<isl_pw_aff>s. The order is not strictly defined.
4396 The current order sorts expressions that only involve
4397 earlier dimensions before those that involve later dimensions.
4401 #include <isl/aff.h>
4402 __isl_give isl_aff *isl_aff_add(__isl_take isl_aff *aff1,
4403 __isl_take isl_aff *aff2);
4404 __isl_give isl_pw_aff *isl_pw_aff_add(
4405 __isl_take isl_pw_aff *pwaff1,
4406 __isl_take isl_pw_aff *pwaff2);
4407 __isl_give isl_pw_aff *isl_pw_aff_min(
4408 __isl_take isl_pw_aff *pwaff1,
4409 __isl_take isl_pw_aff *pwaff2);
4410 __isl_give isl_pw_aff *isl_pw_aff_max(
4411 __isl_take isl_pw_aff *pwaff1,
4412 __isl_take isl_pw_aff *pwaff2);
4413 __isl_give isl_aff *isl_aff_sub(__isl_take isl_aff *aff1,
4414 __isl_take isl_aff *aff2);
4415 __isl_give isl_pw_aff *isl_pw_aff_sub(
4416 __isl_take isl_pw_aff *pwaff1,
4417 __isl_take isl_pw_aff *pwaff2);
4418 __isl_give isl_aff *isl_aff_neg(__isl_take isl_aff *aff);
4419 __isl_give isl_pw_aff *isl_pw_aff_neg(
4420 __isl_take isl_pw_aff *pwaff);
4421 __isl_give isl_aff *isl_aff_ceil(__isl_take isl_aff *aff);
4422 __isl_give isl_pw_aff *isl_pw_aff_ceil(
4423 __isl_take isl_pw_aff *pwaff);
4424 __isl_give isl_aff *isl_aff_floor(__isl_take isl_aff *aff);
4425 __isl_give isl_pw_aff *isl_pw_aff_floor(
4426 __isl_take isl_pw_aff *pwaff);
4427 __isl_give isl_aff *isl_aff_mod_val(__isl_take isl_aff *aff,
4428 __isl_take isl_val *mod);
4429 __isl_give isl_pw_aff *isl_pw_aff_mod_val(
4430 __isl_take isl_pw_aff *pa,
4431 __isl_take isl_val *mod);
4432 __isl_give isl_aff *isl_aff_scale_val(__isl_take isl_aff *aff,
4433 __isl_take isl_val *v);
4434 __isl_give isl_pw_aff *isl_pw_aff_scale_val(
4435 __isl_take isl_pw_aff *pa, __isl_take isl_val *v);
4436 __isl_give isl_aff *isl_aff_scale_down_ui(
4437 __isl_take isl_aff *aff, unsigned f);
4438 __isl_give isl_aff *isl_aff_scale_down_val(
4439 __isl_take isl_aff *aff, __isl_take isl_val *v);
4440 __isl_give isl_pw_aff *isl_pw_aff_scale_down_val(
4441 __isl_take isl_pw_aff *pa,
4442 __isl_take isl_val *f);
4444 __isl_give isl_pw_aff *isl_pw_aff_list_min(
4445 __isl_take isl_pw_aff_list *list);
4446 __isl_give isl_pw_aff *isl_pw_aff_list_max(
4447 __isl_take isl_pw_aff_list *list);
4449 __isl_give isl_pw_aff *isl_pw_aff_coalesce(
4450 __isl_take isl_pw_aff *pwqp);
4452 __isl_give isl_aff *isl_aff_align_params(
4453 __isl_take isl_aff *aff,
4454 __isl_take isl_space *model);
4455 __isl_give isl_pw_aff *isl_pw_aff_align_params(
4456 __isl_take isl_pw_aff *pwaff,
4457 __isl_take isl_space *model);
4459 __isl_give isl_aff *isl_aff_project_domain_on_params(
4460 __isl_take isl_aff *aff);
4461 __isl_give isl_pw_aff *isl_pw_aff_from_range(
4462 __isl_take isl_pw_aff *pwa);
4464 __isl_give isl_aff *isl_aff_gist_params(
4465 __isl_take isl_aff *aff,
4466 __isl_take isl_set *context);
4467 __isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff,
4468 __isl_take isl_set *context);
4469 __isl_give isl_pw_aff *isl_pw_aff_gist_params(
4470 __isl_take isl_pw_aff *pwaff,
4471 __isl_take isl_set *context);
4472 __isl_give isl_pw_aff *isl_pw_aff_gist(
4473 __isl_take isl_pw_aff *pwaff,
4474 __isl_take isl_set *context);
4476 __isl_give isl_set *isl_pw_aff_domain(
4477 __isl_take isl_pw_aff *pwaff);
4478 __isl_give isl_set *isl_pw_aff_params(
4479 __isl_take isl_pw_aff *pwa);
4480 __isl_give isl_pw_aff *isl_pw_aff_intersect_domain(
4481 __isl_take isl_pw_aff *pa,
4482 __isl_take isl_set *set);
4483 __isl_give isl_pw_aff *isl_pw_aff_intersect_params(
4484 __isl_take isl_pw_aff *pa,
4485 __isl_take isl_set *set);
4487 __isl_give isl_aff *isl_aff_mul(__isl_take isl_aff *aff1,
4488 __isl_take isl_aff *aff2);
4489 __isl_give isl_aff *isl_aff_div(__isl_take isl_aff *aff1,
4490 __isl_take isl_aff *aff2);
4491 __isl_give isl_pw_aff *isl_pw_aff_mul(
4492 __isl_take isl_pw_aff *pwaff1,
4493 __isl_take isl_pw_aff *pwaff2);
4494 __isl_give isl_pw_aff *isl_pw_aff_div(
4495 __isl_take isl_pw_aff *pa1,
4496 __isl_take isl_pw_aff *pa2);
4497 __isl_give isl_pw_aff *isl_pw_aff_tdiv_q(
4498 __isl_take isl_pw_aff *pa1,
4499 __isl_take isl_pw_aff *pa2);
4500 __isl_give isl_pw_aff *isl_pw_aff_tdiv_r(
4501 __isl_take isl_pw_aff *pa1,
4502 __isl_take isl_pw_aff *pa2);
4504 When multiplying two affine expressions, at least one of the two needs
4505 to be a constant. Similarly, when dividing an affine expression by another,
4506 the second expression needs to be a constant.
4507 C<isl_pw_aff_tdiv_q> computes the quotient of an integer division with
4508 rounding towards zero. C<isl_pw_aff_tdiv_r> computes the corresponding
4511 #include <isl/aff.h>
4512 __isl_give isl_aff *isl_aff_pullback_aff(
4513 __isl_take isl_aff *aff1,
4514 __isl_take isl_aff *aff2);
4515 __isl_give isl_aff *isl_aff_pullback_multi_aff(
4516 __isl_take isl_aff *aff,
4517 __isl_take isl_multi_aff *ma);
4518 __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_aff(
4519 __isl_take isl_pw_aff *pa,
4520 __isl_take isl_multi_aff *ma);
4521 __isl_give isl_pw_aff *isl_pw_aff_pullback_pw_multi_aff(
4522 __isl_take isl_pw_aff *pa,
4523 __isl_take isl_pw_multi_aff *pma);
4524 __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_pw_aff(
4525 __isl_take isl_pw_aff *pa,
4526 __isl_take isl_multi_pw_aff *mpa);
4528 These functions precompose the input expression by the given
4529 C<isl_aff>, C<isl_multi_aff> or C<isl_pw_multi_aff>. In other words,
4530 the C<isl_aff>, C<isl_multi_aff> or C<isl_pw_multi_aff> is plugged
4531 into the (piecewise) affine expression.
4532 Objects of type C<isl_multi_aff> are described in
4533 L</"Piecewise Multiple Quasi Affine Expressions">.
4535 #include <isl/aff.h>
4536 __isl_give isl_basic_set *isl_aff_zero_basic_set(
4537 __isl_take isl_aff *aff);
4538 __isl_give isl_basic_set *isl_aff_neg_basic_set(
4539 __isl_take isl_aff *aff);
4540 __isl_give isl_basic_set *isl_aff_le_basic_set(
4541 __isl_take isl_aff *aff1, __isl_take isl_aff *aff2);
4542 __isl_give isl_basic_set *isl_aff_ge_basic_set(
4543 __isl_take isl_aff *aff1, __isl_take isl_aff *aff2);
4544 __isl_give isl_set *isl_pw_aff_eq_set(
4545 __isl_take isl_pw_aff *pwaff1,
4546 __isl_take isl_pw_aff *pwaff2);
4547 __isl_give isl_set *isl_pw_aff_ne_set(
4548 __isl_take isl_pw_aff *pwaff1,
4549 __isl_take isl_pw_aff *pwaff2);
4550 __isl_give isl_set *isl_pw_aff_le_set(
4551 __isl_take isl_pw_aff *pwaff1,
4552 __isl_take isl_pw_aff *pwaff2);
4553 __isl_give isl_set *isl_pw_aff_lt_set(
4554 __isl_take isl_pw_aff *pwaff1,
4555 __isl_take isl_pw_aff *pwaff2);
4556 __isl_give isl_set *isl_pw_aff_ge_set(
4557 __isl_take isl_pw_aff *pwaff1,
4558 __isl_take isl_pw_aff *pwaff2);
4559 __isl_give isl_set *isl_pw_aff_gt_set(
4560 __isl_take isl_pw_aff *pwaff1,
4561 __isl_take isl_pw_aff *pwaff2);
4563 __isl_give isl_set *isl_pw_aff_list_eq_set(
4564 __isl_take isl_pw_aff_list *list1,
4565 __isl_take isl_pw_aff_list *list2);
4566 __isl_give isl_set *isl_pw_aff_list_ne_set(
4567 __isl_take isl_pw_aff_list *list1,
4568 __isl_take isl_pw_aff_list *list2);
4569 __isl_give isl_set *isl_pw_aff_list_le_set(
4570 __isl_take isl_pw_aff_list *list1,
4571 __isl_take isl_pw_aff_list *list2);
4572 __isl_give isl_set *isl_pw_aff_list_lt_set(
4573 __isl_take isl_pw_aff_list *list1,
4574 __isl_take isl_pw_aff_list *list2);
4575 __isl_give isl_set *isl_pw_aff_list_ge_set(
4576 __isl_take isl_pw_aff_list *list1,
4577 __isl_take isl_pw_aff_list *list2);
4578 __isl_give isl_set *isl_pw_aff_list_gt_set(
4579 __isl_take isl_pw_aff_list *list1,
4580 __isl_take isl_pw_aff_list *list2);
4582 The function C<isl_aff_neg_basic_set> returns a basic set
4583 containing those elements in the domain space
4584 of C<aff> where C<aff> is negative.
4585 The function C<isl_aff_ge_basic_set> returns a basic set
4586 containing those elements in the shared space
4587 of C<aff1> and C<aff2> where C<aff1> is greater than or equal to C<aff2>.
4588 The function C<isl_pw_aff_ge_set> returns a set
4589 containing those elements in the shared domain
4590 of C<pwaff1> and C<pwaff2> where C<pwaff1> is greater than or equal to C<pwaff2>.
4591 The functions operating on C<isl_pw_aff_list> apply the corresponding
4592 C<isl_pw_aff> function to each pair of elements in the two lists.
4594 #include <isl/aff.h>
4595 __isl_give isl_set *isl_pw_aff_nonneg_set(
4596 __isl_take isl_pw_aff *pwaff);
4597 __isl_give isl_set *isl_pw_aff_zero_set(
4598 __isl_take isl_pw_aff *pwaff);
4599 __isl_give isl_set *isl_pw_aff_non_zero_set(
4600 __isl_take isl_pw_aff *pwaff);
4602 The function C<isl_pw_aff_nonneg_set> returns a set
4603 containing those elements in the domain
4604 of C<pwaff> where C<pwaff> is non-negative.
4606 #include <isl/aff.h>
4607 __isl_give isl_pw_aff *isl_pw_aff_cond(
4608 __isl_take isl_pw_aff *cond,
4609 __isl_take isl_pw_aff *pwaff_true,
4610 __isl_take isl_pw_aff *pwaff_false);
4612 The function C<isl_pw_aff_cond> performs a conditional operator
4613 and returns an expression that is equal to C<pwaff_true>
4614 for elements where C<cond> is non-zero and equal to C<pwaff_false> for elements
4615 where C<cond> is zero.
4617 #include <isl/aff.h>
4618 __isl_give isl_pw_aff *isl_pw_aff_union_min(
4619 __isl_take isl_pw_aff *pwaff1,
4620 __isl_take isl_pw_aff *pwaff2);
4621 __isl_give isl_pw_aff *isl_pw_aff_union_max(
4622 __isl_take isl_pw_aff *pwaff1,
4623 __isl_take isl_pw_aff *pwaff2);
4624 __isl_give isl_pw_aff *isl_pw_aff_union_add(
4625 __isl_take isl_pw_aff *pwaff1,
4626 __isl_take isl_pw_aff *pwaff2);
4628 The function C<isl_pw_aff_union_max> computes a piecewise quasi-affine
4629 expression with a domain that is the union of those of C<pwaff1> and
4630 C<pwaff2> and such that on each cell, the quasi-affine expression is
4631 the maximum of those of C<pwaff1> and C<pwaff2>. If only one of
4632 C<pwaff1> or C<pwaff2> is defined on a given cell, then the
4633 associated expression is the defined one.
4635 An expression can be read from input using
4637 #include <isl/aff.h>
4638 __isl_give isl_aff *isl_aff_read_from_str(
4639 isl_ctx *ctx, const char *str);
4640 __isl_give isl_pw_aff *isl_pw_aff_read_from_str(
4641 isl_ctx *ctx, const char *str);
4643 An expression can be printed using
4645 #include <isl/aff.h>
4646 __isl_give isl_printer *isl_printer_print_aff(
4647 __isl_take isl_printer *p, __isl_keep isl_aff *aff);
4649 __isl_give isl_printer *isl_printer_print_pw_aff(
4650 __isl_take isl_printer *p,
4651 __isl_keep isl_pw_aff *pwaff);
4653 =head2 Piecewise Multiple Quasi Affine Expressions
4655 An C<isl_multi_aff> object represents a sequence of
4656 zero or more affine expressions, all defined on the same domain space.
4657 Similarly, an C<isl_multi_pw_aff> object represents a sequence of
4658 zero or more piecewise affine expressions.
4660 An C<isl_multi_aff> can be constructed from a single
4661 C<isl_aff> or an C<isl_aff_list> using the
4662 following functions. Similarly for C<isl_multi_pw_aff>
4663 and C<isl_pw_multi_aff>.
4665 #include <isl/aff.h>
4666 __isl_give isl_multi_aff *isl_multi_aff_from_aff(
4667 __isl_take isl_aff *aff);
4668 __isl_give isl_multi_pw_aff *
4669 isl_multi_pw_aff_from_multi_aff(
4670 __isl_take isl_multi_aff *ma);
4671 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_aff(
4672 __isl_take isl_pw_aff *pa);
4673 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_pw_aff(
4674 __isl_take isl_pw_aff *pa);
4675 __isl_give isl_multi_aff *isl_multi_aff_from_aff_list(
4676 __isl_take isl_space *space,
4677 __isl_take isl_aff_list *list);
4679 An C<isl_multi_pw_aff> can be converted to an C<isl_pw_multi_aff>
4680 using the function C<isl_pw_multi_aff_from_multi_pw_aff> below.
4681 Note however that the domain
4682 of the result is the intersection of the domains of the input.
4683 The reverse conversion is exact.
4685 #include <isl/aff.h>
4686 __isl_give isl_pw_multi_aff *
4687 isl_pw_multi_aff_from_multi_pw_aff(
4688 __isl_take isl_multi_pw_aff *mpa);
4689 __isl_give isl_multi_pw_aff *
4690 isl_multi_pw_aff_from_pw_multi_aff(
4691 __isl_take isl_pw_multi_aff *pma);
4693 An empty piecewise multiple quasi affine expression (one with no cells),
4694 the zero piecewise multiple quasi affine expression (with value zero
4695 for each output dimension),
4696 a piecewise multiple quasi affine expression with a single cell (with
4697 either a universe or a specified domain) or
4698 a zero-dimensional piecewise multiple quasi affine expression
4700 can be created using the following functions.
4702 #include <isl/aff.h>
4703 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_empty(
4704 __isl_take isl_space *space);
4705 __isl_give isl_multi_aff *isl_multi_aff_zero(
4706 __isl_take isl_space *space);
4707 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_zero(
4708 __isl_take isl_space *space);
4709 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_zero(
4710 __isl_take isl_space *space);
4711 __isl_give isl_multi_aff *isl_multi_aff_identity(
4712 __isl_take isl_space *space);
4713 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_identity(
4714 __isl_take isl_space *space);
4715 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_identity(
4716 __isl_take isl_space *space);
4717 __isl_give isl_multi_aff *isl_multi_aff_domain_map(
4718 __isl_take isl_space *space);
4719 __isl_give isl_multi_aff *isl_multi_aff_range_map(
4720 __isl_take isl_space *space);
4721 __isl_give isl_multi_aff *isl_multi_aff_project_out_map(
4722 __isl_take isl_space *space,
4723 enum isl_dim_type type,
4724 unsigned first, unsigned n);
4725 __isl_give isl_pw_multi_aff *
4726 isl_pw_multi_aff_project_out_map(
4727 __isl_take isl_space *space,
4728 enum isl_dim_type type,
4729 unsigned first, unsigned n);
4730 __isl_give isl_pw_multi_aff *
4731 isl_pw_multi_aff_from_multi_aff(
4732 __isl_take isl_multi_aff *ma);
4733 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_alloc(
4734 __isl_take isl_set *set,
4735 __isl_take isl_multi_aff *maff);
4736 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_domain(
4737 __isl_take isl_set *set);
4739 __isl_give isl_union_pw_multi_aff *
4740 isl_union_pw_multi_aff_empty(
4741 __isl_take isl_space *space);
4742 __isl_give isl_union_pw_multi_aff *
4743 isl_union_pw_multi_aff_add_pw_multi_aff(
4744 __isl_take isl_union_pw_multi_aff *upma,
4745 __isl_take isl_pw_multi_aff *pma);
4746 __isl_give isl_union_pw_multi_aff *
4747 isl_union_pw_multi_aff_from_domain(
4748 __isl_take isl_union_set *uset);
4750 A piecewise multiple quasi affine expression can also be initialized
4751 from an C<isl_set> or C<isl_map>, provided the C<isl_set> is a singleton
4752 and the C<isl_map> is single-valued.
4753 In case of a conversion from an C<isl_union_map>
4754 to an C<isl_union_pw_multi_aff>, these properties need to hold
4755 in each domain space.
4757 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_set(
4758 __isl_take isl_set *set);
4759 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_map(
4760 __isl_take isl_map *map);
4762 __isl_give isl_union_pw_multi_aff *
4763 isl_union_pw_multi_aff_from_union_set(
4764 __isl_take isl_union_set *uset);
4765 __isl_give isl_union_pw_multi_aff *
4766 isl_union_pw_multi_aff_from_union_map(
4767 __isl_take isl_union_map *umap);
4769 Multiple quasi affine expressions can be copied and freed using
4771 #include <isl/aff.h>
4772 __isl_give isl_multi_aff *isl_multi_aff_copy(
4773 __isl_keep isl_multi_aff *maff);
4774 __isl_null isl_multi_aff *isl_multi_aff_free(
4775 __isl_take isl_multi_aff *maff);
4777 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_copy(
4778 __isl_keep isl_pw_multi_aff *pma);
4779 __isl_null isl_pw_multi_aff *isl_pw_multi_aff_free(
4780 __isl_take isl_pw_multi_aff *pma);
4782 __isl_give isl_union_pw_multi_aff *
4783 isl_union_pw_multi_aff_copy(
4784 __isl_keep isl_union_pw_multi_aff *upma);
4785 __isl_null isl_union_pw_multi_aff *
4786 isl_union_pw_multi_aff_free(
4787 __isl_take isl_union_pw_multi_aff *upma);
4789 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_copy(
4790 __isl_keep isl_multi_pw_aff *mpa);
4791 __isl_null isl_multi_pw_aff *isl_multi_pw_aff_free(
4792 __isl_take isl_multi_pw_aff *mpa);
4794 The expression can be inspected using
4796 #include <isl/aff.h>
4797 isl_ctx *isl_multi_aff_get_ctx(
4798 __isl_keep isl_multi_aff *maff);
4799 isl_ctx *isl_pw_multi_aff_get_ctx(
4800 __isl_keep isl_pw_multi_aff *pma);
4801 isl_ctx *isl_union_pw_multi_aff_get_ctx(
4802 __isl_keep isl_union_pw_multi_aff *upma);
4803 isl_ctx *isl_multi_pw_aff_get_ctx(
4804 __isl_keep isl_multi_pw_aff *mpa);
4806 int isl_multi_aff_involves_dims(
4807 __isl_keep isl_multi_aff *ma,
4808 enum isl_dim_type type, unsigned first, unsigned n);
4809 int isl_multi_pw_aff_involves_dims(
4810 __isl_keep isl_multi_pw_aff *mpa,
4811 enum isl_dim_type type, unsigned first, unsigned n);
4813 __isl_give isl_aff *isl_multi_aff_get_aff(
4814 __isl_keep isl_multi_aff *multi, int pos);
4815 __isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff(
4816 __isl_keep isl_pw_multi_aff *pma, int pos);
4817 __isl_give isl_pw_aff *isl_multi_pw_aff_get_pw_aff(
4818 __isl_keep isl_multi_pw_aff *mpa, int pos);
4819 int isl_multi_aff_range_is_wrapping(
4820 __isl_keep isl_multi_aff *ma);
4821 int isl_multi_pw_aff_range_is_wrapping(
4822 __isl_keep isl_multi_pw_aff *mpa);
4824 int isl_pw_multi_aff_foreach_piece(
4825 __isl_keep isl_pw_multi_aff *pma,
4826 int (*fn)(__isl_take isl_set *set,
4827 __isl_take isl_multi_aff *maff,
4828 void *user), void *user);
4830 int isl_union_pw_multi_aff_foreach_pw_multi_aff(
4831 __isl_keep isl_union_pw_multi_aff *upma,
4832 int (*fn)(__isl_take isl_pw_multi_aff *pma,
4833 void *user), void *user);
4835 It can be modified using
4837 #include <isl/aff.h>
4838 __isl_give isl_multi_aff *isl_multi_aff_set_aff(
4839 __isl_take isl_multi_aff *multi, int pos,
4840 __isl_take isl_aff *aff);
4841 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_pw_aff(
4842 __isl_take isl_pw_multi_aff *pma, unsigned pos,
4843 __isl_take isl_pw_aff *pa);
4845 __isl_give isl_multi_aff *isl_multi_aff_flatten_domain(
4846 __isl_take isl_multi_aff *ma);
4848 __isl_give isl_multi_aff *isl_multi_aff_insert_dims(
4849 __isl_take isl_multi_aff *ma,
4850 enum isl_dim_type type, unsigned first, unsigned n);
4851 __isl_give isl_multi_aff *isl_multi_aff_add_dims(
4852 __isl_take isl_multi_aff *ma,
4853 enum isl_dim_type type, unsigned n);
4854 __isl_give isl_multi_aff *isl_multi_aff_drop_dims(
4855 __isl_take isl_multi_aff *maff,
4856 enum isl_dim_type type, unsigned first, unsigned n);
4857 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_drop_dims(
4858 __isl_take isl_pw_multi_aff *pma,
4859 enum isl_dim_type type, unsigned first, unsigned n);
4861 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_insert_dims(
4862 __isl_take isl_multi_pw_aff *mpa,
4863 enum isl_dim_type type, unsigned first, unsigned n);
4864 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_add_dims(
4865 __isl_take isl_multi_pw_aff *mpa,
4866 enum isl_dim_type type, unsigned n);
4867 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_move_dims(
4868 __isl_take isl_multi_pw_aff *pma,
4869 enum isl_dim_type dst_type, unsigned dst_pos,
4870 enum isl_dim_type src_type, unsigned src_pos,
4873 To check whether two multiple affine expressions are
4874 (obviously) equal to each other, use
4876 int isl_multi_aff_plain_is_equal(__isl_keep isl_multi_aff *maff1,
4877 __isl_keep isl_multi_aff *maff2);
4878 int isl_pw_multi_aff_plain_is_equal(
4879 __isl_keep isl_pw_multi_aff *pma1,
4880 __isl_keep isl_pw_multi_aff *pma2);
4881 int isl_multi_pw_aff_plain_is_equal(
4882 __isl_keep isl_multi_pw_aff *mpa1,
4883 __isl_keep isl_multi_pw_aff *mpa2);
4884 int isl_multi_pw_aff_is_equal(
4885 __isl_keep isl_multi_pw_aff *mpa1,
4886 __isl_keep isl_multi_pw_aff *mpa2);
4890 #include <isl/aff.h>
4891 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmin(
4892 __isl_take isl_pw_multi_aff *pma1,
4893 __isl_take isl_pw_multi_aff *pma2);
4894 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmax(
4895 __isl_take isl_pw_multi_aff *pma1,
4896 __isl_take isl_pw_multi_aff *pma2);
4897 __isl_give isl_multi_aff *isl_multi_aff_floor(
4898 __isl_take isl_multi_aff *ma);
4899 __isl_give isl_multi_aff *isl_multi_aff_add(
4900 __isl_take isl_multi_aff *maff1,
4901 __isl_take isl_multi_aff *maff2);
4902 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_add(
4903 __isl_take isl_pw_multi_aff *pma1,
4904 __isl_take isl_pw_multi_aff *pma2);
4905 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_add(
4906 __isl_take isl_union_pw_multi_aff *upma1,
4907 __isl_take isl_union_pw_multi_aff *upma2);
4908 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_add(
4909 __isl_take isl_pw_multi_aff *pma1,
4910 __isl_take isl_pw_multi_aff *pma2);
4911 __isl_give isl_multi_aff *isl_multi_aff_sub(
4912 __isl_take isl_multi_aff *ma1,
4913 __isl_take isl_multi_aff *ma2);
4914 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_sub(
4915 __isl_take isl_pw_multi_aff *pma1,
4916 __isl_take isl_pw_multi_aff *pma2);
4917 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_sub(
4918 __isl_take isl_union_pw_multi_aff *upma1,
4919 __isl_take isl_union_pw_multi_aff *upma2);
4921 C<isl_multi_aff_sub> subtracts the second argument from the first.
4923 __isl_give isl_multi_aff *isl_multi_aff_scale_val(
4924 __isl_take isl_multi_aff *ma,
4925 __isl_take isl_val *v);
4926 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_val(
4927 __isl_take isl_pw_multi_aff *pma,
4928 __isl_take isl_val *v);
4929 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_scale_val(
4930 __isl_take isl_multi_pw_aff *mpa,
4931 __isl_take isl_val *v);
4932 __isl_give isl_multi_aff *isl_multi_aff_scale_multi_val(
4933 __isl_take isl_multi_aff *ma,
4934 __isl_take isl_multi_val *mv);
4935 __isl_give isl_pw_multi_aff *
4936 isl_pw_multi_aff_scale_multi_val(
4937 __isl_take isl_pw_multi_aff *pma,
4938 __isl_take isl_multi_val *mv);
4939 __isl_give isl_multi_pw_aff *
4940 isl_multi_pw_aff_scale_multi_val(
4941 __isl_take isl_multi_pw_aff *mpa,
4942 __isl_take isl_multi_val *mv);
4943 __isl_give isl_union_pw_multi_aff *
4944 isl_union_pw_multi_aff_scale_multi_val(
4945 __isl_take isl_union_pw_multi_aff *upma,
4946 __isl_take isl_multi_val *mv);
4947 __isl_give isl_multi_aff *
4948 isl_multi_aff_scale_down_multi_val(
4949 __isl_take isl_multi_aff *ma,
4950 __isl_take isl_multi_val *mv);
4951 __isl_give isl_multi_pw_aff *
4952 isl_multi_pw_aff_scale_down_multi_val(
4953 __isl_take isl_multi_pw_aff *mpa,
4954 __isl_take isl_multi_val *mv);
4956 C<isl_multi_aff_scale_multi_val> scales the elements of C<ma>
4957 by the corresponding elements of C<mv>.
4959 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_fix_si(
4960 __isl_take isl_pw_multi_aff *pma,
4961 enum isl_dim_type type, unsigned pos, int value);
4962 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_params(
4963 __isl_take isl_pw_multi_aff *pma,
4964 __isl_take isl_set *set);
4965 __isl_give isl_set *isl_multi_pw_aff_domain(
4966 __isl_take isl_multi_pw_aff *mpa);
4967 __isl_give isl_multi_pw_aff *
4968 isl_multi_pw_aff_intersect_params(
4969 __isl_take isl_multi_pw_aff *mpa,
4970 __isl_take isl_set *set);
4971 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_domain(
4972 __isl_take isl_pw_multi_aff *pma,
4973 __isl_take isl_set *set);
4974 __isl_give isl_multi_pw_aff *
4975 isl_multi_pw_aff_intersect_domain(
4976 __isl_take isl_multi_pw_aff *mpa,
4977 __isl_take isl_set *domain);
4978 __isl_give isl_union_pw_multi_aff *
4979 isl_union_pw_multi_aff_intersect_domain(
4980 __isl_take isl_union_pw_multi_aff *upma,
4981 __isl_take isl_union_set *uset);
4982 __isl_give isl_multi_aff *isl_multi_aff_lift(
4983 __isl_take isl_multi_aff *maff,
4984 __isl_give isl_local_space **ls);
4985 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_coalesce(
4986 __isl_take isl_pw_multi_aff *pma);
4987 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_coalesce(
4988 __isl_take isl_multi_pw_aff *mpa);
4989 __isl_give isl_multi_aff *isl_multi_aff_align_params(
4990 __isl_take isl_multi_aff *multi,
4991 __isl_take isl_space *model);
4992 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_align_params(
4993 __isl_take isl_pw_multi_aff *pma,
4994 __isl_take isl_space *model);
4995 __isl_give isl_union_pw_multi_aff *
4996 isl_union_pw_multi_aff_align_params(
4997 __isl_take isl_union_pw_multi_aff *upma,
4998 __isl_take isl_space *model);
4999 __isl_give isl_pw_multi_aff *
5000 isl_pw_multi_aff_project_domain_on_params(
5001 __isl_take isl_pw_multi_aff *pma);
5002 __isl_give isl_multi_aff *isl_multi_aff_gist_params(
5003 __isl_take isl_multi_aff *maff,
5004 __isl_take isl_set *context);
5005 __isl_give isl_multi_aff *isl_multi_aff_gist(
5006 __isl_take isl_multi_aff *maff,
5007 __isl_take isl_set *context);
5008 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist_params(
5009 __isl_take isl_pw_multi_aff *pma,
5010 __isl_take isl_set *set);
5011 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist(
5012 __isl_take isl_pw_multi_aff *pma,
5013 __isl_take isl_set *set);
5014 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist_params(
5015 __isl_take isl_multi_pw_aff *mpa,
5016 __isl_take isl_set *set);
5017 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist(
5018 __isl_take isl_multi_pw_aff *mpa,
5019 __isl_take isl_set *set);
5020 __isl_give isl_multi_aff *isl_multi_aff_from_range(
5021 __isl_take isl_multi_aff *ma);
5022 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_range(
5023 __isl_take isl_multi_pw_aff *mpa);
5024 __isl_give isl_set *isl_pw_multi_aff_domain(
5025 __isl_take isl_pw_multi_aff *pma);
5026 __isl_give isl_union_set *isl_union_pw_multi_aff_domain(
5027 __isl_take isl_union_pw_multi_aff *upma);
5028 __isl_give isl_multi_aff *isl_multi_aff_range_splice(
5029 __isl_take isl_multi_aff *ma1, unsigned pos,
5030 __isl_take isl_multi_aff *ma2);
5031 __isl_give isl_multi_aff *isl_multi_aff_splice(
5032 __isl_take isl_multi_aff *ma1,
5033 unsigned in_pos, unsigned out_pos,
5034 __isl_take isl_multi_aff *ma2);
5035 __isl_give isl_multi_aff *isl_multi_aff_range_product(
5036 __isl_take isl_multi_aff *ma1,
5037 __isl_take isl_multi_aff *ma2);
5038 __isl_give isl_multi_aff *
5039 isl_multi_aff_range_factor_domain(
5040 __isl_take isl_multi_aff *ma);
5041 __isl_give isl_multi_aff *
5042 isl_multi_aff_range_factor_range(
5043 __isl_take isl_multi_aff *ma);
5044 __isl_give isl_multi_aff *isl_multi_aff_flat_range_product(
5045 __isl_take isl_multi_aff *ma1,
5046 __isl_take isl_multi_aff *ma2);
5047 __isl_give isl_multi_aff *isl_multi_aff_product(
5048 __isl_take isl_multi_aff *ma1,
5049 __isl_take isl_multi_aff *ma2);
5050 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_product(
5051 __isl_take isl_multi_pw_aff *mpa1,
5052 __isl_take isl_multi_pw_aff *mpa2);
5053 __isl_give isl_pw_multi_aff *
5054 isl_pw_multi_aff_range_product(
5055 __isl_take isl_pw_multi_aff *pma1,
5056 __isl_take isl_pw_multi_aff *pma2);
5057 __isl_give isl_multi_pw_aff *
5058 isl_multi_pw_aff_range_factor_domain(
5059 __isl_take isl_multi_pw_aff *mpa);
5060 __isl_give isl_multi_pw_aff *
5061 isl_multi_pw_aff_range_factor_range(
5062 __isl_take isl_multi_pw_aff *mpa);
5063 __isl_give isl_pw_multi_aff *
5064 isl_pw_multi_aff_flat_range_product(
5065 __isl_take isl_pw_multi_aff *pma1,
5066 __isl_take isl_pw_multi_aff *pma2);
5067 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_product(
5068 __isl_take isl_pw_multi_aff *pma1,
5069 __isl_take isl_pw_multi_aff *pma2);
5070 __isl_give isl_union_pw_multi_aff *
5071 isl_union_pw_multi_aff_flat_range_product(
5072 __isl_take isl_union_pw_multi_aff *upma1,
5073 __isl_take isl_union_pw_multi_aff *upma2);
5074 __isl_give isl_multi_pw_aff *
5075 isl_multi_pw_aff_range_splice(
5076 __isl_take isl_multi_pw_aff *mpa1, unsigned pos,
5077 __isl_take isl_multi_pw_aff *mpa2);
5078 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_splice(
5079 __isl_take isl_multi_pw_aff *mpa1,
5080 unsigned in_pos, unsigned out_pos,
5081 __isl_take isl_multi_pw_aff *mpa2);
5082 __isl_give isl_multi_pw_aff *
5083 isl_multi_pw_aff_range_product(
5084 __isl_take isl_multi_pw_aff *mpa1,
5085 __isl_take isl_multi_pw_aff *mpa2);
5086 __isl_give isl_multi_pw_aff *
5087 isl_multi_pw_aff_flat_range_product(
5088 __isl_take isl_multi_pw_aff *mpa1,
5089 __isl_take isl_multi_pw_aff *mpa2);
5091 If the C<ls> argument of C<isl_multi_aff_lift> is not C<NULL>,
5092 then it is assigned the local space that lies at the basis of
5093 the lifting applied.
5095 #include <isl/aff.h>
5096 __isl_give isl_multi_aff *isl_multi_aff_pullback_multi_aff(
5097 __isl_take isl_multi_aff *ma1,
5098 __isl_take isl_multi_aff *ma2);
5099 __isl_give isl_pw_multi_aff *
5100 isl_pw_multi_aff_pullback_multi_aff(
5101 __isl_take isl_pw_multi_aff *pma,
5102 __isl_take isl_multi_aff *ma);
5103 __isl_give isl_multi_pw_aff *
5104 isl_multi_pw_aff_pullback_multi_aff(
5105 __isl_take isl_multi_pw_aff *mpa,
5106 __isl_take isl_multi_aff *ma);
5107 __isl_give isl_pw_multi_aff *
5108 isl_pw_multi_aff_pullback_pw_multi_aff(
5109 __isl_take isl_pw_multi_aff *pma1,
5110 __isl_take isl_pw_multi_aff *pma2);
5111 __isl_give isl_multi_pw_aff *
5112 isl_multi_pw_aff_pullback_pw_multi_aff(
5113 __isl_take isl_multi_pw_aff *mpa,
5114 __isl_take isl_pw_multi_aff *pma);
5115 __isl_give isl_multi_pw_aff *
5116 isl_multi_pw_aff_pullback_multi_pw_aff(
5117 __isl_take isl_multi_pw_aff *mpa1,
5118 __isl_take isl_multi_pw_aff *mpa2);
5120 The function C<isl_multi_aff_pullback_multi_aff> precomposes C<ma1> by C<ma2>.
5121 In other words, C<ma2> is plugged
5124 __isl_give isl_set *isl_multi_aff_lex_le_set(
5125 __isl_take isl_multi_aff *ma1,
5126 __isl_take isl_multi_aff *ma2);
5127 __isl_give isl_set *isl_multi_aff_lex_ge_set(
5128 __isl_take isl_multi_aff *ma1,
5129 __isl_take isl_multi_aff *ma2);
5131 The function C<isl_multi_aff_lex_le_set> returns a set
5132 containing those elements in the shared domain space
5133 where C<ma1> is lexicographically smaller than or
5136 An expression can be read from input using
5138 #include <isl/aff.h>
5139 __isl_give isl_multi_aff *isl_multi_aff_read_from_str(
5140 isl_ctx *ctx, const char *str);
5141 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str(
5142 isl_ctx *ctx, const char *str);
5143 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_read_from_str(
5144 isl_ctx *ctx, const char *str);
5145 __isl_give isl_union_pw_multi_aff *
5146 isl_union_pw_multi_aff_read_from_str(
5147 isl_ctx *ctx, const char *str);
5149 An expression can be printed using
5151 #include <isl/aff.h>
5152 __isl_give isl_printer *isl_printer_print_multi_aff(
5153 __isl_take isl_printer *p,
5154 __isl_keep isl_multi_aff *maff);
5155 __isl_give isl_printer *isl_printer_print_pw_multi_aff(
5156 __isl_take isl_printer *p,
5157 __isl_keep isl_pw_multi_aff *pma);
5158 __isl_give isl_printer *isl_printer_print_union_pw_multi_aff(
5159 __isl_take isl_printer *p,
5160 __isl_keep isl_union_pw_multi_aff *upma);
5161 __isl_give isl_printer *isl_printer_print_multi_pw_aff(
5162 __isl_take isl_printer *p,
5163 __isl_keep isl_multi_pw_aff *mpa);
5167 Points are elements of a set. They can be used to construct
5168 simple sets (boxes) or they can be used to represent the
5169 individual elements of a set.
5170 The zero point (the origin) can be created using
5172 __isl_give isl_point *isl_point_zero(__isl_take isl_space *space);
5174 The coordinates of a point can be inspected, set and changed
5177 __isl_give isl_val *isl_point_get_coordinate_val(
5178 __isl_keep isl_point *pnt,
5179 enum isl_dim_type type, int pos);
5180 __isl_give isl_point *isl_point_set_coordinate_val(
5181 __isl_take isl_point *pnt,
5182 enum isl_dim_type type, int pos,
5183 __isl_take isl_val *v);
5185 __isl_give isl_point *isl_point_add_ui(
5186 __isl_take isl_point *pnt,
5187 enum isl_dim_type type, int pos, unsigned val);
5188 __isl_give isl_point *isl_point_sub_ui(
5189 __isl_take isl_point *pnt,
5190 enum isl_dim_type type, int pos, unsigned val);
5192 Other properties can be obtained using
5194 isl_ctx *isl_point_get_ctx(__isl_keep isl_point *pnt);
5196 Points can be copied or freed using
5198 __isl_give isl_point *isl_point_copy(
5199 __isl_keep isl_point *pnt);
5200 void isl_point_free(__isl_take isl_point *pnt);
5202 A singleton set can be created from a point using
5204 __isl_give isl_basic_set *isl_basic_set_from_point(
5205 __isl_take isl_point *pnt);
5206 __isl_give isl_set *isl_set_from_point(
5207 __isl_take isl_point *pnt);
5209 and a box can be created from two opposite extremal points using
5211 __isl_give isl_basic_set *isl_basic_set_box_from_points(
5212 __isl_take isl_point *pnt1,
5213 __isl_take isl_point *pnt2);
5214 __isl_give isl_set *isl_set_box_from_points(
5215 __isl_take isl_point *pnt1,
5216 __isl_take isl_point *pnt2);
5218 All elements of a B<bounded> (union) set can be enumerated using
5219 the following functions.
5221 int isl_set_foreach_point(__isl_keep isl_set *set,
5222 int (*fn)(__isl_take isl_point *pnt, void *user),
5224 int isl_union_set_foreach_point(__isl_keep isl_union_set *uset,
5225 int (*fn)(__isl_take isl_point *pnt, void *user),
5228 The function C<fn> is called for each integer point in
5229 C<set> with as second argument the last argument of
5230 the C<isl_set_foreach_point> call. The function C<fn>
5231 should return C<0> on success and C<-1> on failure.
5232 In the latter case, C<isl_set_foreach_point> will stop
5233 enumerating and return C<-1> as well.
5234 If the enumeration is performed successfully and to completion,
5235 then C<isl_set_foreach_point> returns C<0>.
5237 To obtain a single point of a (basic) set, use
5239 __isl_give isl_point *isl_basic_set_sample_point(
5240 __isl_take isl_basic_set *bset);
5241 __isl_give isl_point *isl_set_sample_point(
5242 __isl_take isl_set *set);
5244 If C<set> does not contain any (integer) points, then the
5245 resulting point will be ``void'', a property that can be
5248 int isl_point_is_void(__isl_keep isl_point *pnt);
5250 =head2 Piecewise Quasipolynomials
5252 A piecewise quasipolynomial is a particular kind of function that maps
5253 a parametric point to a rational value.
5254 More specifically, a quasipolynomial is a polynomial expression in greatest
5255 integer parts of affine expressions of parameters and variables.
5256 A piecewise quasipolynomial is a subdivision of a given parametric
5257 domain into disjoint cells with a quasipolynomial associated to
5258 each cell. The value of the piecewise quasipolynomial at a given
5259 point is the value of the quasipolynomial associated to the cell
5260 that contains the point. Outside of the union of cells,
5261 the value is assumed to be zero.
5262 For example, the piecewise quasipolynomial
5264 [n] -> { [x] -> ((1 + n) - x) : x <= n and x >= 0 }
5266 maps C<x> to C<1 + n - x> for values of C<x> between C<0> and C<n>.
5267 A given piecewise quasipolynomial has a fixed domain dimension.
5268 Union piecewise quasipolynomials are used to contain piecewise quasipolynomials
5269 defined over different domains.
5270 Piecewise quasipolynomials are mainly used by the C<barvinok>
5271 library for representing the number of elements in a parametric set or map.
5272 For example, the piecewise quasipolynomial above represents
5273 the number of points in the map
5275 [n] -> { [x] -> [y] : x,y >= 0 and 0 <= x + y <= n }
5277 =head3 Input and Output
5279 Piecewise quasipolynomials can be read from input using
5281 __isl_give isl_union_pw_qpolynomial *
5282 isl_union_pw_qpolynomial_read_from_str(
5283 isl_ctx *ctx, const char *str);
5285 Quasipolynomials and piecewise quasipolynomials can be printed
5286 using the following functions.
5288 __isl_give isl_printer *isl_printer_print_qpolynomial(
5289 __isl_take isl_printer *p,
5290 __isl_keep isl_qpolynomial *qp);
5292 __isl_give isl_printer *isl_printer_print_pw_qpolynomial(
5293 __isl_take isl_printer *p,
5294 __isl_keep isl_pw_qpolynomial *pwqp);
5296 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial(
5297 __isl_take isl_printer *p,
5298 __isl_keep isl_union_pw_qpolynomial *upwqp);
5300 The output format of the printer
5301 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
5302 For C<isl_printer_print_union_pw_qpolynomial>, only C<ISL_FORMAT_ISL>
5304 In case of printing in C<ISL_FORMAT_C>, the user may want
5305 to set the names of all dimensions first.
5307 =head3 Creating New (Piecewise) Quasipolynomials
5309 Some simple quasipolynomials can be created using the following functions.
5310 More complicated quasipolynomials can be created by applying
5311 operations such as addition and multiplication
5312 on the resulting quasipolynomials
5314 __isl_give isl_qpolynomial *isl_qpolynomial_zero_on_domain(
5315 __isl_take isl_space *domain);
5316 __isl_give isl_qpolynomial *isl_qpolynomial_one_on_domain(
5317 __isl_take isl_space *domain);
5318 __isl_give isl_qpolynomial *isl_qpolynomial_infty_on_domain(
5319 __isl_take isl_space *domain);
5320 __isl_give isl_qpolynomial *isl_qpolynomial_neginfty_on_domain(
5321 __isl_take isl_space *domain);
5322 __isl_give isl_qpolynomial *isl_qpolynomial_nan_on_domain(
5323 __isl_take isl_space *domain);
5324 __isl_give isl_qpolynomial *isl_qpolynomial_val_on_domain(
5325 __isl_take isl_space *domain,
5326 __isl_take isl_val *val);
5327 __isl_give isl_qpolynomial *isl_qpolynomial_var_on_domain(
5328 __isl_take isl_space *domain,
5329 enum isl_dim_type type, unsigned pos);
5330 __isl_give isl_qpolynomial *isl_qpolynomial_from_aff(
5331 __isl_take isl_aff *aff);
5333 Note that the space in which a quasipolynomial lives is a map space
5334 with a one-dimensional range. The C<domain> argument in some of
5335 the functions above corresponds to the domain of this map space.
5337 The zero piecewise quasipolynomial or a piecewise quasipolynomial
5338 with a single cell can be created using the following functions.
5339 Multiple of these single cell piecewise quasipolynomials can
5340 be combined to create more complicated piecewise quasipolynomials.
5342 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero(
5343 __isl_take isl_space *space);
5344 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_alloc(
5345 __isl_take isl_set *set,
5346 __isl_take isl_qpolynomial *qp);
5347 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial(
5348 __isl_take isl_qpolynomial *qp);
5349 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_pw_aff(
5350 __isl_take isl_pw_aff *pwaff);
5352 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_zero(
5353 __isl_take isl_space *space);
5354 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_from_pw_qpolynomial(
5355 __isl_take isl_pw_qpolynomial *pwqp);
5356 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add_pw_qpolynomial(
5357 __isl_take isl_union_pw_qpolynomial *upwqp,
5358 __isl_take isl_pw_qpolynomial *pwqp);
5360 Quasipolynomials can be copied and freed again using the following
5363 __isl_give isl_qpolynomial *isl_qpolynomial_copy(
5364 __isl_keep isl_qpolynomial *qp);
5365 __isl_null isl_qpolynomial *isl_qpolynomial_free(
5366 __isl_take isl_qpolynomial *qp);
5368 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy(
5369 __isl_keep isl_pw_qpolynomial *pwqp);
5370 __isl_null isl_pw_qpolynomial *isl_pw_qpolynomial_free(
5371 __isl_take isl_pw_qpolynomial *pwqp);
5373 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_copy(
5374 __isl_keep isl_union_pw_qpolynomial *upwqp);
5375 __isl_null isl_union_pw_qpolynomial *
5376 isl_union_pw_qpolynomial_free(
5377 __isl_take isl_union_pw_qpolynomial *upwqp);
5379 =head3 Inspecting (Piecewise) Quasipolynomials
5381 To iterate over all piecewise quasipolynomials in a union
5382 piecewise quasipolynomial, use the following function
5384 int isl_union_pw_qpolynomial_foreach_pw_qpolynomial(
5385 __isl_keep isl_union_pw_qpolynomial *upwqp,
5386 int (*fn)(__isl_take isl_pw_qpolynomial *pwqp, void *user),
5389 To extract the piecewise quasipolynomial in a given space from a union, use
5391 __isl_give isl_pw_qpolynomial *
5392 isl_union_pw_qpolynomial_extract_pw_qpolynomial(
5393 __isl_keep isl_union_pw_qpolynomial *upwqp,
5394 __isl_take isl_space *space);
5396 To iterate over the cells in a piecewise quasipolynomial,
5397 use either of the following two functions
5399 int isl_pw_qpolynomial_foreach_piece(
5400 __isl_keep isl_pw_qpolynomial *pwqp,
5401 int (*fn)(__isl_take isl_set *set,
5402 __isl_take isl_qpolynomial *qp,
5403 void *user), void *user);
5404 int isl_pw_qpolynomial_foreach_lifted_piece(
5405 __isl_keep isl_pw_qpolynomial *pwqp,
5406 int (*fn)(__isl_take isl_set *set,
5407 __isl_take isl_qpolynomial *qp,
5408 void *user), void *user);
5410 As usual, the function C<fn> should return C<0> on success
5411 and C<-1> on failure. The difference between
5412 C<isl_pw_qpolynomial_foreach_piece> and
5413 C<isl_pw_qpolynomial_foreach_lifted_piece> is that
5414 C<isl_pw_qpolynomial_foreach_lifted_piece> will first
5415 compute unique representations for all existentially quantified
5416 variables and then turn these existentially quantified variables
5417 into extra set variables, adapting the associated quasipolynomial
5418 accordingly. This means that the C<set> passed to C<fn>
5419 will not have any existentially quantified variables, but that
5420 the dimensions of the sets may be different for different
5421 invocations of C<fn>.
5423 The constant term of a quasipolynomial can be extracted using
5425 __isl_give isl_val *isl_qpolynomial_get_constant_val(
5426 __isl_keep isl_qpolynomial *qp);
5428 To iterate over all terms in a quasipolynomial,
5431 int isl_qpolynomial_foreach_term(
5432 __isl_keep isl_qpolynomial *qp,
5433 int (*fn)(__isl_take isl_term *term,
5434 void *user), void *user);
5436 The terms themselves can be inspected and freed using
5439 unsigned isl_term_dim(__isl_keep isl_term *term,
5440 enum isl_dim_type type);
5441 __isl_give isl_val *isl_term_get_coefficient_val(
5442 __isl_keep isl_term *term);
5443 int isl_term_get_exp(__isl_keep isl_term *term,
5444 enum isl_dim_type type, unsigned pos);
5445 __isl_give isl_aff *isl_term_get_div(
5446 __isl_keep isl_term *term, unsigned pos);
5447 void isl_term_free(__isl_take isl_term *term);
5449 Each term is a product of parameters, set variables and
5450 integer divisions. The function C<isl_term_get_exp>
5451 returns the exponent of a given dimensions in the given term.
5453 =head3 Properties of (Piecewise) Quasipolynomials
5455 To check whether two union piecewise quasipolynomials are
5456 obviously equal, use
5458 int isl_union_pw_qpolynomial_plain_is_equal(
5459 __isl_keep isl_union_pw_qpolynomial *upwqp1,
5460 __isl_keep isl_union_pw_qpolynomial *upwqp2);
5462 =head3 Operations on (Piecewise) Quasipolynomials
5464 __isl_give isl_qpolynomial *isl_qpolynomial_scale_val(
5465 __isl_take isl_qpolynomial *qp,
5466 __isl_take isl_val *v);
5467 __isl_give isl_qpolynomial *isl_qpolynomial_neg(
5468 __isl_take isl_qpolynomial *qp);
5469 __isl_give isl_qpolynomial *isl_qpolynomial_add(
5470 __isl_take isl_qpolynomial *qp1,
5471 __isl_take isl_qpolynomial *qp2);
5472 __isl_give isl_qpolynomial *isl_qpolynomial_sub(
5473 __isl_take isl_qpolynomial *qp1,
5474 __isl_take isl_qpolynomial *qp2);
5475 __isl_give isl_qpolynomial *isl_qpolynomial_mul(
5476 __isl_take isl_qpolynomial *qp1,
5477 __isl_take isl_qpolynomial *qp2);
5478 __isl_give isl_qpolynomial *isl_qpolynomial_pow(
5479 __isl_take isl_qpolynomial *qp, unsigned exponent);
5481 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_fix_val(
5482 __isl_take isl_pw_qpolynomial *pwqp,
5483 enum isl_dim_type type, unsigned n,
5484 __isl_take isl_val *v);
5485 __isl_give isl_pw_qpolynomial *
5486 isl_pw_qpolynomial_scale_val(
5487 __isl_take isl_pw_qpolynomial *pwqp,
5488 __isl_take isl_val *v);
5489 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
5490 __isl_take isl_pw_qpolynomial *pwqp1,
5491 __isl_take isl_pw_qpolynomial *pwqp2);
5492 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub(
5493 __isl_take isl_pw_qpolynomial *pwqp1,
5494 __isl_take isl_pw_qpolynomial *pwqp2);
5495 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint(
5496 __isl_take isl_pw_qpolynomial *pwqp1,
5497 __isl_take isl_pw_qpolynomial *pwqp2);
5498 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg(
5499 __isl_take isl_pw_qpolynomial *pwqp);
5500 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
5501 __isl_take isl_pw_qpolynomial *pwqp1,
5502 __isl_take isl_pw_qpolynomial *pwqp2);
5503 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_pow(
5504 __isl_take isl_pw_qpolynomial *pwqp, unsigned exponent);
5506 __isl_give isl_union_pw_qpolynomial *
5507 isl_union_pw_qpolynomial_scale_val(
5508 __isl_take isl_union_pw_qpolynomial *upwqp,
5509 __isl_take isl_val *v);
5510 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add(
5511 __isl_take isl_union_pw_qpolynomial *upwqp1,
5512 __isl_take isl_union_pw_qpolynomial *upwqp2);
5513 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
5514 __isl_take isl_union_pw_qpolynomial *upwqp1,
5515 __isl_take isl_union_pw_qpolynomial *upwqp2);
5516 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
5517 __isl_take isl_union_pw_qpolynomial *upwqp1,
5518 __isl_take isl_union_pw_qpolynomial *upwqp2);
5520 __isl_give isl_val *isl_pw_qpolynomial_eval(
5521 __isl_take isl_pw_qpolynomial *pwqp,
5522 __isl_take isl_point *pnt);
5524 __isl_give isl_val *isl_union_pw_qpolynomial_eval(
5525 __isl_take isl_union_pw_qpolynomial *upwqp,
5526 __isl_take isl_point *pnt);
5528 __isl_give isl_set *isl_pw_qpolynomial_domain(
5529 __isl_take isl_pw_qpolynomial *pwqp);
5530 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_domain(
5531 __isl_take isl_pw_qpolynomial *pwpq,
5532 __isl_take isl_set *set);
5533 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_params(
5534 __isl_take isl_pw_qpolynomial *pwpq,
5535 __isl_take isl_set *set);
5537 __isl_give isl_union_set *isl_union_pw_qpolynomial_domain(
5538 __isl_take isl_union_pw_qpolynomial *upwqp);
5539 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_intersect_domain(
5540 __isl_take isl_union_pw_qpolynomial *upwpq,
5541 __isl_take isl_union_set *uset);
5542 __isl_give isl_union_pw_qpolynomial *
5543 isl_union_pw_qpolynomial_intersect_params(
5544 __isl_take isl_union_pw_qpolynomial *upwpq,
5545 __isl_take isl_set *set);
5547 __isl_give isl_qpolynomial *isl_qpolynomial_align_params(
5548 __isl_take isl_qpolynomial *qp,
5549 __isl_take isl_space *model);
5551 __isl_give isl_qpolynomial *isl_qpolynomial_project_domain_on_params(
5552 __isl_take isl_qpolynomial *qp);
5553 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_project_domain_on_params(
5554 __isl_take isl_pw_qpolynomial *pwqp);
5556 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_coalesce(
5557 __isl_take isl_union_pw_qpolynomial *upwqp);
5559 __isl_give isl_qpolynomial *isl_qpolynomial_gist_params(
5560 __isl_take isl_qpolynomial *qp,
5561 __isl_take isl_set *context);
5562 __isl_give isl_qpolynomial *isl_qpolynomial_gist(
5563 __isl_take isl_qpolynomial *qp,
5564 __isl_take isl_set *context);
5566 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist_params(
5567 __isl_take isl_pw_qpolynomial *pwqp,
5568 __isl_take isl_set *context);
5569 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist(
5570 __isl_take isl_pw_qpolynomial *pwqp,
5571 __isl_take isl_set *context);
5573 __isl_give isl_union_pw_qpolynomial *
5574 isl_union_pw_qpolynomial_gist_params(
5575 __isl_take isl_union_pw_qpolynomial *upwqp,
5576 __isl_take isl_set *context);
5577 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist(
5578 __isl_take isl_union_pw_qpolynomial *upwqp,
5579 __isl_take isl_union_set *context);
5581 The gist operation applies the gist operation to each of
5582 the cells in the domain of the input piecewise quasipolynomial.
5583 The context is also exploited
5584 to simplify the quasipolynomials associated to each cell.
5586 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_to_polynomial(
5587 __isl_take isl_pw_qpolynomial *pwqp, int sign);
5588 __isl_give isl_union_pw_qpolynomial *
5589 isl_union_pw_qpolynomial_to_polynomial(
5590 __isl_take isl_union_pw_qpolynomial *upwqp, int sign);
5592 Approximate each quasipolynomial by a polynomial. If C<sign> is positive,
5593 the polynomial will be an overapproximation. If C<sign> is negative,
5594 it will be an underapproximation. If C<sign> is zero, the approximation
5595 will lie somewhere in between.
5597 =head2 Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions
5599 A piecewise quasipolynomial reduction is a piecewise
5600 reduction (or fold) of quasipolynomials.
5601 In particular, the reduction can be maximum or a minimum.
5602 The objects are mainly used to represent the result of
5603 an upper or lower bound on a quasipolynomial over its domain,
5604 i.e., as the result of the following function.
5606 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound(
5607 __isl_take isl_pw_qpolynomial *pwqp,
5608 enum isl_fold type, int *tight);
5610 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_bound(
5611 __isl_take isl_union_pw_qpolynomial *upwqp,
5612 enum isl_fold type, int *tight);
5614 The C<type> argument may be either C<isl_fold_min> or C<isl_fold_max>.
5615 If C<tight> is not C<NULL>, then C<*tight> is set to C<1>
5616 is the returned bound is known be tight, i.e., for each value
5617 of the parameters there is at least
5618 one element in the domain that reaches the bound.
5619 If the domain of C<pwqp> is not wrapping, then the bound is computed
5620 over all elements in that domain and the result has a purely parametric
5621 domain. If the domain of C<pwqp> is wrapping, then the bound is
5622 computed over the range of the wrapped relation. The domain of the
5623 wrapped relation becomes the domain of the result.
5625 A (piecewise) quasipolynomial reduction can be copied or freed using the
5626 following functions.
5628 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_copy(
5629 __isl_keep isl_qpolynomial_fold *fold);
5630 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_copy(
5631 __isl_keep isl_pw_qpolynomial_fold *pwf);
5632 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_copy(
5633 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
5634 void isl_qpolynomial_fold_free(
5635 __isl_take isl_qpolynomial_fold *fold);
5636 __isl_null isl_pw_qpolynomial_fold *
5637 isl_pw_qpolynomial_fold_free(
5638 __isl_take isl_pw_qpolynomial_fold *pwf);
5639 __isl_null isl_union_pw_qpolynomial_fold *
5640 isl_union_pw_qpolynomial_fold_free(
5641 __isl_take isl_union_pw_qpolynomial_fold *upwf);
5643 =head3 Printing Piecewise Quasipolynomial Reductions
5645 Piecewise quasipolynomial reductions can be printed
5646 using the following function.
5648 __isl_give isl_printer *isl_printer_print_pw_qpolynomial_fold(
5649 __isl_take isl_printer *p,
5650 __isl_keep isl_pw_qpolynomial_fold *pwf);
5651 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial_fold(
5652 __isl_take isl_printer *p,
5653 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
5655 For C<isl_printer_print_pw_qpolynomial_fold>,
5656 output format of the printer
5657 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
5658 For C<isl_printer_print_union_pw_qpolynomial_fold>,
5659 output format of the printer
5660 needs to be set to C<ISL_FORMAT_ISL>.
5661 In case of printing in C<ISL_FORMAT_C>, the user may want
5662 to set the names of all dimensions first.
5664 =head3 Inspecting (Piecewise) Quasipolynomial Reductions
5666 To iterate over all piecewise quasipolynomial reductions in a union
5667 piecewise quasipolynomial reduction, use the following function
5669 int isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(
5670 __isl_keep isl_union_pw_qpolynomial_fold *upwf,
5671 int (*fn)(__isl_take isl_pw_qpolynomial_fold *pwf,
5672 void *user), void *user);
5674 To iterate over the cells in a piecewise quasipolynomial reduction,
5675 use either of the following two functions
5677 int isl_pw_qpolynomial_fold_foreach_piece(
5678 __isl_keep isl_pw_qpolynomial_fold *pwf,
5679 int (*fn)(__isl_take isl_set *set,
5680 __isl_take isl_qpolynomial_fold *fold,
5681 void *user), void *user);
5682 int isl_pw_qpolynomial_fold_foreach_lifted_piece(
5683 __isl_keep isl_pw_qpolynomial_fold *pwf,
5684 int (*fn)(__isl_take isl_set *set,
5685 __isl_take isl_qpolynomial_fold *fold,
5686 void *user), void *user);
5688 See L<Inspecting (Piecewise) Quasipolynomials> for an explanation
5689 of the difference between these two functions.
5691 To iterate over all quasipolynomials in a reduction, use
5693 int isl_qpolynomial_fold_foreach_qpolynomial(
5694 __isl_keep isl_qpolynomial_fold *fold,
5695 int (*fn)(__isl_take isl_qpolynomial *qp,
5696 void *user), void *user);
5698 =head3 Properties of Piecewise Quasipolynomial Reductions
5700 To check whether two union piecewise quasipolynomial reductions are
5701 obviously equal, use
5703 int isl_union_pw_qpolynomial_fold_plain_is_equal(
5704 __isl_keep isl_union_pw_qpolynomial_fold *upwf1,
5705 __isl_keep isl_union_pw_qpolynomial_fold *upwf2);
5707 =head3 Operations on Piecewise Quasipolynomial Reductions
5709 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_scale_val(
5710 __isl_take isl_qpolynomial_fold *fold,
5711 __isl_take isl_val *v);
5712 __isl_give isl_pw_qpolynomial_fold *
5713 isl_pw_qpolynomial_fold_scale_val(
5714 __isl_take isl_pw_qpolynomial_fold *pwf,
5715 __isl_take isl_val *v);
5716 __isl_give isl_union_pw_qpolynomial_fold *
5717 isl_union_pw_qpolynomial_fold_scale_val(
5718 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5719 __isl_take isl_val *v);
5721 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
5722 __isl_take isl_pw_qpolynomial_fold *pwf1,
5723 __isl_take isl_pw_qpolynomial_fold *pwf2);
5725 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_fold(
5726 __isl_take isl_pw_qpolynomial_fold *pwf1,
5727 __isl_take isl_pw_qpolynomial_fold *pwf2);
5729 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_fold(
5730 __isl_take isl_union_pw_qpolynomial_fold *upwf1,
5731 __isl_take isl_union_pw_qpolynomial_fold *upwf2);
5733 __isl_give isl_val *isl_pw_qpolynomial_fold_eval(
5734 __isl_take isl_pw_qpolynomial_fold *pwf,
5735 __isl_take isl_point *pnt);
5737 __isl_give isl_val *isl_union_pw_qpolynomial_fold_eval(
5738 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5739 __isl_take isl_point *pnt);
5741 __isl_give isl_pw_qpolynomial_fold *
5742 isl_pw_qpolynomial_fold_intersect_params(
5743 __isl_take isl_pw_qpolynomial_fold *pwf,
5744 __isl_take isl_set *set);
5746 __isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain(
5747 __isl_take isl_union_pw_qpolynomial_fold *upwf);
5748 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_intersect_domain(
5749 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5750 __isl_take isl_union_set *uset);
5751 __isl_give isl_union_pw_qpolynomial_fold *
5752 isl_union_pw_qpolynomial_fold_intersect_params(
5753 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5754 __isl_take isl_set *set);
5756 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_project_domain_on_params(
5757 __isl_take isl_pw_qpolynomial_fold *pwf);
5759 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_coalesce(
5760 __isl_take isl_pw_qpolynomial_fold *pwf);
5762 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_coalesce(
5763 __isl_take isl_union_pw_qpolynomial_fold *upwf);
5765 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist_params(
5766 __isl_take isl_qpolynomial_fold *fold,
5767 __isl_take isl_set *context);
5768 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist(
5769 __isl_take isl_qpolynomial_fold *fold,
5770 __isl_take isl_set *context);
5772 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist(
5773 __isl_take isl_pw_qpolynomial_fold *pwf,
5774 __isl_take isl_set *context);
5775 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist_params(
5776 __isl_take isl_pw_qpolynomial_fold *pwf,
5777 __isl_take isl_set *context);
5779 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_gist(
5780 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5781 __isl_take isl_union_set *context);
5782 __isl_give isl_union_pw_qpolynomial_fold *
5783 isl_union_pw_qpolynomial_fold_gist_params(
5784 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5785 __isl_take isl_set *context);
5787 The gist operation applies the gist operation to each of
5788 the cells in the domain of the input piecewise quasipolynomial reduction.
5789 In future, the operation will also exploit the context
5790 to simplify the quasipolynomial reductions associated to each cell.
5792 __isl_give isl_pw_qpolynomial_fold *
5793 isl_set_apply_pw_qpolynomial_fold(
5794 __isl_take isl_set *set,
5795 __isl_take isl_pw_qpolynomial_fold *pwf,
5797 __isl_give isl_pw_qpolynomial_fold *
5798 isl_map_apply_pw_qpolynomial_fold(
5799 __isl_take isl_map *map,
5800 __isl_take isl_pw_qpolynomial_fold *pwf,
5802 __isl_give isl_union_pw_qpolynomial_fold *
5803 isl_union_set_apply_union_pw_qpolynomial_fold(
5804 __isl_take isl_union_set *uset,
5805 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5807 __isl_give isl_union_pw_qpolynomial_fold *
5808 isl_union_map_apply_union_pw_qpolynomial_fold(
5809 __isl_take isl_union_map *umap,
5810 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5813 The functions taking a map
5814 compose the given map with the given piecewise quasipolynomial reduction.
5815 That is, compute a bound (of the same type as C<pwf> or C<upwf> itself)
5816 over all elements in the intersection of the range of the map
5817 and the domain of the piecewise quasipolynomial reduction
5818 as a function of an element in the domain of the map.
5819 The functions taking a set compute a bound over all elements in the
5820 intersection of the set and the domain of the
5821 piecewise quasipolynomial reduction.
5823 =head2 Parametric Vertex Enumeration
5825 The parametric vertex enumeration described in this section
5826 is mainly intended to be used internally and by the C<barvinok>
5829 #include <isl/vertices.h>
5830 __isl_give isl_vertices *isl_basic_set_compute_vertices(
5831 __isl_keep isl_basic_set *bset);
5833 The function C<isl_basic_set_compute_vertices> performs the
5834 actual computation of the parametric vertices and the chamber
5835 decomposition and store the result in an C<isl_vertices> object.
5836 This information can be queried by either iterating over all
5837 the vertices or iterating over all the chambers or cells
5838 and then iterating over all vertices that are active on the chamber.
5840 int isl_vertices_foreach_vertex(
5841 __isl_keep isl_vertices *vertices,
5842 int (*fn)(__isl_take isl_vertex *vertex, void *user),
5845 int isl_vertices_foreach_cell(
5846 __isl_keep isl_vertices *vertices,
5847 int (*fn)(__isl_take isl_cell *cell, void *user),
5849 int isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
5850 int (*fn)(__isl_take isl_vertex *vertex, void *user),
5853 Other operations that can be performed on an C<isl_vertices> object are
5856 isl_ctx *isl_vertices_get_ctx(
5857 __isl_keep isl_vertices *vertices);
5858 int isl_vertices_get_n_vertices(
5859 __isl_keep isl_vertices *vertices);
5860 void isl_vertices_free(__isl_take isl_vertices *vertices);
5862 Vertices can be inspected and destroyed using the following functions.
5864 isl_ctx *isl_vertex_get_ctx(__isl_keep isl_vertex *vertex);
5865 int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
5866 __isl_give isl_basic_set *isl_vertex_get_domain(
5867 __isl_keep isl_vertex *vertex);
5868 __isl_give isl_multi_aff *isl_vertex_get_expr(
5869 __isl_keep isl_vertex *vertex);
5870 void isl_vertex_free(__isl_take isl_vertex *vertex);
5872 C<isl_vertex_get_expr> returns a multiple quasi-affine expression
5873 describing the vertex in terms of the parameters,
5874 while C<isl_vertex_get_domain> returns the activity domain
5877 Chambers can be inspected and destroyed using the following functions.
5879 isl_ctx *isl_cell_get_ctx(__isl_keep isl_cell *cell);
5880 __isl_give isl_basic_set *isl_cell_get_domain(
5881 __isl_keep isl_cell *cell);
5882 void isl_cell_free(__isl_take isl_cell *cell);
5884 =head1 Polyhedral Compilation Library
5886 This section collects functionality in C<isl> that has been specifically
5887 designed for use during polyhedral compilation.
5889 =head2 Dependence Analysis
5891 C<isl> contains specialized functionality for performing
5892 array dataflow analysis. That is, given a I<sink> access relation
5893 and a collection of possible I<source> access relations,
5894 C<isl> can compute relations that describe
5895 for each iteration of the sink access, which iteration
5896 of which of the source access relations was the last
5897 to access the same data element before the given iteration
5899 The resulting dependence relations map source iterations
5900 to the corresponding sink iterations.
5901 To compute standard flow dependences, the sink should be
5902 a read, while the sources should be writes.
5903 If any of the source accesses are marked as being I<may>
5904 accesses, then there will be a dependence from the last
5905 I<must> access B<and> from any I<may> access that follows
5906 this last I<must> access.
5907 In particular, if I<all> sources are I<may> accesses,
5908 then memory based dependence analysis is performed.
5909 If, on the other hand, all sources are I<must> accesses,
5910 then value based dependence analysis is performed.
5912 #include <isl/flow.h>
5914 typedef int (*isl_access_level_before)(void *first, void *second);
5916 __isl_give isl_access_info *isl_access_info_alloc(
5917 __isl_take isl_map *sink,
5918 void *sink_user, isl_access_level_before fn,
5920 __isl_give isl_access_info *isl_access_info_add_source(
5921 __isl_take isl_access_info *acc,
5922 __isl_take isl_map *source, int must,
5924 __isl_null isl_access_info *isl_access_info_free(
5925 __isl_take isl_access_info *acc);
5927 __isl_give isl_flow *isl_access_info_compute_flow(
5928 __isl_take isl_access_info *acc);
5930 int isl_flow_foreach(__isl_keep isl_flow *deps,
5931 int (*fn)(__isl_take isl_map *dep, int must,
5932 void *dep_user, void *user),
5934 __isl_give isl_map *isl_flow_get_no_source(
5935 __isl_keep isl_flow *deps, int must);
5936 void isl_flow_free(__isl_take isl_flow *deps);
5938 The function C<isl_access_info_compute_flow> performs the actual
5939 dependence analysis. The other functions are used to construct
5940 the input for this function or to read off the output.
5942 The input is collected in an C<isl_access_info>, which can
5943 be created through a call to C<isl_access_info_alloc>.
5944 The arguments to this functions are the sink access relation
5945 C<sink>, a token C<sink_user> used to identify the sink
5946 access to the user, a callback function for specifying the
5947 relative order of source and sink accesses, and the number
5948 of source access relations that will be added.
5949 The callback function has type C<int (*)(void *first, void *second)>.
5950 The function is called with two user supplied tokens identifying
5951 either a source or the sink and it should return the shared nesting
5952 level and the relative order of the two accesses.
5953 In particular, let I<n> be the number of loops shared by
5954 the two accesses. If C<first> precedes C<second> textually,
5955 then the function should return I<2 * n + 1>; otherwise,
5956 it should return I<2 * n>.
5957 The sources can be added to the C<isl_access_info> by performing
5958 (at most) C<max_source> calls to C<isl_access_info_add_source>.
5959 C<must> indicates whether the source is a I<must> access
5960 or a I<may> access. Note that a multi-valued access relation
5961 should only be marked I<must> if every iteration in the domain
5962 of the relation accesses I<all> elements in its image.
5963 The C<source_user> token is again used to identify
5964 the source access. The range of the source access relation
5965 C<source> should have the same dimension as the range
5966 of the sink access relation.
5967 The C<isl_access_info_free> function should usually not be
5968 called explicitly, because it is called implicitly by
5969 C<isl_access_info_compute_flow>.
5971 The result of the dependence analysis is collected in an
5972 C<isl_flow>. There may be elements of
5973 the sink access for which no preceding source access could be
5974 found or for which all preceding sources are I<may> accesses.
5975 The relations containing these elements can be obtained through
5976 calls to C<isl_flow_get_no_source>, the first with C<must> set
5977 and the second with C<must> unset.
5978 In the case of standard flow dependence analysis,
5979 with the sink a read and the sources I<must> writes,
5980 the first relation corresponds to the reads from uninitialized
5981 array elements and the second relation is empty.
5982 The actual flow dependences can be extracted using
5983 C<isl_flow_foreach>. This function will call the user-specified
5984 callback function C<fn> for each B<non-empty> dependence between
5985 a source and the sink. The callback function is called
5986 with four arguments, the actual flow dependence relation
5987 mapping source iterations to sink iterations, a boolean that
5988 indicates whether it is a I<must> or I<may> dependence, a token
5989 identifying the source and an additional C<void *> with value
5990 equal to the third argument of the C<isl_flow_foreach> call.
5991 A dependence is marked I<must> if it originates from a I<must>
5992 source and if it is not followed by any I<may> sources.
5994 After finishing with an C<isl_flow>, the user should call
5995 C<isl_flow_free> to free all associated memory.
5997 A higher-level interface to dependence analysis is provided
5998 by the following function.
6000 #include <isl/flow.h>
6002 int isl_union_map_compute_flow(__isl_take isl_union_map *sink,
6003 __isl_take isl_union_map *must_source,
6004 __isl_take isl_union_map *may_source,
6005 __isl_take isl_union_map *schedule,
6006 __isl_give isl_union_map **must_dep,
6007 __isl_give isl_union_map **may_dep,
6008 __isl_give isl_union_map **must_no_source,
6009 __isl_give isl_union_map **may_no_source);
6011 The arrays are identified by the tuple names of the ranges
6012 of the accesses. The iteration domains by the tuple names
6013 of the domains of the accesses and of the schedule.
6014 The relative order of the iteration domains is given by the
6015 schedule. The relations returned through C<must_no_source>
6016 and C<may_no_source> are subsets of C<sink>.
6017 Any of C<must_dep>, C<may_dep>, C<must_no_source>
6018 or C<may_no_source> may be C<NULL>, but a C<NULL> value for
6019 any of the other arguments is treated as an error.
6021 =head3 Interaction with Dependence Analysis
6023 During the dependence analysis, we frequently need to perform
6024 the following operation. Given a relation between sink iterations
6025 and potential source iterations from a particular source domain,
6026 what is the last potential source iteration corresponding to each
6027 sink iteration. It can sometimes be convenient to adjust
6028 the set of potential source iterations before or after each such operation.
6029 The prototypical example is fuzzy array dataflow analysis,
6030 where we need to analyze if, based on data-dependent constraints,
6031 the sink iteration can ever be executed without one or more of
6032 the corresponding potential source iterations being executed.
6033 If so, we can introduce extra parameters and select an unknown
6034 but fixed source iteration from the potential source iterations.
6035 To be able to perform such manipulations, C<isl> provides the following
6038 #include <isl/flow.h>
6040 typedef __isl_give isl_restriction *(*isl_access_restrict)(
6041 __isl_keep isl_map *source_map,
6042 __isl_keep isl_set *sink, void *source_user,
6044 __isl_give isl_access_info *isl_access_info_set_restrict(
6045 __isl_take isl_access_info *acc,
6046 isl_access_restrict fn, void *user);
6048 The function C<isl_access_info_set_restrict> should be called
6049 before calling C<isl_access_info_compute_flow> and registers a callback function
6050 that will be called any time C<isl> is about to compute the last
6051 potential source. The first argument is the (reverse) proto-dependence,
6052 mapping sink iterations to potential source iterations.
6053 The second argument represents the sink iterations for which
6054 we want to compute the last source iteration.
6055 The third argument is the token corresponding to the source
6056 and the final argument is the token passed to C<isl_access_info_set_restrict>.
6057 The callback is expected to return a restriction on either the input or
6058 the output of the operation computing the last potential source.
6059 If the input needs to be restricted then restrictions are needed
6060 for both the source and the sink iterations. The sink iterations
6061 and the potential source iterations will be intersected with these sets.
6062 If the output needs to be restricted then only a restriction on the source
6063 iterations is required.
6064 If any error occurs, the callback should return C<NULL>.
6065 An C<isl_restriction> object can be created, freed and inspected
6066 using the following functions.
6068 #include <isl/flow.h>
6070 __isl_give isl_restriction *isl_restriction_input(
6071 __isl_take isl_set *source_restr,
6072 __isl_take isl_set *sink_restr);
6073 __isl_give isl_restriction *isl_restriction_output(
6074 __isl_take isl_set *source_restr);
6075 __isl_give isl_restriction *isl_restriction_none(
6076 __isl_take isl_map *source_map);
6077 __isl_give isl_restriction *isl_restriction_empty(
6078 __isl_take isl_map *source_map);
6079 __isl_null isl_restriction *isl_restriction_free(
6080 __isl_take isl_restriction *restr);
6081 isl_ctx *isl_restriction_get_ctx(
6082 __isl_keep isl_restriction *restr);
6084 C<isl_restriction_none> and C<isl_restriction_empty> are special
6085 cases of C<isl_restriction_input>. C<isl_restriction_none>
6086 is essentially equivalent to
6088 isl_restriction_input(isl_set_universe(
6089 isl_space_range(isl_map_get_space(source_map))),
6091 isl_space_domain(isl_map_get_space(source_map))));
6093 whereas C<isl_restriction_empty> is essentially equivalent to
6095 isl_restriction_input(isl_set_empty(
6096 isl_space_range(isl_map_get_space(source_map))),
6098 isl_space_domain(isl_map_get_space(source_map))));
6102 B<The functionality described in this section is fairly new
6103 and may be subject to change.>
6105 #include <isl/schedule.h>
6106 __isl_give isl_schedule *
6107 isl_schedule_constraints_compute_schedule(
6108 __isl_take isl_schedule_constraints *sc);
6109 __isl_null isl_schedule *isl_schedule_free(
6110 __isl_take isl_schedule *sched);
6112 The function C<isl_schedule_constraints_compute_schedule> can be
6113 used to compute a schedule that satisfies the given schedule constraints.
6114 These schedule constraints include the iteration domain for which
6115 a schedule should be computed and dependences between pairs of
6116 iterations. In particular, these dependences include
6117 I<validity> dependences and I<proximity> dependences.
6118 By default, the algorithm used to construct the schedule is similar
6119 to that of C<Pluto>.
6120 Alternatively, Feautrier's multi-dimensional scheduling algorithm can
6122 The generated schedule respects all validity dependences.
6123 That is, all dependence distances over these dependences in the
6124 scheduled space are lexicographically positive.
6125 The default algorithm tries to ensure that the dependence distances
6126 over coincidence constraints are zero and to minimize the
6127 dependence distances over proximity dependences.
6128 Moreover, it tries to obtain sequences (bands) of schedule dimensions
6129 for groups of domains where the dependence distances over validity
6130 dependences have only non-negative values.
6131 When using Feautrier's algorithm, the coincidence and proximity constraints
6132 are only taken into account during the extension to a
6133 full-dimensional schedule.
6135 An C<isl_schedule_constraints> object can be constructed
6136 and manipulated using the following functions.
6138 #include <isl/schedule.h>
6139 __isl_give isl_schedule_constraints *
6140 isl_schedule_constraints_copy(
6141 __isl_keep isl_schedule_constraints *sc);
6142 __isl_give isl_schedule_constraints *
6143 isl_schedule_constraints_on_domain(
6144 __isl_take isl_union_set *domain);
6145 isl_ctx *isl_schedule_constraints_get_ctx(
6146 __isl_keep isl_schedule_constraints *sc);
6147 __isl_give isl_schedule_constraints *
6148 isl_schedule_constraints_set_validity(
6149 __isl_take isl_schedule_constraints *sc,
6150 __isl_take isl_union_map *validity);
6151 __isl_give isl_schedule_constraints *
6152 isl_schedule_constraints_set_coincidence(
6153 __isl_take isl_schedule_constraints *sc,
6154 __isl_take isl_union_map *coincidence);
6155 __isl_give isl_schedule_constraints *
6156 isl_schedule_constraints_set_proximity(
6157 __isl_take isl_schedule_constraints *sc,
6158 __isl_take isl_union_map *proximity);
6159 __isl_give isl_schedule_constraints *
6160 isl_schedule_constraints_set_conditional_validity(
6161 __isl_take isl_schedule_constraints *sc,
6162 __isl_take isl_union_map *condition,
6163 __isl_take isl_union_map *validity);
6164 __isl_null isl_schedule_constraints *
6165 isl_schedule_constraints_free(
6166 __isl_take isl_schedule_constraints *sc);
6168 The initial C<isl_schedule_constraints> object created by
6169 C<isl_schedule_constraints_on_domain> does not impose any constraints.
6170 That is, it has an empty set of dependences.
6171 The function C<isl_schedule_constraints_set_validity> replaces the
6172 validity dependences, mapping domain elements I<i> to domain
6173 elements that should be scheduled after I<i>.
6174 The function C<isl_schedule_constraints_set_coincidence> replaces the
6175 coincidence dependences, mapping domain elements I<i> to domain
6176 elements that should be scheduled together with I<I>, if possible.
6177 The function C<isl_schedule_constraints_set_proximity> replaces the
6178 proximity dependences, mapping domain elements I<i> to domain
6179 elements that should be scheduled either before I<I>
6180 or as early as possible after I<i>.
6182 The function C<isl_schedule_constraints_set_conditional_validity>
6183 replaces the conditional validity constraints.
6184 A conditional validity constraint is only imposed when any of the corresponding
6185 conditions is satisfied, i.e., when any of them is non-zero.
6186 That is, the scheduler ensures that within each band if the dependence
6187 distances over the condition constraints are not all zero
6188 then all corresponding conditional validity constraints are respected.
6189 A conditional validity constraint corresponds to a condition
6190 if the two are adjacent, i.e., if the domain of one relation intersect
6191 the range of the other relation.
6192 The typical use case of conditional validity constraints is
6193 to allow order constraints between live ranges to be violated
6194 as long as the live ranges themselves are local to the band.
6195 To allow more fine-grained control over which conditions correspond
6196 to which conditional validity constraints, the domains and ranges
6197 of these relations may include I<tags>. That is, the domains and
6198 ranges of those relation may themselves be wrapped relations
6199 where the iteration domain appears in the domain of those wrapped relations
6200 and the range of the wrapped relations can be arbitrarily chosen
6201 by the user. Conditions and conditional validity constraints are only
6202 considered adjacent to each other if the entire wrapped relation matches.
6203 In particular, a relation with a tag will never be considered adjacent
6204 to a relation without a tag.
6206 The following function computes a schedule directly from
6207 an iteration domain and validity and proximity dependences
6208 and is implemented in terms of the functions described above.
6209 The use of C<isl_union_set_compute_schedule> is discouraged.
6211 #include <isl/schedule.h>
6212 __isl_give isl_schedule *isl_union_set_compute_schedule(
6213 __isl_take isl_union_set *domain,
6214 __isl_take isl_union_map *validity,
6215 __isl_take isl_union_map *proximity);
6217 A mapping from the domains to the scheduled space can be obtained
6218 from an C<isl_schedule> using the following function.
6220 __isl_give isl_union_map *isl_schedule_get_map(
6221 __isl_keep isl_schedule *sched);
6223 A representation of the schedule can be printed using
6225 __isl_give isl_printer *isl_printer_print_schedule(
6226 __isl_take isl_printer *p,
6227 __isl_keep isl_schedule *schedule);
6229 A representation of the schedule as a forest of bands can be obtained
6230 using the following function.
6232 __isl_give isl_band_list *isl_schedule_get_band_forest(
6233 __isl_keep isl_schedule *schedule);
6235 The individual bands can be visited in depth-first post-order
6236 using the following function.
6238 #include <isl/schedule.h>
6239 int isl_schedule_foreach_band(
6240 __isl_keep isl_schedule *sched,
6241 int (*fn)(__isl_keep isl_band *band, void *user),
6244 The list can be manipulated as explained in L<"Lists">.
6245 The bands inside the list can be copied and freed using the following
6248 #include <isl/band.h>
6249 __isl_give isl_band *isl_band_copy(
6250 __isl_keep isl_band *band);
6251 __isl_null isl_band *isl_band_free(
6252 __isl_take isl_band *band);
6254 Each band contains zero or more scheduling dimensions.
6255 These are referred to as the members of the band.
6256 The section of the schedule that corresponds to the band is
6257 referred to as the partial schedule of the band.
6258 For those nodes that participate in a band, the outer scheduling
6259 dimensions form the prefix schedule, while the inner scheduling
6260 dimensions form the suffix schedule.
6261 That is, if we take a cut of the band forest, then the union of
6262 the concatenations of the prefix, partial and suffix schedules of
6263 each band in the cut is equal to the entire schedule (modulo
6264 some possible padding at the end with zero scheduling dimensions).
6265 The properties of a band can be inspected using the following functions.
6267 #include <isl/band.h>
6268 isl_ctx *isl_band_get_ctx(__isl_keep isl_band *band);
6270 int isl_band_has_children(__isl_keep isl_band *band);
6271 __isl_give isl_band_list *isl_band_get_children(
6272 __isl_keep isl_band *band);
6274 __isl_give isl_union_map *isl_band_get_prefix_schedule(
6275 __isl_keep isl_band *band);
6276 __isl_give isl_union_map *isl_band_get_partial_schedule(
6277 __isl_keep isl_band *band);
6278 __isl_give isl_union_map *isl_band_get_suffix_schedule(
6279 __isl_keep isl_band *band);
6281 int isl_band_n_member(__isl_keep isl_band *band);
6282 int isl_band_member_is_coincident(
6283 __isl_keep isl_band *band, int pos);
6285 int isl_band_list_foreach_band(
6286 __isl_keep isl_band_list *list,
6287 int (*fn)(__isl_keep isl_band *band, void *user),
6290 Note that a scheduling dimension is considered to be ``coincident''
6291 if it satisfies the coincidence constraints within its band.
6292 That is, if the dependence distances of the coincidence
6293 constraints are all zero in that direction (for fixed
6294 iterations of outer bands).
6295 Like C<isl_schedule_foreach_band>,
6296 the function C<isl_band_list_foreach_band> calls C<fn> on the bands
6297 in depth-first post-order.
6299 A band can be tiled using the following function.
6301 #include <isl/band.h>
6302 int isl_band_tile(__isl_keep isl_band *band,
6303 __isl_take isl_vec *sizes);
6305 int isl_options_set_tile_scale_tile_loops(isl_ctx *ctx,
6307 int isl_options_get_tile_scale_tile_loops(isl_ctx *ctx);
6308 int isl_options_set_tile_shift_point_loops(isl_ctx *ctx,
6310 int isl_options_get_tile_shift_point_loops(isl_ctx *ctx);
6312 The C<isl_band_tile> function tiles the band using the given tile sizes
6313 inside its schedule.
6314 A new child band is created to represent the point loops and it is
6315 inserted between the modified band and its children.
6316 The C<tile_scale_tile_loops> option specifies whether the tile
6317 loops iterators should be scaled by the tile sizes.
6318 If the C<tile_shift_point_loops> option is set, then the point loops
6319 are shifted to start at zero.
6321 A band can be split into two nested bands using the following function.
6323 int isl_band_split(__isl_keep isl_band *band, int pos);
6325 The resulting outer band contains the first C<pos> dimensions of C<band>
6326 while the inner band contains the remaining dimensions.
6328 A representation of the band can be printed using
6330 #include <isl/band.h>
6331 __isl_give isl_printer *isl_printer_print_band(
6332 __isl_take isl_printer *p,
6333 __isl_keep isl_band *band);
6337 #include <isl/schedule.h>
6338 int isl_options_set_schedule_max_coefficient(
6339 isl_ctx *ctx, int val);
6340 int isl_options_get_schedule_max_coefficient(
6342 int isl_options_set_schedule_max_constant_term(
6343 isl_ctx *ctx, int val);
6344 int isl_options_get_schedule_max_constant_term(
6346 int isl_options_set_schedule_fuse(isl_ctx *ctx, int val);
6347 int isl_options_get_schedule_fuse(isl_ctx *ctx);
6348 int isl_options_set_schedule_maximize_band_depth(
6349 isl_ctx *ctx, int val);
6350 int isl_options_get_schedule_maximize_band_depth(
6352 int isl_options_set_schedule_outer_coincidence(
6353 isl_ctx *ctx, int val);
6354 int isl_options_get_schedule_outer_coincidence(
6356 int isl_options_set_schedule_split_scaled(
6357 isl_ctx *ctx, int val);
6358 int isl_options_get_schedule_split_scaled(
6360 int isl_options_set_schedule_algorithm(
6361 isl_ctx *ctx, int val);
6362 int isl_options_get_schedule_algorithm(
6364 int isl_options_set_schedule_separate_components(
6365 isl_ctx *ctx, int val);
6366 int isl_options_get_schedule_separate_components(
6371 =item * schedule_max_coefficient
6373 This option enforces that the coefficients for variable and parameter
6374 dimensions in the calculated schedule are not larger than the specified value.
6375 This option can significantly increase the speed of the scheduling calculation
6376 and may also prevent fusing of unrelated dimensions. A value of -1 means that
6377 this option does not introduce bounds on the variable or parameter
6380 =item * schedule_max_constant_term
6382 This option enforces that the constant coefficients in the calculated schedule
6383 are not larger than the maximal constant term. This option can significantly
6384 increase the speed of the scheduling calculation and may also prevent fusing of
6385 unrelated dimensions. A value of -1 means that this option does not introduce
6386 bounds on the constant coefficients.
6388 =item * schedule_fuse
6390 This option controls the level of fusion.
6391 If this option is set to C<ISL_SCHEDULE_FUSE_MIN>, then loops in the
6392 resulting schedule will be distributed as much as possible.
6393 If this option is set to C<ISL_SCHEDULE_FUSE_MAX>, then C<isl> will
6394 try to fuse loops in the resulting schedule.
6396 =item * schedule_maximize_band_depth
6398 If this option is set, we do not split bands at the point
6399 where we detect splitting is necessary. Instead, we
6400 backtrack and split bands as early as possible. This
6401 reduces the number of splits and maximizes the width of
6402 the bands. Wider bands give more possibilities for tiling.
6403 Note that if the C<schedule_fuse> option is set to C<ISL_SCHEDULE_FUSE_MIN>,
6404 then bands will be split as early as possible, even if there is no need.
6405 The C<schedule_maximize_band_depth> option therefore has no effect in this case.
6407 =item * schedule_outer_coincidence
6409 If this option is set, then we try to construct schedules
6410 where the outermost scheduling dimension in each band
6411 satisfies the coincidence constraints.
6413 =item * schedule_split_scaled
6415 If this option is set, then we try to construct schedules in which the
6416 constant term is split off from the linear part if the linear parts of
6417 the scheduling rows for all nodes in the graphs have a common non-trivial
6419 The constant term is then placed in a separate band and the linear
6422 =item * schedule_algorithm
6424 Selects the scheduling algorithm to be used.
6425 Available scheduling algorithms are C<ISL_SCHEDULE_ALGORITHM_ISL>
6426 and C<ISL_SCHEDULE_ALGORITHM_FEAUTRIER>.
6428 =item * schedule_separate_components
6430 If at any point the dependence graph contains any (weakly connected) components,
6431 then these components are scheduled separately.
6432 If this option is not set, then some iterations of the domains
6433 in these components may be scheduled together.
6434 If this option is set, then the components are given consecutive
6439 =head2 AST Generation
6441 This section describes the C<isl> functionality for generating
6442 ASTs that visit all the elements
6443 in a domain in an order specified by a schedule.
6444 In particular, given a C<isl_union_map>, an AST is generated
6445 that visits all the elements in the domain of the C<isl_union_map>
6446 according to the lexicographic order of the corresponding image
6447 element(s). If the range of the C<isl_union_map> consists of
6448 elements in more than one space, then each of these spaces is handled
6449 separately in an arbitrary order.
6450 It should be noted that the image elements only specify the I<order>
6451 in which the corresponding domain elements should be visited.
6452 No direct relation between the image elements and the loop iterators
6453 in the generated AST should be assumed.
6455 Each AST is generated within a build. The initial build
6456 simply specifies the constraints on the parameters (if any)
6457 and can be created, inspected, copied and freed using the following functions.
6459 #include <isl/ast_build.h>
6460 __isl_give isl_ast_build *isl_ast_build_from_context(
6461 __isl_take isl_set *set);
6462 isl_ctx *isl_ast_build_get_ctx(
6463 __isl_keep isl_ast_build *build);
6464 __isl_give isl_ast_build *isl_ast_build_copy(
6465 __isl_keep isl_ast_build *build);
6466 __isl_null isl_ast_build *isl_ast_build_free(
6467 __isl_take isl_ast_build *build);
6469 The C<set> argument is usually a parameter set with zero or more parameters.
6470 More C<isl_ast_build> functions are described in L</"Nested AST Generation">
6471 and L</"Fine-grained Control over AST Generation">.
6472 Finally, the AST itself can be constructed using the following
6475 #include <isl/ast_build.h>
6476 __isl_give isl_ast_node *isl_ast_build_ast_from_schedule(
6477 __isl_keep isl_ast_build *build,
6478 __isl_take isl_union_map *schedule);
6480 =head3 Inspecting the AST
6482 The basic properties of an AST node can be obtained as follows.
6484 #include <isl/ast.h>
6485 isl_ctx *isl_ast_node_get_ctx(
6486 __isl_keep isl_ast_node *node);
6487 enum isl_ast_node_type isl_ast_node_get_type(
6488 __isl_keep isl_ast_node *node);
6490 The type of an AST node is one of
6491 C<isl_ast_node_for>,
6493 C<isl_ast_node_block> or
6494 C<isl_ast_node_user>.
6495 An C<isl_ast_node_for> represents a for node.
6496 An C<isl_ast_node_if> represents an if node.
6497 An C<isl_ast_node_block> represents a compound node.
6498 An C<isl_ast_node_user> represents an expression statement.
6499 An expression statement typically corresponds to a domain element, i.e.,
6500 one of the elements that is visited by the AST.
6502 Each type of node has its own additional properties.
6504 #include <isl/ast.h>
6505 __isl_give isl_ast_expr *isl_ast_node_for_get_iterator(
6506 __isl_keep isl_ast_node *node);
6507 __isl_give isl_ast_expr *isl_ast_node_for_get_init(
6508 __isl_keep isl_ast_node *node);
6509 __isl_give isl_ast_expr *isl_ast_node_for_get_cond(
6510 __isl_keep isl_ast_node *node);
6511 __isl_give isl_ast_expr *isl_ast_node_for_get_inc(
6512 __isl_keep isl_ast_node *node);
6513 __isl_give isl_ast_node *isl_ast_node_for_get_body(
6514 __isl_keep isl_ast_node *node);
6515 int isl_ast_node_for_is_degenerate(
6516 __isl_keep isl_ast_node *node);
6518 An C<isl_ast_for> is considered degenerate if it is known to execute
6521 #include <isl/ast.h>
6522 __isl_give isl_ast_expr *isl_ast_node_if_get_cond(
6523 __isl_keep isl_ast_node *node);
6524 __isl_give isl_ast_node *isl_ast_node_if_get_then(
6525 __isl_keep isl_ast_node *node);
6526 int isl_ast_node_if_has_else(
6527 __isl_keep isl_ast_node *node);
6528 __isl_give isl_ast_node *isl_ast_node_if_get_else(
6529 __isl_keep isl_ast_node *node);
6531 __isl_give isl_ast_node_list *
6532 isl_ast_node_block_get_children(
6533 __isl_keep isl_ast_node *node);
6535 __isl_give isl_ast_expr *isl_ast_node_user_get_expr(
6536 __isl_keep isl_ast_node *node);
6538 Each of the returned C<isl_ast_expr>s can in turn be inspected using
6539 the following functions.
6541 #include <isl/ast.h>
6542 isl_ctx *isl_ast_expr_get_ctx(
6543 __isl_keep isl_ast_expr *expr);
6544 enum isl_ast_expr_type isl_ast_expr_get_type(
6545 __isl_keep isl_ast_expr *expr);
6547 The type of an AST expression is one of
6549 C<isl_ast_expr_id> or
6550 C<isl_ast_expr_int>.
6551 An C<isl_ast_expr_op> represents the result of an operation.
6552 An C<isl_ast_expr_id> represents an identifier.
6553 An C<isl_ast_expr_int> represents an integer value.
6555 Each type of expression has its own additional properties.
6557 #include <isl/ast.h>
6558 enum isl_ast_op_type isl_ast_expr_get_op_type(
6559 __isl_keep isl_ast_expr *expr);
6560 int isl_ast_expr_get_op_n_arg(__isl_keep isl_ast_expr *expr);
6561 __isl_give isl_ast_expr *isl_ast_expr_get_op_arg(
6562 __isl_keep isl_ast_expr *expr, int pos);
6563 int isl_ast_node_foreach_ast_op_type(
6564 __isl_keep isl_ast_node *node,
6565 int (*fn)(enum isl_ast_op_type type, void *user),
6568 C<isl_ast_expr_get_op_type> returns the type of the operation
6569 performed. C<isl_ast_expr_get_op_n_arg> returns the number of
6570 arguments. C<isl_ast_expr_get_op_arg> returns the specified
6572 C<isl_ast_node_foreach_ast_op_type> calls C<fn> for each distinct
6573 C<isl_ast_op_type> that appears in C<node>.
6574 The operation type is one of the following.
6578 =item C<isl_ast_op_and>
6580 Logical I<and> of two arguments.
6581 Both arguments can be evaluated.
6583 =item C<isl_ast_op_and_then>
6585 Logical I<and> of two arguments.
6586 The second argument can only be evaluated if the first evaluates to true.
6588 =item C<isl_ast_op_or>
6590 Logical I<or> of two arguments.
6591 Both arguments can be evaluated.
6593 =item C<isl_ast_op_or_else>
6595 Logical I<or> of two arguments.
6596 The second argument can only be evaluated if the first evaluates to false.
6598 =item C<isl_ast_op_max>
6600 Maximum of two or more arguments.
6602 =item C<isl_ast_op_min>
6604 Minimum of two or more arguments.
6606 =item C<isl_ast_op_minus>
6610 =item C<isl_ast_op_add>
6612 Sum of two arguments.
6614 =item C<isl_ast_op_sub>
6616 Difference of two arguments.
6618 =item C<isl_ast_op_mul>
6620 Product of two arguments.
6622 =item C<isl_ast_op_div>
6624 Exact division. That is, the result is known to be an integer.
6626 =item C<isl_ast_op_fdiv_q>
6628 Result of integer division, rounded towards negative
6631 =item C<isl_ast_op_pdiv_q>
6633 Result of integer division, where dividend is known to be non-negative.
6635 =item C<isl_ast_op_pdiv_r>
6637 Remainder of integer division, where dividend is known to be non-negative.
6639 =item C<isl_ast_op_zdiv_r>
6641 Equal to zero iff the remainder on integer division is zero.
6643 =item C<isl_ast_op_cond>
6645 Conditional operator defined on three arguments.
6646 If the first argument evaluates to true, then the result
6647 is equal to the second argument. Otherwise, the result
6648 is equal to the third argument.
6649 The second and third argument may only be evaluated if
6650 the first argument evaluates to true and false, respectively.
6651 Corresponds to C<a ? b : c> in C.
6653 =item C<isl_ast_op_select>
6655 Conditional operator defined on three arguments.
6656 If the first argument evaluates to true, then the result
6657 is equal to the second argument. Otherwise, the result
6658 is equal to the third argument.
6659 The second and third argument may be evaluated independently
6660 of the value of the first argument.
6661 Corresponds to C<a * b + (1 - a) * c> in C.
6663 =item C<isl_ast_op_eq>
6667 =item C<isl_ast_op_le>
6669 Less than or equal relation.
6671 =item C<isl_ast_op_lt>
6675 =item C<isl_ast_op_ge>
6677 Greater than or equal relation.
6679 =item C<isl_ast_op_gt>
6681 Greater than relation.
6683 =item C<isl_ast_op_call>
6686 The number of arguments of the C<isl_ast_expr> is one more than
6687 the number of arguments in the function call, the first argument
6688 representing the function being called.
6690 =item C<isl_ast_op_access>
6693 The number of arguments of the C<isl_ast_expr> is one more than
6694 the number of index expressions in the array access, the first argument
6695 representing the array being accessed.
6697 =item C<isl_ast_op_member>
6700 This operation has two arguments, a structure and the name of
6701 the member of the structure being accessed.
6705 #include <isl/ast.h>
6706 __isl_give isl_id *isl_ast_expr_get_id(
6707 __isl_keep isl_ast_expr *expr);
6709 Return the identifier represented by the AST expression.
6711 #include <isl/ast.h>
6712 __isl_give isl_val *isl_ast_expr_get_val(
6713 __isl_keep isl_ast_expr *expr);
6715 Return the integer represented by the AST expression.
6717 =head3 Properties of ASTs
6719 #include <isl/ast.h>
6720 int isl_ast_expr_is_equal(__isl_keep isl_ast_expr *expr1,
6721 __isl_keep isl_ast_expr *expr2);
6723 Check if two C<isl_ast_expr>s are equal to each other.
6725 =head3 Manipulating and printing the AST
6727 AST nodes can be copied and freed using the following functions.
6729 #include <isl/ast.h>
6730 __isl_give isl_ast_node *isl_ast_node_copy(
6731 __isl_keep isl_ast_node *node);
6732 __isl_null isl_ast_node *isl_ast_node_free(
6733 __isl_take isl_ast_node *node);
6735 AST expressions can be copied and freed using the following functions.
6737 #include <isl/ast.h>
6738 __isl_give isl_ast_expr *isl_ast_expr_copy(
6739 __isl_keep isl_ast_expr *expr);
6740 __isl_null isl_ast_expr *isl_ast_expr_free(
6741 __isl_take isl_ast_expr *expr);
6743 New AST expressions can be created either directly or within
6744 the context of an C<isl_ast_build>.
6746 #include <isl/ast.h>
6747 __isl_give isl_ast_expr *isl_ast_expr_from_val(
6748 __isl_take isl_val *v);
6749 __isl_give isl_ast_expr *isl_ast_expr_from_id(
6750 __isl_take isl_id *id);
6751 __isl_give isl_ast_expr *isl_ast_expr_neg(
6752 __isl_take isl_ast_expr *expr);
6753 __isl_give isl_ast_expr *isl_ast_expr_address_of(
6754 __isl_take isl_ast_expr *expr);
6755 __isl_give isl_ast_expr *isl_ast_expr_add(
6756 __isl_take isl_ast_expr *expr1,
6757 __isl_take isl_ast_expr *expr2);
6758 __isl_give isl_ast_expr *isl_ast_expr_sub(
6759 __isl_take isl_ast_expr *expr1,
6760 __isl_take isl_ast_expr *expr2);
6761 __isl_give isl_ast_expr *isl_ast_expr_mul(
6762 __isl_take isl_ast_expr *expr1,
6763 __isl_take isl_ast_expr *expr2);
6764 __isl_give isl_ast_expr *isl_ast_expr_div(
6765 __isl_take isl_ast_expr *expr1,
6766 __isl_take isl_ast_expr *expr2);
6767 __isl_give isl_ast_expr *isl_ast_expr_and(
6768 __isl_take isl_ast_expr *expr1,
6769 __isl_take isl_ast_expr *expr2)
6770 __isl_give isl_ast_expr *isl_ast_expr_or(
6771 __isl_take isl_ast_expr *expr1,
6772 __isl_take isl_ast_expr *expr2)
6773 __isl_give isl_ast_expr *isl_ast_expr_eq(
6774 __isl_take isl_ast_expr *expr1,
6775 __isl_take isl_ast_expr *expr2);
6776 __isl_give isl_ast_expr *isl_ast_expr_le(
6777 __isl_take isl_ast_expr *expr1,
6778 __isl_take isl_ast_expr *expr2);
6779 __isl_give isl_ast_expr *isl_ast_expr_lt(
6780 __isl_take isl_ast_expr *expr1,
6781 __isl_take isl_ast_expr *expr2);
6782 __isl_give isl_ast_expr *isl_ast_expr_ge(
6783 __isl_take isl_ast_expr *expr1,
6784 __isl_take isl_ast_expr *expr2);
6785 __isl_give isl_ast_expr *isl_ast_expr_gt(
6786 __isl_take isl_ast_expr *expr1,
6787 __isl_take isl_ast_expr *expr2);
6788 __isl_give isl_ast_expr *isl_ast_expr_access(
6789 __isl_take isl_ast_expr *array,
6790 __isl_take isl_ast_expr_list *indices);
6792 The function C<isl_ast_expr_address_of> can be applied to an
6793 C<isl_ast_expr> of type C<isl_ast_op_access> only. It is meant
6794 to represent the address of the C<isl_ast_expr_access>.
6796 #include <isl/ast_build.h>
6797 __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff(
6798 __isl_keep isl_ast_build *build,
6799 __isl_take isl_pw_aff *pa);
6800 __isl_give isl_ast_expr *
6801 isl_ast_build_access_from_pw_multi_aff(
6802 __isl_keep isl_ast_build *build,
6803 __isl_take isl_pw_multi_aff *pma);
6804 __isl_give isl_ast_expr *
6805 isl_ast_build_access_from_multi_pw_aff(
6806 __isl_keep isl_ast_build *build,
6807 __isl_take isl_multi_pw_aff *mpa);
6808 __isl_give isl_ast_expr *
6809 isl_ast_build_call_from_pw_multi_aff(
6810 __isl_keep isl_ast_build *build,
6811 __isl_take isl_pw_multi_aff *pma);
6812 __isl_give isl_ast_expr *
6813 isl_ast_build_call_from_multi_pw_aff(
6814 __isl_keep isl_ast_build *build,
6815 __isl_take isl_multi_pw_aff *mpa);
6817 The domains of C<pa>, C<mpa> and C<pma> should correspond
6818 to the schedule space of C<build>.
6819 The tuple id of C<mpa> or C<pma> is used as the array being accessed or
6820 the function being called.
6821 If the accessed space is a nested relation, then it is taken
6822 to represent an access of the member specified by the range
6823 of this nested relation of the structure specified by the domain
6824 of the nested relation.
6826 The following functions can be used to modify an C<isl_ast_expr>.
6828 #include <isl/ast.h>
6829 __isl_give isl_ast_expr *isl_ast_expr_set_op_arg(
6830 __isl_take isl_ast_expr *expr, int pos,
6831 __isl_take isl_ast_expr *arg);
6833 Replace the argument of C<expr> at position C<pos> by C<arg>.
6835 #include <isl/ast.h>
6836 __isl_give isl_ast_expr *isl_ast_expr_substitute_ids(
6837 __isl_take isl_ast_expr *expr,
6838 __isl_take isl_id_to_ast_expr *id2expr);
6840 The function C<isl_ast_expr_substitute_ids> replaces the
6841 subexpressions of C<expr> of type C<isl_ast_expr_id>
6842 by the corresponding expression in C<id2expr>, if there is any.
6845 User specified data can be attached to an C<isl_ast_node> and obtained
6846 from the same C<isl_ast_node> using the following functions.
6848 #include <isl/ast.h>
6849 __isl_give isl_ast_node *isl_ast_node_set_annotation(
6850 __isl_take isl_ast_node *node,
6851 __isl_take isl_id *annotation);
6852 __isl_give isl_id *isl_ast_node_get_annotation(
6853 __isl_keep isl_ast_node *node);
6855 Basic printing can be performed using the following functions.
6857 #include <isl/ast.h>
6858 __isl_give isl_printer *isl_printer_print_ast_expr(
6859 __isl_take isl_printer *p,
6860 __isl_keep isl_ast_expr *expr);
6861 __isl_give isl_printer *isl_printer_print_ast_node(
6862 __isl_take isl_printer *p,
6863 __isl_keep isl_ast_node *node);
6865 More advanced printing can be performed using the following functions.
6867 #include <isl/ast.h>
6868 __isl_give isl_printer *isl_ast_op_type_print_macro(
6869 enum isl_ast_op_type type,
6870 __isl_take isl_printer *p);
6871 __isl_give isl_printer *isl_ast_node_print_macros(
6872 __isl_keep isl_ast_node *node,
6873 __isl_take isl_printer *p);
6874 __isl_give isl_printer *isl_ast_node_print(
6875 __isl_keep isl_ast_node *node,
6876 __isl_take isl_printer *p,
6877 __isl_take isl_ast_print_options *options);
6878 __isl_give isl_printer *isl_ast_node_for_print(
6879 __isl_keep isl_ast_node *node,
6880 __isl_take isl_printer *p,
6881 __isl_take isl_ast_print_options *options);
6882 __isl_give isl_printer *isl_ast_node_if_print(
6883 __isl_keep isl_ast_node *node,
6884 __isl_take isl_printer *p,
6885 __isl_take isl_ast_print_options *options);
6887 While printing an C<isl_ast_node> in C<ISL_FORMAT_C>,
6888 C<isl> may print out an AST that makes use of macros such
6889 as C<floord>, C<min> and C<max>.
6890 C<isl_ast_op_type_print_macro> prints out the macro
6891 corresponding to a specific C<isl_ast_op_type>.
6892 C<isl_ast_node_print_macros> scans the C<isl_ast_node>
6893 for expressions where these macros would be used and prints
6894 out the required macro definitions.
6895 Essentially, C<isl_ast_node_print_macros> calls
6896 C<isl_ast_node_foreach_ast_op_type> with C<isl_ast_op_type_print_macro>
6897 as function argument.
6898 C<isl_ast_node_print>, C<isl_ast_node_for_print> and
6899 C<isl_ast_node_if_print> print an C<isl_ast_node>
6900 in C<ISL_FORMAT_C>, but allow for some extra control
6901 through an C<isl_ast_print_options> object.
6902 This object can be created using the following functions.
6904 #include <isl/ast.h>
6905 __isl_give isl_ast_print_options *
6906 isl_ast_print_options_alloc(isl_ctx *ctx);
6907 __isl_give isl_ast_print_options *
6908 isl_ast_print_options_copy(
6909 __isl_keep isl_ast_print_options *options);
6910 __isl_null isl_ast_print_options *
6911 isl_ast_print_options_free(
6912 __isl_take isl_ast_print_options *options);
6914 __isl_give isl_ast_print_options *
6915 isl_ast_print_options_set_print_user(
6916 __isl_take isl_ast_print_options *options,
6917 __isl_give isl_printer *(*print_user)(
6918 __isl_take isl_printer *p,
6919 __isl_take isl_ast_print_options *options,
6920 __isl_keep isl_ast_node *node, void *user),
6922 __isl_give isl_ast_print_options *
6923 isl_ast_print_options_set_print_for(
6924 __isl_take isl_ast_print_options *options,
6925 __isl_give isl_printer *(*print_for)(
6926 __isl_take isl_printer *p,
6927 __isl_take isl_ast_print_options *options,
6928 __isl_keep isl_ast_node *node, void *user),
6931 The callback set by C<isl_ast_print_options_set_print_user>
6932 is called whenever a node of type C<isl_ast_node_user> needs to
6934 The callback set by C<isl_ast_print_options_set_print_for>
6935 is called whenever a node of type C<isl_ast_node_for> needs to
6937 Note that C<isl_ast_node_for_print> will I<not> call the
6938 callback set by C<isl_ast_print_options_set_print_for> on the node
6939 on which C<isl_ast_node_for_print> is called, but only on nested
6940 nodes of type C<isl_ast_node_for>. It is therefore safe to
6941 call C<isl_ast_node_for_print> from within the callback set by
6942 C<isl_ast_print_options_set_print_for>.
6944 The following option determines the type to be used for iterators
6945 while printing the AST.
6947 int isl_options_set_ast_iterator_type(
6948 isl_ctx *ctx, const char *val);
6949 const char *isl_options_get_ast_iterator_type(
6952 The AST printer only prints body nodes as blocks if these
6953 blocks cannot be safely omitted.
6954 For example, a C<for> node with one body node will not be
6955 surrounded with braces in C<ISL_FORMAT_C>.
6956 A block will always be printed by setting the following option.
6958 int isl_options_set_ast_always_print_block(isl_ctx *ctx,
6960 int isl_options_get_ast_always_print_block(isl_ctx *ctx);
6964 #include <isl/ast_build.h>
6965 int isl_options_set_ast_build_atomic_upper_bound(
6966 isl_ctx *ctx, int val);
6967 int isl_options_get_ast_build_atomic_upper_bound(
6969 int isl_options_set_ast_build_prefer_pdiv(isl_ctx *ctx,
6971 int isl_options_get_ast_build_prefer_pdiv(isl_ctx *ctx);
6972 int isl_options_set_ast_build_exploit_nested_bounds(
6973 isl_ctx *ctx, int val);
6974 int isl_options_get_ast_build_exploit_nested_bounds(
6976 int isl_options_set_ast_build_group_coscheduled(
6977 isl_ctx *ctx, int val);
6978 int isl_options_get_ast_build_group_coscheduled(
6980 int isl_options_set_ast_build_scale_strides(
6981 isl_ctx *ctx, int val);
6982 int isl_options_get_ast_build_scale_strides(
6984 int isl_options_set_ast_build_allow_else(isl_ctx *ctx,
6986 int isl_options_get_ast_build_allow_else(isl_ctx *ctx);
6987 int isl_options_set_ast_build_allow_or(isl_ctx *ctx,
6989 int isl_options_get_ast_build_allow_or(isl_ctx *ctx);
6993 =item * ast_build_atomic_upper_bound
6995 Generate loop upper bounds that consist of the current loop iterator,
6996 an operator and an expression not involving the iterator.
6997 If this option is not set, then the current loop iterator may appear
6998 several times in the upper bound.
6999 For example, when this option is turned off, AST generation
7002 [n] -> { A[i] -> [i] : 0 <= i <= 100, n }
7006 for (int c0 = 0; c0 <= 100 && n >= c0; c0 += 1)
7009 When the option is turned on, the following AST is generated
7011 for (int c0 = 0; c0 <= min(100, n); c0 += 1)
7014 =item * ast_build_prefer_pdiv
7016 If this option is turned off, then the AST generation will
7017 produce ASTs that may only contain C<isl_ast_op_fdiv_q>
7018 operators, but no C<isl_ast_op_pdiv_q> or
7019 C<isl_ast_op_pdiv_r> operators.
7020 If this options is turned on, then C<isl> will try to convert
7021 some of the C<isl_ast_op_fdiv_q> operators to (expressions containing)
7022 C<isl_ast_op_pdiv_q> or C<isl_ast_op_pdiv_r> operators.
7024 =item * ast_build_exploit_nested_bounds
7026 Simplify conditions based on bounds of nested for loops.
7027 In particular, remove conditions that are implied by the fact
7028 that one or more nested loops have at least one iteration,
7029 meaning that the upper bound is at least as large as the lower bound.
7030 For example, when this option is turned off, AST generation
7033 [N,M] -> { A[i,j] -> [i,j] : 0 <= i <= N and
7039 for (int c0 = 0; c0 <= N; c0 += 1)
7040 for (int c1 = 0; c1 <= M; c1 += 1)
7043 When the option is turned on, the following AST is generated
7045 for (int c0 = 0; c0 <= N; c0 += 1)
7046 for (int c1 = 0; c1 <= M; c1 += 1)
7049 =item * ast_build_group_coscheduled
7051 If two domain elements are assigned the same schedule point, then
7052 they may be executed in any order and they may even appear in different
7053 loops. If this options is set, then the AST generator will make
7054 sure that coscheduled domain elements do not appear in separate parts
7055 of the AST. This is useful in case of nested AST generation
7056 if the outer AST generation is given only part of a schedule
7057 and the inner AST generation should handle the domains that are
7058 coscheduled by this initial part of the schedule together.
7059 For example if an AST is generated for a schedule
7061 { A[i] -> [0]; B[i] -> [0] }
7063 then the C<isl_ast_build_set_create_leaf> callback described
7064 below may get called twice, once for each domain.
7065 Setting this option ensures that the callback is only called once
7066 on both domains together.
7068 =item * ast_build_separation_bounds
7070 This option specifies which bounds to use during separation.
7071 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT>
7072 then all (possibly implicit) bounds on the current dimension will
7073 be used during separation.
7074 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT>
7075 then only those bounds that are explicitly available will
7076 be used during separation.
7078 =item * ast_build_scale_strides
7080 This option specifies whether the AST generator is allowed
7081 to scale down iterators of strided loops.
7083 =item * ast_build_allow_else
7085 This option specifies whether the AST generator is allowed
7086 to construct if statements with else branches.
7088 =item * ast_build_allow_or
7090 This option specifies whether the AST generator is allowed
7091 to construct if conditions with disjunctions.
7095 =head3 Fine-grained Control over AST Generation
7097 Besides specifying the constraints on the parameters,
7098 an C<isl_ast_build> object can be used to control
7099 various aspects of the AST generation process.
7100 The most prominent way of control is through ``options'',
7101 which can be set using the following function.
7103 #include <isl/ast_build.h>
7104 __isl_give isl_ast_build *
7105 isl_ast_build_set_options(
7106 __isl_take isl_ast_build *control,
7107 __isl_take isl_union_map *options);
7109 The options are encoded in an C<isl_union_map>.
7110 The domain of this union relation refers to the schedule domain,
7111 i.e., the range of the schedule passed to C<isl_ast_build_ast_from_schedule>.
7112 In the case of nested AST generation (see L</"Nested AST Generation">),
7113 the domain of C<options> should refer to the extra piece of the schedule.
7114 That is, it should be equal to the range of the wrapped relation in the
7115 range of the schedule.
7116 The range of the options can consist of elements in one or more spaces,
7117 the names of which determine the effect of the option.
7118 The values of the range typically also refer to the schedule dimension
7119 to which the option applies. In case of nested AST generation
7120 (see L</"Nested AST Generation">), these values refer to the position
7121 of the schedule dimension within the innermost AST generation.
7122 The constraints on the domain elements of
7123 the option should only refer to this dimension and earlier dimensions.
7124 We consider the following spaces.
7128 =item C<separation_class>
7130 This space is a wrapped relation between two one dimensional spaces.
7131 The input space represents the schedule dimension to which the option
7132 applies and the output space represents the separation class.
7133 While constructing a loop corresponding to the specified schedule
7134 dimension(s), the AST generator will try to generate separate loops
7135 for domain elements that are assigned different classes.
7136 If only some of the elements are assigned a class, then those elements
7137 that are not assigned any class will be treated as belonging to a class
7138 that is separate from the explicitly assigned classes.
7139 The typical use case for this option is to separate full tiles from
7141 The other options, described below, are applied after the separation
7144 As an example, consider the separation into full and partial tiles
7145 of a tiling of a triangular domain.
7146 Take, for example, the domain
7148 { A[i,j] : 0 <= i,j and i + j <= 100 }
7150 and a tiling into tiles of 10 by 10. The input to the AST generator
7151 is then the schedule
7153 { A[i,j] -> [([i/10]),[j/10],i,j] : 0 <= i,j and
7156 Without any options, the following AST is generated
7158 for (int c0 = 0; c0 <= 10; c0 += 1)
7159 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7160 for (int c2 = 10 * c0;
7161 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7163 for (int c3 = 10 * c1;
7164 c3 <= min(10 * c1 + 9, -c2 + 100);
7168 Separation into full and partial tiles can be obtained by assigning
7169 a class, say C<0>, to the full tiles. The full tiles are represented by those
7170 values of the first and second schedule dimensions for which there are
7171 values of the third and fourth dimensions to cover an entire tile.
7172 That is, we need to specify the following option
7174 { [a,b,c,d] -> separation_class[[0]->[0]] :
7175 exists b': 0 <= 10a,10b' and
7176 10a+9+10b'+9 <= 100;
7177 [a,b,c,d] -> separation_class[[1]->[0]] :
7178 0 <= 10a,10b and 10a+9+10b+9 <= 100 }
7182 { [a, b, c, d] -> separation_class[[1] -> [0]] :
7183 a >= 0 and b >= 0 and b <= 8 - a;
7184 [a, b, c, d] -> separation_class[[0] -> [0]] :
7187 With this option, the generated AST is as follows
7190 for (int c0 = 0; c0 <= 8; c0 += 1) {
7191 for (int c1 = 0; c1 <= -c0 + 8; c1 += 1)
7192 for (int c2 = 10 * c0;
7193 c2 <= 10 * c0 + 9; c2 += 1)
7194 for (int c3 = 10 * c1;
7195 c3 <= 10 * c1 + 9; c3 += 1)
7197 for (int c1 = -c0 + 9; c1 <= -c0 + 10; c1 += 1)
7198 for (int c2 = 10 * c0;
7199 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7201 for (int c3 = 10 * c1;
7202 c3 <= min(-c2 + 100, 10 * c1 + 9);
7206 for (int c0 = 9; c0 <= 10; c0 += 1)
7207 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7208 for (int c2 = 10 * c0;
7209 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7211 for (int c3 = 10 * c1;
7212 c3 <= min(10 * c1 + 9, -c2 + 100);
7219 This is a single-dimensional space representing the schedule dimension(s)
7220 to which ``separation'' should be applied. Separation tries to split
7221 a loop into several pieces if this can avoid the generation of guards
7223 See also the C<atomic> option.
7227 This is a single-dimensional space representing the schedule dimension(s)
7228 for which the domains should be considered ``atomic''. That is, the
7229 AST generator will make sure that any given domain space will only appear
7230 in a single loop at the specified level.
7232 Consider the following schedule
7234 { a[i] -> [i] : 0 <= i < 10;
7235 b[i] -> [i+1] : 0 <= i < 10 }
7237 If the following option is specified
7239 { [i] -> separate[x] }
7241 then the following AST will be generated
7245 for (int c0 = 1; c0 <= 9; c0 += 1) {
7252 If, on the other hand, the following option is specified
7254 { [i] -> atomic[x] }
7256 then the following AST will be generated
7258 for (int c0 = 0; c0 <= 10; c0 += 1) {
7265 If neither C<atomic> nor C<separate> is specified, then the AST generator
7266 may produce either of these two results or some intermediate form.
7270 This is a single-dimensional space representing the schedule dimension(s)
7271 that should be I<completely> unrolled.
7272 To obtain a partial unrolling, the user should apply an additional
7273 strip-mining to the schedule and fully unroll the inner loop.
7277 Additional control is available through the following functions.
7279 #include <isl/ast_build.h>
7280 __isl_give isl_ast_build *
7281 isl_ast_build_set_iterators(
7282 __isl_take isl_ast_build *control,
7283 __isl_take isl_id_list *iterators);
7285 The function C<isl_ast_build_set_iterators> allows the user to
7286 specify a list of iterator C<isl_id>s to be used as iterators.
7287 If the input schedule is injective, then
7288 the number of elements in this list should be as large as the dimension
7289 of the schedule space, but no direct correspondence should be assumed
7290 between dimensions and elements.
7291 If the input schedule is not injective, then an additional number
7292 of C<isl_id>s equal to the largest dimension of the input domains
7294 If the number of provided C<isl_id>s is insufficient, then additional
7295 names are automatically generated.
7297 #include <isl/ast_build.h>
7298 __isl_give isl_ast_build *
7299 isl_ast_build_set_create_leaf(
7300 __isl_take isl_ast_build *control,
7301 __isl_give isl_ast_node *(*fn)(
7302 __isl_take isl_ast_build *build,
7303 void *user), void *user);
7306 C<isl_ast_build_set_create_leaf> function allows for the
7307 specification of a callback that should be called whenever the AST
7308 generator arrives at an element of the schedule domain.
7309 The callback should return an AST node that should be inserted
7310 at the corresponding position of the AST. The default action (when
7311 the callback is not set) is to continue generating parts of the AST to scan
7312 all the domain elements associated to the schedule domain element
7313 and to insert user nodes, ``calling'' the domain element, for each of them.
7314 The C<build> argument contains the current state of the C<isl_ast_build>.
7315 To ease nested AST generation (see L</"Nested AST Generation">),
7316 all control information that is
7317 specific to the current AST generation such as the options and
7318 the callbacks has been removed from this C<isl_ast_build>.
7319 The callback would typically return the result of a nested
7321 user defined node created using the following function.
7323 #include <isl/ast.h>
7324 __isl_give isl_ast_node *isl_ast_node_alloc_user(
7325 __isl_take isl_ast_expr *expr);
7327 #include <isl/ast_build.h>
7328 __isl_give isl_ast_build *
7329 isl_ast_build_set_at_each_domain(
7330 __isl_take isl_ast_build *build,
7331 __isl_give isl_ast_node *(*fn)(
7332 __isl_take isl_ast_node *node,
7333 __isl_keep isl_ast_build *build,
7334 void *user), void *user);
7335 __isl_give isl_ast_build *
7336 isl_ast_build_set_before_each_for(
7337 __isl_take isl_ast_build *build,
7338 __isl_give isl_id *(*fn)(
7339 __isl_keep isl_ast_build *build,
7340 void *user), void *user);
7341 __isl_give isl_ast_build *
7342 isl_ast_build_set_after_each_for(
7343 __isl_take isl_ast_build *build,
7344 __isl_give isl_ast_node *(*fn)(
7345 __isl_take isl_ast_node *node,
7346 __isl_keep isl_ast_build *build,
7347 void *user), void *user);
7349 The callback set by C<isl_ast_build_set_at_each_domain> will
7350 be called for each domain AST node.
7351 The callbacks set by C<isl_ast_build_set_before_each_for>
7352 and C<isl_ast_build_set_after_each_for> will be called
7353 for each for AST node. The first will be called in depth-first
7354 pre-order, while the second will be called in depth-first post-order.
7355 Since C<isl_ast_build_set_before_each_for> is called before the for
7356 node is actually constructed, it is only passed an C<isl_ast_build>.
7357 The returned C<isl_id> will be added as an annotation (using
7358 C<isl_ast_node_set_annotation>) to the constructed for node.
7359 In particular, if the user has also specified an C<after_each_for>
7360 callback, then the annotation can be retrieved from the node passed to
7361 that callback using C<isl_ast_node_get_annotation>.
7362 All callbacks should C<NULL> on failure.
7363 The given C<isl_ast_build> can be used to create new
7364 C<isl_ast_expr> objects using C<isl_ast_build_expr_from_pw_aff>
7365 or C<isl_ast_build_call_from_pw_multi_aff>.
7367 =head3 Nested AST Generation
7369 C<isl> allows the user to create an AST within the context
7370 of another AST. These nested ASTs are created using the
7371 same C<isl_ast_build_ast_from_schedule> function that is used to create the
7372 outer AST. The C<build> argument should be an C<isl_ast_build>
7373 passed to a callback set by
7374 C<isl_ast_build_set_create_leaf>.
7375 The space of the range of the C<schedule> argument should refer
7376 to this build. In particular, the space should be a wrapped
7377 relation and the domain of this wrapped relation should be the
7378 same as that of the range of the schedule returned by
7379 C<isl_ast_build_get_schedule> below.
7380 In practice, the new schedule is typically
7381 created by calling C<isl_union_map_range_product> on the old schedule
7382 and some extra piece of the schedule.
7383 The space of the schedule domain is also available from
7384 the C<isl_ast_build>.
7386 #include <isl/ast_build.h>
7387 __isl_give isl_union_map *isl_ast_build_get_schedule(
7388 __isl_keep isl_ast_build *build);
7389 __isl_give isl_space *isl_ast_build_get_schedule_space(
7390 __isl_keep isl_ast_build *build);
7391 __isl_give isl_ast_build *isl_ast_build_restrict(
7392 __isl_take isl_ast_build *build,
7393 __isl_take isl_set *set);
7395 The C<isl_ast_build_get_schedule> function returns a (partial)
7396 schedule for the domains elements for which part of the AST still needs to
7397 be generated in the current build.
7398 In particular, the domain elements are mapped to those iterations of the loops
7399 enclosing the current point of the AST generation inside which
7400 the domain elements are executed.
7401 No direct correspondence between
7402 the input schedule and this schedule should be assumed.
7403 The space obtained from C<isl_ast_build_get_schedule_space> can be used
7404 to create a set for C<isl_ast_build_restrict> to intersect
7405 with the current build. In particular, the set passed to
7406 C<isl_ast_build_restrict> can have additional parameters.
7407 The ids of the set dimensions in the space returned by
7408 C<isl_ast_build_get_schedule_space> correspond to the
7409 iterators of the already generated loops.
7410 The user should not rely on the ids of the output dimensions
7411 of the relations in the union relation returned by
7412 C<isl_ast_build_get_schedule> having any particular value.
7416 Although C<isl> is mainly meant to be used as a library,
7417 it also contains some basic applications that use some
7418 of the functionality of C<isl>.
7419 The input may be specified in either the L<isl format>
7420 or the L<PolyLib format>.
7422 =head2 C<isl_polyhedron_sample>
7424 C<isl_polyhedron_sample> takes a polyhedron as input and prints
7425 an integer element of the polyhedron, if there is any.
7426 The first column in the output is the denominator and is always
7427 equal to 1. If the polyhedron contains no integer points,
7428 then a vector of length zero is printed.
7432 C<isl_pip> takes the same input as the C<example> program
7433 from the C<piplib> distribution, i.e., a set of constraints
7434 on the parameters, a line containing only -1 and finally a set
7435 of constraints on a parametric polyhedron.
7436 The coefficients of the parameters appear in the last columns
7437 (but before the final constant column).
7438 The output is the lexicographic minimum of the parametric polyhedron.
7439 As C<isl> currently does not have its own output format, the output
7440 is just a dump of the internal state.
7442 =head2 C<isl_polyhedron_minimize>
7444 C<isl_polyhedron_minimize> computes the minimum of some linear
7445 or affine objective function over the integer points in a polyhedron.
7446 If an affine objective function
7447 is given, then the constant should appear in the last column.
7449 =head2 C<isl_polytope_scan>
7451 Given a polytope, C<isl_polytope_scan> prints
7452 all integer points in the polytope.
7454 =head2 C<isl_codegen>
7456 Given a schedule, a context set and an options relation,
7457 C<isl_codegen> prints out an AST that scans the domain elements
7458 of the schedule in the order of their image(s) taking into account
7459 the constraints in the context set.