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.
213 C<isl> is released under the MIT license.
217 Permission is hereby granted, free of charge, to any person obtaining a copy of
218 this software and associated documentation files (the "Software"), to deal in
219 the Software without restriction, including without limitation the rights to
220 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
221 of the Software, and to permit persons to whom the Software is furnished to do
222 so, subject to the following conditions:
224 The above copyright notice and this permission notice shall be included in all
225 copies or substantial portions of the Software.
227 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
228 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
229 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
230 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
231 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
232 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
237 Note that by default C<isl> requires C<GMP>, which is released
238 under the GNU Lesser General Public License (LGPL). This means
239 that code linked against C<isl> is also linked against LGPL code.
241 When configuring with C<--with-int=imath>, C<isl> will link against C<imath>, a
242 library for exact integer arithmetic released under the MIT license.
246 The source of C<isl> can be obtained either as a tarball
247 or from the git repository. Both are available from
248 L<http://freshmeat.net/projects/isl/>.
249 The installation process depends on how you obtained
252 =head2 Installation from the git repository
256 =item 1 Clone or update the repository
258 The first time the source is obtained, you need to clone
261 git clone git://repo.or.cz/isl.git
263 To obtain updates, you need to pull in the latest changes
267 =item 2 Optionally get C<imath> submodule
269 To build C<isl> with C<imath>, you need to obtain the C<imath>
270 submodule by running in the git source tree of C<isl>
275 This will fetch the required version of C<imath> in a subdirectory of C<isl>.
277 =item 2 Generate C<configure>
283 After performing the above steps, continue
284 with the L<Common installation instructions>.
286 =head2 Common installation instructions
290 =item 1 Obtain C<GMP>
292 By default, building C<isl> requires C<GMP>, including its headers files.
293 Your distribution may not provide these header files by default
294 and you may need to install a package called C<gmp-devel> or something
295 similar. Alternatively, C<GMP> can be built from
296 source, available from L<http://gmplib.org/>.
297 C<GMP> is not needed if you build C<isl> with C<imath>.
301 C<isl> uses the standard C<autoconf> C<configure> script.
306 optionally followed by some configure options.
307 A complete list of options can be obtained by running
311 Below we discuss some of the more common options.
317 Installation prefix for C<isl>
319 =item C<--with-int=[gmp|imath]>
321 Select the integer library to be used by C<isl>, the default is C<gmp>.
322 Note that C<isl> may run significantly slower if you use C<imath>.
324 =item C<--with-gmp-prefix>
326 Installation prefix for C<GMP> (architecture-independent files).
328 =item C<--with-gmp-exec-prefix>
330 Installation prefix for C<GMP> (architecture-dependent files).
338 =item 4 Install (optional)
344 =head1 Integer Set Library
346 =head2 Initialization
348 All manipulations of integer sets and relations occur within
349 the context of an C<isl_ctx>.
350 A given C<isl_ctx> can only be used within a single thread.
351 All arguments of a function are required to have been allocated
352 within the same context.
353 There are currently no functions available for moving an object
354 from one C<isl_ctx> to another C<isl_ctx>. This means that
355 there is currently no way of safely moving an object from one
356 thread to another, unless the whole C<isl_ctx> is moved.
358 An C<isl_ctx> can be allocated using C<isl_ctx_alloc> and
359 freed using C<isl_ctx_free>.
360 All objects allocated within an C<isl_ctx> should be freed
361 before the C<isl_ctx> itself is freed.
363 isl_ctx *isl_ctx_alloc();
364 void isl_ctx_free(isl_ctx *ctx);
366 The user can impose a bound on the number of low-level I<operations>
367 that can be performed by an C<isl_ctx>. This bound can be set and
368 retrieved using the following functions. A bound of zero means that
369 no bound is imposed. The number of operations performed can be
370 reset using C<isl_ctx_reset_operations>. Note that the number
371 of low-level operations needed to perform a high-level computation
372 may differ significantly across different versions
373 of C<isl>, but it should be the same across different platforms
374 for the same version of C<isl>.
376 Warning: This feature is experimental. C<isl> has good support to abort and
377 bail out during the computation, but this feature may exercise error code paths
378 that are normally not used that much. Consequently, it is not unlikely that
379 hidden bugs will be exposed.
381 void isl_ctx_set_max_operations(isl_ctx *ctx,
382 unsigned long max_operations);
383 unsigned long isl_ctx_get_max_operations(isl_ctx *ctx);
384 void isl_ctx_reset_operations(isl_ctx *ctx);
386 =head2 Memory Management
388 Since a high-level operation on isl objects usually involves
389 several substeps and since the user is usually not interested in
390 the intermediate results, most functions that return a new object
391 will also release all the objects passed as arguments.
392 If the user still wants to use one or more of these arguments
393 after the function call, she should pass along a copy of the
394 object rather than the object itself.
395 The user is then responsible for making sure that the original
396 object gets used somewhere else or is explicitly freed.
398 The arguments and return values of all documented functions are
399 annotated to make clear which arguments are released and which
400 arguments are preserved. In particular, the following annotations
407 C<__isl_give> means that a new object is returned.
408 The user should make sure that the returned pointer is
409 used exactly once as a value for an C<__isl_take> argument.
410 In between, it can be used as a value for as many
411 C<__isl_keep> arguments as the user likes.
412 There is one exception, and that is the case where the
413 pointer returned is C<NULL>. Is this case, the user
414 is free to use it as an C<__isl_take> argument or not.
418 C<__isl_null> means that a C<NULL> value is returned.
422 C<__isl_take> means that the object the argument points to
423 is taken over by the function and may no longer be used
424 by the user as an argument to any other function.
425 The pointer value must be one returned by a function
426 returning an C<__isl_give> pointer.
427 If the user passes in a C<NULL> value, then this will
428 be treated as an error in the sense that the function will
429 not perform its usual operation. However, it will still
430 make sure that all the other C<__isl_take> arguments
435 C<__isl_keep> means that the function will only use the object
436 temporarily. After the function has finished, the user
437 can still use it as an argument to other functions.
438 A C<NULL> value will be treated in the same way as
439 a C<NULL> value for an C<__isl_take> argument.
445 An C<isl_val> represents an integer value, a rational value
446 or one of three special values, infinity, negative infinity and NaN.
447 Some predefined values can be created using the following functions.
450 __isl_give isl_val *isl_val_zero(isl_ctx *ctx);
451 __isl_give isl_val *isl_val_one(isl_ctx *ctx);
452 __isl_give isl_val *isl_val_negone(isl_ctx *ctx);
453 __isl_give isl_val *isl_val_nan(isl_ctx *ctx);
454 __isl_give isl_val *isl_val_infty(isl_ctx *ctx);
455 __isl_give isl_val *isl_val_neginfty(isl_ctx *ctx);
457 Specific integer values can be created using the following functions.
460 __isl_give isl_val *isl_val_int_from_si(isl_ctx *ctx,
462 __isl_give isl_val *isl_val_int_from_ui(isl_ctx *ctx,
464 __isl_give isl_val *isl_val_int_from_chunks(isl_ctx *ctx,
465 size_t n, size_t size, const void *chunks);
467 The function C<isl_val_int_from_chunks> constructs an C<isl_val>
468 from the C<n> I<digits>, each consisting of C<size> bytes, stored at C<chunks>.
469 The least significant digit is assumed to be stored first.
471 Value objects can be copied and freed using the following functions.
474 __isl_give isl_val *isl_val_copy(__isl_keep isl_val *v);
475 __isl_null isl_val *isl_val_free(__isl_take isl_val *v);
477 They can be inspected using the following functions.
480 isl_ctx *isl_val_get_ctx(__isl_keep isl_val *val);
481 long isl_val_get_num_si(__isl_keep isl_val *v);
482 long isl_val_get_den_si(__isl_keep isl_val *v);
483 double isl_val_get_d(__isl_keep isl_val *v);
484 size_t isl_val_n_abs_num_chunks(__isl_keep isl_val *v,
486 int isl_val_get_abs_num_chunks(__isl_keep isl_val *v,
487 size_t size, void *chunks);
489 C<isl_val_n_abs_num_chunks> returns the number of I<digits>
490 of C<size> bytes needed to store the absolute value of the
492 C<isl_val_get_abs_num_chunks> stores these digits at C<chunks>,
493 which is assumed to have been preallocated by the caller.
494 The least significant digit is stored first.
495 Note that C<isl_val_get_num_si>, C<isl_val_get_den_si>,
496 C<isl_val_get_d>, C<isl_val_n_abs_num_chunks>
497 and C<isl_val_get_abs_num_chunks> can only be applied to rational values.
499 An C<isl_val> can be modified using the following function.
502 __isl_give isl_val *isl_val_set_si(__isl_take isl_val *v,
505 The following unary properties are defined on C<isl_val>s.
508 int isl_val_sgn(__isl_keep isl_val *v);
509 int isl_val_is_zero(__isl_keep isl_val *v);
510 int isl_val_is_one(__isl_keep isl_val *v);
511 int isl_val_is_negone(__isl_keep isl_val *v);
512 int isl_val_is_nonneg(__isl_keep isl_val *v);
513 int isl_val_is_nonpos(__isl_keep isl_val *v);
514 int isl_val_is_pos(__isl_keep isl_val *v);
515 int isl_val_is_neg(__isl_keep isl_val *v);
516 int isl_val_is_int(__isl_keep isl_val *v);
517 int isl_val_is_rat(__isl_keep isl_val *v);
518 int isl_val_is_nan(__isl_keep isl_val *v);
519 int isl_val_is_infty(__isl_keep isl_val *v);
520 int isl_val_is_neginfty(__isl_keep isl_val *v);
522 Note that the sign of NaN is undefined.
524 The following binary properties are defined on pairs of C<isl_val>s.
527 int isl_val_lt(__isl_keep isl_val *v1,
528 __isl_keep isl_val *v2);
529 int isl_val_le(__isl_keep isl_val *v1,
530 __isl_keep isl_val *v2);
531 int isl_val_gt(__isl_keep isl_val *v1,
532 __isl_keep isl_val *v2);
533 int isl_val_ge(__isl_keep isl_val *v1,
534 __isl_keep isl_val *v2);
535 int isl_val_eq(__isl_keep isl_val *v1,
536 __isl_keep isl_val *v2);
537 int isl_val_ne(__isl_keep isl_val *v1,
538 __isl_keep isl_val *v2);
540 For integer C<isl_val>s we additionally have the following binary property.
543 int isl_val_is_divisible_by(__isl_keep isl_val *v1,
544 __isl_keep isl_val *v2);
546 An C<isl_val> can also be compared to an integer using the following
547 function. The result is undefined for NaN.
550 int isl_val_cmp_si(__isl_keep isl_val *v, long i);
552 The following unary operations are available on C<isl_val>s.
555 __isl_give isl_val *isl_val_abs(__isl_take isl_val *v);
556 __isl_give isl_val *isl_val_neg(__isl_take isl_val *v);
557 __isl_give isl_val *isl_val_floor(__isl_take isl_val *v);
558 __isl_give isl_val *isl_val_ceil(__isl_take isl_val *v);
559 __isl_give isl_val *isl_val_trunc(__isl_take isl_val *v);
560 __isl_give isl_val *isl_val_2exp(__isl_take isl_val *v);
562 The following binary operations are available on C<isl_val>s.
565 __isl_give isl_val *isl_val_min(__isl_take isl_val *v1,
566 __isl_take isl_val *v2);
567 __isl_give isl_val *isl_val_max(__isl_take isl_val *v1,
568 __isl_take isl_val *v2);
569 __isl_give isl_val *isl_val_add(__isl_take isl_val *v1,
570 __isl_take isl_val *v2);
571 __isl_give isl_val *isl_val_add_ui(__isl_take isl_val *v1,
573 __isl_give isl_val *isl_val_sub(__isl_take isl_val *v1,
574 __isl_take isl_val *v2);
575 __isl_give isl_val *isl_val_sub_ui(__isl_take isl_val *v1,
577 __isl_give isl_val *isl_val_mul(__isl_take isl_val *v1,
578 __isl_take isl_val *v2);
579 __isl_give isl_val *isl_val_mul_ui(__isl_take isl_val *v1,
581 __isl_give isl_val *isl_val_div(__isl_take isl_val *v1,
582 __isl_take isl_val *v2);
584 On integer values, we additionally have the following operations.
587 __isl_give isl_val *isl_val_2exp(__isl_take isl_val *v);
588 __isl_give isl_val *isl_val_mod(__isl_take isl_val *v1,
589 __isl_take isl_val *v2);
590 __isl_give isl_val *isl_val_gcd(__isl_take isl_val *v1,
591 __isl_take isl_val *v2);
592 __isl_give isl_val *isl_val_gcdext(__isl_take isl_val *v1,
593 __isl_take isl_val *v2, __isl_give isl_val **x,
594 __isl_give isl_val **y);
596 The function C<isl_val_gcdext> returns the greatest common divisor g
597 of C<v1> and C<v2> as well as two integers C<*x> and C<*y> such
598 that C<*x> * C<v1> + C<*y> * C<v2> = g.
600 A value can be read from input using
603 __isl_give isl_val *isl_val_read_from_str(isl_ctx *ctx,
606 A value can be printed using
609 __isl_give isl_printer *isl_printer_print_val(
610 __isl_take isl_printer *p, __isl_keep isl_val *v);
612 =head3 GMP specific functions
614 These functions are only available if C<isl> has been compiled with C<GMP>
617 Specific integer and rational values can be created from C<GMP> values using
618 the following functions.
620 #include <isl/val_gmp.h>
621 __isl_give isl_val *isl_val_int_from_gmp(isl_ctx *ctx,
623 __isl_give isl_val *isl_val_from_gmp(isl_ctx *ctx,
624 const mpz_t n, const mpz_t d);
626 The numerator and denominator of a rational value can be extracted as
627 C<GMP> values using the following functions.
629 #include <isl/val_gmp.h>
630 int isl_val_get_num_gmp(__isl_keep isl_val *v, mpz_t z);
631 int isl_val_get_den_gmp(__isl_keep isl_val *v, mpz_t z);
633 =head2 Sets and Relations
635 C<isl> uses six types of objects for representing sets and relations,
636 C<isl_basic_set>, C<isl_basic_map>, C<isl_set>, C<isl_map>,
637 C<isl_union_set> and C<isl_union_map>.
638 C<isl_basic_set> and C<isl_basic_map> represent sets and relations that
639 can be described as a conjunction of affine constraints, while
640 C<isl_set> and C<isl_map> represent unions of
641 C<isl_basic_set>s and C<isl_basic_map>s, respectively.
642 However, all C<isl_basic_set>s or C<isl_basic_map>s in the union need
643 to live in the same space. C<isl_union_set>s and C<isl_union_map>s
644 represent unions of C<isl_set>s or C<isl_map>s in I<different> spaces,
645 where spaces are considered different if they have a different number
646 of dimensions and/or different names (see L<"Spaces">).
647 The difference between sets and relations (maps) is that sets have
648 one set of variables, while relations have two sets of variables,
649 input variables and output variables.
651 =head2 Error Handling
653 C<isl> supports different ways to react in case a runtime error is triggered.
654 Runtime errors arise, e.g., if a function such as C<isl_map_intersect> is called
655 with two maps that have incompatible spaces. There are three possible ways
656 to react on error: to warn, to continue or to abort.
658 The default behavior is to warn. In this mode, C<isl> prints a warning, stores
659 the last error in the corresponding C<isl_ctx> and the function in which the
660 error was triggered returns C<NULL>. An error does not corrupt internal state,
661 such that isl can continue to be used. C<isl> also provides functions to
662 read the last error and to reset the memory that stores the last error. The
663 last error is only stored for information purposes. Its presence does not
664 change the behavior of C<isl>. Hence, resetting an error is not required to
665 continue to use isl, but only to observe new errors.
668 enum isl_error isl_ctx_last_error(isl_ctx *ctx);
669 void isl_ctx_reset_error(isl_ctx *ctx);
671 Another option is to continue on error. This is similar to warn on error mode,
672 except that C<isl> does not print any warning. This allows a program to
673 implement its own error reporting.
675 The last option is to directly abort the execution of the program from within
676 the isl library. This makes it obviously impossible to recover from an error,
677 but it allows to directly spot the error location. By aborting on error,
678 debuggers break at the location the error occurred and can provide a stack
679 trace. Other tools that automatically provide stack traces on abort or that do
680 not want to continue execution after an error was triggered may also prefer to
683 The on error behavior of isl can be specified by calling
684 C<isl_options_set_on_error> or by setting the command line option
685 C<--isl-on-error>. Valid arguments for the function call are
686 C<ISL_ON_ERROR_WARN>, C<ISL_ON_ERROR_CONTINUE> and C<ISL_ON_ERROR_ABORT>. The
687 choices for the command line option are C<warn>, C<continue> and C<abort>.
688 It is also possible to query the current error mode.
690 #include <isl/options.h>
691 int isl_options_set_on_error(isl_ctx *ctx, int val);
692 int isl_options_get_on_error(isl_ctx *ctx);
696 Identifiers are used to identify both individual dimensions
697 and tuples of dimensions. They consist of an optional name and an optional
698 user pointer. The name and the user pointer cannot both be C<NULL>, however.
699 Identifiers with the same name but different pointer values
700 are considered to be distinct.
701 Similarly, identifiers with different names but the same pointer value
702 are also considered to be distinct.
703 Equal identifiers are represented using the same object.
704 Pairs of identifiers can therefore be tested for equality using the
706 Identifiers can be constructed, copied, freed, inspected and printed
707 using the following functions.
710 __isl_give isl_id *isl_id_alloc(isl_ctx *ctx,
711 __isl_keep const char *name, void *user);
712 __isl_give isl_id *isl_id_set_free_user(
713 __isl_take isl_id *id,
714 __isl_give void (*free_user)(void *user));
715 __isl_give isl_id *isl_id_copy(isl_id *id);
716 __isl_null isl_id *isl_id_free(__isl_take isl_id *id);
718 isl_ctx *isl_id_get_ctx(__isl_keep isl_id *id);
719 void *isl_id_get_user(__isl_keep isl_id *id);
720 __isl_keep const char *isl_id_get_name(__isl_keep isl_id *id);
722 __isl_give isl_printer *isl_printer_print_id(
723 __isl_take isl_printer *p, __isl_keep isl_id *id);
725 The callback set by C<isl_id_set_free_user> is called on the user
726 pointer when the last reference to the C<isl_id> is freed.
727 Note that C<isl_id_get_name> returns a pointer to some internal
728 data structure, so the result can only be used while the
729 corresponding C<isl_id> is alive.
733 Whenever a new set, relation or similar object is created from scratch,
734 the space in which it lives needs to be specified using an C<isl_space>.
735 Each space involves zero or more parameters and zero, one or two
736 tuples of set or input/output dimensions. The parameters and dimensions
737 are identified by an C<isl_dim_type> and a position.
738 The type C<isl_dim_param> refers to parameters,
739 the type C<isl_dim_set> refers to set dimensions (for spaces
740 with a single tuple of dimensions) and the types C<isl_dim_in>
741 and C<isl_dim_out> refer to input and output dimensions
742 (for spaces with two tuples of dimensions).
743 Local spaces (see L</"Local Spaces">) also contain dimensions
744 of type C<isl_dim_div>.
745 Note that parameters are only identified by their position within
746 a given object. Across different objects, parameters are (usually)
747 identified by their names or identifiers. Only unnamed parameters
748 are identified by their positions across objects. The use of unnamed
749 parameters is discouraged.
751 #include <isl/space.h>
752 __isl_give isl_space *isl_space_alloc(isl_ctx *ctx,
753 unsigned nparam, unsigned n_in, unsigned n_out);
754 __isl_give isl_space *isl_space_params_alloc(isl_ctx *ctx,
756 __isl_give isl_space *isl_space_set_alloc(isl_ctx *ctx,
757 unsigned nparam, unsigned dim);
758 __isl_give isl_space *isl_space_copy(__isl_keep isl_space *space);
759 __isl_null isl_space *isl_space_free(__isl_take isl_space *space);
760 unsigned isl_space_dim(__isl_keep isl_space *space,
761 enum isl_dim_type type);
763 The space used for creating a parameter domain
764 needs to be created using C<isl_space_params_alloc>.
765 For other sets, the space
766 needs to be created using C<isl_space_set_alloc>, while
767 for a relation, the space
768 needs to be created using C<isl_space_alloc>.
769 C<isl_space_dim> can be used
770 to find out the number of dimensions of each type in
771 a space, where type may be
772 C<isl_dim_param>, C<isl_dim_in> (only for relations),
773 C<isl_dim_out> (only for relations), C<isl_dim_set>
774 (only for sets) or C<isl_dim_all>.
776 To check whether a given space is that of a set or a map
777 or whether it is a parameter space, use these functions:
779 #include <isl/space.h>
780 int isl_space_is_params(__isl_keep isl_space *space);
781 int isl_space_is_set(__isl_keep isl_space *space);
782 int isl_space_is_map(__isl_keep isl_space *space);
784 Spaces can be compared using the following functions:
786 #include <isl/space.h>
787 int isl_space_is_equal(__isl_keep isl_space *space1,
788 __isl_keep isl_space *space2);
789 int isl_space_is_domain(__isl_keep isl_space *space1,
790 __isl_keep isl_space *space2);
791 int isl_space_is_range(__isl_keep isl_space *space1,
792 __isl_keep isl_space *space2);
793 int isl_space_tuple_is_equal(
794 __isl_keep isl_space *space1,
795 enum isl_dim_type type1,
796 __isl_keep isl_space *space2,
797 enum isl_dim_type type2);
799 C<isl_space_is_domain> checks whether the first argument is equal
800 to the domain of the second argument. This requires in particular that
801 the first argument is a set space and that the second argument
802 is a map space. C<isl_space_tuple_is_equal> checks whether the given
803 tuples (C<isl_dim_in>, C<isl_dim_out> or C<isl_dim_set>) of the given
804 spaces are the same. That is, it checks if they have the same
805 identifier (if any), the same dimension and the same internal structure
808 It is often useful to create objects that live in the
809 same space as some other object. This can be accomplished
810 by creating the new objects
811 (see L</"Creating New Sets and Relations"> or
812 L</"Creating New (Piecewise) Quasipolynomials">) based on the space
813 of the original object.
816 __isl_give isl_space *isl_basic_set_get_space(
817 __isl_keep isl_basic_set *bset);
818 __isl_give isl_space *isl_set_get_space(__isl_keep isl_set *set);
820 #include <isl/union_set.h>
821 __isl_give isl_space *isl_union_set_get_space(
822 __isl_keep isl_union_set *uset);
825 __isl_give isl_space *isl_basic_map_get_space(
826 __isl_keep isl_basic_map *bmap);
827 __isl_give isl_space *isl_map_get_space(__isl_keep isl_map *map);
829 #include <isl/union_map.h>
830 __isl_give isl_space *isl_union_map_get_space(
831 __isl_keep isl_union_map *umap);
833 #include <isl/constraint.h>
834 __isl_give isl_space *isl_constraint_get_space(
835 __isl_keep isl_constraint *constraint);
837 #include <isl/polynomial.h>
838 __isl_give isl_space *isl_qpolynomial_get_domain_space(
839 __isl_keep isl_qpolynomial *qp);
840 __isl_give isl_space *isl_qpolynomial_get_space(
841 __isl_keep isl_qpolynomial *qp);
842 __isl_give isl_space *isl_qpolynomial_fold_get_space(
843 __isl_keep isl_qpolynomial_fold *fold);
844 __isl_give isl_space *isl_pw_qpolynomial_get_domain_space(
845 __isl_keep isl_pw_qpolynomial *pwqp);
846 __isl_give isl_space *isl_pw_qpolynomial_get_space(
847 __isl_keep isl_pw_qpolynomial *pwqp);
848 __isl_give isl_space *isl_pw_qpolynomial_fold_get_domain_space(
849 __isl_keep isl_pw_qpolynomial_fold *pwf);
850 __isl_give isl_space *isl_pw_qpolynomial_fold_get_space(
851 __isl_keep isl_pw_qpolynomial_fold *pwf);
852 __isl_give isl_space *isl_union_pw_qpolynomial_get_space(
853 __isl_keep isl_union_pw_qpolynomial *upwqp);
854 __isl_give isl_space *isl_union_pw_qpolynomial_fold_get_space(
855 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
858 __isl_give isl_space *isl_multi_val_get_space(
859 __isl_keep isl_multi_val *mv);
862 __isl_give isl_space *isl_aff_get_domain_space(
863 __isl_keep isl_aff *aff);
864 __isl_give isl_space *isl_aff_get_space(
865 __isl_keep isl_aff *aff);
866 __isl_give isl_space *isl_pw_aff_get_domain_space(
867 __isl_keep isl_pw_aff *pwaff);
868 __isl_give isl_space *isl_pw_aff_get_space(
869 __isl_keep isl_pw_aff *pwaff);
870 __isl_give isl_space *isl_multi_aff_get_domain_space(
871 __isl_keep isl_multi_aff *maff);
872 __isl_give isl_space *isl_multi_aff_get_space(
873 __isl_keep isl_multi_aff *maff);
874 __isl_give isl_space *isl_pw_multi_aff_get_domain_space(
875 __isl_keep isl_pw_multi_aff *pma);
876 __isl_give isl_space *isl_pw_multi_aff_get_space(
877 __isl_keep isl_pw_multi_aff *pma);
878 __isl_give isl_space *isl_union_pw_multi_aff_get_space(
879 __isl_keep isl_union_pw_multi_aff *upma);
880 __isl_give isl_space *isl_multi_pw_aff_get_domain_space(
881 __isl_keep isl_multi_pw_aff *mpa);
882 __isl_give isl_space *isl_multi_pw_aff_get_space(
883 __isl_keep isl_multi_pw_aff *mpa);
885 #include <isl/point.h>
886 __isl_give isl_space *isl_point_get_space(
887 __isl_keep isl_point *pnt);
889 The identifiers or names of the individual dimensions may be set or read off
890 using the following functions.
892 #include <isl/space.h>
893 __isl_give isl_space *isl_space_set_dim_id(
894 __isl_take isl_space *space,
895 enum isl_dim_type type, unsigned pos,
896 __isl_take isl_id *id);
897 int isl_space_has_dim_id(__isl_keep isl_space *space,
898 enum isl_dim_type type, unsigned pos);
899 __isl_give isl_id *isl_space_get_dim_id(
900 __isl_keep isl_space *space,
901 enum isl_dim_type type, unsigned pos);
902 __isl_give isl_space *isl_space_set_dim_name(
903 __isl_take isl_space *space,
904 enum isl_dim_type type, unsigned pos,
905 __isl_keep const char *name);
906 int isl_space_has_dim_name(__isl_keep isl_space *space,
907 enum isl_dim_type type, unsigned pos);
908 __isl_keep const char *isl_space_get_dim_name(
909 __isl_keep isl_space *space,
910 enum isl_dim_type type, unsigned pos);
912 Note that C<isl_space_get_name> returns a pointer to some internal
913 data structure, so the result can only be used while the
914 corresponding C<isl_space> is alive.
915 Also note that every function that operates on two sets or relations
916 requires that both arguments have the same parameters. This also
917 means that if one of the arguments has named parameters, then the
918 other needs to have named parameters too and the names need to match.
919 Pairs of C<isl_set>, C<isl_map>, C<isl_union_set> and/or C<isl_union_map>
920 arguments may have different parameters (as long as they are named),
921 in which case the result will have as parameters the union of the parameters of
924 Given the identifier or name of a dimension (typically a parameter),
925 its position can be obtained from the following function.
927 #include <isl/space.h>
928 int isl_space_find_dim_by_id(__isl_keep isl_space *space,
929 enum isl_dim_type type, __isl_keep isl_id *id);
930 int isl_space_find_dim_by_name(__isl_keep isl_space *space,
931 enum isl_dim_type type, const char *name);
933 The identifiers or names of entire spaces may be set or read off
934 using the following functions.
936 #include <isl/space.h>
937 __isl_give isl_space *isl_space_set_tuple_id(
938 __isl_take isl_space *space,
939 enum isl_dim_type type, __isl_take isl_id *id);
940 __isl_give isl_space *isl_space_reset_tuple_id(
941 __isl_take isl_space *space, enum isl_dim_type type);
942 int isl_space_has_tuple_id(__isl_keep isl_space *space,
943 enum isl_dim_type type);
944 __isl_give isl_id *isl_space_get_tuple_id(
945 __isl_keep isl_space *space, enum isl_dim_type type);
946 __isl_give isl_space *isl_space_set_tuple_name(
947 __isl_take isl_space *space,
948 enum isl_dim_type type, const char *s);
949 int isl_space_has_tuple_name(__isl_keep isl_space *space,
950 enum isl_dim_type type);
951 const char *isl_space_get_tuple_name(__isl_keep isl_space *space,
952 enum isl_dim_type type);
954 The C<type> argument needs to be one of C<isl_dim_in>, C<isl_dim_out>
955 or C<isl_dim_set>. As with C<isl_space_get_name>,
956 the C<isl_space_get_tuple_name> function returns a pointer to some internal
958 Binary operations require the corresponding spaces of their arguments
959 to have the same name.
961 To keep the names of all parameters and tuples, but reset the user pointers
962 of all the corresponding identifiers, use the following function.
964 __isl_give isl_space *isl_space_reset_user(
965 __isl_take isl_space *space);
967 Spaces can be nested. In particular, the domain of a set or
968 the domain or range of a relation can be a nested relation.
969 This process is also called I<wrapping>.
970 The functions for detecting, constructing and deconstructing
971 such nested spaces can be found in the wrapping properties
972 of L</"Unary Properties">, the wrapping operations
973 of L</"Unary Operations"> and the Cartesian product operations
974 of L</"Basic Operations">.
976 Spaces can be created from other spaces
977 using the following functions.
979 __isl_give isl_space *isl_space_domain(__isl_take isl_space *space);
980 __isl_give isl_space *isl_space_from_domain(__isl_take isl_space *space);
981 __isl_give isl_space *isl_space_range(__isl_take isl_space *space);
982 __isl_give isl_space *isl_space_from_range(__isl_take isl_space *space);
983 __isl_give isl_space *isl_space_domain_map(
984 __isl_take isl_space *space);
985 __isl_give isl_space *isl_space_range_map(
986 __isl_take isl_space *space);
987 __isl_give isl_space *isl_space_params(
988 __isl_take isl_space *space);
989 __isl_give isl_space *isl_space_set_from_params(
990 __isl_take isl_space *space);
991 __isl_give isl_space *isl_space_reverse(__isl_take isl_space *space);
992 __isl_give isl_space *isl_space_join(__isl_take isl_space *left,
993 __isl_take isl_space *right);
994 __isl_give isl_space *isl_space_align_params(
995 __isl_take isl_space *space1, __isl_take isl_space *space2)
996 __isl_give isl_space *isl_space_insert_dims(__isl_take isl_space *space,
997 enum isl_dim_type type, unsigned pos, unsigned n);
998 __isl_give isl_space *isl_space_add_dims(__isl_take isl_space *space,
999 enum isl_dim_type type, unsigned n);
1000 __isl_give isl_space *isl_space_drop_dims(__isl_take isl_space *space,
1001 enum isl_dim_type type, unsigned first, unsigned n);
1002 __isl_give isl_space *isl_space_move_dims(__isl_take isl_space *space,
1003 enum isl_dim_type dst_type, unsigned dst_pos,
1004 enum isl_dim_type src_type, unsigned src_pos,
1006 __isl_give isl_space *isl_space_map_from_set(
1007 __isl_take isl_space *space);
1008 __isl_give isl_space *isl_space_map_from_domain_and_range(
1009 __isl_take isl_space *domain,
1010 __isl_take isl_space *range);
1011 __isl_give isl_space *isl_space_zip(__isl_take isl_space *space);
1012 __isl_give isl_space *isl_space_curry(
1013 __isl_take isl_space *space);
1014 __isl_give isl_space *isl_space_uncurry(
1015 __isl_take isl_space *space);
1017 Note that if dimensions are added or removed from a space, then
1018 the name and the internal structure are lost.
1022 A local space is essentially a space with
1023 zero or more existentially quantified variables.
1024 The local space of a (constraint of a) basic set or relation can be obtained
1025 using the following functions.
1027 #include <isl/constraint.h>
1028 __isl_give isl_local_space *isl_constraint_get_local_space(
1029 __isl_keep isl_constraint *constraint);
1031 #include <isl/set.h>
1032 __isl_give isl_local_space *isl_basic_set_get_local_space(
1033 __isl_keep isl_basic_set *bset);
1035 #include <isl/map.h>
1036 __isl_give isl_local_space *isl_basic_map_get_local_space(
1037 __isl_keep isl_basic_map *bmap);
1039 A new local space can be created from a space using
1041 #include <isl/local_space.h>
1042 __isl_give isl_local_space *isl_local_space_from_space(
1043 __isl_take isl_space *space);
1045 They can be inspected, modified, copied and freed using the following functions.
1047 #include <isl/local_space.h>
1048 isl_ctx *isl_local_space_get_ctx(
1049 __isl_keep isl_local_space *ls);
1050 int isl_local_space_is_set(__isl_keep isl_local_space *ls);
1051 int isl_local_space_dim(__isl_keep isl_local_space *ls,
1052 enum isl_dim_type type);
1053 __isl_give isl_local_space *isl_local_space_set_tuple_id(
1054 __isl_take isl_local_space *ls,
1055 enum isl_dim_type type, __isl_take isl_id *id);
1056 int isl_local_space_has_dim_id(
1057 __isl_keep isl_local_space *ls,
1058 enum isl_dim_type type, unsigned pos);
1059 __isl_give isl_id *isl_local_space_get_dim_id(
1060 __isl_keep isl_local_space *ls,
1061 enum isl_dim_type type, unsigned pos);
1062 int isl_local_space_has_dim_name(
1063 __isl_keep isl_local_space *ls,
1064 enum isl_dim_type type, unsigned pos)
1065 const char *isl_local_space_get_dim_name(
1066 __isl_keep isl_local_space *ls,
1067 enum isl_dim_type type, unsigned pos);
1068 __isl_give isl_local_space *isl_local_space_set_dim_name(
1069 __isl_take isl_local_space *ls,
1070 enum isl_dim_type type, unsigned pos, const char *s);
1071 __isl_give isl_local_space *isl_local_space_set_dim_id(
1072 __isl_take isl_local_space *ls,
1073 enum isl_dim_type type, unsigned pos,
1074 __isl_take isl_id *id);
1075 __isl_give isl_space *isl_local_space_get_space(
1076 __isl_keep isl_local_space *ls);
1077 __isl_give isl_aff *isl_local_space_get_div(
1078 __isl_keep isl_local_space *ls, int pos);
1079 __isl_give isl_local_space *isl_local_space_copy(
1080 __isl_keep isl_local_space *ls);
1081 __isl_null isl_local_space *isl_local_space_free(
1082 __isl_take isl_local_space *ls);
1084 Note that C<isl_local_space_get_div> can only be used on local spaces
1087 Two local spaces can be compared using
1089 int isl_local_space_is_equal(__isl_keep isl_local_space *ls1,
1090 __isl_keep isl_local_space *ls2);
1092 Local spaces can be created from other local spaces
1093 using the functions described in L</"Unary Operations">
1094 and L</"Binary Operations">.
1096 =head2 Input and Output
1098 C<isl> supports its own input/output format, which is similar
1099 to the C<Omega> format, but also supports the C<PolyLib> format
1102 =head3 C<isl> format
1104 The C<isl> format is similar to that of C<Omega>, but has a different
1105 syntax for describing the parameters and allows for the definition
1106 of an existentially quantified variable as the integer division
1107 of an affine expression.
1108 For example, the set of integers C<i> between C<0> and C<n>
1109 such that C<i % 10 <= 6> can be described as
1111 [n] -> { [i] : exists (a = [i/10] : 0 <= i and i <= n and
1114 A set or relation can have several disjuncts, separated
1115 by the keyword C<or>. Each disjunct is either a conjunction
1116 of constraints or a projection (C<exists>) of a conjunction
1117 of constraints. The constraints are separated by the keyword
1120 =head3 C<PolyLib> format
1122 If the represented set is a union, then the first line
1123 contains a single number representing the number of disjuncts.
1124 Otherwise, a line containing the number C<1> is optional.
1126 Each disjunct is represented by a matrix of constraints.
1127 The first line contains two numbers representing
1128 the number of rows and columns,
1129 where the number of rows is equal to the number of constraints
1130 and the number of columns is equal to two plus the number of variables.
1131 The following lines contain the actual rows of the constraint matrix.
1132 In each row, the first column indicates whether the constraint
1133 is an equality (C<0>) or inequality (C<1>). The final column
1134 corresponds to the constant term.
1136 If the set is parametric, then the coefficients of the parameters
1137 appear in the last columns before the constant column.
1138 The coefficients of any existentially quantified variables appear
1139 between those of the set variables and those of the parameters.
1141 =head3 Extended C<PolyLib> format
1143 The extended C<PolyLib> format is nearly identical to the
1144 C<PolyLib> format. The only difference is that the line
1145 containing the number of rows and columns of a constraint matrix
1146 also contains four additional numbers:
1147 the number of output dimensions, the number of input dimensions,
1148 the number of local dimensions (i.e., the number of existentially
1149 quantified variables) and the number of parameters.
1150 For sets, the number of ``output'' dimensions is equal
1151 to the number of set dimensions, while the number of ``input''
1156 #include <isl/set.h>
1157 __isl_give isl_basic_set *isl_basic_set_read_from_file(
1158 isl_ctx *ctx, FILE *input);
1159 __isl_give isl_basic_set *isl_basic_set_read_from_str(
1160 isl_ctx *ctx, const char *str);
1161 __isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx,
1163 __isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx,
1166 #include <isl/map.h>
1167 __isl_give isl_basic_map *isl_basic_map_read_from_file(
1168 isl_ctx *ctx, FILE *input);
1169 __isl_give isl_basic_map *isl_basic_map_read_from_str(
1170 isl_ctx *ctx, const char *str);
1171 __isl_give isl_map *isl_map_read_from_file(
1172 isl_ctx *ctx, FILE *input);
1173 __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx,
1176 #include <isl/union_set.h>
1177 __isl_give isl_union_set *isl_union_set_read_from_file(
1178 isl_ctx *ctx, FILE *input);
1179 __isl_give isl_union_set *isl_union_set_read_from_str(
1180 isl_ctx *ctx, const char *str);
1182 #include <isl/union_map.h>
1183 __isl_give isl_union_map *isl_union_map_read_from_file(
1184 isl_ctx *ctx, FILE *input);
1185 __isl_give isl_union_map *isl_union_map_read_from_str(
1186 isl_ctx *ctx, const char *str);
1188 The input format is autodetected and may be either the C<PolyLib> format
1189 or the C<isl> format.
1193 Before anything can be printed, an C<isl_printer> needs to
1196 __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx,
1198 __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx);
1199 __isl_null isl_printer *isl_printer_free(
1200 __isl_take isl_printer *printer);
1201 __isl_give char *isl_printer_get_str(
1202 __isl_keep isl_printer *printer);
1204 The printer can be inspected using the following functions.
1206 FILE *isl_printer_get_file(
1207 __isl_keep isl_printer *printer);
1208 int isl_printer_get_output_format(
1209 __isl_keep isl_printer *p);
1211 The behavior of the printer can be modified in various ways
1213 __isl_give isl_printer *isl_printer_set_output_format(
1214 __isl_take isl_printer *p, int output_format);
1215 __isl_give isl_printer *isl_printer_set_indent(
1216 __isl_take isl_printer *p, int indent);
1217 __isl_give isl_printer *isl_printer_set_indent_prefix(
1218 __isl_take isl_printer *p, const char *prefix);
1219 __isl_give isl_printer *isl_printer_indent(
1220 __isl_take isl_printer *p, int indent);
1221 __isl_give isl_printer *isl_printer_set_prefix(
1222 __isl_take isl_printer *p, const char *prefix);
1223 __isl_give isl_printer *isl_printer_set_suffix(
1224 __isl_take isl_printer *p, const char *suffix);
1226 The C<output_format> may be either C<ISL_FORMAT_ISL>, C<ISL_FORMAT_OMEGA>,
1227 C<ISL_FORMAT_POLYLIB>, C<ISL_FORMAT_EXT_POLYLIB> or C<ISL_FORMAT_LATEX>
1228 and defaults to C<ISL_FORMAT_ISL>.
1229 Each line in the output is prefixed by C<indent_prefix>,
1230 indented by C<indent> (set by C<isl_printer_set_indent>) spaces
1231 (default: 0), prefixed by C<prefix> and suffixed by C<suffix>.
1232 In the C<PolyLib> format output,
1233 the coefficients of the existentially quantified variables
1234 appear between those of the set variables and those
1236 The function C<isl_printer_indent> increases the indentation
1237 by the specified amount (which may be negative).
1239 To actually print something, use
1241 #include <isl/printer.h>
1242 __isl_give isl_printer *isl_printer_print_double(
1243 __isl_take isl_printer *p, double d);
1245 #include <isl/set.h>
1246 __isl_give isl_printer *isl_printer_print_basic_set(
1247 __isl_take isl_printer *printer,
1248 __isl_keep isl_basic_set *bset);
1249 __isl_give isl_printer *isl_printer_print_set(
1250 __isl_take isl_printer *printer,
1251 __isl_keep isl_set *set);
1253 #include <isl/map.h>
1254 __isl_give isl_printer *isl_printer_print_basic_map(
1255 __isl_take isl_printer *printer,
1256 __isl_keep isl_basic_map *bmap);
1257 __isl_give isl_printer *isl_printer_print_map(
1258 __isl_take isl_printer *printer,
1259 __isl_keep isl_map *map);
1261 #include <isl/union_set.h>
1262 __isl_give isl_printer *isl_printer_print_union_set(
1263 __isl_take isl_printer *p,
1264 __isl_keep isl_union_set *uset);
1266 #include <isl/union_map.h>
1267 __isl_give isl_printer *isl_printer_print_union_map(
1268 __isl_take isl_printer *p,
1269 __isl_keep isl_union_map *umap);
1271 When called on a file printer, the following function flushes
1272 the file. When called on a string printer, the buffer is cleared.
1274 __isl_give isl_printer *isl_printer_flush(
1275 __isl_take isl_printer *p);
1277 =head2 Creating New Sets and Relations
1279 C<isl> has functions for creating some standard sets and relations.
1283 =item * Empty sets and relations
1285 __isl_give isl_basic_set *isl_basic_set_empty(
1286 __isl_take isl_space *space);
1287 __isl_give isl_basic_map *isl_basic_map_empty(
1288 __isl_take isl_space *space);
1289 __isl_give isl_set *isl_set_empty(
1290 __isl_take isl_space *space);
1291 __isl_give isl_map *isl_map_empty(
1292 __isl_take isl_space *space);
1293 __isl_give isl_union_set *isl_union_set_empty(
1294 __isl_take isl_space *space);
1295 __isl_give isl_union_map *isl_union_map_empty(
1296 __isl_take isl_space *space);
1298 For C<isl_union_set>s and C<isl_union_map>s, the space
1299 is only used to specify the parameters.
1301 =item * Universe sets and relations
1303 __isl_give isl_basic_set *isl_basic_set_universe(
1304 __isl_take isl_space *space);
1305 __isl_give isl_basic_map *isl_basic_map_universe(
1306 __isl_take isl_space *space);
1307 __isl_give isl_set *isl_set_universe(
1308 __isl_take isl_space *space);
1309 __isl_give isl_map *isl_map_universe(
1310 __isl_take isl_space *space);
1311 __isl_give isl_union_set *isl_union_set_universe(
1312 __isl_take isl_union_set *uset);
1313 __isl_give isl_union_map *isl_union_map_universe(
1314 __isl_take isl_union_map *umap);
1316 The sets and relations constructed by the functions above
1317 contain all integer values, while those constructed by the
1318 functions below only contain non-negative values.
1320 __isl_give isl_basic_set *isl_basic_set_nat_universe(
1321 __isl_take isl_space *space);
1322 __isl_give isl_basic_map *isl_basic_map_nat_universe(
1323 __isl_take isl_space *space);
1324 __isl_give isl_set *isl_set_nat_universe(
1325 __isl_take isl_space *space);
1326 __isl_give isl_map *isl_map_nat_universe(
1327 __isl_take isl_space *space);
1329 =item * Identity relations
1331 __isl_give isl_basic_map *isl_basic_map_identity(
1332 __isl_take isl_space *space);
1333 __isl_give isl_map *isl_map_identity(
1334 __isl_take isl_space *space);
1336 The number of input and output dimensions in C<space> needs
1339 =item * Lexicographic order
1341 __isl_give isl_map *isl_map_lex_lt(
1342 __isl_take isl_space *set_space);
1343 __isl_give isl_map *isl_map_lex_le(
1344 __isl_take isl_space *set_space);
1345 __isl_give isl_map *isl_map_lex_gt(
1346 __isl_take isl_space *set_space);
1347 __isl_give isl_map *isl_map_lex_ge(
1348 __isl_take isl_space *set_space);
1349 __isl_give isl_map *isl_map_lex_lt_first(
1350 __isl_take isl_space *space, unsigned n);
1351 __isl_give isl_map *isl_map_lex_le_first(
1352 __isl_take isl_space *space, unsigned n);
1353 __isl_give isl_map *isl_map_lex_gt_first(
1354 __isl_take isl_space *space, unsigned n);
1355 __isl_give isl_map *isl_map_lex_ge_first(
1356 __isl_take isl_space *space, unsigned n);
1358 The first four functions take a space for a B<set>
1359 and return relations that express that the elements in the domain
1360 are lexicographically less
1361 (C<isl_map_lex_lt>), less or equal (C<isl_map_lex_le>),
1362 greater (C<isl_map_lex_gt>) or greater or equal (C<isl_map_lex_ge>)
1363 than the elements in the range.
1364 The last four functions take a space for a map
1365 and return relations that express that the first C<n> dimensions
1366 in the domain are lexicographically less
1367 (C<isl_map_lex_lt_first>), less or equal (C<isl_map_lex_le_first>),
1368 greater (C<isl_map_lex_gt_first>) or greater or equal (C<isl_map_lex_ge_first>)
1369 than the first C<n> dimensions in the range.
1373 A basic set or relation can be converted to a set or relation
1374 using the following functions.
1376 __isl_give isl_set *isl_set_from_basic_set(
1377 __isl_take isl_basic_set *bset);
1378 __isl_give isl_map *isl_map_from_basic_map(
1379 __isl_take isl_basic_map *bmap);
1381 Sets and relations can be converted to union sets and relations
1382 using the following functions.
1384 __isl_give isl_union_set *isl_union_set_from_basic_set(
1385 __isl_take isl_basic_set *bset);
1386 __isl_give isl_union_map *isl_union_map_from_basic_map(
1387 __isl_take isl_basic_map *bmap);
1388 __isl_give isl_union_set *isl_union_set_from_set(
1389 __isl_take isl_set *set);
1390 __isl_give isl_union_map *isl_union_map_from_map(
1391 __isl_take isl_map *map);
1393 The inverse conversions below can only be used if the input
1394 union set or relation is known to contain elements in exactly one
1397 __isl_give isl_set *isl_set_from_union_set(
1398 __isl_take isl_union_set *uset);
1399 __isl_give isl_map *isl_map_from_union_map(
1400 __isl_take isl_union_map *umap);
1402 A zero-dimensional (basic) set can be constructed on a given parameter domain
1403 using the following function.
1405 __isl_give isl_basic_set *isl_basic_set_from_params(
1406 __isl_take isl_basic_set *bset);
1407 __isl_give isl_set *isl_set_from_params(
1408 __isl_take isl_set *set);
1410 Sets and relations can be copied and freed again using the following
1413 __isl_give isl_basic_set *isl_basic_set_copy(
1414 __isl_keep isl_basic_set *bset);
1415 __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set);
1416 __isl_give isl_union_set *isl_union_set_copy(
1417 __isl_keep isl_union_set *uset);
1418 __isl_give isl_basic_map *isl_basic_map_copy(
1419 __isl_keep isl_basic_map *bmap);
1420 __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map);
1421 __isl_give isl_union_map *isl_union_map_copy(
1422 __isl_keep isl_union_map *umap);
1423 __isl_null isl_basic_set *isl_basic_set_free(
1424 __isl_take isl_basic_set *bset);
1425 __isl_null isl_set *isl_set_free(__isl_take isl_set *set);
1426 __isl_null isl_union_set *isl_union_set_free(
1427 __isl_take isl_union_set *uset);
1428 __isl_null isl_basic_map *isl_basic_map_free(
1429 __isl_take isl_basic_map *bmap);
1430 __isl_null isl_map *isl_map_free(__isl_take isl_map *map);
1431 __isl_null isl_union_map *isl_union_map_free(
1432 __isl_take isl_union_map *umap);
1434 Other sets and relations can be constructed by starting
1435 from a universe set or relation, adding equality and/or
1436 inequality constraints and then projecting out the
1437 existentially quantified variables, if any.
1438 Constraints can be constructed, manipulated and
1439 added to (or removed from) (basic) sets and relations
1440 using the following functions.
1442 #include <isl/constraint.h>
1443 __isl_give isl_constraint *isl_equality_alloc(
1444 __isl_take isl_local_space *ls);
1445 __isl_give isl_constraint *isl_inequality_alloc(
1446 __isl_take isl_local_space *ls);
1447 __isl_give isl_constraint *isl_constraint_set_constant_si(
1448 __isl_take isl_constraint *constraint, int v);
1449 __isl_give isl_constraint *isl_constraint_set_constant_val(
1450 __isl_take isl_constraint *constraint,
1451 __isl_take isl_val *v);
1452 __isl_give isl_constraint *isl_constraint_set_coefficient_si(
1453 __isl_take isl_constraint *constraint,
1454 enum isl_dim_type type, int pos, int v);
1455 __isl_give isl_constraint *
1456 isl_constraint_set_coefficient_val(
1457 __isl_take isl_constraint *constraint,
1458 enum isl_dim_type type, int pos,
1459 __isl_take isl_val *v);
1460 __isl_give isl_basic_map *isl_basic_map_add_constraint(
1461 __isl_take isl_basic_map *bmap,
1462 __isl_take isl_constraint *constraint);
1463 __isl_give isl_basic_set *isl_basic_set_add_constraint(
1464 __isl_take isl_basic_set *bset,
1465 __isl_take isl_constraint *constraint);
1466 __isl_give isl_map *isl_map_add_constraint(
1467 __isl_take isl_map *map,
1468 __isl_take isl_constraint *constraint);
1469 __isl_give isl_set *isl_set_add_constraint(
1470 __isl_take isl_set *set,
1471 __isl_take isl_constraint *constraint);
1472 __isl_give isl_basic_set *isl_basic_set_drop_constraint(
1473 __isl_take isl_basic_set *bset,
1474 __isl_take isl_constraint *constraint);
1476 For example, to create a set containing the even integers
1477 between 10 and 42, you would use the following code.
1480 isl_local_space *ls;
1482 isl_basic_set *bset;
1484 space = isl_space_set_alloc(ctx, 0, 2);
1485 bset = isl_basic_set_universe(isl_space_copy(space));
1486 ls = isl_local_space_from_space(space);
1488 c = isl_equality_alloc(isl_local_space_copy(ls));
1489 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1490 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 1, 2);
1491 bset = isl_basic_set_add_constraint(bset, c);
1493 c = isl_inequality_alloc(isl_local_space_copy(ls));
1494 c = isl_constraint_set_constant_si(c, -10);
1495 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, 1);
1496 bset = isl_basic_set_add_constraint(bset, c);
1498 c = isl_inequality_alloc(ls);
1499 c = isl_constraint_set_constant_si(c, 42);
1500 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1);
1501 bset = isl_basic_set_add_constraint(bset, c);
1503 bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 1);
1507 isl_basic_set *bset;
1508 bset = isl_basic_set_read_from_str(ctx,
1509 "{[i] : exists (a : i = 2a and i >= 10 and i <= 42)}");
1511 A basic set or relation can also be constructed from two matrices
1512 describing the equalities and the inequalities.
1514 __isl_give isl_basic_set *isl_basic_set_from_constraint_matrices(
1515 __isl_take isl_space *space,
1516 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1517 enum isl_dim_type c1,
1518 enum isl_dim_type c2, enum isl_dim_type c3,
1519 enum isl_dim_type c4);
1520 __isl_give isl_basic_map *isl_basic_map_from_constraint_matrices(
1521 __isl_take isl_space *space,
1522 __isl_take isl_mat *eq, __isl_take isl_mat *ineq,
1523 enum isl_dim_type c1,
1524 enum isl_dim_type c2, enum isl_dim_type c3,
1525 enum isl_dim_type c4, enum isl_dim_type c5);
1527 The C<isl_dim_type> arguments indicate the order in which
1528 different kinds of variables appear in the input matrices
1529 and should be a permutation of C<isl_dim_cst>, C<isl_dim_param>,
1530 C<isl_dim_set> and C<isl_dim_div> for sets and
1531 of C<isl_dim_cst>, C<isl_dim_param>,
1532 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div> for relations.
1534 A (basic or union) set or relation can also be constructed from a
1535 (union) (piecewise) (multiple) affine expression
1536 or a list of affine expressions
1537 (See L<"Piecewise Quasi Affine Expressions"> and
1538 L<"Piecewise Multiple Quasi Affine Expressions">).
1540 __isl_give isl_basic_map *isl_basic_map_from_aff(
1541 __isl_take isl_aff *aff);
1542 __isl_give isl_map *isl_map_from_aff(
1543 __isl_take isl_aff *aff);
1544 __isl_give isl_set *isl_set_from_pw_aff(
1545 __isl_take isl_pw_aff *pwaff);
1546 __isl_give isl_map *isl_map_from_pw_aff(
1547 __isl_take isl_pw_aff *pwaff);
1548 __isl_give isl_basic_map *isl_basic_map_from_aff_list(
1549 __isl_take isl_space *domain_space,
1550 __isl_take isl_aff_list *list);
1551 __isl_give isl_basic_map *isl_basic_map_from_multi_aff(
1552 __isl_take isl_multi_aff *maff)
1553 __isl_give isl_map *isl_map_from_multi_aff(
1554 __isl_take isl_multi_aff *maff)
1555 __isl_give isl_set *isl_set_from_pw_multi_aff(
1556 __isl_take isl_pw_multi_aff *pma);
1557 __isl_give isl_map *isl_map_from_pw_multi_aff(
1558 __isl_take isl_pw_multi_aff *pma);
1559 __isl_give isl_set *isl_set_from_multi_pw_aff(
1560 __isl_take isl_multi_pw_aff *mpa);
1561 __isl_give isl_map *isl_map_from_multi_pw_aff(
1562 __isl_take isl_multi_pw_aff *mpa);
1563 __isl_give isl_union_map *
1564 isl_union_map_from_union_pw_multi_aff(
1565 __isl_take isl_union_pw_multi_aff *upma);
1567 The C<domain_space> argument describes the domain of the resulting
1568 basic relation. It is required because the C<list> may consist
1569 of zero affine expressions.
1571 =head2 Inspecting Sets and Relations
1573 Usually, the user should not have to care about the actual constraints
1574 of the sets and maps, but should instead apply the abstract operations
1575 explained in the following sections.
1576 Occasionally, however, it may be required to inspect the individual
1577 coefficients of the constraints. This section explains how to do so.
1578 In these cases, it may also be useful to have C<isl> compute
1579 an explicit representation of the existentially quantified variables.
1581 __isl_give isl_set *isl_set_compute_divs(
1582 __isl_take isl_set *set);
1583 __isl_give isl_map *isl_map_compute_divs(
1584 __isl_take isl_map *map);
1585 __isl_give isl_union_set *isl_union_set_compute_divs(
1586 __isl_take isl_union_set *uset);
1587 __isl_give isl_union_map *isl_union_map_compute_divs(
1588 __isl_take isl_union_map *umap);
1590 This explicit representation defines the existentially quantified
1591 variables as integer divisions of the other variables, possibly
1592 including earlier existentially quantified variables.
1593 An explicitly represented existentially quantified variable therefore
1594 has a unique value when the values of the other variables are known.
1595 If, furthermore, the same existentials, i.e., existentials
1596 with the same explicit representations, should appear in the
1597 same order in each of the disjuncts of a set or map, then the user should call
1598 either of the following functions.
1600 __isl_give isl_set *isl_set_align_divs(
1601 __isl_take isl_set *set);
1602 __isl_give isl_map *isl_map_align_divs(
1603 __isl_take isl_map *map);
1605 Alternatively, the existentially quantified variables can be removed
1606 using the following functions, which compute an overapproximation.
1608 __isl_give isl_basic_set *isl_basic_set_remove_divs(
1609 __isl_take isl_basic_set *bset);
1610 __isl_give isl_basic_map *isl_basic_map_remove_divs(
1611 __isl_take isl_basic_map *bmap);
1612 __isl_give isl_set *isl_set_remove_divs(
1613 __isl_take isl_set *set);
1614 __isl_give isl_map *isl_map_remove_divs(
1615 __isl_take isl_map *map);
1617 It is also possible to only remove those divs that are defined
1618 in terms of a given range of dimensions or only those for which
1619 no explicit representation is known.
1621 __isl_give isl_basic_set *
1622 isl_basic_set_remove_divs_involving_dims(
1623 __isl_take isl_basic_set *bset,
1624 enum isl_dim_type type,
1625 unsigned first, unsigned n);
1626 __isl_give isl_basic_map *
1627 isl_basic_map_remove_divs_involving_dims(
1628 __isl_take isl_basic_map *bmap,
1629 enum isl_dim_type type,
1630 unsigned first, unsigned n);
1631 __isl_give isl_set *isl_set_remove_divs_involving_dims(
1632 __isl_take isl_set *set, enum isl_dim_type type,
1633 unsigned first, unsigned n);
1634 __isl_give isl_map *isl_map_remove_divs_involving_dims(
1635 __isl_take isl_map *map, enum isl_dim_type type,
1636 unsigned first, unsigned n);
1638 __isl_give isl_basic_set *
1639 isl_basic_set_remove_unknown_divs(
1640 __isl_take isl_basic_set *bset);
1641 __isl_give isl_set *isl_set_remove_unknown_divs(
1642 __isl_take isl_set *set);
1643 __isl_give isl_map *isl_map_remove_unknown_divs(
1644 __isl_take isl_map *map);
1646 To iterate over all the sets or maps in a union set or map, use
1648 int isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
1649 int (*fn)(__isl_take isl_set *set, void *user),
1651 int isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
1652 int (*fn)(__isl_take isl_map *map, void *user),
1655 The number of sets or maps in a union set or map can be obtained
1658 int isl_union_set_n_set(__isl_keep isl_union_set *uset);
1659 int isl_union_map_n_map(__isl_keep isl_union_map *umap);
1661 To extract the set or map in a given space from a union, use
1663 __isl_give isl_set *isl_union_set_extract_set(
1664 __isl_keep isl_union_set *uset,
1665 __isl_take isl_space *space);
1666 __isl_give isl_map *isl_union_map_extract_map(
1667 __isl_keep isl_union_map *umap,
1668 __isl_take isl_space *space);
1670 To iterate over all the basic sets or maps in a set or map, use
1672 int isl_set_foreach_basic_set(__isl_keep isl_set *set,
1673 int (*fn)(__isl_take isl_basic_set *bset, void *user),
1675 int isl_map_foreach_basic_map(__isl_keep isl_map *map,
1676 int (*fn)(__isl_take isl_basic_map *bmap, void *user),
1679 The callback function C<fn> should return 0 if successful and
1680 -1 if an error occurs. In the latter case, or if any other error
1681 occurs, the above functions will return -1.
1683 It should be noted that C<isl> does not guarantee that
1684 the basic sets or maps passed to C<fn> are disjoint.
1685 If this is required, then the user should call one of
1686 the following functions first.
1688 __isl_give isl_set *isl_set_make_disjoint(
1689 __isl_take isl_set *set);
1690 __isl_give isl_map *isl_map_make_disjoint(
1691 __isl_take isl_map *map);
1693 The number of basic sets in a set can be obtained
1694 or the number of basic maps in a map can be obtained
1697 #include <isl/set.h>
1698 int isl_set_n_basic_set(__isl_keep isl_set *set);
1700 #include <isl/map.h>
1701 int isl_map_n_basic_map(__isl_keep isl_map *map);
1703 To iterate over the constraints of a basic set or map, use
1705 #include <isl/constraint.h>
1707 int isl_basic_set_n_constraint(
1708 __isl_keep isl_basic_set *bset);
1709 int isl_basic_set_foreach_constraint(
1710 __isl_keep isl_basic_set *bset,
1711 int (*fn)(__isl_take isl_constraint *c, void *user),
1713 int isl_basic_map_n_constraint(
1714 __isl_keep isl_basic_map *bmap);
1715 int isl_basic_map_foreach_constraint(
1716 __isl_keep isl_basic_map *bmap,
1717 int (*fn)(__isl_take isl_constraint *c, void *user),
1719 __isl_null isl_constraint *isl_constraint_free(
1720 __isl_take isl_constraint *c);
1722 Again, the callback function C<fn> should return 0 if successful and
1723 -1 if an error occurs. In the latter case, or if any other error
1724 occurs, the above functions will return -1.
1725 The constraint C<c> represents either an equality or an inequality.
1726 Use the following function to find out whether a constraint
1727 represents an equality. If not, it represents an inequality.
1729 int isl_constraint_is_equality(
1730 __isl_keep isl_constraint *constraint);
1732 It is also possible to obtain a list of constraints from a basic
1735 #include <isl/constraint.h>
1736 __isl_give isl_constraint_list *
1737 isl_basic_map_get_constraint_list(
1738 __isl_keep isl_basic_map *bmap);
1739 __isl_give isl_constraint_list *
1740 isl_basic_set_get_constraint_list(
1741 __isl_keep isl_basic_set *bset);
1743 These functions require that all existentially quantified variables
1744 have an explicit representation.
1745 The returned list can be manipulated using the functions in L<"Lists">.
1747 The coefficients of the constraints can be inspected using
1748 the following functions.
1750 int isl_constraint_is_lower_bound(
1751 __isl_keep isl_constraint *constraint,
1752 enum isl_dim_type type, unsigned pos);
1753 int isl_constraint_is_upper_bound(
1754 __isl_keep isl_constraint *constraint,
1755 enum isl_dim_type type, unsigned pos);
1756 __isl_give isl_val *isl_constraint_get_constant_val(
1757 __isl_keep isl_constraint *constraint);
1758 __isl_give isl_val *isl_constraint_get_coefficient_val(
1759 __isl_keep isl_constraint *constraint,
1760 enum isl_dim_type type, int pos);
1761 int isl_constraint_involves_dims(
1762 __isl_keep isl_constraint *constraint,
1763 enum isl_dim_type type, unsigned first, unsigned n);
1765 The explicit representations of the existentially quantified
1766 variables can be inspected using the following function.
1767 Note that the user is only allowed to use this function
1768 if the inspected set or map is the result of a call
1769 to C<isl_set_compute_divs> or C<isl_map_compute_divs>.
1770 The existentially quantified variable is equal to the floor
1771 of the returned affine expression. The affine expression
1772 itself can be inspected using the functions in
1773 L<"Piecewise Quasi Affine Expressions">.
1775 __isl_give isl_aff *isl_constraint_get_div(
1776 __isl_keep isl_constraint *constraint, int pos);
1778 To obtain the constraints of a basic set or map in matrix
1779 form, use the following functions.
1781 __isl_give isl_mat *isl_basic_set_equalities_matrix(
1782 __isl_keep isl_basic_set *bset,
1783 enum isl_dim_type c1, enum isl_dim_type c2,
1784 enum isl_dim_type c3, enum isl_dim_type c4);
1785 __isl_give isl_mat *isl_basic_set_inequalities_matrix(
1786 __isl_keep isl_basic_set *bset,
1787 enum isl_dim_type c1, enum isl_dim_type c2,
1788 enum isl_dim_type c3, enum isl_dim_type c4);
1789 __isl_give isl_mat *isl_basic_map_equalities_matrix(
1790 __isl_keep isl_basic_map *bmap,
1791 enum isl_dim_type c1,
1792 enum isl_dim_type c2, enum isl_dim_type c3,
1793 enum isl_dim_type c4, enum isl_dim_type c5);
1794 __isl_give isl_mat *isl_basic_map_inequalities_matrix(
1795 __isl_keep isl_basic_map *bmap,
1796 enum isl_dim_type c1,
1797 enum isl_dim_type c2, enum isl_dim_type c3,
1798 enum isl_dim_type c4, enum isl_dim_type c5);
1800 The C<isl_dim_type> arguments dictate the order in which
1801 different kinds of variables appear in the resulting matrix.
1802 For set inputs, they should be a permutation of
1803 C<isl_dim_cst>, C<isl_dim_param>, C<isl_dim_set> and C<isl_dim_div>.
1804 For map inputs, they should be a permutation of
1805 C<isl_dim_cst>, C<isl_dim_param>,
1806 C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div>.
1808 The number of parameters, input, output or set dimensions can
1809 be obtained using the following functions.
1811 unsigned isl_basic_set_dim(__isl_keep isl_basic_set *bset,
1812 enum isl_dim_type type);
1813 unsigned isl_basic_map_dim(__isl_keep isl_basic_map *bmap,
1814 enum isl_dim_type type);
1815 unsigned isl_set_dim(__isl_keep isl_set *set,
1816 enum isl_dim_type type);
1817 unsigned isl_map_dim(__isl_keep isl_map *map,
1818 enum isl_dim_type type);
1819 unsigned isl_union_map_dim(__isl_keep isl_union_map *umap,
1820 enum isl_dim_type type);
1822 Note that a C<isl_union_map> only has parameters.
1824 To check whether the description of a set or relation depends
1825 on one or more given dimensions, it is not necessary to iterate over all
1826 constraints. Instead the following functions can be used.
1828 int isl_basic_set_involves_dims(
1829 __isl_keep isl_basic_set *bset,
1830 enum isl_dim_type type, unsigned first, unsigned n);
1831 int isl_set_involves_dims(__isl_keep isl_set *set,
1832 enum isl_dim_type type, unsigned first, unsigned n);
1833 int isl_basic_map_involves_dims(
1834 __isl_keep isl_basic_map *bmap,
1835 enum isl_dim_type type, unsigned first, unsigned n);
1836 int isl_map_involves_dims(__isl_keep isl_map *map,
1837 enum isl_dim_type type, unsigned first, unsigned n);
1839 Similarly, the following functions can be used to check whether
1840 a given dimension is involved in any lower or upper bound.
1842 int isl_set_dim_has_any_lower_bound(__isl_keep isl_set *set,
1843 enum isl_dim_type type, unsigned pos);
1844 int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set,
1845 enum isl_dim_type type, unsigned pos);
1847 Note that these functions return true even if there is a bound on
1848 the dimension on only some of the basic sets of C<set>.
1849 To check if they have a bound for all of the basic sets in C<set>,
1850 use the following functions instead.
1852 int isl_set_dim_has_lower_bound(__isl_keep isl_set *set,
1853 enum isl_dim_type type, unsigned pos);
1854 int isl_set_dim_has_upper_bound(__isl_keep isl_set *set,
1855 enum isl_dim_type type, unsigned pos);
1857 The identifiers or names of the domain and range spaces of a set
1858 or relation can be read off or set using the following functions.
1860 __isl_give isl_basic_set *isl_basic_set_set_tuple_id(
1861 __isl_take isl_basic_set *bset,
1862 __isl_take isl_id *id);
1863 __isl_give isl_set *isl_set_set_tuple_id(
1864 __isl_take isl_set *set, __isl_take isl_id *id);
1865 __isl_give isl_set *isl_set_reset_tuple_id(
1866 __isl_take isl_set *set);
1867 int isl_set_has_tuple_id(__isl_keep isl_set *set);
1868 __isl_give isl_id *isl_set_get_tuple_id(
1869 __isl_keep isl_set *set);
1870 __isl_give isl_basic_map *isl_basic_map_set_tuple_id(
1871 __isl_take isl_basic_map *bmap,
1872 enum isl_dim_type type, __isl_take isl_id *id);
1873 __isl_give isl_map *isl_map_set_tuple_id(
1874 __isl_take isl_map *map, enum isl_dim_type type,
1875 __isl_take isl_id *id);
1876 __isl_give isl_map *isl_map_reset_tuple_id(
1877 __isl_take isl_map *map, enum isl_dim_type type);
1878 int isl_map_has_tuple_id(__isl_keep isl_map *map,
1879 enum isl_dim_type type);
1880 __isl_give isl_id *isl_map_get_tuple_id(
1881 __isl_keep isl_map *map, enum isl_dim_type type);
1883 const char *isl_basic_set_get_tuple_name(
1884 __isl_keep isl_basic_set *bset);
1885 __isl_give isl_basic_set *isl_basic_set_set_tuple_name(
1886 __isl_take isl_basic_set *set, const char *s);
1887 int isl_set_has_tuple_name(__isl_keep isl_set *set);
1888 const char *isl_set_get_tuple_name(
1889 __isl_keep isl_set *set);
1890 __isl_give isl_set *isl_set_set_tuple_name(
1891 __isl_take isl_set *set, const char *s);
1892 const char *isl_basic_map_get_tuple_name(
1893 __isl_keep isl_basic_map *bmap,
1894 enum isl_dim_type type);
1895 __isl_give isl_basic_map *isl_basic_map_set_tuple_name(
1896 __isl_take isl_basic_map *bmap,
1897 enum isl_dim_type type, const char *s);
1898 int isl_map_has_tuple_name(__isl_keep isl_map *map,
1899 enum isl_dim_type type);
1900 const char *isl_map_get_tuple_name(
1901 __isl_keep isl_map *map,
1902 enum isl_dim_type type);
1903 __isl_give isl_map *isl_map_set_tuple_name(
1904 __isl_take isl_map *map,
1905 enum isl_dim_type type, const char *s);
1907 As with C<isl_space_get_tuple_name>, the value returned points to
1908 an internal data structure.
1909 The identifiers, positions or names of individual dimensions can be
1910 read off using the following functions.
1912 __isl_give isl_id *isl_basic_set_get_dim_id(
1913 __isl_keep isl_basic_set *bset,
1914 enum isl_dim_type type, unsigned pos);
1915 __isl_give isl_set *isl_set_set_dim_id(
1916 __isl_take isl_set *set, enum isl_dim_type type,
1917 unsigned pos, __isl_take isl_id *id);
1918 int isl_set_has_dim_id(__isl_keep isl_set *set,
1919 enum isl_dim_type type, unsigned pos);
1920 __isl_give isl_id *isl_set_get_dim_id(
1921 __isl_keep isl_set *set, enum isl_dim_type type,
1923 int isl_basic_map_has_dim_id(
1924 __isl_keep isl_basic_map *bmap,
1925 enum isl_dim_type type, unsigned pos);
1926 __isl_give isl_map *isl_map_set_dim_id(
1927 __isl_take isl_map *map, enum isl_dim_type type,
1928 unsigned pos, __isl_take isl_id *id);
1929 int isl_map_has_dim_id(__isl_keep isl_map *map,
1930 enum isl_dim_type type, unsigned pos);
1931 __isl_give isl_id *isl_map_get_dim_id(
1932 __isl_keep isl_map *map, enum isl_dim_type type,
1934 __isl_give isl_id *isl_union_map_get_dim_id(
1935 __isl_keep isl_union_map *umap,
1936 enum isl_dim_type type, unsigned pos);
1938 int isl_set_find_dim_by_id(__isl_keep isl_set *set,
1939 enum isl_dim_type type, __isl_keep isl_id *id);
1940 int isl_map_find_dim_by_id(__isl_keep isl_map *map,
1941 enum isl_dim_type type, __isl_keep isl_id *id);
1942 int isl_set_find_dim_by_name(__isl_keep isl_set *set,
1943 enum isl_dim_type type, const char *name);
1944 int isl_map_find_dim_by_name(__isl_keep isl_map *map,
1945 enum isl_dim_type type, const char *name);
1947 const char *isl_constraint_get_dim_name(
1948 __isl_keep isl_constraint *constraint,
1949 enum isl_dim_type type, unsigned pos);
1950 const char *isl_basic_set_get_dim_name(
1951 __isl_keep isl_basic_set *bset,
1952 enum isl_dim_type type, unsigned pos);
1953 int isl_set_has_dim_name(__isl_keep isl_set *set,
1954 enum isl_dim_type type, unsigned pos);
1955 const char *isl_set_get_dim_name(
1956 __isl_keep isl_set *set,
1957 enum isl_dim_type type, unsigned pos);
1958 const char *isl_basic_map_get_dim_name(
1959 __isl_keep isl_basic_map *bmap,
1960 enum isl_dim_type type, unsigned pos);
1961 int isl_map_has_dim_name(__isl_keep isl_map *map,
1962 enum isl_dim_type type, unsigned pos);
1963 const char *isl_map_get_dim_name(
1964 __isl_keep isl_map *map,
1965 enum isl_dim_type type, unsigned pos);
1967 These functions are mostly useful to obtain the identifiers, positions
1968 or names of the parameters. Identifiers of individual dimensions are
1969 essentially only useful for printing. They are ignored by all other
1970 operations and may not be preserved across those operations.
1972 The user pointers on all parameters and tuples can be reset
1973 using the following functions.
1975 #include <isl/set.h>
1976 __isl_give isl_set *isl_set_reset_user(
1977 __isl_take isl_set *set);
1978 #include <isl/map.h>
1979 __isl_give isl_map *isl_map_reset_user(
1980 __isl_take isl_map *map);
1981 #include <isl/union_set.h>
1982 __isl_give isl_union_set *isl_union_set_reset_user(
1983 __isl_take isl_union_set *uset);
1984 #include <isl/union_map.h>
1985 __isl_give isl_union_map *isl_union_map_reset_user(
1986 __isl_take isl_union_map *umap);
1990 =head3 Unary Properties
1996 The following functions test whether the given set or relation
1997 contains any integer points. The ``plain'' variants do not perform
1998 any computations, but simply check if the given set or relation
1999 is already known to be empty.
2001 int isl_basic_set_plain_is_empty(__isl_keep isl_basic_set *bset);
2002 int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
2003 int isl_set_plain_is_empty(__isl_keep isl_set *set);
2004 int isl_set_is_empty(__isl_keep isl_set *set);
2005 int isl_union_set_is_empty(__isl_keep isl_union_set *uset);
2006 int isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap);
2007 int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap);
2008 int isl_map_plain_is_empty(__isl_keep isl_map *map);
2009 int isl_map_is_empty(__isl_keep isl_map *map);
2010 int isl_union_map_is_empty(__isl_keep isl_union_map *umap);
2012 =item * Universality
2014 int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset);
2015 int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
2016 int isl_set_plain_is_universe(__isl_keep isl_set *set);
2018 =item * Single-valuedness
2020 #include <isl/set.h>
2021 int isl_set_is_singleton(__isl_keep isl_set *set);
2023 #include <isl/map.h>
2024 int isl_basic_map_is_single_valued(
2025 __isl_keep isl_basic_map *bmap);
2026 int isl_map_plain_is_single_valued(
2027 __isl_keep isl_map *map);
2028 int isl_map_is_single_valued(__isl_keep isl_map *map);
2030 #include <isl/union_map.h>
2031 int isl_union_map_is_single_valued(__isl_keep isl_union_map *umap);
2035 int isl_map_plain_is_injective(__isl_keep isl_map *map);
2036 int isl_map_is_injective(__isl_keep isl_map *map);
2037 int isl_union_map_plain_is_injective(
2038 __isl_keep isl_union_map *umap);
2039 int isl_union_map_is_injective(
2040 __isl_keep isl_union_map *umap);
2044 int isl_map_is_bijective(__isl_keep isl_map *map);
2045 int isl_union_map_is_bijective(__isl_keep isl_union_map *umap);
2049 __isl_give isl_val *
2050 isl_basic_map_plain_get_val_if_fixed(
2051 __isl_keep isl_basic_map *bmap,
2052 enum isl_dim_type type, unsigned pos);
2053 __isl_give isl_val *isl_set_plain_get_val_if_fixed(
2054 __isl_keep isl_set *set,
2055 enum isl_dim_type type, unsigned pos);
2056 __isl_give isl_val *isl_map_plain_get_val_if_fixed(
2057 __isl_keep isl_map *map,
2058 enum isl_dim_type type, unsigned pos);
2060 If the set or relation obviously lies on a hyperplane where the given dimension
2061 has a fixed value, then return that value.
2062 Otherwise return NaN.
2066 int isl_set_dim_residue_class_val(
2067 __isl_keep isl_set *set,
2068 int pos, __isl_give isl_val **modulo,
2069 __isl_give isl_val **residue);
2071 Check if the values of the given set dimension are equal to a fixed
2072 value modulo some integer value. If so, assign the modulo to C<*modulo>
2073 and the fixed value to C<*residue>. If the given dimension attains only
2074 a single value, then assign C<0> to C<*modulo> and the fixed value to
2076 If the dimension does not attain only a single value and if no modulo
2077 can be found then assign C<1> to C<*modulo> and C<1> to C<*residue>.
2081 To check whether a set is a parameter domain, use this function:
2083 int isl_set_is_params(__isl_keep isl_set *set);
2084 int isl_union_set_is_params(
2085 __isl_keep isl_union_set *uset);
2089 The following functions check whether the space of the given
2090 (basic) set or relation range is a wrapped relation.
2092 #include <isl/space.h>
2093 int isl_space_is_wrapping(
2094 __isl_keep isl_space *space);
2095 int isl_space_domain_is_wrapping(
2096 __isl_keep isl_space *space);
2097 int isl_space_range_is_wrapping(
2098 __isl_keep isl_space *space);
2100 #include <isl/set.h>
2101 int isl_basic_set_is_wrapping(
2102 __isl_keep isl_basic_set *bset);
2103 int isl_set_is_wrapping(__isl_keep isl_set *set);
2105 #include <isl/map.h>
2106 int isl_map_domain_is_wrapping(
2107 __isl_keep isl_map *map);
2108 int isl_map_range_is_wrapping(
2109 __isl_keep isl_map *map);
2111 The input to C<isl_space_is_wrapping> should
2112 be the space of a set, while that of
2113 C<isl_space_domain_is_wrapping> and
2114 C<isl_space_range_is_wrapping> should be the space of a relation.
2116 =item * Internal Product
2118 int isl_basic_map_can_zip(
2119 __isl_keep isl_basic_map *bmap);
2120 int isl_map_can_zip(__isl_keep isl_map *map);
2122 Check whether the product of domain and range of the given relation
2124 i.e., whether both domain and range are nested relations.
2128 int isl_basic_map_can_curry(
2129 __isl_keep isl_basic_map *bmap);
2130 int isl_map_can_curry(__isl_keep isl_map *map);
2132 Check whether the domain of the (basic) relation is a wrapped relation.
2134 int isl_basic_map_can_uncurry(
2135 __isl_keep isl_basic_map *bmap);
2136 int isl_map_can_uncurry(__isl_keep isl_map *map);
2138 Check whether the range of the (basic) relation is a wrapped relation.
2142 =head3 Binary Properties
2148 int isl_basic_set_plain_is_equal(
2149 __isl_keep isl_basic_set *bset1,
2150 __isl_keep isl_basic_set *bset2);
2151 int isl_set_plain_is_equal(__isl_keep isl_set *set1,
2152 __isl_keep isl_set *set2);
2153 int isl_set_is_equal(__isl_keep isl_set *set1,
2154 __isl_keep isl_set *set2);
2155 int isl_union_set_is_equal(
2156 __isl_keep isl_union_set *uset1,
2157 __isl_keep isl_union_set *uset2);
2158 int isl_basic_map_is_equal(
2159 __isl_keep isl_basic_map *bmap1,
2160 __isl_keep isl_basic_map *bmap2);
2161 int isl_map_is_equal(__isl_keep isl_map *map1,
2162 __isl_keep isl_map *map2);
2163 int isl_map_plain_is_equal(__isl_keep isl_map *map1,
2164 __isl_keep isl_map *map2);
2165 int isl_union_map_is_equal(
2166 __isl_keep isl_union_map *umap1,
2167 __isl_keep isl_union_map *umap2);
2169 =item * Disjointness
2171 int isl_basic_set_is_disjoint(
2172 __isl_keep isl_basic_set *bset1,
2173 __isl_keep isl_basic_set *bset2);
2174 int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
2175 __isl_keep isl_set *set2);
2176 int isl_set_is_disjoint(__isl_keep isl_set *set1,
2177 __isl_keep isl_set *set2);
2178 int isl_basic_map_is_disjoint(
2179 __isl_keep isl_basic_map *bmap1,
2180 __isl_keep isl_basic_map *bmap2);
2181 int isl_map_is_disjoint(__isl_keep isl_map *map1,
2182 __isl_keep isl_map *map2);
2186 int isl_basic_set_is_subset(
2187 __isl_keep isl_basic_set *bset1,
2188 __isl_keep isl_basic_set *bset2);
2189 int isl_set_is_subset(__isl_keep isl_set *set1,
2190 __isl_keep isl_set *set2);
2191 int isl_set_is_strict_subset(
2192 __isl_keep isl_set *set1,
2193 __isl_keep isl_set *set2);
2194 int isl_union_set_is_subset(
2195 __isl_keep isl_union_set *uset1,
2196 __isl_keep isl_union_set *uset2);
2197 int isl_union_set_is_strict_subset(
2198 __isl_keep isl_union_set *uset1,
2199 __isl_keep isl_union_set *uset2);
2200 int isl_basic_map_is_subset(
2201 __isl_keep isl_basic_map *bmap1,
2202 __isl_keep isl_basic_map *bmap2);
2203 int isl_basic_map_is_strict_subset(
2204 __isl_keep isl_basic_map *bmap1,
2205 __isl_keep isl_basic_map *bmap2);
2206 int isl_map_is_subset(
2207 __isl_keep isl_map *map1,
2208 __isl_keep isl_map *map2);
2209 int isl_map_is_strict_subset(
2210 __isl_keep isl_map *map1,
2211 __isl_keep isl_map *map2);
2212 int isl_union_map_is_subset(
2213 __isl_keep isl_union_map *umap1,
2214 __isl_keep isl_union_map *umap2);
2215 int isl_union_map_is_strict_subset(
2216 __isl_keep isl_union_map *umap1,
2217 __isl_keep isl_union_map *umap2);
2219 Check whether the first argument is a (strict) subset of the
2224 Every comparison function returns a negative value if the first
2225 argument is considered smaller than the second, a positive value
2226 if the first argument is considered greater and zero if the two
2227 constraints are considered the same by the comparison criterion.
2229 #include <isl/constraint.h>
2230 int isl_constraint_plain_cmp(
2231 __isl_keep isl_constraint *c1,
2232 __isl_keep isl_constraint *c2);
2234 This function is useful for sorting C<isl_constraint>s.
2235 The order depends on the internal representation of the inputs.
2236 The order is fixed over different calls to the function (assuming
2237 the internal representation of the inputs has not changed), but may
2238 change over different versions of C<isl>.
2240 #include <isl/constraint.h>
2241 int isl_constraint_cmp_last_non_zero(
2242 __isl_keep isl_constraint *c1,
2243 __isl_keep isl_constraint *c2);
2245 This function can be used to sort constraints that live in the same
2246 local space. Constraints that involve ``earlier'' dimensions or
2247 that have a smaller coefficient for the shared latest dimension
2248 are considered smaller than other constraints.
2249 This function only defines a B<partial> order.
2251 #include <isl/set.h>
2252 int isl_set_plain_cmp(__isl_keep isl_set *set1,
2253 __isl_keep isl_set *set2);
2255 This function is useful for sorting C<isl_set>s.
2256 The order depends on the internal representation of the inputs.
2257 The order is fixed over different calls to the function (assuming
2258 the internal representation of the inputs has not changed), but may
2259 change over different versions of C<isl>.
2263 =head2 Unary Operations
2269 __isl_give isl_set *isl_set_complement(
2270 __isl_take isl_set *set);
2271 __isl_give isl_map *isl_map_complement(
2272 __isl_take isl_map *map);
2276 __isl_give isl_basic_map *isl_basic_map_reverse(
2277 __isl_take isl_basic_map *bmap);
2278 __isl_give isl_map *isl_map_reverse(
2279 __isl_take isl_map *map);
2280 __isl_give isl_union_map *isl_union_map_reverse(
2281 __isl_take isl_union_map *umap);
2285 #include <isl/local_space.h>
2286 __isl_give isl_local_space *isl_local_space_domain(
2287 __isl_take isl_local_space *ls);
2288 __isl_give isl_local_space *isl_local_space_range(
2289 __isl_take isl_local_space *ls);
2291 #include <isl/set.h>
2292 __isl_give isl_basic_set *isl_basic_set_project_out(
2293 __isl_take isl_basic_set *bset,
2294 enum isl_dim_type type, unsigned first, unsigned n);
2295 __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set,
2296 enum isl_dim_type type, unsigned first, unsigned n);
2297 __isl_give isl_basic_set *isl_basic_set_params(
2298 __isl_take isl_basic_set *bset);
2299 __isl_give isl_set *isl_set_params(__isl_take isl_set *set);
2301 #include <isl/map.h>
2302 __isl_give isl_basic_map *isl_basic_map_project_out(
2303 __isl_take isl_basic_map *bmap,
2304 enum isl_dim_type type, unsigned first, unsigned n);
2305 __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map,
2306 enum isl_dim_type type, unsigned first, unsigned n);
2307 __isl_give isl_basic_set *isl_basic_map_domain(
2308 __isl_take isl_basic_map *bmap);
2309 __isl_give isl_basic_set *isl_basic_map_range(
2310 __isl_take isl_basic_map *bmap);
2311 __isl_give isl_set *isl_map_params(__isl_take isl_map *map);
2312 __isl_give isl_set *isl_map_domain(
2313 __isl_take isl_map *bmap);
2314 __isl_give isl_set *isl_map_range(
2315 __isl_take isl_map *map);
2317 #include <isl/union_set.h>
2318 __isl_give isl_set *isl_union_set_params(
2319 __isl_take isl_union_set *uset);
2321 #include <isl/union_map.h>
2322 __isl_give isl_union_map *isl_union_map_project_out(
2323 __isl_take isl_union_map *umap,
2324 enum isl_dim_type type, unsigned first, unsigned n);
2325 __isl_give isl_set *isl_union_map_params(
2326 __isl_take isl_union_map *umap);
2327 __isl_give isl_union_set *isl_union_map_domain(
2328 __isl_take isl_union_map *umap);
2329 __isl_give isl_union_set *isl_union_map_range(
2330 __isl_take isl_union_map *umap);
2332 The function C<isl_union_map_project_out> can only project out
2335 #include <isl/map.h>
2336 __isl_give isl_basic_map *isl_basic_map_domain_map(
2337 __isl_take isl_basic_map *bmap);
2338 __isl_give isl_basic_map *isl_basic_map_range_map(
2339 __isl_take isl_basic_map *bmap);
2340 __isl_give isl_map *isl_map_domain_map(__isl_take isl_map *map);
2341 __isl_give isl_map *isl_map_range_map(__isl_take isl_map *map);
2343 #include <isl/union_map.h>
2344 __isl_give isl_union_map *isl_union_map_domain_map(
2345 __isl_take isl_union_map *umap);
2346 __isl_give isl_union_map *isl_union_map_range_map(
2347 __isl_take isl_union_map *umap);
2349 The functions above construct a (basic, regular or union) relation
2350 that maps (a wrapped version of) the input relation to its domain or range.
2354 __isl_give isl_basic_set *isl_basic_set_eliminate(
2355 __isl_take isl_basic_set *bset,
2356 enum isl_dim_type type,
2357 unsigned first, unsigned n);
2358 __isl_give isl_set *isl_set_eliminate(
2359 __isl_take isl_set *set, enum isl_dim_type type,
2360 unsigned first, unsigned n);
2361 __isl_give isl_basic_map *isl_basic_map_eliminate(
2362 __isl_take isl_basic_map *bmap,
2363 enum isl_dim_type type,
2364 unsigned first, unsigned n);
2365 __isl_give isl_map *isl_map_eliminate(
2366 __isl_take isl_map *map, enum isl_dim_type type,
2367 unsigned first, unsigned n);
2369 Eliminate the coefficients for the given dimensions from the constraints,
2370 without removing the dimensions.
2372 =item * Constructing a relation from a set
2374 #include <isl/local_space.h>
2375 __isl_give isl_local_space *isl_local_space_from_domain(
2376 __isl_take isl_local_space *ls);
2378 #include <isl/map.h>
2379 __isl_give isl_map *isl_map_from_domain(
2380 __isl_take isl_set *set);
2381 __isl_give isl_map *isl_map_from_range(
2382 __isl_take isl_set *set);
2384 Create a relation with the given set as domain or range.
2385 The range or domain of the created relation is a zero-dimensional
2386 flat anonymous space.
2390 __isl_give isl_basic_set *isl_basic_set_fix_si(
2391 __isl_take isl_basic_set *bset,
2392 enum isl_dim_type type, unsigned pos, int value);
2393 __isl_give isl_basic_set *isl_basic_set_fix_val(
2394 __isl_take isl_basic_set *bset,
2395 enum isl_dim_type type, unsigned pos,
2396 __isl_take isl_val *v);
2397 __isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set,
2398 enum isl_dim_type type, unsigned pos, int value);
2399 __isl_give isl_set *isl_set_fix_val(
2400 __isl_take isl_set *set,
2401 enum isl_dim_type type, unsigned pos,
2402 __isl_take isl_val *v);
2403 __isl_give isl_basic_map *isl_basic_map_fix_si(
2404 __isl_take isl_basic_map *bmap,
2405 enum isl_dim_type type, unsigned pos, int value);
2406 __isl_give isl_basic_map *isl_basic_map_fix_val(
2407 __isl_take isl_basic_map *bmap,
2408 enum isl_dim_type type, unsigned pos,
2409 __isl_take isl_val *v);
2410 __isl_give isl_map *isl_map_fix_si(__isl_take isl_map *map,
2411 enum isl_dim_type type, unsigned pos, int value);
2412 __isl_give isl_map *isl_map_fix_val(
2413 __isl_take isl_map *map,
2414 enum isl_dim_type type, unsigned pos,
2415 __isl_take isl_val *v);
2417 Intersect the set or relation with the hyperplane where the given
2418 dimension has the fixed given value.
2420 __isl_give isl_basic_map *isl_basic_map_lower_bound_si(
2421 __isl_take isl_basic_map *bmap,
2422 enum isl_dim_type type, unsigned pos, int value);
2423 __isl_give isl_basic_map *isl_basic_map_upper_bound_si(
2424 __isl_take isl_basic_map *bmap,
2425 enum isl_dim_type type, unsigned pos, int value);
2426 __isl_give isl_set *isl_set_lower_bound_si(
2427 __isl_take isl_set *set,
2428 enum isl_dim_type type, unsigned pos, int value);
2429 __isl_give isl_set *isl_set_lower_bound_val(
2430 __isl_take isl_set *set,
2431 enum isl_dim_type type, unsigned pos,
2432 __isl_take isl_val *value);
2433 __isl_give isl_map *isl_map_lower_bound_si(
2434 __isl_take isl_map *map,
2435 enum isl_dim_type type, unsigned pos, int value);
2436 __isl_give isl_set *isl_set_upper_bound_si(
2437 __isl_take isl_set *set,
2438 enum isl_dim_type type, unsigned pos, int value);
2439 __isl_give isl_set *isl_set_upper_bound_val(
2440 __isl_take isl_set *set,
2441 enum isl_dim_type type, unsigned pos,
2442 __isl_take isl_val *value);
2443 __isl_give isl_map *isl_map_upper_bound_si(
2444 __isl_take isl_map *map,
2445 enum isl_dim_type type, unsigned pos, int value);
2447 Intersect the set or relation with the half-space where the given
2448 dimension has a value bounded by the fixed given integer value.
2450 __isl_give isl_set *isl_set_equate(__isl_take isl_set *set,
2451 enum isl_dim_type type1, int pos1,
2452 enum isl_dim_type type2, int pos2);
2453 __isl_give isl_basic_map *isl_basic_map_equate(
2454 __isl_take isl_basic_map *bmap,
2455 enum isl_dim_type type1, int pos1,
2456 enum isl_dim_type type2, int pos2);
2457 __isl_give isl_map *isl_map_equate(__isl_take isl_map *map,
2458 enum isl_dim_type type1, int pos1,
2459 enum isl_dim_type type2, int pos2);
2461 Intersect the set or relation with the hyperplane where the given
2462 dimensions are equal to each other.
2464 __isl_give isl_map *isl_map_oppose(__isl_take isl_map *map,
2465 enum isl_dim_type type1, int pos1,
2466 enum isl_dim_type type2, int pos2);
2468 Intersect the relation with the hyperplane where the given
2469 dimensions have opposite values.
2471 __isl_give isl_map *isl_map_order_le(
2472 __isl_take isl_map *map,
2473 enum isl_dim_type type1, int pos1,
2474 enum isl_dim_type type2, int pos2);
2475 __isl_give isl_basic_map *isl_basic_map_order_ge(
2476 __isl_take isl_basic_map *bmap,
2477 enum isl_dim_type type1, int pos1,
2478 enum isl_dim_type type2, int pos2);
2479 __isl_give isl_map *isl_map_order_ge(
2480 __isl_take isl_map *map,
2481 enum isl_dim_type type1, int pos1,
2482 enum isl_dim_type type2, int pos2);
2483 __isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map,
2484 enum isl_dim_type type1, int pos1,
2485 enum isl_dim_type type2, int pos2);
2486 __isl_give isl_basic_map *isl_basic_map_order_gt(
2487 __isl_take isl_basic_map *bmap,
2488 enum isl_dim_type type1, int pos1,
2489 enum isl_dim_type type2, int pos2);
2490 __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map,
2491 enum isl_dim_type type1, int pos1,
2492 enum isl_dim_type type2, int pos2);
2494 Intersect the relation with the half-space where the given
2495 dimensions satisfy the given ordering.
2499 __isl_give isl_map *isl_set_identity(
2500 __isl_take isl_set *set);
2501 __isl_give isl_union_map *isl_union_set_identity(
2502 __isl_take isl_union_set *uset);
2504 Construct an identity relation on the given (union) set.
2508 __isl_give isl_basic_set *isl_basic_map_deltas(
2509 __isl_take isl_basic_map *bmap);
2510 __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map);
2511 __isl_give isl_union_set *isl_union_map_deltas(
2512 __isl_take isl_union_map *umap);
2514 These functions return a (basic) set containing the differences
2515 between image elements and corresponding domain elements in the input.
2517 __isl_give isl_basic_map *isl_basic_map_deltas_map(
2518 __isl_take isl_basic_map *bmap);
2519 __isl_give isl_map *isl_map_deltas_map(
2520 __isl_take isl_map *map);
2521 __isl_give isl_union_map *isl_union_map_deltas_map(
2522 __isl_take isl_union_map *umap);
2524 The functions above construct a (basic, regular or union) relation
2525 that maps (a wrapped version of) the input relation to its delta set.
2529 Simplify the representation of a set or relation by trying
2530 to combine pairs of basic sets or relations into a single
2531 basic set or relation.
2533 __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set);
2534 __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map);
2535 __isl_give isl_union_set *isl_union_set_coalesce(
2536 __isl_take isl_union_set *uset);
2537 __isl_give isl_union_map *isl_union_map_coalesce(
2538 __isl_take isl_union_map *umap);
2540 One of the methods for combining pairs of basic sets or relations
2541 can result in coefficients that are much larger than those that appear
2542 in the constraints of the input. By default, the coefficients are
2543 not allowed to grow larger, but this can be changed by unsetting
2544 the following option.
2546 int isl_options_set_coalesce_bounded_wrapping(
2547 isl_ctx *ctx, int val);
2548 int isl_options_get_coalesce_bounded_wrapping(
2551 =item * Detecting equalities
2553 __isl_give isl_basic_set *isl_basic_set_detect_equalities(
2554 __isl_take isl_basic_set *bset);
2555 __isl_give isl_basic_map *isl_basic_map_detect_equalities(
2556 __isl_take isl_basic_map *bmap);
2557 __isl_give isl_set *isl_set_detect_equalities(
2558 __isl_take isl_set *set);
2559 __isl_give isl_map *isl_map_detect_equalities(
2560 __isl_take isl_map *map);
2561 __isl_give isl_union_set *isl_union_set_detect_equalities(
2562 __isl_take isl_union_set *uset);
2563 __isl_give isl_union_map *isl_union_map_detect_equalities(
2564 __isl_take isl_union_map *umap);
2566 Simplify the representation of a set or relation by detecting implicit
2569 =item * Removing redundant constraints
2571 __isl_give isl_basic_set *isl_basic_set_remove_redundancies(
2572 __isl_take isl_basic_set *bset);
2573 __isl_give isl_set *isl_set_remove_redundancies(
2574 __isl_take isl_set *set);
2575 __isl_give isl_basic_map *isl_basic_map_remove_redundancies(
2576 __isl_take isl_basic_map *bmap);
2577 __isl_give isl_map *isl_map_remove_redundancies(
2578 __isl_take isl_map *map);
2582 __isl_give isl_basic_set *isl_set_convex_hull(
2583 __isl_take isl_set *set);
2584 __isl_give isl_basic_map *isl_map_convex_hull(
2585 __isl_take isl_map *map);
2587 If the input set or relation has any existentially quantified
2588 variables, then the result of these operations is currently undefined.
2592 #include <isl/set.h>
2593 __isl_give isl_basic_set *
2594 isl_set_unshifted_simple_hull(
2595 __isl_take isl_set *set);
2596 __isl_give isl_basic_set *isl_set_simple_hull(
2597 __isl_take isl_set *set);
2598 __isl_give isl_basic_set *
2599 isl_set_unshifted_simple_hull_from_set_list(
2600 __isl_take isl_set *set,
2601 __isl_take isl_set_list *list);
2603 #include <isl/map.h>
2604 __isl_give isl_basic_map *
2605 isl_map_unshifted_simple_hull(
2606 __isl_take isl_map *map);
2607 __isl_give isl_basic_map *isl_map_simple_hull(
2608 __isl_take isl_map *map);
2610 #include <isl/union_map.h>
2611 __isl_give isl_union_map *isl_union_map_simple_hull(
2612 __isl_take isl_union_map *umap);
2614 These functions compute a single basic set or relation
2615 that contains the whole input set or relation.
2616 In particular, the output is described by translates
2617 of the constraints describing the basic sets or relations in the input.
2618 In case of C<isl_set_unshifted_simple_hull>, only the original
2619 constraints are used, without any translation.
2620 In case of C<isl_set_unshifted_simple_hull_from_set_list>, the
2621 constraints are taken from the elements of the second argument.
2625 (See \autoref{s:simple hull}.)
2631 __isl_give isl_basic_set *isl_basic_set_affine_hull(
2632 __isl_take isl_basic_set *bset);
2633 __isl_give isl_basic_set *isl_set_affine_hull(
2634 __isl_take isl_set *set);
2635 __isl_give isl_union_set *isl_union_set_affine_hull(
2636 __isl_take isl_union_set *uset);
2637 __isl_give isl_basic_map *isl_basic_map_affine_hull(
2638 __isl_take isl_basic_map *bmap);
2639 __isl_give isl_basic_map *isl_map_affine_hull(
2640 __isl_take isl_map *map);
2641 __isl_give isl_union_map *isl_union_map_affine_hull(
2642 __isl_take isl_union_map *umap);
2644 In case of union sets and relations, the affine hull is computed
2647 =item * Polyhedral hull
2649 __isl_give isl_basic_set *isl_set_polyhedral_hull(
2650 __isl_take isl_set *set);
2651 __isl_give isl_basic_map *isl_map_polyhedral_hull(
2652 __isl_take isl_map *map);
2653 __isl_give isl_union_set *isl_union_set_polyhedral_hull(
2654 __isl_take isl_union_set *uset);
2655 __isl_give isl_union_map *isl_union_map_polyhedral_hull(
2656 __isl_take isl_union_map *umap);
2658 These functions compute a single basic set or relation
2659 not involving any existentially quantified variables
2660 that contains the whole input set or relation.
2661 In case of union sets and relations, the polyhedral hull is computed
2664 =item * Other approximations
2666 __isl_give isl_basic_set *
2667 isl_basic_set_drop_constraints_involving_dims(
2668 __isl_take isl_basic_set *bset,
2669 enum isl_dim_type type,
2670 unsigned first, unsigned n);
2671 __isl_give isl_basic_map *
2672 isl_basic_map_drop_constraints_involving_dims(
2673 __isl_take isl_basic_map *bmap,
2674 enum isl_dim_type type,
2675 unsigned first, unsigned n);
2676 __isl_give isl_basic_set *
2677 isl_basic_set_drop_constraints_not_involving_dims(
2678 __isl_take isl_basic_set *bset,
2679 enum isl_dim_type type,
2680 unsigned first, unsigned n);
2681 __isl_give isl_set *
2682 isl_set_drop_constraints_involving_dims(
2683 __isl_take isl_set *set,
2684 enum isl_dim_type type,
2685 unsigned first, unsigned n);
2686 __isl_give isl_map *
2687 isl_map_drop_constraints_involving_dims(
2688 __isl_take isl_map *map,
2689 enum isl_dim_type type,
2690 unsigned first, unsigned n);
2692 These functions drop any constraints (not) involving the specified dimensions.
2693 Note that the result depends on the representation of the input.
2697 __isl_give isl_basic_set *isl_basic_set_sample(
2698 __isl_take isl_basic_set *bset);
2699 __isl_give isl_basic_set *isl_set_sample(
2700 __isl_take isl_set *set);
2701 __isl_give isl_basic_map *isl_basic_map_sample(
2702 __isl_take isl_basic_map *bmap);
2703 __isl_give isl_basic_map *isl_map_sample(
2704 __isl_take isl_map *map);
2706 If the input (basic) set or relation is non-empty, then return
2707 a singleton subset of the input. Otherwise, return an empty set.
2709 =item * Optimization
2711 #include <isl/ilp.h>
2712 __isl_give isl_val *isl_basic_set_max_val(
2713 __isl_keep isl_basic_set *bset,
2714 __isl_keep isl_aff *obj);
2715 __isl_give isl_val *isl_set_min_val(
2716 __isl_keep isl_set *set,
2717 __isl_keep isl_aff *obj);
2718 __isl_give isl_val *isl_set_max_val(
2719 __isl_keep isl_set *set,
2720 __isl_keep isl_aff *obj);
2722 Compute the minimum or maximum of the integer affine expression C<obj>
2723 over the points in C<set>, returning the result in C<opt>.
2724 The result is C<NULL> in case of an error, the optimal value in case
2725 there is one, negative infinity or infinity if the problem is unbounded and
2726 NaN if the problem is empty.
2728 =item * Parametric optimization
2730 __isl_give isl_pw_aff *isl_set_dim_min(
2731 __isl_take isl_set *set, int pos);
2732 __isl_give isl_pw_aff *isl_set_dim_max(
2733 __isl_take isl_set *set, int pos);
2734 __isl_give isl_pw_aff *isl_map_dim_max(
2735 __isl_take isl_map *map, int pos);
2737 Compute the minimum or maximum of the given set or output dimension
2738 as a function of the parameters (and input dimensions), but independently
2739 of the other set or output dimensions.
2740 For lexicographic optimization, see L<"Lexicographic Optimization">.
2744 The following functions compute either the set of (rational) coefficient
2745 values of valid constraints for the given set or the set of (rational)
2746 values satisfying the constraints with coefficients from the given set.
2747 Internally, these two sets of functions perform essentially the
2748 same operations, except that the set of coefficients is assumed to
2749 be a cone, while the set of values may be any polyhedron.
2750 The current implementation is based on the Farkas lemma and
2751 Fourier-Motzkin elimination, but this may change or be made optional
2752 in future. In particular, future implementations may use different
2753 dualization algorithms or skip the elimination step.
2755 __isl_give isl_basic_set *isl_basic_set_coefficients(
2756 __isl_take isl_basic_set *bset);
2757 __isl_give isl_basic_set *isl_set_coefficients(
2758 __isl_take isl_set *set);
2759 __isl_give isl_union_set *isl_union_set_coefficients(
2760 __isl_take isl_union_set *bset);
2761 __isl_give isl_basic_set *isl_basic_set_solutions(
2762 __isl_take isl_basic_set *bset);
2763 __isl_give isl_basic_set *isl_set_solutions(
2764 __isl_take isl_set *set);
2765 __isl_give isl_union_set *isl_union_set_solutions(
2766 __isl_take isl_union_set *bset);
2770 __isl_give isl_map *isl_map_fixed_power_val(
2771 __isl_take isl_map *map,
2772 __isl_take isl_val *exp);
2773 __isl_give isl_union_map *
2774 isl_union_map_fixed_power_val(
2775 __isl_take isl_union_map *umap,
2776 __isl_take isl_val *exp);
2778 Compute the given power of C<map>, where C<exp> is assumed to be non-zero.
2779 If the exponent C<exp> is negative, then the -C<exp> th power of the inverse
2780 of C<map> is computed.
2782 __isl_give isl_map *isl_map_power(__isl_take isl_map *map,
2784 __isl_give isl_union_map *isl_union_map_power(
2785 __isl_take isl_union_map *umap, int *exact);
2787 Compute a parametric representation for all positive powers I<k> of C<map>.
2788 The result maps I<k> to a nested relation corresponding to the
2789 I<k>th power of C<map>.
2790 The result may be an overapproximation. If the result is known to be exact,
2791 then C<*exact> is set to C<1>.
2793 =item * Transitive closure
2795 __isl_give isl_map *isl_map_transitive_closure(
2796 __isl_take isl_map *map, int *exact);
2797 __isl_give isl_union_map *isl_union_map_transitive_closure(
2798 __isl_take isl_union_map *umap, int *exact);
2800 Compute the transitive closure of C<map>.
2801 The result may be an overapproximation. If the result is known to be exact,
2802 then C<*exact> is set to C<1>.
2804 =item * Reaching path lengths
2806 __isl_give isl_map *isl_map_reaching_path_lengths(
2807 __isl_take isl_map *map, int *exact);
2809 Compute a relation that maps each element in the range of C<map>
2810 to the lengths of all paths composed of edges in C<map> that
2811 end up in the given element.
2812 The result may be an overapproximation. If the result is known to be exact,
2813 then C<*exact> is set to C<1>.
2814 To compute the I<maximal> path length, the resulting relation
2815 should be postprocessed by C<isl_map_lexmax>.
2816 In particular, if the input relation is a dependence relation
2817 (mapping sources to sinks), then the maximal path length corresponds
2818 to the free schedule.
2819 Note, however, that C<isl_map_lexmax> expects the maximum to be
2820 finite, so if the path lengths are unbounded (possibly due to
2821 the overapproximation), then you will get an error message.
2825 #include <isl/space.h>
2826 __isl_give isl_space *isl_space_wrap(
2827 __isl_take isl_space *space);
2828 __isl_give isl_space *isl_space_unwrap(
2829 __isl_take isl_space *space);
2831 #include <isl/set.h>
2832 __isl_give isl_basic_map *isl_basic_set_unwrap(
2833 __isl_take isl_basic_set *bset);
2834 __isl_give isl_map *isl_set_unwrap(
2835 __isl_take isl_set *set);
2837 #include <isl/map.h>
2838 __isl_give isl_basic_set *isl_basic_map_wrap(
2839 __isl_take isl_basic_map *bmap);
2840 __isl_give isl_set *isl_map_wrap(
2841 __isl_take isl_map *map);
2843 #include <isl/union_set.h>
2844 __isl_give isl_union_map *isl_union_set_unwrap(
2845 __isl_take isl_union_set *uset);
2847 #include <isl/union_map.h>
2848 __isl_give isl_union_set *isl_union_map_wrap(
2849 __isl_take isl_union_map *umap);
2851 The input to C<isl_space_unwrap> should
2852 be the space of a set, while that of
2853 C<isl_space_wrap> should be the space of a relation.
2854 Conversely, the output of C<isl_space_unwrap> is the space
2855 of a relation, while that of C<isl_space_wrap> is the space of a set.
2859 Remove any internal structure of domain (and range) of the given
2860 set or relation. If there is any such internal structure in the input,
2861 then the name of the space is also removed.
2863 #include <isl/local_space.h>
2864 __isl_give isl_local_space *
2865 isl_local_space_flatten_domain(
2866 __isl_take isl_local_space *ls);
2867 __isl_give isl_local_space *
2868 isl_local_space_flatten_range(
2869 __isl_take isl_local_space *ls);
2871 #include <isl/set.h>
2872 __isl_give isl_basic_set *isl_basic_set_flatten(
2873 __isl_take isl_basic_set *bset);
2874 __isl_give isl_set *isl_set_flatten(
2875 __isl_take isl_set *set);
2877 #include <isl/map.h>
2878 __isl_give isl_basic_map *isl_basic_map_flatten_domain(
2879 __isl_take isl_basic_map *bmap);
2880 __isl_give isl_basic_map *isl_basic_map_flatten_range(
2881 __isl_take isl_basic_map *bmap);
2882 __isl_give isl_map *isl_map_flatten_range(
2883 __isl_take isl_map *map);
2884 __isl_give isl_map *isl_map_flatten_domain(
2885 __isl_take isl_map *map);
2886 __isl_give isl_basic_map *isl_basic_map_flatten(
2887 __isl_take isl_basic_map *bmap);
2888 __isl_give isl_map *isl_map_flatten(
2889 __isl_take isl_map *map);
2891 #include <isl/map.h>
2892 __isl_give isl_map *isl_set_flatten_map(
2893 __isl_take isl_set *set);
2895 The function above constructs a relation
2896 that maps the input set to a flattened version of the set.
2900 Lift the input set to a space with extra dimensions corresponding
2901 to the existentially quantified variables in the input.
2902 In particular, the result lives in a wrapped map where the domain
2903 is the original space and the range corresponds to the original
2904 existentially quantified variables.
2906 __isl_give isl_basic_set *isl_basic_set_lift(
2907 __isl_take isl_basic_set *bset);
2908 __isl_give isl_set *isl_set_lift(
2909 __isl_take isl_set *set);
2910 __isl_give isl_union_set *isl_union_set_lift(
2911 __isl_take isl_union_set *uset);
2913 Given a local space that contains the existentially quantified
2914 variables of a set, a basic relation that, when applied to
2915 a basic set, has essentially the same effect as C<isl_basic_set_lift>,
2916 can be constructed using the following function.
2918 #include <isl/local_space.h>
2919 __isl_give isl_basic_map *isl_local_space_lifting(
2920 __isl_take isl_local_space *ls);
2922 =item * Internal Product
2924 __isl_give isl_basic_map *isl_basic_map_zip(
2925 __isl_take isl_basic_map *bmap);
2926 __isl_give isl_map *isl_map_zip(
2927 __isl_take isl_map *map);
2928 __isl_give isl_union_map *isl_union_map_zip(
2929 __isl_take isl_union_map *umap);
2931 Given a relation with nested relations for domain and range,
2932 interchange the range of the domain with the domain of the range.
2936 __isl_give isl_basic_map *isl_basic_map_curry(
2937 __isl_take isl_basic_map *bmap);
2938 __isl_give isl_basic_map *isl_basic_map_uncurry(
2939 __isl_take isl_basic_map *bmap);
2940 __isl_give isl_map *isl_map_curry(
2941 __isl_take isl_map *map);
2942 __isl_give isl_map *isl_map_uncurry(
2943 __isl_take isl_map *map);
2944 __isl_give isl_union_map *isl_union_map_curry(
2945 __isl_take isl_union_map *umap);
2946 __isl_give isl_union_map *isl_union_map_uncurry(
2947 __isl_take isl_union_map *umap);
2949 Given a relation with a nested relation for domain,
2950 the C<curry> functions
2951 move the range of the nested relation out of the domain
2952 and use it as the domain of a nested relation in the range,
2953 with the original range as range of this nested relation.
2954 The C<uncurry> functions perform the inverse operation.
2956 =item * Aligning parameters
2958 __isl_give isl_basic_set *isl_basic_set_align_params(
2959 __isl_take isl_basic_set *bset,
2960 __isl_take isl_space *model);
2961 __isl_give isl_set *isl_set_align_params(
2962 __isl_take isl_set *set,
2963 __isl_take isl_space *model);
2964 __isl_give isl_basic_map *isl_basic_map_align_params(
2965 __isl_take isl_basic_map *bmap,
2966 __isl_take isl_space *model);
2967 __isl_give isl_map *isl_map_align_params(
2968 __isl_take isl_map *map,
2969 __isl_take isl_space *model);
2971 Change the order of the parameters of the given set or relation
2972 such that the first parameters match those of C<model>.
2973 This may involve the introduction of extra parameters.
2974 All parameters need to be named.
2976 =item * Dimension manipulation
2978 #include <isl/local_space.h>
2979 __isl_give isl_local_space *isl_local_space_add_dims(
2980 __isl_take isl_local_space *ls,
2981 enum isl_dim_type type, unsigned n);
2982 __isl_give isl_local_space *isl_local_space_insert_dims(
2983 __isl_take isl_local_space *ls,
2984 enum isl_dim_type type, unsigned first, unsigned n);
2985 __isl_give isl_local_space *isl_local_space_drop_dims(
2986 __isl_take isl_local_space *ls,
2987 enum isl_dim_type type, unsigned first, unsigned n);
2989 #include <isl/set.h>
2990 __isl_give isl_basic_set *isl_basic_set_add_dims(
2991 __isl_take isl_basic_set *bset,
2992 enum isl_dim_type type, unsigned n);
2993 __isl_give isl_set *isl_set_add_dims(
2994 __isl_take isl_set *set,
2995 enum isl_dim_type type, unsigned n);
2996 __isl_give isl_basic_set *isl_basic_set_insert_dims(
2997 __isl_take isl_basic_set *bset,
2998 enum isl_dim_type type, unsigned pos,
3000 __isl_give isl_set *isl_set_insert_dims(
3001 __isl_take isl_set *set,
3002 enum isl_dim_type type, unsigned pos, unsigned n);
3003 __isl_give isl_basic_set *isl_basic_set_move_dims(
3004 __isl_take isl_basic_set *bset,
3005 enum isl_dim_type dst_type, unsigned dst_pos,
3006 enum isl_dim_type src_type, unsigned src_pos,
3008 __isl_give isl_set *isl_set_move_dims(
3009 __isl_take isl_set *set,
3010 enum isl_dim_type dst_type, unsigned dst_pos,
3011 enum isl_dim_type src_type, unsigned src_pos,
3014 #include <isl/map.h>
3015 __isl_give isl_map *isl_map_add_dims(
3016 __isl_take isl_map *map,
3017 enum isl_dim_type type, unsigned n);
3018 __isl_give isl_basic_map *isl_basic_map_insert_dims(
3019 __isl_take isl_basic_map *bmap,
3020 enum isl_dim_type type, unsigned pos,
3022 __isl_give isl_map *isl_map_insert_dims(
3023 __isl_take isl_map *map,
3024 enum isl_dim_type type, unsigned pos, unsigned n);
3025 __isl_give isl_basic_map *isl_basic_map_move_dims(
3026 __isl_take isl_basic_map *bmap,
3027 enum isl_dim_type dst_type, unsigned dst_pos,
3028 enum isl_dim_type src_type, unsigned src_pos,
3030 __isl_give isl_map *isl_map_move_dims(
3031 __isl_take isl_map *map,
3032 enum isl_dim_type dst_type, unsigned dst_pos,
3033 enum isl_dim_type src_type, unsigned src_pos,
3036 It is usually not advisable to directly change the (input or output)
3037 space of a set or a relation as this removes the name and the internal
3038 structure of the space. However, the above functions can be useful
3039 to add new parameters, assuming
3040 C<isl_set_align_params> and C<isl_map_align_params>
3045 =head2 Binary Operations
3047 The two arguments of a binary operation not only need to live
3048 in the same C<isl_ctx>, they currently also need to have
3049 the same (number of) parameters.
3051 =head3 Basic Operations
3055 =item * Intersection
3057 #include <isl/local_space.h>
3058 __isl_give isl_local_space *isl_local_space_intersect(
3059 __isl_take isl_local_space *ls1,
3060 __isl_take isl_local_space *ls2);
3062 #include <isl/set.h>
3063 __isl_give isl_basic_set *isl_basic_set_intersect_params(
3064 __isl_take isl_basic_set *bset1,
3065 __isl_take isl_basic_set *bset2);
3066 __isl_give isl_basic_set *isl_basic_set_intersect(
3067 __isl_take isl_basic_set *bset1,
3068 __isl_take isl_basic_set *bset2);
3069 __isl_give isl_basic_set *isl_basic_set_list_intersect(
3070 __isl_take struct isl_basic_set_list *list);
3071 __isl_give isl_set *isl_set_intersect_params(
3072 __isl_take isl_set *set,
3073 __isl_take isl_set *params);
3074 __isl_give isl_set *isl_set_intersect(
3075 __isl_take isl_set *set1,
3076 __isl_take isl_set *set2);
3078 #include <isl/map.h>
3079 __isl_give isl_basic_map *isl_basic_map_intersect_domain(
3080 __isl_take isl_basic_map *bmap,
3081 __isl_take isl_basic_set *bset);
3082 __isl_give isl_basic_map *isl_basic_map_intersect_range(
3083 __isl_take isl_basic_map *bmap,
3084 __isl_take isl_basic_set *bset);
3085 __isl_give isl_basic_map *isl_basic_map_intersect(
3086 __isl_take isl_basic_map *bmap1,
3087 __isl_take isl_basic_map *bmap2);
3088 __isl_give isl_map *isl_map_intersect_params(
3089 __isl_take isl_map *map,
3090 __isl_take isl_set *params);
3091 __isl_give isl_map *isl_map_intersect_domain(
3092 __isl_take isl_map *map,
3093 __isl_take isl_set *set);
3094 __isl_give isl_map *isl_map_intersect_range(
3095 __isl_take isl_map *map,
3096 __isl_take isl_set *set);
3097 __isl_give isl_map *isl_map_intersect(
3098 __isl_take isl_map *map1,
3099 __isl_take isl_map *map2);
3101 #include <isl/union_set.h>
3102 __isl_give isl_union_set *isl_union_set_intersect_params(
3103 __isl_take isl_union_set *uset,
3104 __isl_take isl_set *set);
3105 __isl_give isl_union_set *isl_union_set_intersect(
3106 __isl_take isl_union_set *uset1,
3107 __isl_take isl_union_set *uset2);
3109 #include <isl/union_map.h>
3110 __isl_give isl_union_map *isl_union_map_intersect_params(
3111 __isl_take isl_union_map *umap,
3112 __isl_take isl_set *set);
3113 __isl_give isl_union_map *isl_union_map_intersect_domain(
3114 __isl_take isl_union_map *umap,
3115 __isl_take isl_union_set *uset);
3116 __isl_give isl_union_map *isl_union_map_intersect_range(
3117 __isl_take isl_union_map *umap,
3118 __isl_take isl_union_set *uset);
3119 __isl_give isl_union_map *isl_union_map_intersect(
3120 __isl_take isl_union_map *umap1,
3121 __isl_take isl_union_map *umap2);
3123 The second argument to the C<_params> functions needs to be
3124 a parametric (basic) set. For the other functions, a parametric set
3125 for either argument is only allowed if the other argument is
3126 a parametric set as well.
3127 The list passed to C<isl_basic_set_list_intersect> needs to have
3128 at least one element and all elements need to live in the same space.
3132 __isl_give isl_set *isl_basic_set_union(
3133 __isl_take isl_basic_set *bset1,
3134 __isl_take isl_basic_set *bset2);
3135 __isl_give isl_map *isl_basic_map_union(
3136 __isl_take isl_basic_map *bmap1,
3137 __isl_take isl_basic_map *bmap2);
3138 __isl_give isl_set *isl_set_union(
3139 __isl_take isl_set *set1,
3140 __isl_take isl_set *set2);
3141 __isl_give isl_map *isl_map_union(
3142 __isl_take isl_map *map1,
3143 __isl_take isl_map *map2);
3144 __isl_give isl_union_set *isl_union_set_union(
3145 __isl_take isl_union_set *uset1,
3146 __isl_take isl_union_set *uset2);
3147 __isl_give isl_union_map *isl_union_map_union(
3148 __isl_take isl_union_map *umap1,
3149 __isl_take isl_union_map *umap2);
3151 =item * Set difference
3153 __isl_give isl_set *isl_set_subtract(
3154 __isl_take isl_set *set1,
3155 __isl_take isl_set *set2);
3156 __isl_give isl_map *isl_map_subtract(
3157 __isl_take isl_map *map1,
3158 __isl_take isl_map *map2);
3159 __isl_give isl_map *isl_map_subtract_domain(
3160 __isl_take isl_map *map,
3161 __isl_take isl_set *dom);
3162 __isl_give isl_map *isl_map_subtract_range(
3163 __isl_take isl_map *map,
3164 __isl_take isl_set *dom);
3165 __isl_give isl_union_set *isl_union_set_subtract(
3166 __isl_take isl_union_set *uset1,
3167 __isl_take isl_union_set *uset2);
3168 __isl_give isl_union_map *isl_union_map_subtract(
3169 __isl_take isl_union_map *umap1,
3170 __isl_take isl_union_map *umap2);
3171 __isl_give isl_union_map *isl_union_map_subtract_domain(
3172 __isl_take isl_union_map *umap,
3173 __isl_take isl_union_set *dom);
3174 __isl_give isl_union_map *isl_union_map_subtract_range(
3175 __isl_take isl_union_map *umap,
3176 __isl_take isl_union_set *dom);
3180 __isl_give isl_basic_set *isl_basic_set_apply(
3181 __isl_take isl_basic_set *bset,
3182 __isl_take isl_basic_map *bmap);
3183 __isl_give isl_set *isl_set_apply(
3184 __isl_take isl_set *set,
3185 __isl_take isl_map *map);
3186 __isl_give isl_union_set *isl_union_set_apply(
3187 __isl_take isl_union_set *uset,
3188 __isl_take isl_union_map *umap);
3189 __isl_give isl_basic_map *isl_basic_map_apply_domain(
3190 __isl_take isl_basic_map *bmap1,
3191 __isl_take isl_basic_map *bmap2);
3192 __isl_give isl_basic_map *isl_basic_map_apply_range(
3193 __isl_take isl_basic_map *bmap1,
3194 __isl_take isl_basic_map *bmap2);
3195 __isl_give isl_map *isl_map_apply_domain(
3196 __isl_take isl_map *map1,
3197 __isl_take isl_map *map2);
3198 __isl_give isl_union_map *isl_union_map_apply_domain(
3199 __isl_take isl_union_map *umap1,
3200 __isl_take isl_union_map *umap2);
3201 __isl_give isl_map *isl_map_apply_range(
3202 __isl_take isl_map *map1,
3203 __isl_take isl_map *map2);
3204 __isl_give isl_union_map *isl_union_map_apply_range(
3205 __isl_take isl_union_map *umap1,
3206 __isl_take isl_union_map *umap2);
3210 #include <isl/set.h>
3211 __isl_give isl_basic_set *
3212 isl_basic_set_preimage_multi_aff(
3213 __isl_take isl_basic_set *bset,
3214 __isl_take isl_multi_aff *ma);
3215 __isl_give isl_set *isl_set_preimage_multi_aff(
3216 __isl_take isl_set *set,
3217 __isl_take isl_multi_aff *ma);
3218 __isl_give isl_set *isl_set_preimage_pw_multi_aff(
3219 __isl_take isl_set *set,
3220 __isl_take isl_pw_multi_aff *pma);
3221 __isl_give isl_set *isl_set_preimage_multi_pw_aff(
3222 __isl_take isl_set *set,
3223 __isl_take isl_multi_pw_aff *mpa);
3225 #include <isl/union_set.h>
3226 __isl_give isl_union_set *
3227 isl_union_set_preimage_multi_aff(
3228 __isl_take isl_union_set *uset,
3229 __isl_take isl_multi_aff *ma);
3230 __isl_give isl_union_set *
3231 isl_union_set_preimage_pw_multi_aff(
3232 __isl_take isl_union_set *uset,
3233 __isl_take isl_pw_multi_aff *pma);
3234 __isl_give isl_union_set *
3235 isl_union_set_preimage_union_pw_multi_aff(
3236 __isl_take isl_union_set *uset,
3237 __isl_take isl_union_pw_multi_aff *upma);
3239 #include <isl/map.h>
3240 __isl_give isl_basic_map *
3241 isl_basic_map_preimage_domain_multi_aff(
3242 __isl_take isl_basic_map *bmap,
3243 __isl_take isl_multi_aff *ma);
3244 __isl_give isl_map *isl_map_preimage_domain_multi_aff(
3245 __isl_take isl_map *map,
3246 __isl_take isl_multi_aff *ma);
3247 __isl_give isl_map *isl_map_preimage_range_multi_aff(
3248 __isl_take isl_map *map,
3249 __isl_take isl_multi_aff *ma);
3250 __isl_give isl_map *
3251 isl_map_preimage_domain_pw_multi_aff(
3252 __isl_take isl_map *map,
3253 __isl_take isl_pw_multi_aff *pma);
3254 __isl_give isl_map *
3255 isl_map_preimage_range_pw_multi_aff(
3256 __isl_take isl_map *map,
3257 __isl_take isl_pw_multi_aff *pma);
3258 __isl_give isl_map *
3259 isl_map_preimage_domain_multi_pw_aff(
3260 __isl_take isl_map *map,
3261 __isl_take isl_multi_pw_aff *mpa);
3262 __isl_give isl_basic_map *
3263 isl_basic_map_preimage_range_multi_aff(
3264 __isl_take isl_basic_map *bmap,
3265 __isl_take isl_multi_aff *ma);
3267 #include <isl/union_map.h>
3268 __isl_give isl_union_map *
3269 isl_union_map_preimage_domain_multi_aff(
3270 __isl_take isl_union_map *umap,
3271 __isl_take isl_multi_aff *ma);
3272 __isl_give isl_union_map *
3273 isl_union_map_preimage_range_multi_aff(
3274 __isl_take isl_union_map *umap,
3275 __isl_take isl_multi_aff *ma);
3276 __isl_give isl_union_map *
3277 isl_union_map_preimage_domain_pw_multi_aff(
3278 __isl_take isl_union_map *umap,
3279 __isl_take isl_pw_multi_aff *pma);
3280 __isl_give isl_union_map *
3281 isl_union_map_preimage_range_pw_multi_aff(
3282 __isl_take isl_union_map *umap,
3283 __isl_take isl_pw_multi_aff *pma);
3284 __isl_give isl_union_map *
3285 isl_union_map_preimage_domain_union_pw_multi_aff(
3286 __isl_take isl_union_map *umap,
3287 __isl_take isl_union_pw_multi_aff *upma);
3288 __isl_give isl_union_map *
3289 isl_union_map_preimage_range_union_pw_multi_aff(
3290 __isl_take isl_union_map *umap,
3291 __isl_take isl_union_pw_multi_aff *upma);
3293 These functions compute the preimage of the given set or map domain/range under
3294 the given function. In other words, the expression is plugged
3295 into the set description or into the domain/range of the map.
3296 Objects of types C<isl_multi_aff> and C<isl_pw_multi_aff> are described in
3297 L</"Piecewise Multiple Quasi Affine Expressions">.
3299 =item * Cartesian Product
3301 #include <isl/space.h>
3302 __isl_give isl_space *isl_space_product(
3303 __isl_take isl_space *space1,
3304 __isl_take isl_space *space2);
3305 __isl_give isl_space *isl_space_domain_product(
3306 __isl_take isl_space *space1,
3307 __isl_take isl_space *space2);
3308 __isl_give isl_space *isl_space_range_product(
3309 __isl_take isl_space *space1,
3310 __isl_take isl_space *space2);
3313 C<isl_space_product>, C<isl_space_domain_product>
3314 and C<isl_space_range_product> take pairs or relation spaces and
3315 produce a single relations space, where either the domain, the range
3316 or both domain and range are wrapped spaces of relations between
3317 the domains and/or ranges of the input spaces.
3318 If the product is only constructed over the domain or the range
3319 then the ranges or the domains of the inputs should be the same.
3320 The function C<isl_space_product> also accepts a pair of set spaces,
3321 in which case it returns a wrapped space of a relation between the
3324 #include <isl/set.h>
3325 __isl_give isl_set *isl_set_product(
3326 __isl_take isl_set *set1,
3327 __isl_take isl_set *set2);
3329 #include <isl/map.h>
3330 __isl_give isl_basic_map *isl_basic_map_domain_product(
3331 __isl_take isl_basic_map *bmap1,
3332 __isl_take isl_basic_map *bmap2);
3333 __isl_give isl_basic_map *isl_basic_map_range_product(
3334 __isl_take isl_basic_map *bmap1,
3335 __isl_take isl_basic_map *bmap2);
3336 __isl_give isl_basic_map *isl_basic_map_product(
3337 __isl_take isl_basic_map *bmap1,
3338 __isl_take isl_basic_map *bmap2);
3339 __isl_give isl_map *isl_map_domain_product(
3340 __isl_take isl_map *map1,
3341 __isl_take isl_map *map2);
3342 __isl_give isl_map *isl_map_range_product(
3343 __isl_take isl_map *map1,
3344 __isl_take isl_map *map2);
3345 __isl_give isl_map *isl_map_product(
3346 __isl_take isl_map *map1,
3347 __isl_take isl_map *map2);
3349 #include <isl/union_set.h>
3350 __isl_give isl_union_set *isl_union_set_product(
3351 __isl_take isl_union_set *uset1,
3352 __isl_take isl_union_set *uset2);
3354 #include <isl/union_map.h>
3355 __isl_give isl_union_map *isl_union_map_domain_product(
3356 __isl_take isl_union_map *umap1,
3357 __isl_take isl_union_map *umap2);
3358 __isl_give isl_union_map *isl_union_map_range_product(
3359 __isl_take isl_union_map *umap1,
3360 __isl_take isl_union_map *umap2);
3361 __isl_give isl_union_map *isl_union_map_product(
3362 __isl_take isl_union_map *umap1,
3363 __isl_take isl_union_map *umap2);
3365 The above functions compute the cross product of the given
3366 sets or relations. The domains and ranges of the results
3367 are wrapped maps between domains and ranges of the inputs.
3368 To obtain a ``flat'' product, use the following functions
3371 __isl_give isl_basic_set *isl_basic_set_flat_product(
3372 __isl_take isl_basic_set *bset1,
3373 __isl_take isl_basic_set *bset2);
3374 __isl_give isl_set *isl_set_flat_product(
3375 __isl_take isl_set *set1,
3376 __isl_take isl_set *set2);
3377 __isl_give isl_basic_map *isl_basic_map_flat_range_product(
3378 __isl_take isl_basic_map *bmap1,
3379 __isl_take isl_basic_map *bmap2);
3380 __isl_give isl_map *isl_map_flat_domain_product(
3381 __isl_take isl_map *map1,
3382 __isl_take isl_map *map2);
3383 __isl_give isl_map *isl_map_flat_range_product(
3384 __isl_take isl_map *map1,
3385 __isl_take isl_map *map2);
3386 __isl_give isl_union_map *isl_union_map_flat_range_product(
3387 __isl_take isl_union_map *umap1,
3388 __isl_take isl_union_map *umap2);
3389 __isl_give isl_basic_map *isl_basic_map_flat_product(
3390 __isl_take isl_basic_map *bmap1,
3391 __isl_take isl_basic_map *bmap2);
3392 __isl_give isl_map *isl_map_flat_product(
3393 __isl_take isl_map *map1,
3394 __isl_take isl_map *map2);
3396 #include <isl/space.h>
3397 __isl_give isl_space *isl_space_domain_factor_domain(
3398 __isl_take isl_space *space);
3399 __isl_give isl_space *isl_space_range_factor_domain(
3400 __isl_take isl_space *space);
3401 __isl_give isl_space *isl_space_range_factor_range(
3402 __isl_take isl_space *space);
3404 The functions C<isl_space_range_factor_domain> and
3405 C<isl_space_range_factor_range> extract the two arguments from
3406 the result of a call to C<isl_space_range_product>.
3408 The arguments of a call to C<isl_map_range_product> can be extracted
3409 from the result using the following two functions.
3411 #include <isl/map.h>
3412 __isl_give isl_map *isl_map_range_factor_domain(
3413 __isl_take isl_map *map);
3414 __isl_give isl_map *isl_map_range_factor_range(
3415 __isl_take isl_map *map);
3417 =item * Simplification
3419 __isl_give isl_basic_set *isl_basic_set_gist(
3420 __isl_take isl_basic_set *bset,
3421 __isl_take isl_basic_set *context);
3422 __isl_give isl_set *isl_set_gist(__isl_take isl_set *set,
3423 __isl_take isl_set *context);
3424 __isl_give isl_set *isl_set_gist_params(
3425 __isl_take isl_set *set,
3426 __isl_take isl_set *context);
3427 __isl_give isl_union_set *isl_union_set_gist(
3428 __isl_take isl_union_set *uset,
3429 __isl_take isl_union_set *context);
3430 __isl_give isl_union_set *isl_union_set_gist_params(
3431 __isl_take isl_union_set *uset,
3432 __isl_take isl_set *set);
3433 __isl_give isl_basic_map *isl_basic_map_gist(
3434 __isl_take isl_basic_map *bmap,
3435 __isl_take isl_basic_map *context);
3436 __isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
3437 __isl_take isl_map *context);
3438 __isl_give isl_map *isl_map_gist_params(
3439 __isl_take isl_map *map,
3440 __isl_take isl_set *context);
3441 __isl_give isl_map *isl_map_gist_domain(
3442 __isl_take isl_map *map,
3443 __isl_take isl_set *context);
3444 __isl_give isl_map *isl_map_gist_range(
3445 __isl_take isl_map *map,
3446 __isl_take isl_set *context);
3447 __isl_give isl_union_map *isl_union_map_gist(
3448 __isl_take isl_union_map *umap,
3449 __isl_take isl_union_map *context);
3450 __isl_give isl_union_map *isl_union_map_gist_params(
3451 __isl_take isl_union_map *umap,
3452 __isl_take isl_set *set);
3453 __isl_give isl_union_map *isl_union_map_gist_domain(
3454 __isl_take isl_union_map *umap,
3455 __isl_take isl_union_set *uset);
3456 __isl_give isl_union_map *isl_union_map_gist_range(
3457 __isl_take isl_union_map *umap,
3458 __isl_take isl_union_set *uset);
3460 The gist operation returns a set or relation that has the
3461 same intersection with the context as the input set or relation.
3462 Any implicit equality in the intersection is made explicit in the result,
3463 while all inequalities that are redundant with respect to the intersection
3465 In case of union sets and relations, the gist operation is performed
3470 =head3 Lexicographic Optimization
3472 Given a (basic) set C<set> (or C<bset>) and a zero-dimensional domain C<dom>,
3473 the following functions
3474 compute a set that contains the lexicographic minimum or maximum
3475 of the elements in C<set> (or C<bset>) for those values of the parameters
3476 that satisfy C<dom>.
3477 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
3478 that contains the parameter values in C<dom> for which C<set> (or C<bset>)
3480 In other words, the union of the parameter values
3481 for which the result is non-empty and of C<*empty>
3484 __isl_give isl_set *isl_basic_set_partial_lexmin(
3485 __isl_take isl_basic_set *bset,
3486 __isl_take isl_basic_set *dom,
3487 __isl_give isl_set **empty);
3488 __isl_give isl_set *isl_basic_set_partial_lexmax(
3489 __isl_take isl_basic_set *bset,
3490 __isl_take isl_basic_set *dom,
3491 __isl_give isl_set **empty);
3492 __isl_give isl_set *isl_set_partial_lexmin(
3493 __isl_take isl_set *set, __isl_take isl_set *dom,
3494 __isl_give isl_set **empty);
3495 __isl_give isl_set *isl_set_partial_lexmax(
3496 __isl_take isl_set *set, __isl_take isl_set *dom,
3497 __isl_give isl_set **empty);
3499 Given a (basic) set C<set> (or C<bset>), the following functions simply
3500 return a set containing the lexicographic minimum or maximum
3501 of the elements in C<set> (or C<bset>).
3502 In case of union sets, the optimum is computed per space.
3504 __isl_give isl_set *isl_basic_set_lexmin(
3505 __isl_take isl_basic_set *bset);
3506 __isl_give isl_set *isl_basic_set_lexmax(
3507 __isl_take isl_basic_set *bset);
3508 __isl_give isl_set *isl_set_lexmin(
3509 __isl_take isl_set *set);
3510 __isl_give isl_set *isl_set_lexmax(
3511 __isl_take isl_set *set);
3512 __isl_give isl_union_set *isl_union_set_lexmin(
3513 __isl_take isl_union_set *uset);
3514 __isl_give isl_union_set *isl_union_set_lexmax(
3515 __isl_take isl_union_set *uset);
3517 Given a (basic) relation C<map> (or C<bmap>) and a domain C<dom>,
3518 the following functions
3519 compute a relation that maps each element of C<dom>
3520 to the single lexicographic minimum or maximum
3521 of the elements that are associated to that same
3522 element in C<map> (or C<bmap>).
3523 If C<empty> is not C<NULL>, then C<*empty> is assigned a set
3524 that contains the elements in C<dom> that do not map
3525 to any elements in C<map> (or C<bmap>).
3526 In other words, the union of the domain of the result and of C<*empty>
3529 __isl_give isl_map *isl_basic_map_partial_lexmax(
3530 __isl_take isl_basic_map *bmap,
3531 __isl_take isl_basic_set *dom,
3532 __isl_give isl_set **empty);
3533 __isl_give isl_map *isl_basic_map_partial_lexmin(
3534 __isl_take isl_basic_map *bmap,
3535 __isl_take isl_basic_set *dom,
3536 __isl_give isl_set **empty);
3537 __isl_give isl_map *isl_map_partial_lexmax(
3538 __isl_take isl_map *map, __isl_take isl_set *dom,
3539 __isl_give isl_set **empty);
3540 __isl_give isl_map *isl_map_partial_lexmin(
3541 __isl_take isl_map *map, __isl_take isl_set *dom,
3542 __isl_give isl_set **empty);
3544 Given a (basic) map C<map> (or C<bmap>), the following functions simply
3545 return a map mapping each element in the domain of
3546 C<map> (or C<bmap>) to the lexicographic minimum or maximum
3547 of all elements associated to that element.
3548 In case of union relations, the optimum is computed per space.
3550 __isl_give isl_map *isl_basic_map_lexmin(
3551 __isl_take isl_basic_map *bmap);
3552 __isl_give isl_map *isl_basic_map_lexmax(
3553 __isl_take isl_basic_map *bmap);
3554 __isl_give isl_map *isl_map_lexmin(
3555 __isl_take isl_map *map);
3556 __isl_give isl_map *isl_map_lexmax(
3557 __isl_take isl_map *map);
3558 __isl_give isl_union_map *isl_union_map_lexmin(
3559 __isl_take isl_union_map *umap);
3560 __isl_give isl_union_map *isl_union_map_lexmax(
3561 __isl_take isl_union_map *umap);
3563 The following functions return their result in the form of
3564 a piecewise multi-affine expression
3565 (See L<"Piecewise Multiple Quasi Affine Expressions">),
3566 but are otherwise equivalent to the corresponding functions
3567 returning a basic set or relation.
3569 __isl_give isl_pw_multi_aff *
3570 isl_basic_map_lexmin_pw_multi_aff(
3571 __isl_take isl_basic_map *bmap);
3572 __isl_give isl_pw_multi_aff *
3573 isl_basic_set_partial_lexmin_pw_multi_aff(
3574 __isl_take isl_basic_set *bset,
3575 __isl_take isl_basic_set *dom,
3576 __isl_give isl_set **empty);
3577 __isl_give isl_pw_multi_aff *
3578 isl_basic_set_partial_lexmax_pw_multi_aff(
3579 __isl_take isl_basic_set *bset,
3580 __isl_take isl_basic_set *dom,
3581 __isl_give isl_set **empty);
3582 __isl_give isl_pw_multi_aff *
3583 isl_basic_map_partial_lexmin_pw_multi_aff(
3584 __isl_take isl_basic_map *bmap,
3585 __isl_take isl_basic_set *dom,
3586 __isl_give isl_set **empty);
3587 __isl_give isl_pw_multi_aff *
3588 isl_basic_map_partial_lexmax_pw_multi_aff(
3589 __isl_take isl_basic_map *bmap,
3590 __isl_take isl_basic_set *dom,
3591 __isl_give isl_set **empty);
3592 __isl_give isl_pw_multi_aff *isl_set_lexmin_pw_multi_aff(
3593 __isl_take isl_set *set);
3594 __isl_give isl_pw_multi_aff *isl_set_lexmax_pw_multi_aff(
3595 __isl_take isl_set *set);
3596 __isl_give isl_pw_multi_aff *isl_map_lexmin_pw_multi_aff(
3597 __isl_take isl_map *map);
3598 __isl_give isl_pw_multi_aff *isl_map_lexmax_pw_multi_aff(
3599 __isl_take isl_map *map);
3603 Lists are defined over several element types, including
3604 C<isl_val>, C<isl_id>, C<isl_aff>, C<isl_pw_aff>, C<isl_constraint>,
3605 C<isl_basic_set>, C<isl_set>, C<isl_ast_expr> and C<isl_ast_node>.
3606 Here we take lists of C<isl_set>s as an example.
3607 Lists can be created, copied, modified and freed using the following functions.
3609 #include <isl/set.h>
3610 __isl_give isl_set_list *isl_set_list_from_set(
3611 __isl_take isl_set *el);
3612 __isl_give isl_set_list *isl_set_list_alloc(
3613 isl_ctx *ctx, int n);
3614 __isl_give isl_set_list *isl_set_list_copy(
3615 __isl_keep isl_set_list *list);
3616 __isl_give isl_set_list *isl_set_list_insert(
3617 __isl_take isl_set_list *list, unsigned pos,
3618 __isl_take isl_set *el);
3619 __isl_give isl_set_list *isl_set_list_add(
3620 __isl_take isl_set_list *list,
3621 __isl_take isl_set *el);
3622 __isl_give isl_set_list *isl_set_list_drop(
3623 __isl_take isl_set_list *list,
3624 unsigned first, unsigned n);
3625 __isl_give isl_set_list *isl_set_list_set_set(
3626 __isl_take isl_set_list *list, int index,
3627 __isl_take isl_set *set);
3628 __isl_give isl_set_list *isl_set_list_concat(
3629 __isl_take isl_set_list *list1,
3630 __isl_take isl_set_list *list2);
3631 __isl_give isl_set_list *isl_set_list_sort(
3632 __isl_take isl_set_list *list,
3633 int (*cmp)(__isl_keep isl_set *a,
3634 __isl_keep isl_set *b, void *user),
3636 __isl_null isl_set_list *isl_set_list_free(
3637 __isl_take isl_set_list *list);
3639 C<isl_set_list_alloc> creates an empty list with a capacity for
3640 C<n> elements. C<isl_set_list_from_set> creates a list with a single
3643 Lists can be inspected using the following functions.
3645 #include <isl/set.h>
3646 isl_ctx *isl_set_list_get_ctx(__isl_keep isl_set_list *list);
3647 int isl_set_list_n_set(__isl_keep isl_set_list *list);
3648 __isl_give isl_set *isl_set_list_get_set(
3649 __isl_keep isl_set_list *list, int index);
3650 int isl_set_list_foreach(__isl_keep isl_set_list *list,
3651 int (*fn)(__isl_take isl_set *el, void *user),
3653 int isl_set_list_foreach_scc(__isl_keep isl_set_list *list,
3654 int (*follows)(__isl_keep isl_set *a,
3655 __isl_keep isl_set *b, void *user),
3657 int (*fn)(__isl_take isl_set *el, void *user),
3660 The function C<isl_set_list_foreach_scc> calls C<fn> on each of the
3661 strongly connected components of the graph with as vertices the elements
3662 of C<list> and a directed edge from vertex C<b> to vertex C<a>
3663 iff C<follows(a, b)> returns C<1>. The callbacks C<follows> and C<fn>
3664 should return C<-1> on error.
3666 Lists can be printed using
3668 #include <isl/set.h>
3669 __isl_give isl_printer *isl_printer_print_set_list(
3670 __isl_take isl_printer *p,
3671 __isl_keep isl_set_list *list);
3673 =head2 Associative arrays
3675 Associative arrays map isl objects of a specific type to isl objects
3676 of some (other) specific type. They are defined for several pairs
3677 of types, including (C<isl_map>, C<isl_basic_set>),
3678 (C<isl_id>, C<isl_ast_expr>) and.
3679 (C<isl_id>, C<isl_pw_aff>).
3680 Here, we take associative arrays that map C<isl_id>s to C<isl_ast_expr>s
3683 Associative arrays can be created, copied and freed using
3684 the following functions.
3686 #include <isl/id_to_ast_expr.h>
3687 __isl_give id_to_ast_expr *isl_id_to_ast_expr_alloc(
3688 isl_ctx *ctx, int min_size);
3689 __isl_give id_to_ast_expr *isl_id_to_ast_expr_copy(
3690 __isl_keep id_to_ast_expr *id2expr);
3691 __isl_null id_to_ast_expr *isl_id_to_ast_expr_free(
3692 __isl_take id_to_ast_expr *id2expr);
3694 The C<min_size> argument to C<isl_id_to_ast_expr_alloc> can be used
3695 to specify the expected size of the associative array.
3696 The associative array will be grown automatically as needed.
3698 Associative arrays can be inspected using the following functions.
3700 #include <isl/id_to_ast_expr.h>
3701 isl_ctx *isl_id_to_ast_expr_get_ctx(
3702 __isl_keep id_to_ast_expr *id2expr);
3703 int isl_id_to_ast_expr_has(
3704 __isl_keep id_to_ast_expr *id2expr,
3705 __isl_keep isl_id *key);
3706 __isl_give isl_ast_expr *isl_id_to_ast_expr_get(
3707 __isl_keep id_to_ast_expr *id2expr,
3708 __isl_take isl_id *key);
3709 int isl_id_to_ast_expr_foreach(
3710 __isl_keep id_to_ast_expr *id2expr,
3711 int (*fn)(__isl_take isl_id *key,
3712 __isl_take isl_ast_expr *val, void *user),
3715 They can be modified using the following function.
3717 #include <isl/id_to_ast_expr.h>
3718 __isl_give id_to_ast_expr *isl_id_to_ast_expr_set(
3719 __isl_take id_to_ast_expr *id2expr,
3720 __isl_take isl_id *key,
3721 __isl_take isl_ast_expr *val);
3722 __isl_give id_to_ast_expr *isl_id_to_ast_expr_drop(
3723 __isl_take id_to_ast_expr *id2expr,
3724 __isl_take isl_id *key);
3726 Associative arrays can be printed using the following function.
3728 #include <isl/id_to_ast_expr.h>
3729 __isl_give isl_printer *isl_printer_print_id_to_ast_expr(
3730 __isl_take isl_printer *p,
3731 __isl_keep id_to_ast_expr *id2expr);
3733 =head2 Multiple Values
3735 An C<isl_multi_val> object represents a sequence of zero or more values,
3736 living in a set space.
3738 An C<isl_multi_val> can be constructed from an C<isl_val_list>
3739 using the following function
3741 #include <isl/val.h>
3742 __isl_give isl_multi_val *isl_multi_val_from_val_list(
3743 __isl_take isl_space *space,
3744 __isl_take isl_val_list *list);
3746 The zero multiple value (with value zero for each set dimension)
3747 can be created using the following function.
3749 #include <isl/val.h>
3750 __isl_give isl_multi_val *isl_multi_val_zero(
3751 __isl_take isl_space *space);
3753 Multiple values can be copied and freed using
3755 #include <isl/val.h>
3756 __isl_give isl_multi_val *isl_multi_val_copy(
3757 __isl_keep isl_multi_val *mv);
3758 __isl_null isl_multi_val *isl_multi_val_free(
3759 __isl_take isl_multi_val *mv);
3761 They can be inspected using
3763 #include <isl/val.h>
3764 isl_ctx *isl_multi_val_get_ctx(
3765 __isl_keep isl_multi_val *mv);
3766 unsigned isl_multi_val_dim(__isl_keep isl_multi_val *mv,
3767 enum isl_dim_type type);
3768 __isl_give isl_val *isl_multi_val_get_val(
3769 __isl_keep isl_multi_val *mv, int pos);
3770 int isl_multi_val_find_dim_by_id(
3771 __isl_keep isl_multi_val *mv,
3772 enum isl_dim_type type, __isl_keep isl_id *id);
3773 __isl_give isl_id *isl_multi_val_get_dim_id(
3774 __isl_keep isl_multi_val *mv,
3775 enum isl_dim_type type, unsigned pos);
3776 const char *isl_multi_val_get_tuple_name(
3777 __isl_keep isl_multi_val *mv,
3778 enum isl_dim_type type);
3779 int isl_multi_val_has_tuple_id(__isl_keep isl_multi_val *mv,
3780 enum isl_dim_type type);
3781 __isl_give isl_id *isl_multi_val_get_tuple_id(
3782 __isl_keep isl_multi_val *mv,
3783 enum isl_dim_type type);
3784 int isl_multi_val_range_is_wrapping(
3785 __isl_keep isl_multi_val *mv);
3787 They can be modified using
3789 #include <isl/val.h>
3790 __isl_give isl_multi_val *isl_multi_val_set_val(
3791 __isl_take isl_multi_val *mv, int pos,
3792 __isl_take isl_val *val);
3793 __isl_give isl_multi_val *isl_multi_val_set_dim_name(
3794 __isl_take isl_multi_val *mv,
3795 enum isl_dim_type type, unsigned pos, const char *s);
3796 __isl_give isl_multi_val *isl_multi_val_set_dim_id(
3797 __isl_take isl_multi_val *mv,
3798 enum isl_dim_type type, unsigned pos,
3799 __isl_take isl_id *id);
3800 __isl_give isl_multi_val *isl_multi_val_set_tuple_name(
3801 __isl_take isl_multi_val *mv,
3802 enum isl_dim_type type, const char *s);
3803 __isl_give isl_multi_val *isl_multi_val_set_tuple_id(
3804 __isl_take isl_multi_val *mv,
3805 enum isl_dim_type type, __isl_take isl_id *id);
3806 __isl_give isl_multi_val *isl_multi_val_reset_tuple_id(
3807 __isl_take isl_multi_val *mv,
3808 enum isl_dim_type type);
3809 __isl_give isl_multi_val *isl_multi_val_reset_user(
3810 __isl_take isl_multi_val *mv);
3812 __isl_give isl_multi_val *isl_multi_val_insert_dims(
3813 __isl_take isl_multi_val *mv,
3814 enum isl_dim_type type, unsigned first, unsigned n);
3815 __isl_give isl_multi_val *isl_multi_val_add_dims(
3816 __isl_take isl_multi_val *mv,
3817 enum isl_dim_type type, unsigned n);
3818 __isl_give isl_multi_val *isl_multi_val_drop_dims(
3819 __isl_take isl_multi_val *mv,
3820 enum isl_dim_type type, unsigned first, unsigned n);
3824 #include <isl/val.h>
3825 __isl_give isl_multi_val *isl_multi_val_align_params(
3826 __isl_take isl_multi_val *mv,
3827 __isl_take isl_space *model);
3828 __isl_give isl_multi_val *isl_multi_val_from_range(
3829 __isl_take isl_multi_val *mv);
3830 __isl_give isl_multi_val *isl_multi_val_range_splice(
3831 __isl_take isl_multi_val *mv1, unsigned pos,
3832 __isl_take isl_multi_val *mv2);
3833 __isl_give isl_multi_val *isl_multi_val_range_product(
3834 __isl_take isl_multi_val *mv1,
3835 __isl_take isl_multi_val *mv2);
3836 __isl_give isl_multi_val *
3837 isl_multi_val_range_factor_domain(
3838 __isl_take isl_multi_val *mv);
3839 __isl_give isl_multi_val *
3840 isl_multi_val_range_factor_range(
3841 __isl_take isl_multi_val *mv);
3842 __isl_give isl_multi_val *isl_multi_val_flat_range_product(
3843 __isl_take isl_multi_val *mv1,
3844 __isl_take isl_multi_aff *mv2);
3845 __isl_give isl_multi_val *isl_multi_val_product(
3846 __isl_take isl_multi_val *mv1,
3847 __isl_take isl_multi_val *mv2);
3848 __isl_give isl_multi_val *isl_multi_val_add_val(
3849 __isl_take isl_multi_val *mv,
3850 __isl_take isl_val *v);
3851 __isl_give isl_multi_val *isl_multi_val_mod_val(
3852 __isl_take isl_multi_val *mv,
3853 __isl_take isl_val *v);
3854 __isl_give isl_multi_val *isl_multi_val_scale_val(
3855 __isl_take isl_multi_val *mv,
3856 __isl_take isl_val *v);
3857 __isl_give isl_multi_val *isl_multi_val_scale_multi_val(
3858 __isl_take isl_multi_val *mv1,
3859 __isl_take isl_multi_val *mv2);
3860 __isl_give isl_multi_val *
3861 isl_multi_val_scale_down_multi_val(
3862 __isl_take isl_multi_val *mv1,
3863 __isl_take isl_multi_val *mv2);
3865 A multiple value can be printed using
3867 __isl_give isl_printer *isl_printer_print_multi_val(
3868 __isl_take isl_printer *p,
3869 __isl_keep isl_multi_val *mv);
3873 Vectors can be created, copied and freed using the following functions.
3875 #include <isl/vec.h>
3876 __isl_give isl_vec *isl_vec_alloc(isl_ctx *ctx,
3878 __isl_give isl_vec *isl_vec_copy(__isl_keep isl_vec *vec);
3879 __isl_null isl_vec *isl_vec_free(__isl_take isl_vec *vec);
3881 Note that the elements of a newly created vector may have arbitrary values.
3882 The elements can be changed and inspected using the following functions.
3884 isl_ctx *isl_vec_get_ctx(__isl_keep isl_vec *vec);
3885 int isl_vec_size(__isl_keep isl_vec *vec);
3886 __isl_give isl_val *isl_vec_get_element_val(
3887 __isl_keep isl_vec *vec, int pos);
3888 __isl_give isl_vec *isl_vec_set_element_si(
3889 __isl_take isl_vec *vec, int pos, int v);
3890 __isl_give isl_vec *isl_vec_set_element_val(
3891 __isl_take isl_vec *vec, int pos,
3892 __isl_take isl_val *v);
3893 __isl_give isl_vec *isl_vec_set_si(__isl_take isl_vec *vec,
3895 __isl_give isl_vec *isl_vec_set_val(
3896 __isl_take isl_vec *vec, __isl_take isl_val *v);
3897 int isl_vec_cmp_element(__isl_keep isl_vec *vec1,
3898 __isl_keep isl_vec *vec2, int pos);
3900 C<isl_vec_get_element> will return a negative value if anything went wrong.
3901 In that case, the value of C<*v> is undefined.
3903 The following function can be used to concatenate two vectors.
3905 __isl_give isl_vec *isl_vec_concat(__isl_take isl_vec *vec1,
3906 __isl_take isl_vec *vec2);
3910 Matrices can be created, copied and freed using the following functions.
3912 #include <isl/mat.h>
3913 __isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx,
3914 unsigned n_row, unsigned n_col);
3915 __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat);
3916 __isl_null isl_mat *isl_mat_free(__isl_take isl_mat *mat);
3918 Note that the elements of a newly created matrix may have arbitrary values.
3919 The elements can be changed and inspected using the following functions.
3921 isl_ctx *isl_mat_get_ctx(__isl_keep isl_mat *mat);
3922 int isl_mat_rows(__isl_keep isl_mat *mat);
3923 int isl_mat_cols(__isl_keep isl_mat *mat);
3924 __isl_give isl_val *isl_mat_get_element_val(
3925 __isl_keep isl_mat *mat, int row, int col);
3926 __isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat,
3927 int row, int col, int v);
3928 __isl_give isl_mat *isl_mat_set_element_val(
3929 __isl_take isl_mat *mat, int row, int col,
3930 __isl_take isl_val *v);
3932 C<isl_mat_get_element> will return a negative value if anything went wrong.
3933 In that case, the value of C<*v> is undefined.
3935 The following function can be used to compute the (right) inverse
3936 of a matrix, i.e., a matrix such that the product of the original
3937 and the inverse (in that order) is a multiple of the identity matrix.
3938 The input matrix is assumed to be of full row-rank.
3940 __isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat);
3942 The following function can be used to compute the (right) kernel
3943 (or null space) of a matrix, i.e., a matrix such that the product of
3944 the original and the kernel (in that order) is the zero matrix.
3946 __isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat);
3948 =head2 Piecewise Quasi Affine Expressions
3950 The zero quasi affine expression or the quasi affine expression
3951 that is equal to a given value or
3952 a specified dimension on a given domain can be created using
3954 __isl_give isl_aff *isl_aff_zero_on_domain(
3955 __isl_take isl_local_space *ls);
3956 __isl_give isl_pw_aff *isl_pw_aff_zero_on_domain(
3957 __isl_take isl_local_space *ls);
3958 __isl_give isl_aff *isl_aff_val_on_domain(
3959 __isl_take isl_local_space *ls,
3960 __isl_take isl_val *val);
3961 __isl_give isl_aff *isl_aff_var_on_domain(
3962 __isl_take isl_local_space *ls,
3963 enum isl_dim_type type, unsigned pos);
3964 __isl_give isl_pw_aff *isl_pw_aff_var_on_domain(
3965 __isl_take isl_local_space *ls,
3966 enum isl_dim_type type, unsigned pos);
3967 __isl_give isl_aff *isl_aff_nan_on_domain(
3968 __isl_take isl_local_space *ls);
3969 __isl_give isl_pw_aff *isl_pw_aff_nan_on_domain(
3970 __isl_take isl_local_space *ls);
3972 Note that the space in which the resulting objects live is a map space
3973 with the given space as domain and a one-dimensional range.
3975 An empty piecewise quasi affine expression (one with no cells)
3976 or a piecewise quasi affine expression with a single cell can
3977 be created using the following functions.
3979 #include <isl/aff.h>
3980 __isl_give isl_pw_aff *isl_pw_aff_empty(
3981 __isl_take isl_space *space);
3982 __isl_give isl_pw_aff *isl_pw_aff_alloc(
3983 __isl_take isl_set *set, __isl_take isl_aff *aff);
3984 __isl_give isl_pw_aff *isl_pw_aff_from_aff(
3985 __isl_take isl_aff *aff);
3987 A piecewise quasi affine expression that is equal to 1 on a set
3988 and 0 outside the set can be created using the following function.
3990 #include <isl/aff.h>
3991 __isl_give isl_pw_aff *isl_set_indicator_function(
3992 __isl_take isl_set *set);
3994 Quasi affine expressions can be copied and freed using
3996 #include <isl/aff.h>
3997 __isl_give isl_aff *isl_aff_copy(__isl_keep isl_aff *aff);
3998 __isl_null isl_aff *isl_aff_free(__isl_take isl_aff *aff);
4000 __isl_give isl_pw_aff *isl_pw_aff_copy(
4001 __isl_keep isl_pw_aff *pwaff);
4002 __isl_null isl_pw_aff *isl_pw_aff_free(
4003 __isl_take isl_pw_aff *pwaff);
4005 A (rational) bound on a dimension can be extracted from an C<isl_constraint>
4006 using the following function. The constraint is required to have
4007 a non-zero coefficient for the specified dimension.
4009 #include <isl/constraint.h>
4010 __isl_give isl_aff *isl_constraint_get_bound(
4011 __isl_keep isl_constraint *constraint,
4012 enum isl_dim_type type, int pos);
4014 The entire affine expression of the constraint can also be extracted
4015 using the following function.
4017 #include <isl/constraint.h>
4018 __isl_give isl_aff *isl_constraint_get_aff(
4019 __isl_keep isl_constraint *constraint);
4021 Conversely, an equality constraint equating
4022 the affine expression to zero or an inequality constraint enforcing
4023 the affine expression to be non-negative, can be constructed using
4025 __isl_give isl_constraint *isl_equality_from_aff(
4026 __isl_take isl_aff *aff);
4027 __isl_give isl_constraint *isl_inequality_from_aff(
4028 __isl_take isl_aff *aff);
4030 The expression can be inspected using
4032 #include <isl/aff.h>
4033 isl_ctx *isl_aff_get_ctx(__isl_keep isl_aff *aff);
4034 int isl_aff_dim(__isl_keep isl_aff *aff,
4035 enum isl_dim_type type);
4036 __isl_give isl_local_space *isl_aff_get_domain_local_space(
4037 __isl_keep isl_aff *aff);
4038 __isl_give isl_local_space *isl_aff_get_local_space(
4039 __isl_keep isl_aff *aff);
4040 const char *isl_aff_get_dim_name(__isl_keep isl_aff *aff,
4041 enum isl_dim_type type, unsigned pos);
4042 const char *isl_pw_aff_get_dim_name(
4043 __isl_keep isl_pw_aff *pa,
4044 enum isl_dim_type type, unsigned pos);
4045 int isl_pw_aff_has_dim_id(__isl_keep isl_pw_aff *pa,
4046 enum isl_dim_type type, unsigned pos);
4047 __isl_give isl_id *isl_pw_aff_get_dim_id(
4048 __isl_keep isl_pw_aff *pa,
4049 enum isl_dim_type type, unsigned pos);
4050 int isl_pw_aff_has_tuple_id(__isl_keep isl_pw_aff *pa,
4051 enum isl_dim_type type);
4052 __isl_give isl_id *isl_pw_aff_get_tuple_id(
4053 __isl_keep isl_pw_aff *pa,
4054 enum isl_dim_type type);
4055 __isl_give isl_val *isl_aff_get_constant_val(
4056 __isl_keep isl_aff *aff);
4057 __isl_give isl_val *isl_aff_get_coefficient_val(
4058 __isl_keep isl_aff *aff,
4059 enum isl_dim_type type, int pos);
4060 __isl_give isl_val *isl_aff_get_denominator_val(
4061 __isl_keep isl_aff *aff);
4062 __isl_give isl_aff *isl_aff_get_div(
4063 __isl_keep isl_aff *aff, int pos);
4065 int isl_pw_aff_n_piece(__isl_keep isl_pw_aff *pwaff);
4066 int isl_pw_aff_foreach_piece(__isl_keep isl_pw_aff *pwaff,
4067 int (*fn)(__isl_take isl_set *set,
4068 __isl_take isl_aff *aff,
4069 void *user), void *user);
4071 int isl_aff_is_cst(__isl_keep isl_aff *aff);
4072 int isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff);
4074 int isl_aff_is_nan(__isl_keep isl_aff *aff);
4075 int isl_pw_aff_involves_nan(__isl_keep isl_pw_aff *pa);
4077 int isl_aff_involves_dims(__isl_keep isl_aff *aff,
4078 enum isl_dim_type type, unsigned first, unsigned n);
4079 int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff,
4080 enum isl_dim_type type, unsigned first, unsigned n);
4082 isl_ctx *isl_pw_aff_get_ctx(__isl_keep isl_pw_aff *pwaff);
4083 unsigned isl_pw_aff_dim(__isl_keep isl_pw_aff *pwaff,
4084 enum isl_dim_type type);
4085 int isl_pw_aff_is_empty(__isl_keep isl_pw_aff *pwaff);
4087 It can be modified using
4089 #include <isl/aff.h>
4090 __isl_give isl_aff *isl_aff_set_tuple_id(
4091 __isl_take isl_aff *aff,
4092 enum isl_dim_type type, __isl_take isl_id *id);
4093 __isl_give isl_pw_aff *isl_pw_aff_set_tuple_id(
4094 __isl_take isl_pw_aff *pwaff,
4095 enum isl_dim_type type, __isl_take isl_id *id);
4096 __isl_give isl_pw_aff *isl_pw_aff_reset_tuple_id(
4097 __isl_take isl_pw_aff *pa,
4098 enum isl_dim_type type);
4099 __isl_give isl_aff *isl_aff_set_dim_name(
4100 __isl_take isl_aff *aff, enum isl_dim_type type,
4101 unsigned pos, const char *s);
4102 __isl_give isl_aff *isl_aff_set_dim_id(
4103 __isl_take isl_aff *aff, enum isl_dim_type type,
4104 unsigned pos, __isl_take isl_id *id);
4105 __isl_give isl_pw_aff *isl_pw_aff_set_dim_id(
4106 __isl_take isl_pw_aff *pma,
4107 enum isl_dim_type type, unsigned pos,
4108 __isl_take isl_id *id);
4109 __isl_give isl_aff *isl_aff_set_constant_si(
4110 __isl_take isl_aff *aff, int v);
4111 __isl_give isl_aff *isl_aff_set_constant_val(
4112 __isl_take isl_aff *aff, __isl_take isl_val *v);
4113 __isl_give isl_aff *isl_aff_set_coefficient_si(
4114 __isl_take isl_aff *aff,
4115 enum isl_dim_type type, int pos, int v);
4116 __isl_give isl_aff *isl_aff_set_coefficient_val(
4117 __isl_take isl_aff *aff,
4118 enum isl_dim_type type, int pos,
4119 __isl_take isl_val *v);
4121 __isl_give isl_aff *isl_aff_add_constant_si(
4122 __isl_take isl_aff *aff, int v);
4123 __isl_give isl_aff *isl_aff_add_constant_val(
4124 __isl_take isl_aff *aff, __isl_take isl_val *v);
4125 __isl_give isl_aff *isl_aff_add_constant_num_si(
4126 __isl_take isl_aff *aff, int v);
4127 __isl_give isl_aff *isl_aff_add_coefficient_si(
4128 __isl_take isl_aff *aff,
4129 enum isl_dim_type type, int pos, int v);
4130 __isl_give isl_aff *isl_aff_add_coefficient_val(
4131 __isl_take isl_aff *aff,
4132 enum isl_dim_type type, int pos,
4133 __isl_take isl_val *v);
4135 __isl_give isl_aff *isl_aff_insert_dims(
4136 __isl_take isl_aff *aff,
4137 enum isl_dim_type type, unsigned first, unsigned n);
4138 __isl_give isl_pw_aff *isl_pw_aff_insert_dims(
4139 __isl_take isl_pw_aff *pwaff,
4140 enum isl_dim_type type, unsigned first, unsigned n);
4141 __isl_give isl_aff *isl_aff_add_dims(
4142 __isl_take isl_aff *aff,
4143 enum isl_dim_type type, unsigned n);
4144 __isl_give isl_pw_aff *isl_pw_aff_add_dims(
4145 __isl_take isl_pw_aff *pwaff,
4146 enum isl_dim_type type, unsigned n);
4147 __isl_give isl_aff *isl_aff_drop_dims(
4148 __isl_take isl_aff *aff,
4149 enum isl_dim_type type, unsigned first, unsigned n);
4150 __isl_give isl_pw_aff *isl_pw_aff_drop_dims(
4151 __isl_take isl_pw_aff *pwaff,
4152 enum isl_dim_type type, unsigned first, unsigned n);
4153 __isl_give isl_aff *isl_aff_move_dims(
4154 __isl_take isl_aff *aff,
4155 enum isl_dim_type dst_type, unsigned dst_pos,
4156 enum isl_dim_type src_type, unsigned src_pos,
4158 __isl_give isl_pw_aff *isl_pw_aff_move_dims(
4159 __isl_take isl_pw_aff *pa,
4160 enum isl_dim_type dst_type, unsigned dst_pos,
4161 enum isl_dim_type src_type, unsigned src_pos,
4164 Note that C<isl_aff_set_constant_si> and C<isl_aff_set_coefficient_si>
4165 set the I<numerator> of the constant or coefficient, while
4166 C<isl_aff_set_constant_val> and C<isl_aff_set_coefficient_val> set
4167 the constant or coefficient as a whole.
4168 The C<add_constant> and C<add_coefficient> functions add an integer
4169 or rational value to
4170 the possibly rational constant or coefficient.
4171 The C<add_constant_num> functions add an integer value to
4174 To check whether an affine expressions is obviously zero
4175 or (obviously) equal to some other affine expression, use
4177 #include <isl/aff.h>
4178 int isl_aff_plain_is_zero(__isl_keep isl_aff *aff);
4179 int isl_aff_plain_is_equal(__isl_keep isl_aff *aff1,
4180 __isl_keep isl_aff *aff2);
4181 int isl_pw_aff_plain_is_equal(
4182 __isl_keep isl_pw_aff *pwaff1,
4183 __isl_keep isl_pw_aff *pwaff2);
4184 int isl_pw_aff_is_equal(__isl_keep isl_pw_aff *pa1,
4185 __isl_keep isl_pw_aff *pa2);
4186 int isl_pw_aff_plain_cmp(__isl_keep isl_pw_aff *pa1,
4187 __isl_keep isl_pw_aff *pa2);
4189 The function C<isl_pw_aff_plain_cmp> can be used to sort
4190 C<isl_pw_aff>s. The order is not strictly defined.
4191 The current order sorts expressions that only involve
4192 earlier dimensions before those that involve later dimensions.
4196 #include <isl/aff.h>
4197 __isl_give isl_aff *isl_aff_add(__isl_take isl_aff *aff1,
4198 __isl_take isl_aff *aff2);
4199 __isl_give isl_pw_aff *isl_pw_aff_add(
4200 __isl_take isl_pw_aff *pwaff1,
4201 __isl_take isl_pw_aff *pwaff2);
4202 __isl_give isl_pw_aff *isl_pw_aff_min(
4203 __isl_take isl_pw_aff *pwaff1,
4204 __isl_take isl_pw_aff *pwaff2);
4205 __isl_give isl_pw_aff *isl_pw_aff_max(
4206 __isl_take isl_pw_aff *pwaff1,
4207 __isl_take isl_pw_aff *pwaff2);
4208 __isl_give isl_aff *isl_aff_sub(__isl_take isl_aff *aff1,
4209 __isl_take isl_aff *aff2);
4210 __isl_give isl_pw_aff *isl_pw_aff_sub(
4211 __isl_take isl_pw_aff *pwaff1,
4212 __isl_take isl_pw_aff *pwaff2);
4213 __isl_give isl_aff *isl_aff_neg(__isl_take isl_aff *aff);
4214 __isl_give isl_pw_aff *isl_pw_aff_neg(
4215 __isl_take isl_pw_aff *pwaff);
4216 __isl_give isl_aff *isl_aff_ceil(__isl_take isl_aff *aff);
4217 __isl_give isl_pw_aff *isl_pw_aff_ceil(
4218 __isl_take isl_pw_aff *pwaff);
4219 __isl_give isl_aff *isl_aff_floor(__isl_take isl_aff *aff);
4220 __isl_give isl_pw_aff *isl_pw_aff_floor(
4221 __isl_take isl_pw_aff *pwaff);
4222 __isl_give isl_aff *isl_aff_mod_val(__isl_take isl_aff *aff,
4223 __isl_take isl_val *mod);
4224 __isl_give isl_pw_aff *isl_pw_aff_mod_val(
4225 __isl_take isl_pw_aff *pa,
4226 __isl_take isl_val *mod);
4227 __isl_give isl_aff *isl_aff_scale_val(__isl_take isl_aff *aff,
4228 __isl_take isl_val *v);
4229 __isl_give isl_pw_aff *isl_pw_aff_scale_val(
4230 __isl_take isl_pw_aff *pa, __isl_take isl_val *v);
4231 __isl_give isl_aff *isl_aff_scale_down_ui(
4232 __isl_take isl_aff *aff, unsigned f);
4233 __isl_give isl_aff *isl_aff_scale_down_val(
4234 __isl_take isl_aff *aff, __isl_take isl_val *v);
4235 __isl_give isl_pw_aff *isl_pw_aff_scale_down_val(
4236 __isl_take isl_pw_aff *pa,
4237 __isl_take isl_val *f);
4239 __isl_give isl_pw_aff *isl_pw_aff_list_min(
4240 __isl_take isl_pw_aff_list *list);
4241 __isl_give isl_pw_aff *isl_pw_aff_list_max(
4242 __isl_take isl_pw_aff_list *list);
4244 __isl_give isl_pw_aff *isl_pw_aff_coalesce(
4245 __isl_take isl_pw_aff *pwqp);
4247 __isl_give isl_aff *isl_aff_align_params(
4248 __isl_take isl_aff *aff,
4249 __isl_take isl_space *model);
4250 __isl_give isl_pw_aff *isl_pw_aff_align_params(
4251 __isl_take isl_pw_aff *pwaff,
4252 __isl_take isl_space *model);
4254 __isl_give isl_aff *isl_aff_project_domain_on_params(
4255 __isl_take isl_aff *aff);
4256 __isl_give isl_pw_aff *isl_pw_aff_from_range(
4257 __isl_take isl_pw_aff *pwa);
4259 __isl_give isl_aff *isl_aff_gist_params(
4260 __isl_take isl_aff *aff,
4261 __isl_take isl_set *context);
4262 __isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff,
4263 __isl_take isl_set *context);
4264 __isl_give isl_pw_aff *isl_pw_aff_gist_params(
4265 __isl_take isl_pw_aff *pwaff,
4266 __isl_take isl_set *context);
4267 __isl_give isl_pw_aff *isl_pw_aff_gist(
4268 __isl_take isl_pw_aff *pwaff,
4269 __isl_take isl_set *context);
4271 __isl_give isl_set *isl_pw_aff_domain(
4272 __isl_take isl_pw_aff *pwaff);
4273 __isl_give isl_set *isl_pw_aff_params(
4274 __isl_take isl_pw_aff *pwa);
4275 __isl_give isl_pw_aff *isl_pw_aff_intersect_domain(
4276 __isl_take isl_pw_aff *pa,
4277 __isl_take isl_set *set);
4278 __isl_give isl_pw_aff *isl_pw_aff_intersect_params(
4279 __isl_take isl_pw_aff *pa,
4280 __isl_take isl_set *set);
4282 __isl_give isl_aff *isl_aff_mul(__isl_take isl_aff *aff1,
4283 __isl_take isl_aff *aff2);
4284 __isl_give isl_aff *isl_aff_div(__isl_take isl_aff *aff1,
4285 __isl_take isl_aff *aff2);
4286 __isl_give isl_pw_aff *isl_pw_aff_mul(
4287 __isl_take isl_pw_aff *pwaff1,
4288 __isl_take isl_pw_aff *pwaff2);
4289 __isl_give isl_pw_aff *isl_pw_aff_div(
4290 __isl_take isl_pw_aff *pa1,
4291 __isl_take isl_pw_aff *pa2);
4292 __isl_give isl_pw_aff *isl_pw_aff_tdiv_q(
4293 __isl_take isl_pw_aff *pa1,
4294 __isl_take isl_pw_aff *pa2);
4295 __isl_give isl_pw_aff *isl_pw_aff_tdiv_r(
4296 __isl_take isl_pw_aff *pa1,
4297 __isl_take isl_pw_aff *pa2);
4299 When multiplying two affine expressions, at least one of the two needs
4300 to be a constant. Similarly, when dividing an affine expression by another,
4301 the second expression needs to be a constant.
4302 C<isl_pw_aff_tdiv_q> computes the quotient of an integer division with
4303 rounding towards zero. C<isl_pw_aff_tdiv_r> computes the corresponding
4306 #include <isl/aff.h>
4307 __isl_give isl_aff *isl_aff_pullback_aff(
4308 __isl_take isl_aff *aff1,
4309 __isl_take isl_aff *aff2);
4310 __isl_give isl_aff *isl_aff_pullback_multi_aff(
4311 __isl_take isl_aff *aff,
4312 __isl_take isl_multi_aff *ma);
4313 __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_aff(
4314 __isl_take isl_pw_aff *pa,
4315 __isl_take isl_multi_aff *ma);
4316 __isl_give isl_pw_aff *isl_pw_aff_pullback_pw_multi_aff(
4317 __isl_take isl_pw_aff *pa,
4318 __isl_take isl_pw_multi_aff *pma);
4319 __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_pw_aff(
4320 __isl_take isl_pw_aff *pa,
4321 __isl_take isl_multi_pw_aff *mpa);
4323 These functions precompose the input expression by the given
4324 C<isl_aff>, C<isl_multi_aff> or C<isl_pw_multi_aff>. In other words,
4325 the C<isl_aff>, C<isl_multi_aff> or C<isl_pw_multi_aff> is plugged
4326 into the (piecewise) affine expression.
4327 Objects of type C<isl_multi_aff> are described in
4328 L</"Piecewise Multiple Quasi Affine Expressions">.
4330 #include <isl/aff.h>
4331 __isl_give isl_basic_set *isl_aff_zero_basic_set(
4332 __isl_take isl_aff *aff);
4333 __isl_give isl_basic_set *isl_aff_neg_basic_set(
4334 __isl_take isl_aff *aff);
4335 __isl_give isl_basic_set *isl_aff_le_basic_set(
4336 __isl_take isl_aff *aff1, __isl_take isl_aff *aff2);
4337 __isl_give isl_basic_set *isl_aff_ge_basic_set(
4338 __isl_take isl_aff *aff1, __isl_take isl_aff *aff2);
4339 __isl_give isl_set *isl_pw_aff_eq_set(
4340 __isl_take isl_pw_aff *pwaff1,
4341 __isl_take isl_pw_aff *pwaff2);
4342 __isl_give isl_set *isl_pw_aff_ne_set(
4343 __isl_take isl_pw_aff *pwaff1,
4344 __isl_take isl_pw_aff *pwaff2);
4345 __isl_give isl_set *isl_pw_aff_le_set(
4346 __isl_take isl_pw_aff *pwaff1,
4347 __isl_take isl_pw_aff *pwaff2);
4348 __isl_give isl_set *isl_pw_aff_lt_set(
4349 __isl_take isl_pw_aff *pwaff1,
4350 __isl_take isl_pw_aff *pwaff2);
4351 __isl_give isl_set *isl_pw_aff_ge_set(
4352 __isl_take isl_pw_aff *pwaff1,
4353 __isl_take isl_pw_aff *pwaff2);
4354 __isl_give isl_set *isl_pw_aff_gt_set(
4355 __isl_take isl_pw_aff *pwaff1,
4356 __isl_take isl_pw_aff *pwaff2);
4358 __isl_give isl_set *isl_pw_aff_list_eq_set(
4359 __isl_take isl_pw_aff_list *list1,
4360 __isl_take isl_pw_aff_list *list2);
4361 __isl_give isl_set *isl_pw_aff_list_ne_set(
4362 __isl_take isl_pw_aff_list *list1,
4363 __isl_take isl_pw_aff_list *list2);
4364 __isl_give isl_set *isl_pw_aff_list_le_set(
4365 __isl_take isl_pw_aff_list *list1,
4366 __isl_take isl_pw_aff_list *list2);
4367 __isl_give isl_set *isl_pw_aff_list_lt_set(
4368 __isl_take isl_pw_aff_list *list1,
4369 __isl_take isl_pw_aff_list *list2);
4370 __isl_give isl_set *isl_pw_aff_list_ge_set(
4371 __isl_take isl_pw_aff_list *list1,
4372 __isl_take isl_pw_aff_list *list2);
4373 __isl_give isl_set *isl_pw_aff_list_gt_set(
4374 __isl_take isl_pw_aff_list *list1,
4375 __isl_take isl_pw_aff_list *list2);
4377 The function C<isl_aff_neg_basic_set> returns a basic set
4378 containing those elements in the domain space
4379 of C<aff> where C<aff> is negative.
4380 The function C<isl_aff_ge_basic_set> returns a basic set
4381 containing those elements in the shared space
4382 of C<aff1> and C<aff2> where C<aff1> is greater than or equal to C<aff2>.
4383 The function C<isl_pw_aff_ge_set> returns a set
4384 containing those elements in the shared domain
4385 of C<pwaff1> and C<pwaff2> where C<pwaff1> is greater than or equal to C<pwaff2>.
4386 The functions operating on C<isl_pw_aff_list> apply the corresponding
4387 C<isl_pw_aff> function to each pair of elements in the two lists.
4389 #include <isl/aff.h>
4390 __isl_give isl_set *isl_pw_aff_nonneg_set(
4391 __isl_take isl_pw_aff *pwaff);
4392 __isl_give isl_set *isl_pw_aff_zero_set(
4393 __isl_take isl_pw_aff *pwaff);
4394 __isl_give isl_set *isl_pw_aff_non_zero_set(
4395 __isl_take isl_pw_aff *pwaff);
4397 The function C<isl_pw_aff_nonneg_set> returns a set
4398 containing those elements in the domain
4399 of C<pwaff> where C<pwaff> is non-negative.
4401 #include <isl/aff.h>
4402 __isl_give isl_pw_aff *isl_pw_aff_cond(
4403 __isl_take isl_pw_aff *cond,
4404 __isl_take isl_pw_aff *pwaff_true,
4405 __isl_take isl_pw_aff *pwaff_false);
4407 The function C<isl_pw_aff_cond> performs a conditional operator
4408 and returns an expression that is equal to C<pwaff_true>
4409 for elements where C<cond> is non-zero and equal to C<pwaff_false> for elements
4410 where C<cond> is zero.
4412 #include <isl/aff.h>
4413 __isl_give isl_pw_aff *isl_pw_aff_union_min(
4414 __isl_take isl_pw_aff *pwaff1,
4415 __isl_take isl_pw_aff *pwaff2);
4416 __isl_give isl_pw_aff *isl_pw_aff_union_max(
4417 __isl_take isl_pw_aff *pwaff1,
4418 __isl_take isl_pw_aff *pwaff2);
4419 __isl_give isl_pw_aff *isl_pw_aff_union_add(
4420 __isl_take isl_pw_aff *pwaff1,
4421 __isl_take isl_pw_aff *pwaff2);
4423 The function C<isl_pw_aff_union_max> computes a piecewise quasi-affine
4424 expression with a domain that is the union of those of C<pwaff1> and
4425 C<pwaff2> and such that on each cell, the quasi-affine expression is
4426 the maximum of those of C<pwaff1> and C<pwaff2>. If only one of
4427 C<pwaff1> or C<pwaff2> is defined on a given cell, then the
4428 associated expression is the defined one.
4430 An expression can be read from input using
4432 #include <isl/aff.h>
4433 __isl_give isl_aff *isl_aff_read_from_str(
4434 isl_ctx *ctx, const char *str);
4435 __isl_give isl_pw_aff *isl_pw_aff_read_from_str(
4436 isl_ctx *ctx, const char *str);
4438 An expression can be printed using
4440 #include <isl/aff.h>
4441 __isl_give isl_printer *isl_printer_print_aff(
4442 __isl_take isl_printer *p, __isl_keep isl_aff *aff);
4444 __isl_give isl_printer *isl_printer_print_pw_aff(
4445 __isl_take isl_printer *p,
4446 __isl_keep isl_pw_aff *pwaff);
4448 =head2 Piecewise Multiple Quasi Affine Expressions
4450 An C<isl_multi_aff> object represents a sequence of
4451 zero or more affine expressions, all defined on the same domain space.
4452 Similarly, an C<isl_multi_pw_aff> object represents a sequence of
4453 zero or more piecewise affine expressions.
4455 An C<isl_multi_aff> can be constructed from a single
4456 C<isl_aff> or an C<isl_aff_list> using the
4457 following functions. Similarly for C<isl_multi_pw_aff>
4458 and C<isl_pw_multi_aff>.
4460 #include <isl/aff.h>
4461 __isl_give isl_multi_aff *isl_multi_aff_from_aff(
4462 __isl_take isl_aff *aff);
4463 __isl_give isl_multi_pw_aff *
4464 isl_multi_pw_aff_from_multi_aff(
4465 __isl_take isl_multi_aff *ma);
4466 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_aff(
4467 __isl_take isl_pw_aff *pa);
4468 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_pw_aff(
4469 __isl_take isl_pw_aff *pa);
4470 __isl_give isl_multi_aff *isl_multi_aff_from_aff_list(
4471 __isl_take isl_space *space,
4472 __isl_take isl_aff_list *list);
4474 An C<isl_multi_pw_aff> can be converted to an C<isl_pw_multi_aff>
4475 using the function C<isl_pw_multi_aff_from_multi_pw_aff> below.
4476 Note however that the domain
4477 of the result is the intersection of the domains of the input.
4478 The reverse conversion is exact.
4480 #include <isl/aff.h>
4481 __isl_give isl_pw_multi_aff *
4482 isl_pw_multi_aff_from_multi_pw_aff(
4483 __isl_take isl_multi_pw_aff *mpa);
4484 __isl_give isl_multi_pw_aff *
4485 isl_multi_pw_aff_from_pw_multi_aff(
4486 __isl_take isl_pw_multi_aff *pma);
4488 An empty piecewise multiple quasi affine expression (one with no cells),
4489 the zero piecewise multiple quasi affine expression (with value zero
4490 for each output dimension),
4491 a piecewise multiple quasi affine expression with a single cell (with
4492 either a universe or a specified domain) or
4493 a zero-dimensional piecewise multiple quasi affine expression
4495 can be created using the following functions.
4497 #include <isl/aff.h>
4498 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_empty(
4499 __isl_take isl_space *space);
4500 __isl_give isl_multi_aff *isl_multi_aff_zero(
4501 __isl_take isl_space *space);
4502 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_zero(
4503 __isl_take isl_space *space);
4504 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_zero(
4505 __isl_take isl_space *space);
4506 __isl_give isl_multi_aff *isl_multi_aff_identity(
4507 __isl_take isl_space *space);
4508 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_identity(
4509 __isl_take isl_space *space);
4510 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_identity(
4511 __isl_take isl_space *space);
4512 __isl_give isl_multi_aff *isl_multi_aff_domain_map(
4513 __isl_take isl_space *space);
4514 __isl_give isl_multi_aff *isl_multi_aff_range_map(
4515 __isl_take isl_space *space);
4516 __isl_give isl_multi_aff *isl_multi_aff_project_out_map(
4517 __isl_take isl_space *space,
4518 enum isl_dim_type type,
4519 unsigned first, unsigned n);
4520 __isl_give isl_pw_multi_aff *
4521 isl_pw_multi_aff_project_out_map(
4522 __isl_take isl_space *space,
4523 enum isl_dim_type type,
4524 unsigned first, unsigned n);
4525 __isl_give isl_pw_multi_aff *
4526 isl_pw_multi_aff_from_multi_aff(
4527 __isl_take isl_multi_aff *ma);
4528 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_alloc(
4529 __isl_take isl_set *set,
4530 __isl_take isl_multi_aff *maff);
4531 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_domain(
4532 __isl_take isl_set *set);
4534 __isl_give isl_union_pw_multi_aff *
4535 isl_union_pw_multi_aff_empty(
4536 __isl_take isl_space *space);
4537 __isl_give isl_union_pw_multi_aff *
4538 isl_union_pw_multi_aff_add_pw_multi_aff(
4539 __isl_take isl_union_pw_multi_aff *upma,
4540 __isl_take isl_pw_multi_aff *pma);
4541 __isl_give isl_union_pw_multi_aff *
4542 isl_union_pw_multi_aff_from_domain(
4543 __isl_take isl_union_set *uset);
4545 A piecewise multiple quasi affine expression can also be initialized
4546 from an C<isl_set> or C<isl_map>, provided the C<isl_set> is a singleton
4547 and the C<isl_map> is single-valued.
4548 In case of a conversion from an C<isl_union_set> or an C<isl_union_map>
4549 to an C<isl_union_pw_multi_aff>, these properties need to hold in each space.
4551 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_set(
4552 __isl_take isl_set *set);
4553 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_map(
4554 __isl_take isl_map *map);
4556 __isl_give isl_union_pw_multi_aff *
4557 isl_union_pw_multi_aff_from_union_set(
4558 __isl_take isl_union_set *uset);
4559 __isl_give isl_union_pw_multi_aff *
4560 isl_union_pw_multi_aff_from_union_map(
4561 __isl_take isl_union_map *umap);
4563 Multiple quasi affine expressions can be copied and freed using
4565 #include <isl/aff.h>
4566 __isl_give isl_multi_aff *isl_multi_aff_copy(
4567 __isl_keep isl_multi_aff *maff);
4568 __isl_null isl_multi_aff *isl_multi_aff_free(
4569 __isl_take isl_multi_aff *maff);
4571 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_copy(
4572 __isl_keep isl_pw_multi_aff *pma);
4573 __isl_null isl_pw_multi_aff *isl_pw_multi_aff_free(
4574 __isl_take isl_pw_multi_aff *pma);
4576 __isl_give isl_union_pw_multi_aff *
4577 isl_union_pw_multi_aff_copy(
4578 __isl_keep isl_union_pw_multi_aff *upma);
4579 __isl_null isl_union_pw_multi_aff *
4580 isl_union_pw_multi_aff_free(
4581 __isl_take isl_union_pw_multi_aff *upma);
4583 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_copy(
4584 __isl_keep isl_multi_pw_aff *mpa);
4585 __isl_null isl_multi_pw_aff *isl_multi_pw_aff_free(
4586 __isl_take isl_multi_pw_aff *mpa);
4588 The expression can be inspected using
4590 #include <isl/aff.h>
4591 isl_ctx *isl_multi_aff_get_ctx(
4592 __isl_keep isl_multi_aff *maff);
4593 isl_ctx *isl_pw_multi_aff_get_ctx(
4594 __isl_keep isl_pw_multi_aff *pma);
4595 isl_ctx *isl_union_pw_multi_aff_get_ctx(
4596 __isl_keep isl_union_pw_multi_aff *upma);
4597 isl_ctx *isl_multi_pw_aff_get_ctx(
4598 __isl_keep isl_multi_pw_aff *mpa);
4600 int isl_multi_aff_involves_dims(
4601 __isl_keep isl_multi_aff *ma,
4602 enum isl_dim_type type, unsigned first, unsigned n);
4603 int isl_multi_pw_aff_involves_dims(
4604 __isl_keep isl_multi_pw_aff *mpa,
4605 enum isl_dim_type type, unsigned first, unsigned n);
4607 unsigned isl_multi_aff_dim(__isl_keep isl_multi_aff *maff,
4608 enum isl_dim_type type);
4609 unsigned isl_pw_multi_aff_dim(
4610 __isl_keep isl_pw_multi_aff *pma,
4611 enum isl_dim_type type);
4612 unsigned isl_multi_pw_aff_dim(
4613 __isl_keep isl_multi_pw_aff *mpa,
4614 enum isl_dim_type type);
4615 __isl_give isl_aff *isl_multi_aff_get_aff(
4616 __isl_keep isl_multi_aff *multi, int pos);
4617 __isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff(
4618 __isl_keep isl_pw_multi_aff *pma, int pos);
4619 __isl_give isl_pw_aff *isl_multi_pw_aff_get_pw_aff(
4620 __isl_keep isl_multi_pw_aff *mpa, int pos);
4621 int isl_multi_aff_find_dim_by_id(
4622 __isl_keep isl_multi_aff *ma,
4623 enum isl_dim_type type, __isl_keep isl_id *id);
4624 int isl_multi_pw_aff_find_dim_by_id(
4625 __isl_keep isl_multi_pw_aff *mpa,
4626 enum isl_dim_type type, __isl_keep isl_id *id);
4627 const char *isl_pw_multi_aff_get_dim_name(
4628 __isl_keep isl_pw_multi_aff *pma,
4629 enum isl_dim_type type, unsigned pos);
4630 __isl_give isl_id *isl_multi_aff_get_dim_id(
4631 __isl_keep isl_multi_aff *ma,
4632 enum isl_dim_type type, unsigned pos);
4633 __isl_give isl_id *isl_pw_multi_aff_get_dim_id(
4634 __isl_keep isl_pw_multi_aff *pma,
4635 enum isl_dim_type type, unsigned pos);
4636 __isl_give isl_id *isl_multi_pw_aff_get_dim_id(
4637 __isl_keep isl_multi_pw_aff *mpa,
4638 enum isl_dim_type type, unsigned pos);
4639 const char *isl_multi_aff_get_tuple_name(
4640 __isl_keep isl_multi_aff *multi,
4641 enum isl_dim_type type);
4642 int isl_pw_multi_aff_has_tuple_name(
4643 __isl_keep isl_pw_multi_aff *pma,
4644 enum isl_dim_type type);
4645 const char *isl_pw_multi_aff_get_tuple_name(
4646 __isl_keep isl_pw_multi_aff *pma,
4647 enum isl_dim_type type);
4648 int isl_multi_aff_has_tuple_id(__isl_keep isl_multi_aff *ma,
4649 enum isl_dim_type type);
4650 int isl_pw_multi_aff_has_tuple_id(
4651 __isl_keep isl_pw_multi_aff *pma,
4652 enum isl_dim_type type);
4653 int isl_multi_pw_aff_has_tuple_id(
4654 __isl_keep isl_multi_pw_aff *mpa,
4655 enum isl_dim_type type);
4656 __isl_give isl_id *isl_multi_aff_get_tuple_id(
4657 __isl_keep isl_multi_aff *ma,
4658 enum isl_dim_type type);
4659 __isl_give isl_id *isl_pw_multi_aff_get_tuple_id(
4660 __isl_keep isl_pw_multi_aff *pma,
4661 enum isl_dim_type type);
4662 __isl_give isl_id *isl_multi_pw_aff_get_tuple_id(
4663 __isl_keep isl_multi_pw_aff *mpa,
4664 enum isl_dim_type type);
4665 int isl_multi_aff_range_is_wrapping(
4666 __isl_keep isl_multi_aff *ma);
4667 int isl_multi_pw_aff_range_is_wrapping(
4668 __isl_keep isl_multi_pw_aff *mpa);
4670 int isl_pw_multi_aff_foreach_piece(
4671 __isl_keep isl_pw_multi_aff *pma,
4672 int (*fn)(__isl_take isl_set *set,
4673 __isl_take isl_multi_aff *maff,
4674 void *user), void *user);
4676 int isl_union_pw_multi_aff_foreach_pw_multi_aff(
4677 __isl_keep isl_union_pw_multi_aff *upma,
4678 int (*fn)(__isl_take isl_pw_multi_aff *pma,
4679 void *user), void *user);
4681 It can be modified using
4683 #include <isl/aff.h>
4684 __isl_give isl_multi_aff *isl_multi_aff_set_aff(
4685 __isl_take isl_multi_aff *multi, int pos,
4686 __isl_take isl_aff *aff);
4687 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_pw_aff(
4688 __isl_take isl_pw_multi_aff *pma, unsigned pos,
4689 __isl_take isl_pw_aff *pa);
4690 __isl_give isl_multi_aff *isl_multi_aff_set_dim_name(
4691 __isl_take isl_multi_aff *maff,
4692 enum isl_dim_type type, unsigned pos, const char *s);
4693 __isl_give isl_multi_aff *isl_multi_aff_set_dim_id(
4694 __isl_take isl_multi_aff *maff,
4695 enum isl_dim_type type, unsigned pos,
4696 __isl_take isl_id *id);
4697 __isl_give isl_multi_aff *isl_multi_aff_set_tuple_name(
4698 __isl_take isl_multi_aff *maff,
4699 enum isl_dim_type type, const char *s);
4700 __isl_give isl_multi_aff *isl_multi_aff_set_tuple_id(
4701 __isl_take isl_multi_aff *maff,
4702 enum isl_dim_type type, __isl_take isl_id *id);
4703 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_tuple_id(
4704 __isl_take isl_pw_multi_aff *pma,
4705 enum isl_dim_type type, __isl_take isl_id *id);
4706 __isl_give isl_multi_aff *isl_multi_aff_reset_tuple_id(
4707 __isl_take isl_multi_aff *ma,
4708 enum isl_dim_type type);
4709 __isl_give isl_multi_pw_aff *
4710 isl_multi_pw_aff_reset_tuple_id(
4711 __isl_take isl_multi_pw_aff *mpa,
4712 enum isl_dim_type type);
4713 __isl_give isl_multi_aff *isl_multi_aff_reset_user(
4714 __isl_take isl_multi_aff *ma);
4715 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_reset_user(
4716 __isl_take isl_multi_pw_aff *mpa);
4718 __isl_give isl_multi_pw_aff *
4719 isl_multi_pw_aff_set_dim_name(
4720 __isl_take isl_multi_pw_aff *mpa,
4721 enum isl_dim_type type, unsigned pos, const char *s);
4722 __isl_give isl_multi_pw_aff *
4723 isl_multi_pw_aff_set_dim_id(
4724 __isl_take isl_multi_pw_aff *mpa,
4725 enum isl_dim_type type, unsigned pos,
4726 __isl_take isl_id *id);
4727 __isl_give isl_multi_pw_aff *
4728 isl_multi_pw_aff_set_tuple_name(
4729 __isl_take isl_multi_pw_aff *mpa,
4730 enum isl_dim_type type, const char *s);
4732 __isl_give isl_multi_aff *isl_multi_aff_flatten_domain(
4733 __isl_take isl_multi_aff *ma);
4735 __isl_give isl_multi_aff *isl_multi_aff_insert_dims(
4736 __isl_take isl_multi_aff *ma,
4737 enum isl_dim_type type, unsigned first, unsigned n);
4738 __isl_give isl_multi_aff *isl_multi_aff_add_dims(
4739 __isl_take isl_multi_aff *ma,
4740 enum isl_dim_type type, unsigned n);
4741 __isl_give isl_multi_aff *isl_multi_aff_drop_dims(
4742 __isl_take isl_multi_aff *maff,
4743 enum isl_dim_type type, unsigned first, unsigned n);
4744 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_drop_dims(
4745 __isl_take isl_pw_multi_aff *pma,
4746 enum isl_dim_type type, unsigned first, unsigned n);
4748 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_insert_dims(
4749 __isl_take isl_multi_pw_aff *mpa,
4750 enum isl_dim_type type, unsigned first, unsigned n);
4751 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_add_dims(
4752 __isl_take isl_multi_pw_aff *mpa,
4753 enum isl_dim_type type, unsigned n);
4754 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_move_dims(
4755 __isl_take isl_multi_pw_aff *pma,
4756 enum isl_dim_type dst_type, unsigned dst_pos,
4757 enum isl_dim_type src_type, unsigned src_pos,
4760 To check whether two multiple affine expressions are
4761 (obviously) equal to each other, use
4763 int isl_multi_aff_plain_is_equal(__isl_keep isl_multi_aff *maff1,
4764 __isl_keep isl_multi_aff *maff2);
4765 int isl_pw_multi_aff_plain_is_equal(
4766 __isl_keep isl_pw_multi_aff *pma1,
4767 __isl_keep isl_pw_multi_aff *pma2);
4768 int isl_multi_pw_aff_plain_is_equal(
4769 __isl_keep isl_multi_pw_aff *mpa1,
4770 __isl_keep isl_multi_pw_aff *mpa2);
4771 int isl_multi_pw_aff_is_equal(
4772 __isl_keep isl_multi_pw_aff *mpa1,
4773 __isl_keep isl_multi_pw_aff *mpa2);
4777 #include <isl/aff.h>
4778 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmin(
4779 __isl_take isl_pw_multi_aff *pma1,
4780 __isl_take isl_pw_multi_aff *pma2);
4781 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmax(
4782 __isl_take isl_pw_multi_aff *pma1,
4783 __isl_take isl_pw_multi_aff *pma2);
4784 __isl_give isl_multi_aff *isl_multi_aff_floor(
4785 __isl_take isl_multi_aff *ma);
4786 __isl_give isl_multi_aff *isl_multi_aff_add(
4787 __isl_take isl_multi_aff *maff1,
4788 __isl_take isl_multi_aff *maff2);
4789 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_add(
4790 __isl_take isl_pw_multi_aff *pma1,
4791 __isl_take isl_pw_multi_aff *pma2);
4792 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_add(
4793 __isl_take isl_union_pw_multi_aff *upma1,
4794 __isl_take isl_union_pw_multi_aff *upma2);
4795 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_add(
4796 __isl_take isl_pw_multi_aff *pma1,
4797 __isl_take isl_pw_multi_aff *pma2);
4798 __isl_give isl_multi_aff *isl_multi_aff_sub(
4799 __isl_take isl_multi_aff *ma1,
4800 __isl_take isl_multi_aff *ma2);
4801 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_sub(
4802 __isl_take isl_pw_multi_aff *pma1,
4803 __isl_take isl_pw_multi_aff *pma2);
4804 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_sub(
4805 __isl_take isl_union_pw_multi_aff *upma1,
4806 __isl_take isl_union_pw_multi_aff *upma2);
4808 C<isl_multi_aff_sub> subtracts the second argument from the first.
4810 __isl_give isl_multi_aff *isl_multi_aff_scale_val(
4811 __isl_take isl_multi_aff *ma,
4812 __isl_take isl_val *v);
4813 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_val(
4814 __isl_take isl_pw_multi_aff *pma,
4815 __isl_take isl_val *v);
4816 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_scale_val(
4817 __isl_take isl_multi_pw_aff *mpa,
4818 __isl_take isl_val *v);
4819 __isl_give isl_multi_aff *isl_multi_aff_scale_multi_val(
4820 __isl_take isl_multi_aff *ma,
4821 __isl_take isl_multi_val *mv);
4822 __isl_give isl_pw_multi_aff *
4823 isl_pw_multi_aff_scale_multi_val(
4824 __isl_take isl_pw_multi_aff *pma,
4825 __isl_take isl_multi_val *mv);
4826 __isl_give isl_multi_pw_aff *
4827 isl_multi_pw_aff_scale_multi_val(
4828 __isl_take isl_multi_pw_aff *mpa,
4829 __isl_take isl_multi_val *mv);
4830 __isl_give isl_union_pw_multi_aff *
4831 isl_union_pw_multi_aff_scale_multi_val(
4832 __isl_take isl_union_pw_multi_aff *upma,
4833 __isl_take isl_multi_val *mv);
4834 __isl_give isl_multi_aff *
4835 isl_multi_aff_scale_down_multi_val(
4836 __isl_take isl_multi_aff *ma,
4837 __isl_take isl_multi_val *mv);
4838 __isl_give isl_multi_pw_aff *
4839 isl_multi_pw_aff_scale_down_multi_val(
4840 __isl_take isl_multi_pw_aff *mpa,
4841 __isl_take isl_multi_val *mv);
4843 C<isl_multi_aff_scale_multi_val> scales the elements of C<ma>
4844 by the corresponding elements of C<mv>.
4846 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_fix_si(
4847 __isl_take isl_pw_multi_aff *pma,
4848 enum isl_dim_type type, unsigned pos, int value);
4849 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_params(
4850 __isl_take isl_pw_multi_aff *pma,
4851 __isl_take isl_set *set);
4852 __isl_give isl_set *isl_multi_pw_aff_domain(
4853 __isl_take isl_multi_pw_aff *mpa);
4854 __isl_give isl_multi_pw_aff *
4855 isl_multi_pw_aff_intersect_params(
4856 __isl_take isl_multi_pw_aff *mpa,
4857 __isl_take isl_set *set);
4858 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_domain(
4859 __isl_take isl_pw_multi_aff *pma,
4860 __isl_take isl_set *set);
4861 __isl_give isl_multi_pw_aff *
4862 isl_multi_pw_aff_intersect_domain(
4863 __isl_take isl_multi_pw_aff *mpa,
4864 __isl_take isl_set *domain);
4865 __isl_give isl_union_pw_multi_aff *
4866 isl_union_pw_multi_aff_intersect_domain(
4867 __isl_take isl_union_pw_multi_aff *upma,
4868 __isl_take isl_union_set *uset);
4869 __isl_give isl_multi_aff *isl_multi_aff_lift(
4870 __isl_take isl_multi_aff *maff,
4871 __isl_give isl_local_space **ls);
4872 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_coalesce(
4873 __isl_take isl_pw_multi_aff *pma);
4874 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_coalesce(
4875 __isl_take isl_multi_pw_aff *mpa);
4876 __isl_give isl_multi_aff *isl_multi_aff_align_params(
4877 __isl_take isl_multi_aff *multi,
4878 __isl_take isl_space *model);
4879 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_align_params(
4880 __isl_take isl_pw_multi_aff *pma,
4881 __isl_take isl_space *model);
4882 __isl_give isl_union_pw_multi_aff *
4883 isl_union_pw_multi_aff_align_params(
4884 __isl_take isl_union_pw_multi_aff *upma,
4885 __isl_take isl_space *model);
4886 __isl_give isl_pw_multi_aff *
4887 isl_pw_multi_aff_project_domain_on_params(
4888 __isl_take isl_pw_multi_aff *pma);
4889 __isl_give isl_multi_aff *isl_multi_aff_gist_params(
4890 __isl_take isl_multi_aff *maff,
4891 __isl_take isl_set *context);
4892 __isl_give isl_multi_aff *isl_multi_aff_gist(
4893 __isl_take isl_multi_aff *maff,
4894 __isl_take isl_set *context);
4895 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist_params(
4896 __isl_take isl_pw_multi_aff *pma,
4897 __isl_take isl_set *set);
4898 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist(
4899 __isl_take isl_pw_multi_aff *pma,
4900 __isl_take isl_set *set);
4901 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist_params(
4902 __isl_take isl_multi_pw_aff *mpa,
4903 __isl_take isl_set *set);
4904 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_gist(
4905 __isl_take isl_multi_pw_aff *mpa,
4906 __isl_take isl_set *set);
4907 __isl_give isl_multi_aff *isl_multi_aff_from_range(
4908 __isl_take isl_multi_aff *ma);
4909 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_range(
4910 __isl_take isl_multi_pw_aff *mpa);
4911 __isl_give isl_set *isl_pw_multi_aff_domain(
4912 __isl_take isl_pw_multi_aff *pma);
4913 __isl_give isl_union_set *isl_union_pw_multi_aff_domain(
4914 __isl_take isl_union_pw_multi_aff *upma);
4915 __isl_give isl_multi_aff *isl_multi_aff_range_splice(
4916 __isl_take isl_multi_aff *ma1, unsigned pos,
4917 __isl_take isl_multi_aff *ma2);
4918 __isl_give isl_multi_aff *isl_multi_aff_splice(
4919 __isl_take isl_multi_aff *ma1,
4920 unsigned in_pos, unsigned out_pos,
4921 __isl_take isl_multi_aff *ma2);
4922 __isl_give isl_multi_aff *isl_multi_aff_range_product(
4923 __isl_take isl_multi_aff *ma1,
4924 __isl_take isl_multi_aff *ma2);
4925 __isl_give isl_multi_aff *
4926 isl_multi_aff_range_factor_domain(
4927 __isl_take isl_multi_aff *ma);
4928 __isl_give isl_multi_aff *
4929 isl_multi_aff_range_factor_range(
4930 __isl_take isl_multi_aff *ma);
4931 __isl_give isl_multi_aff *isl_multi_aff_flat_range_product(
4932 __isl_take isl_multi_aff *ma1,
4933 __isl_take isl_multi_aff *ma2);
4934 __isl_give isl_multi_aff *isl_multi_aff_product(
4935 __isl_take isl_multi_aff *ma1,
4936 __isl_take isl_multi_aff *ma2);
4937 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_product(
4938 __isl_take isl_multi_pw_aff *mpa1,
4939 __isl_take isl_multi_pw_aff *mpa2);
4940 __isl_give isl_pw_multi_aff *
4941 isl_pw_multi_aff_range_product(
4942 __isl_take isl_pw_multi_aff *pma1,
4943 __isl_take isl_pw_multi_aff *pma2);
4944 __isl_give isl_multi_pw_aff *
4945 isl_multi_pw_aff_range_factor_domain(
4946 __isl_take isl_multi_pw_aff *mpa);
4947 __isl_give isl_multi_pw_aff *
4948 isl_multi_pw_aff_range_factor_range(
4949 __isl_take isl_multi_pw_aff *mpa);
4950 __isl_give isl_pw_multi_aff *
4951 isl_pw_multi_aff_flat_range_product(
4952 __isl_take isl_pw_multi_aff *pma1,
4953 __isl_take isl_pw_multi_aff *pma2);
4954 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_product(
4955 __isl_take isl_pw_multi_aff *pma1,
4956 __isl_take isl_pw_multi_aff *pma2);
4957 __isl_give isl_union_pw_multi_aff *
4958 isl_union_pw_multi_aff_flat_range_product(
4959 __isl_take isl_union_pw_multi_aff *upma1,
4960 __isl_take isl_union_pw_multi_aff *upma2);
4961 __isl_give isl_multi_pw_aff *
4962 isl_multi_pw_aff_range_splice(
4963 __isl_take isl_multi_pw_aff *mpa1, unsigned pos,
4964 __isl_take isl_multi_pw_aff *mpa2);
4965 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_splice(
4966 __isl_take isl_multi_pw_aff *mpa1,
4967 unsigned in_pos, unsigned out_pos,
4968 __isl_take isl_multi_pw_aff *mpa2);
4969 __isl_give isl_multi_pw_aff *
4970 isl_multi_pw_aff_range_product(
4971 __isl_take isl_multi_pw_aff *mpa1,
4972 __isl_take isl_multi_pw_aff *mpa2);
4973 __isl_give isl_multi_pw_aff *
4974 isl_multi_pw_aff_flat_range_product(
4975 __isl_take isl_multi_pw_aff *mpa1,
4976 __isl_take isl_multi_pw_aff *mpa2);
4978 If the C<ls> argument of C<isl_multi_aff_lift> is not C<NULL>,
4979 then it is assigned the local space that lies at the basis of
4980 the lifting applied.
4982 #include <isl/aff.h>
4983 __isl_give isl_multi_aff *isl_multi_aff_pullback_multi_aff(
4984 __isl_take isl_multi_aff *ma1,
4985 __isl_take isl_multi_aff *ma2);
4986 __isl_give isl_pw_multi_aff *
4987 isl_pw_multi_aff_pullback_multi_aff(
4988 __isl_take isl_pw_multi_aff *pma,
4989 __isl_take isl_multi_aff *ma);
4990 __isl_give isl_multi_pw_aff *
4991 isl_multi_pw_aff_pullback_multi_aff(
4992 __isl_take isl_multi_pw_aff *mpa,
4993 __isl_take isl_multi_aff *ma);
4994 __isl_give isl_pw_multi_aff *
4995 isl_pw_multi_aff_pullback_pw_multi_aff(
4996 __isl_take isl_pw_multi_aff *pma1,
4997 __isl_take isl_pw_multi_aff *pma2);
4998 __isl_give isl_multi_pw_aff *
4999 isl_multi_pw_aff_pullback_pw_multi_aff(
5000 __isl_take isl_multi_pw_aff *mpa,
5001 __isl_take isl_pw_multi_aff *pma);
5002 __isl_give isl_multi_pw_aff *
5003 isl_multi_pw_aff_pullback_multi_pw_aff(
5004 __isl_take isl_multi_pw_aff *mpa1,
5005 __isl_take isl_multi_pw_aff *mpa2);
5007 The function C<isl_multi_aff_pullback_multi_aff> precomposes C<ma1> by C<ma2>.
5008 In other words, C<ma2> is plugged
5011 __isl_give isl_set *isl_multi_aff_lex_le_set(
5012 __isl_take isl_multi_aff *ma1,
5013 __isl_take isl_multi_aff *ma2);
5014 __isl_give isl_set *isl_multi_aff_lex_ge_set(
5015 __isl_take isl_multi_aff *ma1,
5016 __isl_take isl_multi_aff *ma2);
5018 The function C<isl_multi_aff_lex_le_set> returns a set
5019 containing those elements in the shared domain space
5020 where C<ma1> is lexicographically smaller than or
5023 An expression can be read from input using
5025 #include <isl/aff.h>
5026 __isl_give isl_multi_aff *isl_multi_aff_read_from_str(
5027 isl_ctx *ctx, const char *str);
5028 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str(
5029 isl_ctx *ctx, const char *str);
5030 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_read_from_str(
5031 isl_ctx *ctx, const char *str);
5032 __isl_give isl_union_pw_multi_aff *
5033 isl_union_pw_multi_aff_read_from_str(
5034 isl_ctx *ctx, const char *str);
5036 An expression can be printed using
5038 #include <isl/aff.h>
5039 __isl_give isl_printer *isl_printer_print_multi_aff(
5040 __isl_take isl_printer *p,
5041 __isl_keep isl_multi_aff *maff);
5042 __isl_give isl_printer *isl_printer_print_pw_multi_aff(
5043 __isl_take isl_printer *p,
5044 __isl_keep isl_pw_multi_aff *pma);
5045 __isl_give isl_printer *isl_printer_print_union_pw_multi_aff(
5046 __isl_take isl_printer *p,
5047 __isl_keep isl_union_pw_multi_aff *upma);
5048 __isl_give isl_printer *isl_printer_print_multi_pw_aff(
5049 __isl_take isl_printer *p,
5050 __isl_keep isl_multi_pw_aff *mpa);
5054 Points are elements of a set. They can be used to construct
5055 simple sets (boxes) or they can be used to represent the
5056 individual elements of a set.
5057 The zero point (the origin) can be created using
5059 __isl_give isl_point *isl_point_zero(__isl_take isl_space *space);
5061 The coordinates of a point can be inspected, set and changed
5064 __isl_give isl_val *isl_point_get_coordinate_val(
5065 __isl_keep isl_point *pnt,
5066 enum isl_dim_type type, int pos);
5067 __isl_give isl_point *isl_point_set_coordinate_val(
5068 __isl_take isl_point *pnt,
5069 enum isl_dim_type type, int pos,
5070 __isl_take isl_val *v);
5072 __isl_give isl_point *isl_point_add_ui(
5073 __isl_take isl_point *pnt,
5074 enum isl_dim_type type, int pos, unsigned val);
5075 __isl_give isl_point *isl_point_sub_ui(
5076 __isl_take isl_point *pnt,
5077 enum isl_dim_type type, int pos, unsigned val);
5079 Other properties can be obtained using
5081 isl_ctx *isl_point_get_ctx(__isl_keep isl_point *pnt);
5083 Points can be copied or freed using
5085 __isl_give isl_point *isl_point_copy(
5086 __isl_keep isl_point *pnt);
5087 void isl_point_free(__isl_take isl_point *pnt);
5089 A singleton set can be created from a point using
5091 __isl_give isl_basic_set *isl_basic_set_from_point(
5092 __isl_take isl_point *pnt);
5093 __isl_give isl_set *isl_set_from_point(
5094 __isl_take isl_point *pnt);
5096 and a box can be created from two opposite extremal points using
5098 __isl_give isl_basic_set *isl_basic_set_box_from_points(
5099 __isl_take isl_point *pnt1,
5100 __isl_take isl_point *pnt2);
5101 __isl_give isl_set *isl_set_box_from_points(
5102 __isl_take isl_point *pnt1,
5103 __isl_take isl_point *pnt2);
5105 All elements of a B<bounded> (union) set can be enumerated using
5106 the following functions.
5108 int isl_set_foreach_point(__isl_keep isl_set *set,
5109 int (*fn)(__isl_take isl_point *pnt, void *user),
5111 int isl_union_set_foreach_point(__isl_keep isl_union_set *uset,
5112 int (*fn)(__isl_take isl_point *pnt, void *user),
5115 The function C<fn> is called for each integer point in
5116 C<set> with as second argument the last argument of
5117 the C<isl_set_foreach_point> call. The function C<fn>
5118 should return C<0> on success and C<-1> on failure.
5119 In the latter case, C<isl_set_foreach_point> will stop
5120 enumerating and return C<-1> as well.
5121 If the enumeration is performed successfully and to completion,
5122 then C<isl_set_foreach_point> returns C<0>.
5124 To obtain a single point of a (basic) set, use
5126 __isl_give isl_point *isl_basic_set_sample_point(
5127 __isl_take isl_basic_set *bset);
5128 __isl_give isl_point *isl_set_sample_point(
5129 __isl_take isl_set *set);
5131 If C<set> does not contain any (integer) points, then the
5132 resulting point will be ``void'', a property that can be
5135 int isl_point_is_void(__isl_keep isl_point *pnt);
5137 =head2 Piecewise Quasipolynomials
5139 A piecewise quasipolynomial is a particular kind of function that maps
5140 a parametric point to a rational value.
5141 More specifically, a quasipolynomial is a polynomial expression in greatest
5142 integer parts of affine expressions of parameters and variables.
5143 A piecewise quasipolynomial is a subdivision of a given parametric
5144 domain into disjoint cells with a quasipolynomial associated to
5145 each cell. The value of the piecewise quasipolynomial at a given
5146 point is the value of the quasipolynomial associated to the cell
5147 that contains the point. Outside of the union of cells,
5148 the value is assumed to be zero.
5149 For example, the piecewise quasipolynomial
5151 [n] -> { [x] -> ((1 + n) - x) : x <= n and x >= 0 }
5153 maps C<x> to C<1 + n - x> for values of C<x> between C<0> and C<n>.
5154 A given piecewise quasipolynomial has a fixed domain dimension.
5155 Union piecewise quasipolynomials are used to contain piecewise quasipolynomials
5156 defined over different domains.
5157 Piecewise quasipolynomials are mainly used by the C<barvinok>
5158 library for representing the number of elements in a parametric set or map.
5159 For example, the piecewise quasipolynomial above represents
5160 the number of points in the map
5162 [n] -> { [x] -> [y] : x,y >= 0 and 0 <= x + y <= n }
5164 =head3 Input and Output
5166 Piecewise quasipolynomials can be read from input using
5168 __isl_give isl_union_pw_qpolynomial *
5169 isl_union_pw_qpolynomial_read_from_str(
5170 isl_ctx *ctx, const char *str);
5172 Quasipolynomials and piecewise quasipolynomials can be printed
5173 using the following functions.
5175 __isl_give isl_printer *isl_printer_print_qpolynomial(
5176 __isl_take isl_printer *p,
5177 __isl_keep isl_qpolynomial *qp);
5179 __isl_give isl_printer *isl_printer_print_pw_qpolynomial(
5180 __isl_take isl_printer *p,
5181 __isl_keep isl_pw_qpolynomial *pwqp);
5183 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial(
5184 __isl_take isl_printer *p,
5185 __isl_keep isl_union_pw_qpolynomial *upwqp);
5187 The output format of the printer
5188 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
5189 For C<isl_printer_print_union_pw_qpolynomial>, only C<ISL_FORMAT_ISL>
5191 In case of printing in C<ISL_FORMAT_C>, the user may want
5192 to set the names of all dimensions
5194 __isl_give isl_qpolynomial *isl_qpolynomial_set_dim_name(
5195 __isl_take isl_qpolynomial *qp,
5196 enum isl_dim_type type, unsigned pos,
5198 __isl_give isl_pw_qpolynomial *
5199 isl_pw_qpolynomial_set_dim_name(
5200 __isl_take isl_pw_qpolynomial *pwqp,
5201 enum isl_dim_type type, unsigned pos,
5204 =head3 Creating New (Piecewise) Quasipolynomials
5206 Some simple quasipolynomials can be created using the following functions.
5207 More complicated quasipolynomials can be created by applying
5208 operations such as addition and multiplication
5209 on the resulting quasipolynomials
5211 __isl_give isl_qpolynomial *isl_qpolynomial_zero_on_domain(
5212 __isl_take isl_space *domain);
5213 __isl_give isl_qpolynomial *isl_qpolynomial_one_on_domain(
5214 __isl_take isl_space *domain);
5215 __isl_give isl_qpolynomial *isl_qpolynomial_infty_on_domain(
5216 __isl_take isl_space *domain);
5217 __isl_give isl_qpolynomial *isl_qpolynomial_neginfty_on_domain(
5218 __isl_take isl_space *domain);
5219 __isl_give isl_qpolynomial *isl_qpolynomial_nan_on_domain(
5220 __isl_take isl_space *domain);
5221 __isl_give isl_qpolynomial *isl_qpolynomial_val_on_domain(
5222 __isl_take isl_space *domain,
5223 __isl_take isl_val *val);
5224 __isl_give isl_qpolynomial *isl_qpolynomial_var_on_domain(
5225 __isl_take isl_space *domain,
5226 enum isl_dim_type type, unsigned pos);
5227 __isl_give isl_qpolynomial *isl_qpolynomial_from_aff(
5228 __isl_take isl_aff *aff);
5230 Note that the space in which a quasipolynomial lives is a map space
5231 with a one-dimensional range. The C<domain> argument in some of
5232 the functions above corresponds to the domain of this map space.
5234 The zero piecewise quasipolynomial or a piecewise quasipolynomial
5235 with a single cell can be created using the following functions.
5236 Multiple of these single cell piecewise quasipolynomials can
5237 be combined to create more complicated piecewise quasipolynomials.
5239 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero(
5240 __isl_take isl_space *space);
5241 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_alloc(
5242 __isl_take isl_set *set,
5243 __isl_take isl_qpolynomial *qp);
5244 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial(
5245 __isl_take isl_qpolynomial *qp);
5246 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_pw_aff(
5247 __isl_take isl_pw_aff *pwaff);
5249 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_zero(
5250 __isl_take isl_space *space);
5251 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_from_pw_qpolynomial(
5252 __isl_take isl_pw_qpolynomial *pwqp);
5253 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add_pw_qpolynomial(
5254 __isl_take isl_union_pw_qpolynomial *upwqp,
5255 __isl_take isl_pw_qpolynomial *pwqp);
5257 Quasipolynomials can be copied and freed again using the following
5260 __isl_give isl_qpolynomial *isl_qpolynomial_copy(
5261 __isl_keep isl_qpolynomial *qp);
5262 __isl_null isl_qpolynomial *isl_qpolynomial_free(
5263 __isl_take isl_qpolynomial *qp);
5265 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy(
5266 __isl_keep isl_pw_qpolynomial *pwqp);
5267 __isl_null isl_pw_qpolynomial *isl_pw_qpolynomial_free(
5268 __isl_take isl_pw_qpolynomial *pwqp);
5270 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_copy(
5271 __isl_keep isl_union_pw_qpolynomial *upwqp);
5272 __isl_null isl_union_pw_qpolynomial *
5273 isl_union_pw_qpolynomial_free(
5274 __isl_take isl_union_pw_qpolynomial *upwqp);
5276 =head3 Inspecting (Piecewise) Quasipolynomials
5278 To iterate over all piecewise quasipolynomials in a union
5279 piecewise quasipolynomial, use the following function
5281 int isl_union_pw_qpolynomial_foreach_pw_qpolynomial(
5282 __isl_keep isl_union_pw_qpolynomial *upwqp,
5283 int (*fn)(__isl_take isl_pw_qpolynomial *pwqp, void *user),
5286 To extract the piecewise quasipolynomial in a given space from a union, use
5288 __isl_give isl_pw_qpolynomial *
5289 isl_union_pw_qpolynomial_extract_pw_qpolynomial(
5290 __isl_keep isl_union_pw_qpolynomial *upwqp,
5291 __isl_take isl_space *space);
5293 To iterate over the cells in a piecewise quasipolynomial,
5294 use either of the following two functions
5296 int isl_pw_qpolynomial_foreach_piece(
5297 __isl_keep isl_pw_qpolynomial *pwqp,
5298 int (*fn)(__isl_take isl_set *set,
5299 __isl_take isl_qpolynomial *qp,
5300 void *user), void *user);
5301 int isl_pw_qpolynomial_foreach_lifted_piece(
5302 __isl_keep isl_pw_qpolynomial *pwqp,
5303 int (*fn)(__isl_take isl_set *set,
5304 __isl_take isl_qpolynomial *qp,
5305 void *user), void *user);
5307 As usual, the function C<fn> should return C<0> on success
5308 and C<-1> on failure. The difference between
5309 C<isl_pw_qpolynomial_foreach_piece> and
5310 C<isl_pw_qpolynomial_foreach_lifted_piece> is that
5311 C<isl_pw_qpolynomial_foreach_lifted_piece> will first
5312 compute unique representations for all existentially quantified
5313 variables and then turn these existentially quantified variables
5314 into extra set variables, adapting the associated quasipolynomial
5315 accordingly. This means that the C<set> passed to C<fn>
5316 will not have any existentially quantified variables, but that
5317 the dimensions of the sets may be different for different
5318 invocations of C<fn>.
5320 The constant term of a quasipolynomial can be extracted using
5322 __isl_give isl_val *isl_qpolynomial_get_constant_val(
5323 __isl_keep isl_qpolynomial *qp);
5325 To iterate over all terms in a quasipolynomial,
5328 int isl_qpolynomial_foreach_term(
5329 __isl_keep isl_qpolynomial *qp,
5330 int (*fn)(__isl_take isl_term *term,
5331 void *user), void *user);
5333 The terms themselves can be inspected and freed using
5336 unsigned isl_term_dim(__isl_keep isl_term *term,
5337 enum isl_dim_type type);
5338 __isl_give isl_val *isl_term_get_coefficient_val(
5339 __isl_keep isl_term *term);
5340 int isl_term_get_exp(__isl_keep isl_term *term,
5341 enum isl_dim_type type, unsigned pos);
5342 __isl_give isl_aff *isl_term_get_div(
5343 __isl_keep isl_term *term, unsigned pos);
5344 void isl_term_free(__isl_take isl_term *term);
5346 Each term is a product of parameters, set variables and
5347 integer divisions. The function C<isl_term_get_exp>
5348 returns the exponent of a given dimensions in the given term.
5350 =head3 Properties of (Piecewise) Quasipolynomials
5352 To check whether two union piecewise quasipolynomials are
5353 obviously equal, use
5355 int isl_union_pw_qpolynomial_plain_is_equal(
5356 __isl_keep isl_union_pw_qpolynomial *upwqp1,
5357 __isl_keep isl_union_pw_qpolynomial *upwqp2);
5359 =head3 Operations on (Piecewise) Quasipolynomials
5361 __isl_give isl_qpolynomial *isl_qpolynomial_scale_val(
5362 __isl_take isl_qpolynomial *qp,
5363 __isl_take isl_val *v);
5364 __isl_give isl_qpolynomial *isl_qpolynomial_neg(
5365 __isl_take isl_qpolynomial *qp);
5366 __isl_give isl_qpolynomial *isl_qpolynomial_add(
5367 __isl_take isl_qpolynomial *qp1,
5368 __isl_take isl_qpolynomial *qp2);
5369 __isl_give isl_qpolynomial *isl_qpolynomial_sub(
5370 __isl_take isl_qpolynomial *qp1,
5371 __isl_take isl_qpolynomial *qp2);
5372 __isl_give isl_qpolynomial *isl_qpolynomial_mul(
5373 __isl_take isl_qpolynomial *qp1,
5374 __isl_take isl_qpolynomial *qp2);
5375 __isl_give isl_qpolynomial *isl_qpolynomial_pow(
5376 __isl_take isl_qpolynomial *qp, unsigned exponent);
5378 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_fix_val(
5379 __isl_take isl_pw_qpolynomial *pwqp,
5380 enum isl_dim_type type, unsigned n,
5381 __isl_take isl_val *v);
5382 __isl_give isl_pw_qpolynomial *
5383 isl_pw_qpolynomial_scale_val(
5384 __isl_take isl_pw_qpolynomial *pwqp,
5385 __isl_take isl_val *v);
5386 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add(
5387 __isl_take isl_pw_qpolynomial *pwqp1,
5388 __isl_take isl_pw_qpolynomial *pwqp2);
5389 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub(
5390 __isl_take isl_pw_qpolynomial *pwqp1,
5391 __isl_take isl_pw_qpolynomial *pwqp2);
5392 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint(
5393 __isl_take isl_pw_qpolynomial *pwqp1,
5394 __isl_take isl_pw_qpolynomial *pwqp2);
5395 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg(
5396 __isl_take isl_pw_qpolynomial *pwqp);
5397 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul(
5398 __isl_take isl_pw_qpolynomial *pwqp1,
5399 __isl_take isl_pw_qpolynomial *pwqp2);
5400 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_pow(
5401 __isl_take isl_pw_qpolynomial *pwqp, unsigned exponent);
5403 __isl_give isl_union_pw_qpolynomial *
5404 isl_union_pw_qpolynomial_scale_val(
5405 __isl_take isl_union_pw_qpolynomial *upwqp,
5406 __isl_take isl_val *v);
5407 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add(
5408 __isl_take isl_union_pw_qpolynomial *upwqp1,
5409 __isl_take isl_union_pw_qpolynomial *upwqp2);
5410 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub(
5411 __isl_take isl_union_pw_qpolynomial *upwqp1,
5412 __isl_take isl_union_pw_qpolynomial *upwqp2);
5413 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul(
5414 __isl_take isl_union_pw_qpolynomial *upwqp1,
5415 __isl_take isl_union_pw_qpolynomial *upwqp2);
5417 __isl_give isl_val *isl_pw_qpolynomial_eval(
5418 __isl_take isl_pw_qpolynomial *pwqp,
5419 __isl_take isl_point *pnt);
5421 __isl_give isl_val *isl_union_pw_qpolynomial_eval(
5422 __isl_take isl_union_pw_qpolynomial *upwqp,
5423 __isl_take isl_point *pnt);
5425 __isl_give isl_set *isl_pw_qpolynomial_domain(
5426 __isl_take isl_pw_qpolynomial *pwqp);
5427 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_domain(
5428 __isl_take isl_pw_qpolynomial *pwpq,
5429 __isl_take isl_set *set);
5430 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_params(
5431 __isl_take isl_pw_qpolynomial *pwpq,
5432 __isl_take isl_set *set);
5434 __isl_give isl_union_set *isl_union_pw_qpolynomial_domain(
5435 __isl_take isl_union_pw_qpolynomial *upwqp);
5436 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_intersect_domain(
5437 __isl_take isl_union_pw_qpolynomial *upwpq,
5438 __isl_take isl_union_set *uset);
5439 __isl_give isl_union_pw_qpolynomial *
5440 isl_union_pw_qpolynomial_intersect_params(
5441 __isl_take isl_union_pw_qpolynomial *upwpq,
5442 __isl_take isl_set *set);
5444 __isl_give isl_qpolynomial *isl_qpolynomial_align_params(
5445 __isl_take isl_qpolynomial *qp,
5446 __isl_take isl_space *model);
5448 __isl_give isl_qpolynomial *isl_qpolynomial_project_domain_on_params(
5449 __isl_take isl_qpolynomial *qp);
5450 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_project_domain_on_params(
5451 __isl_take isl_pw_qpolynomial *pwqp);
5453 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_coalesce(
5454 __isl_take isl_union_pw_qpolynomial *upwqp);
5456 __isl_give isl_qpolynomial *isl_qpolynomial_gist_params(
5457 __isl_take isl_qpolynomial *qp,
5458 __isl_take isl_set *context);
5459 __isl_give isl_qpolynomial *isl_qpolynomial_gist(
5460 __isl_take isl_qpolynomial *qp,
5461 __isl_take isl_set *context);
5463 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist_params(
5464 __isl_take isl_pw_qpolynomial *pwqp,
5465 __isl_take isl_set *context);
5466 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist(
5467 __isl_take isl_pw_qpolynomial *pwqp,
5468 __isl_take isl_set *context);
5470 __isl_give isl_union_pw_qpolynomial *
5471 isl_union_pw_qpolynomial_gist_params(
5472 __isl_take isl_union_pw_qpolynomial *upwqp,
5473 __isl_take isl_set *context);
5474 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist(
5475 __isl_take isl_union_pw_qpolynomial *upwqp,
5476 __isl_take isl_union_set *context);
5478 The gist operation applies the gist operation to each of
5479 the cells in the domain of the input piecewise quasipolynomial.
5480 The context is also exploited
5481 to simplify the quasipolynomials associated to each cell.
5483 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_to_polynomial(
5484 __isl_take isl_pw_qpolynomial *pwqp, int sign);
5485 __isl_give isl_union_pw_qpolynomial *
5486 isl_union_pw_qpolynomial_to_polynomial(
5487 __isl_take isl_union_pw_qpolynomial *upwqp, int sign);
5489 Approximate each quasipolynomial by a polynomial. If C<sign> is positive,
5490 the polynomial will be an overapproximation. If C<sign> is negative,
5491 it will be an underapproximation. If C<sign> is zero, the approximation
5492 will lie somewhere in between.
5494 =head2 Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions
5496 A piecewise quasipolynomial reduction is a piecewise
5497 reduction (or fold) of quasipolynomials.
5498 In particular, the reduction can be maximum or a minimum.
5499 The objects are mainly used to represent the result of
5500 an upper or lower bound on a quasipolynomial over its domain,
5501 i.e., as the result of the following function.
5503 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound(
5504 __isl_take isl_pw_qpolynomial *pwqp,
5505 enum isl_fold type, int *tight);
5507 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_bound(
5508 __isl_take isl_union_pw_qpolynomial *upwqp,
5509 enum isl_fold type, int *tight);
5511 The C<type> argument may be either C<isl_fold_min> or C<isl_fold_max>.
5512 If C<tight> is not C<NULL>, then C<*tight> is set to C<1>
5513 is the returned bound is known be tight, i.e., for each value
5514 of the parameters there is at least
5515 one element in the domain that reaches the bound.
5516 If the domain of C<pwqp> is not wrapping, then the bound is computed
5517 over all elements in that domain and the result has a purely parametric
5518 domain. If the domain of C<pwqp> is wrapping, then the bound is
5519 computed over the range of the wrapped relation. The domain of the
5520 wrapped relation becomes the domain of the result.
5522 A (piecewise) quasipolynomial reduction can be copied or freed using the
5523 following functions.
5525 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_copy(
5526 __isl_keep isl_qpolynomial_fold *fold);
5527 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_copy(
5528 __isl_keep isl_pw_qpolynomial_fold *pwf);
5529 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_copy(
5530 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
5531 void isl_qpolynomial_fold_free(
5532 __isl_take isl_qpolynomial_fold *fold);
5533 __isl_null isl_pw_qpolynomial_fold *
5534 isl_pw_qpolynomial_fold_free(
5535 __isl_take isl_pw_qpolynomial_fold *pwf);
5536 __isl_null isl_union_pw_qpolynomial_fold *
5537 isl_union_pw_qpolynomial_fold_free(
5538 __isl_take isl_union_pw_qpolynomial_fold *upwf);
5540 =head3 Printing Piecewise Quasipolynomial Reductions
5542 Piecewise quasipolynomial reductions can be printed
5543 using the following function.
5545 __isl_give isl_printer *isl_printer_print_pw_qpolynomial_fold(
5546 __isl_take isl_printer *p,
5547 __isl_keep isl_pw_qpolynomial_fold *pwf);
5548 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial_fold(
5549 __isl_take isl_printer *p,
5550 __isl_keep isl_union_pw_qpolynomial_fold *upwf);
5552 For C<isl_printer_print_pw_qpolynomial_fold>,
5553 output format of the printer
5554 needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>.
5555 For C<isl_printer_print_union_pw_qpolynomial_fold>,
5556 output format of the printer
5557 needs to be set to C<ISL_FORMAT_ISL>.
5558 In case of printing in C<ISL_FORMAT_C>, the user may want
5559 to set the names of all dimensions
5561 __isl_give isl_pw_qpolynomial_fold *
5562 isl_pw_qpolynomial_fold_set_dim_name(
5563 __isl_take isl_pw_qpolynomial_fold *pwf,
5564 enum isl_dim_type type, unsigned pos,
5567 =head3 Inspecting (Piecewise) Quasipolynomial Reductions
5569 To iterate over all piecewise quasipolynomial reductions in a union
5570 piecewise quasipolynomial reduction, use the following function
5572 int isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(
5573 __isl_keep isl_union_pw_qpolynomial_fold *upwf,
5574 int (*fn)(__isl_take isl_pw_qpolynomial_fold *pwf,
5575 void *user), void *user);
5577 To iterate over the cells in a piecewise quasipolynomial reduction,
5578 use either of the following two functions
5580 int isl_pw_qpolynomial_fold_foreach_piece(
5581 __isl_keep isl_pw_qpolynomial_fold *pwf,
5582 int (*fn)(__isl_take isl_set *set,
5583 __isl_take isl_qpolynomial_fold *fold,
5584 void *user), void *user);
5585 int isl_pw_qpolynomial_fold_foreach_lifted_piece(
5586 __isl_keep isl_pw_qpolynomial_fold *pwf,
5587 int (*fn)(__isl_take isl_set *set,
5588 __isl_take isl_qpolynomial_fold *fold,
5589 void *user), void *user);
5591 See L<Inspecting (Piecewise) Quasipolynomials> for an explanation
5592 of the difference between these two functions.
5594 To iterate over all quasipolynomials in a reduction, use
5596 int isl_qpolynomial_fold_foreach_qpolynomial(
5597 __isl_keep isl_qpolynomial_fold *fold,
5598 int (*fn)(__isl_take isl_qpolynomial *qp,
5599 void *user), void *user);
5601 =head3 Properties of Piecewise Quasipolynomial Reductions
5603 To check whether two union piecewise quasipolynomial reductions are
5604 obviously equal, use
5606 int isl_union_pw_qpolynomial_fold_plain_is_equal(
5607 __isl_keep isl_union_pw_qpolynomial_fold *upwf1,
5608 __isl_keep isl_union_pw_qpolynomial_fold *upwf2);
5610 =head3 Operations on Piecewise Quasipolynomial Reductions
5612 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_scale_val(
5613 __isl_take isl_qpolynomial_fold *fold,
5614 __isl_take isl_val *v);
5615 __isl_give isl_pw_qpolynomial_fold *
5616 isl_pw_qpolynomial_fold_scale_val(
5617 __isl_take isl_pw_qpolynomial_fold *pwf,
5618 __isl_take isl_val *v);
5619 __isl_give isl_union_pw_qpolynomial_fold *
5620 isl_union_pw_qpolynomial_fold_scale_val(
5621 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5622 __isl_take isl_val *v);
5624 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add(
5625 __isl_take isl_pw_qpolynomial_fold *pwf1,
5626 __isl_take isl_pw_qpolynomial_fold *pwf2);
5628 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_fold(
5629 __isl_take isl_pw_qpolynomial_fold *pwf1,
5630 __isl_take isl_pw_qpolynomial_fold *pwf2);
5632 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_fold(
5633 __isl_take isl_union_pw_qpolynomial_fold *upwf1,
5634 __isl_take isl_union_pw_qpolynomial_fold *upwf2);
5636 __isl_give isl_val *isl_pw_qpolynomial_fold_eval(
5637 __isl_take isl_pw_qpolynomial_fold *pwf,
5638 __isl_take isl_point *pnt);
5640 __isl_give isl_val *isl_union_pw_qpolynomial_fold_eval(
5641 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5642 __isl_take isl_point *pnt);
5644 __isl_give isl_pw_qpolynomial_fold *
5645 isl_pw_qpolynomial_fold_intersect_params(
5646 __isl_take isl_pw_qpolynomial_fold *pwf,
5647 __isl_take isl_set *set);
5649 __isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain(
5650 __isl_take isl_union_pw_qpolynomial_fold *upwf);
5651 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_intersect_domain(
5652 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5653 __isl_take isl_union_set *uset);
5654 __isl_give isl_union_pw_qpolynomial_fold *
5655 isl_union_pw_qpolynomial_fold_intersect_params(
5656 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5657 __isl_take isl_set *set);
5659 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_project_domain_on_params(
5660 __isl_take isl_pw_qpolynomial_fold *pwf);
5662 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_coalesce(
5663 __isl_take isl_pw_qpolynomial_fold *pwf);
5665 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_coalesce(
5666 __isl_take isl_union_pw_qpolynomial_fold *upwf);
5668 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist_params(
5669 __isl_take isl_qpolynomial_fold *fold,
5670 __isl_take isl_set *context);
5671 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist(
5672 __isl_take isl_qpolynomial_fold *fold,
5673 __isl_take isl_set *context);
5675 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist(
5676 __isl_take isl_pw_qpolynomial_fold *pwf,
5677 __isl_take isl_set *context);
5678 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist_params(
5679 __isl_take isl_pw_qpolynomial_fold *pwf,
5680 __isl_take isl_set *context);
5682 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_gist(
5683 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5684 __isl_take isl_union_set *context);
5685 __isl_give isl_union_pw_qpolynomial_fold *
5686 isl_union_pw_qpolynomial_fold_gist_params(
5687 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5688 __isl_take isl_set *context);
5690 The gist operation applies the gist operation to each of
5691 the cells in the domain of the input piecewise quasipolynomial reduction.
5692 In future, the operation will also exploit the context
5693 to simplify the quasipolynomial reductions associated to each cell.
5695 __isl_give isl_pw_qpolynomial_fold *
5696 isl_set_apply_pw_qpolynomial_fold(
5697 __isl_take isl_set *set,
5698 __isl_take isl_pw_qpolynomial_fold *pwf,
5700 __isl_give isl_pw_qpolynomial_fold *
5701 isl_map_apply_pw_qpolynomial_fold(
5702 __isl_take isl_map *map,
5703 __isl_take isl_pw_qpolynomial_fold *pwf,
5705 __isl_give isl_union_pw_qpolynomial_fold *
5706 isl_union_set_apply_union_pw_qpolynomial_fold(
5707 __isl_take isl_union_set *uset,
5708 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5710 __isl_give isl_union_pw_qpolynomial_fold *
5711 isl_union_map_apply_union_pw_qpolynomial_fold(
5712 __isl_take isl_union_map *umap,
5713 __isl_take isl_union_pw_qpolynomial_fold *upwf,
5716 The functions taking a map
5717 compose the given map with the given piecewise quasipolynomial reduction.
5718 That is, compute a bound (of the same type as C<pwf> or C<upwf> itself)
5719 over all elements in the intersection of the range of the map
5720 and the domain of the piecewise quasipolynomial reduction
5721 as a function of an element in the domain of the map.
5722 The functions taking a set compute a bound over all elements in the
5723 intersection of the set and the domain of the
5724 piecewise quasipolynomial reduction.
5726 =head2 Parametric Vertex Enumeration
5728 The parametric vertex enumeration described in this section
5729 is mainly intended to be used internally and by the C<barvinok>
5732 #include <isl/vertices.h>
5733 __isl_give isl_vertices *isl_basic_set_compute_vertices(
5734 __isl_keep isl_basic_set *bset);
5736 The function C<isl_basic_set_compute_vertices> performs the
5737 actual computation of the parametric vertices and the chamber
5738 decomposition and store the result in an C<isl_vertices> object.
5739 This information can be queried by either iterating over all
5740 the vertices or iterating over all the chambers or cells
5741 and then iterating over all vertices that are active on the chamber.
5743 int isl_vertices_foreach_vertex(
5744 __isl_keep isl_vertices *vertices,
5745 int (*fn)(__isl_take isl_vertex *vertex, void *user),
5748 int isl_vertices_foreach_cell(
5749 __isl_keep isl_vertices *vertices,
5750 int (*fn)(__isl_take isl_cell *cell, void *user),
5752 int isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
5753 int (*fn)(__isl_take isl_vertex *vertex, void *user),
5756 Other operations that can be performed on an C<isl_vertices> object are
5759 isl_ctx *isl_vertices_get_ctx(
5760 __isl_keep isl_vertices *vertices);
5761 int isl_vertices_get_n_vertices(
5762 __isl_keep isl_vertices *vertices);
5763 void isl_vertices_free(__isl_take isl_vertices *vertices);
5765 Vertices can be inspected and destroyed using the following functions.
5767 isl_ctx *isl_vertex_get_ctx(__isl_keep isl_vertex *vertex);
5768 int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
5769 __isl_give isl_basic_set *isl_vertex_get_domain(
5770 __isl_keep isl_vertex *vertex);
5771 __isl_give isl_multi_aff *isl_vertex_get_expr(
5772 __isl_keep isl_vertex *vertex);
5773 void isl_vertex_free(__isl_take isl_vertex *vertex);
5775 C<isl_vertex_get_expr> returns a multiple quasi-affine expression
5776 describing the vertex in terms of the parameters,
5777 while C<isl_vertex_get_domain> returns the activity domain
5780 Chambers can be inspected and destroyed using the following functions.
5782 isl_ctx *isl_cell_get_ctx(__isl_keep isl_cell *cell);
5783 __isl_give isl_basic_set *isl_cell_get_domain(
5784 __isl_keep isl_cell *cell);
5785 void isl_cell_free(__isl_take isl_cell *cell);
5787 =head1 Polyhedral Compilation Library
5789 This section collects functionality in C<isl> that has been specifically
5790 designed for use during polyhedral compilation.
5792 =head2 Dependence Analysis
5794 C<isl> contains specialized functionality for performing
5795 array dataflow analysis. That is, given a I<sink> access relation
5796 and a collection of possible I<source> access relations,
5797 C<isl> can compute relations that describe
5798 for each iteration of the sink access, which iteration
5799 of which of the source access relations was the last
5800 to access the same data element before the given iteration
5802 The resulting dependence relations map source iterations
5803 to the corresponding sink iterations.
5804 To compute standard flow dependences, the sink should be
5805 a read, while the sources should be writes.
5806 If any of the source accesses are marked as being I<may>
5807 accesses, then there will be a dependence from the last
5808 I<must> access B<and> from any I<may> access that follows
5809 this last I<must> access.
5810 In particular, if I<all> sources are I<may> accesses,
5811 then memory based dependence analysis is performed.
5812 If, on the other hand, all sources are I<must> accesses,
5813 then value based dependence analysis is performed.
5815 #include <isl/flow.h>
5817 typedef int (*isl_access_level_before)(void *first, void *second);
5819 __isl_give isl_access_info *isl_access_info_alloc(
5820 __isl_take isl_map *sink,
5821 void *sink_user, isl_access_level_before fn,
5823 __isl_give isl_access_info *isl_access_info_add_source(
5824 __isl_take isl_access_info *acc,
5825 __isl_take isl_map *source, int must,
5827 __isl_null isl_access_info *isl_access_info_free(
5828 __isl_take isl_access_info *acc);
5830 __isl_give isl_flow *isl_access_info_compute_flow(
5831 __isl_take isl_access_info *acc);
5833 int isl_flow_foreach(__isl_keep isl_flow *deps,
5834 int (*fn)(__isl_take isl_map *dep, int must,
5835 void *dep_user, void *user),
5837 __isl_give isl_map *isl_flow_get_no_source(
5838 __isl_keep isl_flow *deps, int must);
5839 void isl_flow_free(__isl_take isl_flow *deps);
5841 The function C<isl_access_info_compute_flow> performs the actual
5842 dependence analysis. The other functions are used to construct
5843 the input for this function or to read off the output.
5845 The input is collected in an C<isl_access_info>, which can
5846 be created through a call to C<isl_access_info_alloc>.
5847 The arguments to this functions are the sink access relation
5848 C<sink>, a token C<sink_user> used to identify the sink
5849 access to the user, a callback function for specifying the
5850 relative order of source and sink accesses, and the number
5851 of source access relations that will be added.
5852 The callback function has type C<int (*)(void *first, void *second)>.
5853 The function is called with two user supplied tokens identifying
5854 either a source or the sink and it should return the shared nesting
5855 level and the relative order of the two accesses.
5856 In particular, let I<n> be the number of loops shared by
5857 the two accesses. If C<first> precedes C<second> textually,
5858 then the function should return I<2 * n + 1>; otherwise,
5859 it should return I<2 * n>.
5860 The sources can be added to the C<isl_access_info> by performing
5861 (at most) C<max_source> calls to C<isl_access_info_add_source>.
5862 C<must> indicates whether the source is a I<must> access
5863 or a I<may> access. Note that a multi-valued access relation
5864 should only be marked I<must> if every iteration in the domain
5865 of the relation accesses I<all> elements in its image.
5866 The C<source_user> token is again used to identify
5867 the source access. The range of the source access relation
5868 C<source> should have the same dimension as the range
5869 of the sink access relation.
5870 The C<isl_access_info_free> function should usually not be
5871 called explicitly, because it is called implicitly by
5872 C<isl_access_info_compute_flow>.
5874 The result of the dependence analysis is collected in an
5875 C<isl_flow>. There may be elements of
5876 the sink access for which no preceding source access could be
5877 found or for which all preceding sources are I<may> accesses.
5878 The relations containing these elements can be obtained through
5879 calls to C<isl_flow_get_no_source>, the first with C<must> set
5880 and the second with C<must> unset.
5881 In the case of standard flow dependence analysis,
5882 with the sink a read and the sources I<must> writes,
5883 the first relation corresponds to the reads from uninitialized
5884 array elements and the second relation is empty.
5885 The actual flow dependences can be extracted using
5886 C<isl_flow_foreach>. This function will call the user-specified
5887 callback function C<fn> for each B<non-empty> dependence between
5888 a source and the sink. The callback function is called
5889 with four arguments, the actual flow dependence relation
5890 mapping source iterations to sink iterations, a boolean that
5891 indicates whether it is a I<must> or I<may> dependence, a token
5892 identifying the source and an additional C<void *> with value
5893 equal to the third argument of the C<isl_flow_foreach> call.
5894 A dependence is marked I<must> if it originates from a I<must>
5895 source and if it is not followed by any I<may> sources.
5897 After finishing with an C<isl_flow>, the user should call
5898 C<isl_flow_free> to free all associated memory.
5900 A higher-level interface to dependence analysis is provided
5901 by the following function.
5903 #include <isl/flow.h>
5905 int isl_union_map_compute_flow(__isl_take isl_union_map *sink,
5906 __isl_take isl_union_map *must_source,
5907 __isl_take isl_union_map *may_source,
5908 __isl_take isl_union_map *schedule,
5909 __isl_give isl_union_map **must_dep,
5910 __isl_give isl_union_map **may_dep,
5911 __isl_give isl_union_map **must_no_source,
5912 __isl_give isl_union_map **may_no_source);
5914 The arrays are identified by the tuple names of the ranges
5915 of the accesses. The iteration domains by the tuple names
5916 of the domains of the accesses and of the schedule.
5917 The relative order of the iteration domains is given by the
5918 schedule. The relations returned through C<must_no_source>
5919 and C<may_no_source> are subsets of C<sink>.
5920 Any of C<must_dep>, C<may_dep>, C<must_no_source>
5921 or C<may_no_source> may be C<NULL>, but a C<NULL> value for
5922 any of the other arguments is treated as an error.
5924 =head3 Interaction with Dependence Analysis
5926 During the dependence analysis, we frequently need to perform
5927 the following operation. Given a relation between sink iterations
5928 and potential source iterations from a particular source domain,
5929 what is the last potential source iteration corresponding to each
5930 sink iteration. It can sometimes be convenient to adjust
5931 the set of potential source iterations before or after each such operation.
5932 The prototypical example is fuzzy array dataflow analysis,
5933 where we need to analyze if, based on data-dependent constraints,
5934 the sink iteration can ever be executed without one or more of
5935 the corresponding potential source iterations being executed.
5936 If so, we can introduce extra parameters and select an unknown
5937 but fixed source iteration from the potential source iterations.
5938 To be able to perform such manipulations, C<isl> provides the following
5941 #include <isl/flow.h>
5943 typedef __isl_give isl_restriction *(*isl_access_restrict)(
5944 __isl_keep isl_map *source_map,
5945 __isl_keep isl_set *sink, void *source_user,
5947 __isl_give isl_access_info *isl_access_info_set_restrict(
5948 __isl_take isl_access_info *acc,
5949 isl_access_restrict fn, void *user);
5951 The function C<isl_access_info_set_restrict> should be called
5952 before calling C<isl_access_info_compute_flow> and registers a callback function
5953 that will be called any time C<isl> is about to compute the last
5954 potential source. The first argument is the (reverse) proto-dependence,
5955 mapping sink iterations to potential source iterations.
5956 The second argument represents the sink iterations for which
5957 we want to compute the last source iteration.
5958 The third argument is the token corresponding to the source
5959 and the final argument is the token passed to C<isl_access_info_set_restrict>.
5960 The callback is expected to return a restriction on either the input or
5961 the output of the operation computing the last potential source.
5962 If the input needs to be restricted then restrictions are needed
5963 for both the source and the sink iterations. The sink iterations
5964 and the potential source iterations will be intersected with these sets.
5965 If the output needs to be restricted then only a restriction on the source
5966 iterations is required.
5967 If any error occurs, the callback should return C<NULL>.
5968 An C<isl_restriction> object can be created, freed and inspected
5969 using the following functions.
5971 #include <isl/flow.h>
5973 __isl_give isl_restriction *isl_restriction_input(
5974 __isl_take isl_set *source_restr,
5975 __isl_take isl_set *sink_restr);
5976 __isl_give isl_restriction *isl_restriction_output(
5977 __isl_take isl_set *source_restr);
5978 __isl_give isl_restriction *isl_restriction_none(
5979 __isl_take isl_map *source_map);
5980 __isl_give isl_restriction *isl_restriction_empty(
5981 __isl_take isl_map *source_map);
5982 __isl_null isl_restriction *isl_restriction_free(
5983 __isl_take isl_restriction *restr);
5984 isl_ctx *isl_restriction_get_ctx(
5985 __isl_keep isl_restriction *restr);
5987 C<isl_restriction_none> and C<isl_restriction_empty> are special
5988 cases of C<isl_restriction_input>. C<isl_restriction_none>
5989 is essentially equivalent to
5991 isl_restriction_input(isl_set_universe(
5992 isl_space_range(isl_map_get_space(source_map))),
5994 isl_space_domain(isl_map_get_space(source_map))));
5996 whereas C<isl_restriction_empty> is essentially equivalent to
5998 isl_restriction_input(isl_set_empty(
5999 isl_space_range(isl_map_get_space(source_map))),
6001 isl_space_domain(isl_map_get_space(source_map))));
6005 B<The functionality described in this section is fairly new
6006 and may be subject to change.>
6008 #include <isl/schedule.h>
6009 __isl_give isl_schedule *
6010 isl_schedule_constraints_compute_schedule(
6011 __isl_take isl_schedule_constraints *sc);
6012 __isl_null isl_schedule *isl_schedule_free(
6013 __isl_take isl_schedule *sched);
6015 The function C<isl_schedule_constraints_compute_schedule> can be
6016 used to compute a schedule that satisfies the given schedule constraints.
6017 These schedule constraints include the iteration domain for which
6018 a schedule should be computed and dependences between pairs of
6019 iterations. In particular, these dependences include
6020 I<validity> dependences and I<proximity> dependences.
6021 By default, the algorithm used to construct the schedule is similar
6022 to that of C<Pluto>.
6023 Alternatively, Feautrier's multi-dimensional scheduling algorithm can
6025 The generated schedule respects all validity dependences.
6026 That is, all dependence distances over these dependences in the
6027 scheduled space are lexicographically positive.
6028 The default algorithm tries to ensure that the dependence distances
6029 over coincidence constraints are zero and to minimize the
6030 dependence distances over proximity dependences.
6031 Moreover, it tries to obtain sequences (bands) of schedule dimensions
6032 for groups of domains where the dependence distances over validity
6033 dependences have only non-negative values.
6034 When using Feautrier's algorithm, the coincidence and proximity constraints
6035 are only taken into account during the extension to a
6036 full-dimensional schedule.
6038 An C<isl_schedule_constraints> object can be constructed
6039 and manipulated using the following functions.
6041 #include <isl/schedule.h>
6042 __isl_give isl_schedule_constraints *
6043 isl_schedule_constraints_copy(
6044 __isl_keep isl_schedule_constraints *sc);
6045 __isl_give isl_schedule_constraints *
6046 isl_schedule_constraints_on_domain(
6047 __isl_take isl_union_set *domain);
6048 isl_ctx *isl_schedule_constraints_get_ctx(
6049 __isl_keep isl_schedule_constraints *sc);
6050 __isl_give isl_schedule_constraints *
6051 isl_schedule_constraints_set_validity(
6052 __isl_take isl_schedule_constraints *sc,
6053 __isl_take isl_union_map *validity);
6054 __isl_give isl_schedule_constraints *
6055 isl_schedule_constraints_set_coincidence(
6056 __isl_take isl_schedule_constraints *sc,
6057 __isl_take isl_union_map *coincidence);
6058 __isl_give isl_schedule_constraints *
6059 isl_schedule_constraints_set_proximity(
6060 __isl_take isl_schedule_constraints *sc,
6061 __isl_take isl_union_map *proximity);
6062 __isl_give isl_schedule_constraints *
6063 isl_schedule_constraints_set_conditional_validity(
6064 __isl_take isl_schedule_constraints *sc,
6065 __isl_take isl_union_map *condition,
6066 __isl_take isl_union_map *validity);
6067 __isl_null isl_schedule_constraints *
6068 isl_schedule_constraints_free(
6069 __isl_take isl_schedule_constraints *sc);
6071 The initial C<isl_schedule_constraints> object created by
6072 C<isl_schedule_constraints_on_domain> does not impose any constraints.
6073 That is, it has an empty set of dependences.
6074 The function C<isl_schedule_constraints_set_validity> replaces the
6075 validity dependences, mapping domain elements I<i> to domain
6076 elements that should be scheduled after I<i>.
6077 The function C<isl_schedule_constraints_set_coincidence> replaces the
6078 coincidence dependences, mapping domain elements I<i> to domain
6079 elements that should be scheduled together with I<I>, if possible.
6080 The function C<isl_schedule_constraints_set_proximity> replaces the
6081 proximity dependences, mapping domain elements I<i> to domain
6082 elements that should be scheduled either before I<I>
6083 or as early as possible after I<i>.
6085 The function C<isl_schedule_constraints_set_conditional_validity>
6086 replaces the conditional validity constraints.
6087 A conditional validity constraint is only imposed when any of the corresponding
6088 conditions is satisfied, i.e., when any of them is non-zero.
6089 That is, the scheduler ensures that within each band if the dependence
6090 distances over the condition constraints are not all zero
6091 then all corresponding conditional validity constraints are respected.
6092 A conditional validity constraint corresponds to a condition
6093 if the two are adjacent, i.e., if the domain of one relation intersect
6094 the range of the other relation.
6095 The typical use case of conditional validity constraints is
6096 to allow order constraints between live ranges to be violated
6097 as long as the live ranges themselves are local to the band.
6098 To allow more fine-grained control over which conditions correspond
6099 to which conditional validity constraints, the domains and ranges
6100 of these relations may include I<tags>. That is, the domains and
6101 ranges of those relation may themselves be wrapped relations
6102 where the iteration domain appears in the domain of those wrapped relations
6103 and the range of the wrapped relations can be arbitrarily chosen
6104 by the user. Conditions and conditional validity constraints are only
6105 considered adjacent to each other if the entire wrapped relation matches.
6106 In particular, a relation with a tag will never be considered adjacent
6107 to a relation without a tag.
6109 The following function computes a schedule directly from
6110 an iteration domain and validity and proximity dependences
6111 and is implemented in terms of the functions described above.
6112 The use of C<isl_union_set_compute_schedule> is discouraged.
6114 #include <isl/schedule.h>
6115 __isl_give isl_schedule *isl_union_set_compute_schedule(
6116 __isl_take isl_union_set *domain,
6117 __isl_take isl_union_map *validity,
6118 __isl_take isl_union_map *proximity);
6120 A mapping from the domains to the scheduled space can be obtained
6121 from an C<isl_schedule> using the following function.
6123 __isl_give isl_union_map *isl_schedule_get_map(
6124 __isl_keep isl_schedule *sched);
6126 A representation of the schedule can be printed using
6128 __isl_give isl_printer *isl_printer_print_schedule(
6129 __isl_take isl_printer *p,
6130 __isl_keep isl_schedule *schedule);
6132 A representation of the schedule as a forest of bands can be obtained
6133 using the following function.
6135 __isl_give isl_band_list *isl_schedule_get_band_forest(
6136 __isl_keep isl_schedule *schedule);
6138 The individual bands can be visited in depth-first post-order
6139 using the following function.
6141 #include <isl/schedule.h>
6142 int isl_schedule_foreach_band(
6143 __isl_keep isl_schedule *sched,
6144 int (*fn)(__isl_keep isl_band *band, void *user),
6147 The list can be manipulated as explained in L<"Lists">.
6148 The bands inside the list can be copied and freed using the following
6151 #include <isl/band.h>
6152 __isl_give isl_band *isl_band_copy(
6153 __isl_keep isl_band *band);
6154 __isl_null isl_band *isl_band_free(
6155 __isl_take isl_band *band);
6157 Each band contains zero or more scheduling dimensions.
6158 These are referred to as the members of the band.
6159 The section of the schedule that corresponds to the band is
6160 referred to as the partial schedule of the band.
6161 For those nodes that participate in a band, the outer scheduling
6162 dimensions form the prefix schedule, while the inner scheduling
6163 dimensions form the suffix schedule.
6164 That is, if we take a cut of the band forest, then the union of
6165 the concatenations of the prefix, partial and suffix schedules of
6166 each band in the cut is equal to the entire schedule (modulo
6167 some possible padding at the end with zero scheduling dimensions).
6168 The properties of a band can be inspected using the following functions.
6170 #include <isl/band.h>
6171 isl_ctx *isl_band_get_ctx(__isl_keep isl_band *band);
6173 int isl_band_has_children(__isl_keep isl_band *band);
6174 __isl_give isl_band_list *isl_band_get_children(
6175 __isl_keep isl_band *band);
6177 __isl_give isl_union_map *isl_band_get_prefix_schedule(
6178 __isl_keep isl_band *band);
6179 __isl_give isl_union_map *isl_band_get_partial_schedule(
6180 __isl_keep isl_band *band);
6181 __isl_give isl_union_map *isl_band_get_suffix_schedule(
6182 __isl_keep isl_band *band);
6184 int isl_band_n_member(__isl_keep isl_band *band);
6185 int isl_band_member_is_coincident(
6186 __isl_keep isl_band *band, int pos);
6188 int isl_band_list_foreach_band(
6189 __isl_keep isl_band_list *list,
6190 int (*fn)(__isl_keep isl_band *band, void *user),
6193 Note that a scheduling dimension is considered to be ``coincident''
6194 if it satisfies the coincidence constraints within its band.
6195 That is, if the dependence distances of the coincidence
6196 constraints are all zero in that direction (for fixed
6197 iterations of outer bands).
6198 Like C<isl_schedule_foreach_band>,
6199 the function C<isl_band_list_foreach_band> calls C<fn> on the bands
6200 in depth-first post-order.
6202 A band can be tiled using the following function.
6204 #include <isl/band.h>
6205 int isl_band_tile(__isl_keep isl_band *band,
6206 __isl_take isl_vec *sizes);
6208 int isl_options_set_tile_scale_tile_loops(isl_ctx *ctx,
6210 int isl_options_get_tile_scale_tile_loops(isl_ctx *ctx);
6211 int isl_options_set_tile_shift_point_loops(isl_ctx *ctx,
6213 int isl_options_get_tile_shift_point_loops(isl_ctx *ctx);
6215 The C<isl_band_tile> function tiles the band using the given tile sizes
6216 inside its schedule.
6217 A new child band is created to represent the point loops and it is
6218 inserted between the modified band and its children.
6219 The C<tile_scale_tile_loops> option specifies whether the tile
6220 loops iterators should be scaled by the tile sizes.
6221 If the C<tile_shift_point_loops> option is set, then the point loops
6222 are shifted to start at zero.
6224 A band can be split into two nested bands using the following function.
6226 int isl_band_split(__isl_keep isl_band *band, int pos);
6228 The resulting outer band contains the first C<pos> dimensions of C<band>
6229 while the inner band contains the remaining dimensions.
6231 A representation of the band can be printed using
6233 #include <isl/band.h>
6234 __isl_give isl_printer *isl_printer_print_band(
6235 __isl_take isl_printer *p,
6236 __isl_keep isl_band *band);
6240 #include <isl/schedule.h>
6241 int isl_options_set_schedule_max_coefficient(
6242 isl_ctx *ctx, int val);
6243 int isl_options_get_schedule_max_coefficient(
6245 int isl_options_set_schedule_max_constant_term(
6246 isl_ctx *ctx, int val);
6247 int isl_options_get_schedule_max_constant_term(
6249 int isl_options_set_schedule_fuse(isl_ctx *ctx, int val);
6250 int isl_options_get_schedule_fuse(isl_ctx *ctx);
6251 int isl_options_set_schedule_maximize_band_depth(
6252 isl_ctx *ctx, int val);
6253 int isl_options_get_schedule_maximize_band_depth(
6255 int isl_options_set_schedule_outer_coincidence(
6256 isl_ctx *ctx, int val);
6257 int isl_options_get_schedule_outer_coincidence(
6259 int isl_options_set_schedule_split_scaled(
6260 isl_ctx *ctx, int val);
6261 int isl_options_get_schedule_split_scaled(
6263 int isl_options_set_schedule_algorithm(
6264 isl_ctx *ctx, int val);
6265 int isl_options_get_schedule_algorithm(
6267 int isl_options_set_schedule_separate_components(
6268 isl_ctx *ctx, int val);
6269 int isl_options_get_schedule_separate_components(
6274 =item * schedule_max_coefficient
6276 This option enforces that the coefficients for variable and parameter
6277 dimensions in the calculated schedule are not larger than the specified value.
6278 This option can significantly increase the speed of the scheduling calculation
6279 and may also prevent fusing of unrelated dimensions. A value of -1 means that
6280 this option does not introduce bounds on the variable or parameter
6283 =item * schedule_max_constant_term
6285 This option enforces that the constant coefficients in the calculated schedule
6286 are not larger than the maximal constant term. This option can significantly
6287 increase the speed of the scheduling calculation and may also prevent fusing of
6288 unrelated dimensions. A value of -1 means that this option does not introduce
6289 bounds on the constant coefficients.
6291 =item * schedule_fuse
6293 This option controls the level of fusion.
6294 If this option is set to C<ISL_SCHEDULE_FUSE_MIN>, then loops in the
6295 resulting schedule will be distributed as much as possible.
6296 If this option is set to C<ISL_SCHEDULE_FUSE_MAX>, then C<isl> will
6297 try to fuse loops in the resulting schedule.
6299 =item * schedule_maximize_band_depth
6301 If this option is set, we do not split bands at the point
6302 where we detect splitting is necessary. Instead, we
6303 backtrack and split bands as early as possible. This
6304 reduces the number of splits and maximizes the width of
6305 the bands. Wider bands give more possibilities for tiling.
6306 Note that if the C<schedule_fuse> option is set to C<ISL_SCHEDULE_FUSE_MIN>,
6307 then bands will be split as early as possible, even if there is no need.
6308 The C<schedule_maximize_band_depth> option therefore has no effect in this case.
6310 =item * schedule_outer_coincidence
6312 If this option is set, then we try to construct schedules
6313 where the outermost scheduling dimension in each band
6314 satisfies the coincidence constraints.
6316 =item * schedule_split_scaled
6318 If this option is set, then we try to construct schedules in which the
6319 constant term is split off from the linear part if the linear parts of
6320 the scheduling rows for all nodes in the graphs have a common non-trivial
6322 The constant term is then placed in a separate band and the linear
6325 =item * schedule_algorithm
6327 Selects the scheduling algorithm to be used.
6328 Available scheduling algorithms are C<ISL_SCHEDULE_ALGORITHM_ISL>
6329 and C<ISL_SCHEDULE_ALGORITHM_FEAUTRIER>.
6331 =item * schedule_separate_components
6333 If at any point the dependence graph contains any (weakly connected) components,
6334 then these components are scheduled separately.
6335 If this option is not set, then some iterations of the domains
6336 in these components may be scheduled together.
6337 If this option is set, then the components are given consecutive
6342 =head2 AST Generation
6344 This section describes the C<isl> functionality for generating
6345 ASTs that visit all the elements
6346 in a domain in an order specified by a schedule.
6347 In particular, given a C<isl_union_map>, an AST is generated
6348 that visits all the elements in the domain of the C<isl_union_map>
6349 according to the lexicographic order of the corresponding image
6350 element(s). If the range of the C<isl_union_map> consists of
6351 elements in more than one space, then each of these spaces is handled
6352 separately in an arbitrary order.
6353 It should be noted that the image elements only specify the I<order>
6354 in which the corresponding domain elements should be visited.
6355 No direct relation between the image elements and the loop iterators
6356 in the generated AST should be assumed.
6358 Each AST is generated within a build. The initial build
6359 simply specifies the constraints on the parameters (if any)
6360 and can be created, inspected, copied and freed using the following functions.
6362 #include <isl/ast_build.h>
6363 __isl_give isl_ast_build *isl_ast_build_from_context(
6364 __isl_take isl_set *set);
6365 isl_ctx *isl_ast_build_get_ctx(
6366 __isl_keep isl_ast_build *build);
6367 __isl_give isl_ast_build *isl_ast_build_copy(
6368 __isl_keep isl_ast_build *build);
6369 __isl_null isl_ast_build *isl_ast_build_free(
6370 __isl_take isl_ast_build *build);
6372 The C<set> argument is usually a parameter set with zero or more parameters.
6373 More C<isl_ast_build> functions are described in L</"Nested AST Generation">
6374 and L</"Fine-grained Control over AST Generation">.
6375 Finally, the AST itself can be constructed using the following
6378 #include <isl/ast_build.h>
6379 __isl_give isl_ast_node *isl_ast_build_ast_from_schedule(
6380 __isl_keep isl_ast_build *build,
6381 __isl_take isl_union_map *schedule);
6383 =head3 Inspecting the AST
6385 The basic properties of an AST node can be obtained as follows.
6387 #include <isl/ast.h>
6388 isl_ctx *isl_ast_node_get_ctx(
6389 __isl_keep isl_ast_node *node);
6390 enum isl_ast_node_type isl_ast_node_get_type(
6391 __isl_keep isl_ast_node *node);
6393 The type of an AST node is one of
6394 C<isl_ast_node_for>,
6396 C<isl_ast_node_block> or
6397 C<isl_ast_node_user>.
6398 An C<isl_ast_node_for> represents a for node.
6399 An C<isl_ast_node_if> represents an if node.
6400 An C<isl_ast_node_block> represents a compound node.
6401 An C<isl_ast_node_user> represents an expression statement.
6402 An expression statement typically corresponds to a domain element, i.e.,
6403 one of the elements that is visited by the AST.
6405 Each type of node has its own additional properties.
6407 #include <isl/ast.h>
6408 __isl_give isl_ast_expr *isl_ast_node_for_get_iterator(
6409 __isl_keep isl_ast_node *node);
6410 __isl_give isl_ast_expr *isl_ast_node_for_get_init(
6411 __isl_keep isl_ast_node *node);
6412 __isl_give isl_ast_expr *isl_ast_node_for_get_cond(
6413 __isl_keep isl_ast_node *node);
6414 __isl_give isl_ast_expr *isl_ast_node_for_get_inc(
6415 __isl_keep isl_ast_node *node);
6416 __isl_give isl_ast_node *isl_ast_node_for_get_body(
6417 __isl_keep isl_ast_node *node);
6418 int isl_ast_node_for_is_degenerate(
6419 __isl_keep isl_ast_node *node);
6421 An C<isl_ast_for> is considered degenerate if it is known to execute
6424 #include <isl/ast.h>
6425 __isl_give isl_ast_expr *isl_ast_node_if_get_cond(
6426 __isl_keep isl_ast_node *node);
6427 __isl_give isl_ast_node *isl_ast_node_if_get_then(
6428 __isl_keep isl_ast_node *node);
6429 int isl_ast_node_if_has_else(
6430 __isl_keep isl_ast_node *node);
6431 __isl_give isl_ast_node *isl_ast_node_if_get_else(
6432 __isl_keep isl_ast_node *node);
6434 __isl_give isl_ast_node_list *
6435 isl_ast_node_block_get_children(
6436 __isl_keep isl_ast_node *node);
6438 __isl_give isl_ast_expr *isl_ast_node_user_get_expr(
6439 __isl_keep isl_ast_node *node);
6441 Each of the returned C<isl_ast_expr>s can in turn be inspected using
6442 the following functions.
6444 #include <isl/ast.h>
6445 isl_ctx *isl_ast_expr_get_ctx(
6446 __isl_keep isl_ast_expr *expr);
6447 enum isl_ast_expr_type isl_ast_expr_get_type(
6448 __isl_keep isl_ast_expr *expr);
6450 The type of an AST expression is one of
6452 C<isl_ast_expr_id> or
6453 C<isl_ast_expr_int>.
6454 An C<isl_ast_expr_op> represents the result of an operation.
6455 An C<isl_ast_expr_id> represents an identifier.
6456 An C<isl_ast_expr_int> represents an integer value.
6458 Each type of expression has its own additional properties.
6460 #include <isl/ast.h>
6461 enum isl_ast_op_type isl_ast_expr_get_op_type(
6462 __isl_keep isl_ast_expr *expr);
6463 int isl_ast_expr_get_op_n_arg(__isl_keep isl_ast_expr *expr);
6464 __isl_give isl_ast_expr *isl_ast_expr_get_op_arg(
6465 __isl_keep isl_ast_expr *expr, int pos);
6466 int isl_ast_node_foreach_ast_op_type(
6467 __isl_keep isl_ast_node *node,
6468 int (*fn)(enum isl_ast_op_type type, void *user),
6471 C<isl_ast_expr_get_op_type> returns the type of the operation
6472 performed. C<isl_ast_expr_get_op_n_arg> returns the number of
6473 arguments. C<isl_ast_expr_get_op_arg> returns the specified
6475 C<isl_ast_node_foreach_ast_op_type> calls C<fn> for each distinct
6476 C<isl_ast_op_type> that appears in C<node>.
6477 The operation type is one of the following.
6481 =item C<isl_ast_op_and>
6483 Logical I<and> of two arguments.
6484 Both arguments can be evaluated.
6486 =item C<isl_ast_op_and_then>
6488 Logical I<and> of two arguments.
6489 The second argument can only be evaluated if the first evaluates to true.
6491 =item C<isl_ast_op_or>
6493 Logical I<or> of two arguments.
6494 Both arguments can be evaluated.
6496 =item C<isl_ast_op_or_else>
6498 Logical I<or> of two arguments.
6499 The second argument can only be evaluated if the first evaluates to false.
6501 =item C<isl_ast_op_max>
6503 Maximum of two or more arguments.
6505 =item C<isl_ast_op_min>
6507 Minimum of two or more arguments.
6509 =item C<isl_ast_op_minus>
6513 =item C<isl_ast_op_add>
6515 Sum of two arguments.
6517 =item C<isl_ast_op_sub>
6519 Difference of two arguments.
6521 =item C<isl_ast_op_mul>
6523 Product of two arguments.
6525 =item C<isl_ast_op_div>
6527 Exact division. That is, the result is known to be an integer.
6529 =item C<isl_ast_op_fdiv_q>
6531 Result of integer division, rounded towards negative
6534 =item C<isl_ast_op_pdiv_q>
6536 Result of integer division, where dividend is known to be non-negative.
6538 =item C<isl_ast_op_pdiv_r>
6540 Remainder of integer division, where dividend is known to be non-negative.
6542 =item C<isl_ast_op_cond>
6544 Conditional operator defined on three arguments.
6545 If the first argument evaluates to true, then the result
6546 is equal to the second argument. Otherwise, the result
6547 is equal to the third argument.
6548 The second and third argument may only be evaluated if
6549 the first argument evaluates to true and false, respectively.
6550 Corresponds to C<a ? b : c> in C.
6552 =item C<isl_ast_op_select>
6554 Conditional operator defined on three arguments.
6555 If the first argument evaluates to true, then the result
6556 is equal to the second argument. Otherwise, the result
6557 is equal to the third argument.
6558 The second and third argument may be evaluated independently
6559 of the value of the first argument.
6560 Corresponds to C<a * b + (1 - a) * c> in C.
6562 =item C<isl_ast_op_eq>
6566 =item C<isl_ast_op_le>
6568 Less than or equal relation.
6570 =item C<isl_ast_op_lt>
6574 =item C<isl_ast_op_ge>
6576 Greater than or equal relation.
6578 =item C<isl_ast_op_gt>
6580 Greater than relation.
6582 =item C<isl_ast_op_call>
6585 The number of arguments of the C<isl_ast_expr> is one more than
6586 the number of arguments in the function call, the first argument
6587 representing the function being called.
6589 =item C<isl_ast_op_access>
6592 The number of arguments of the C<isl_ast_expr> is one more than
6593 the number of index expressions in the array access, the first argument
6594 representing the array being accessed.
6596 =item C<isl_ast_op_member>
6599 This operation has two arguments, a structure and the name of
6600 the member of the structure being accessed.
6604 #include <isl/ast.h>
6605 __isl_give isl_id *isl_ast_expr_get_id(
6606 __isl_keep isl_ast_expr *expr);
6608 Return the identifier represented by the AST expression.
6610 #include <isl/ast.h>
6611 __isl_give isl_val *isl_ast_expr_get_val(
6612 __isl_keep isl_ast_expr *expr);
6614 Return the integer represented by the AST expression.
6616 =head3 Properties of ASTs
6618 #include <isl/ast.h>
6619 int isl_ast_expr_is_equal(__isl_keep isl_ast_expr *expr1,
6620 __isl_keep isl_ast_expr *expr2);
6622 Check if two C<isl_ast_expr>s are equal to each other.
6624 =head3 Manipulating and printing the AST
6626 AST nodes can be copied and freed using the following functions.
6628 #include <isl/ast.h>
6629 __isl_give isl_ast_node *isl_ast_node_copy(
6630 __isl_keep isl_ast_node *node);
6631 __isl_null isl_ast_node *isl_ast_node_free(
6632 __isl_take isl_ast_node *node);
6634 AST expressions can be copied and freed using the following functions.
6636 #include <isl/ast.h>
6637 __isl_give isl_ast_expr *isl_ast_expr_copy(
6638 __isl_keep isl_ast_expr *expr);
6639 __isl_null isl_ast_expr *isl_ast_expr_free(
6640 __isl_take isl_ast_expr *expr);
6642 New AST expressions can be created either directly or within
6643 the context of an C<isl_ast_build>.
6645 #include <isl/ast.h>
6646 __isl_give isl_ast_expr *isl_ast_expr_from_val(
6647 __isl_take isl_val *v);
6648 __isl_give isl_ast_expr *isl_ast_expr_from_id(
6649 __isl_take isl_id *id);
6650 __isl_give isl_ast_expr *isl_ast_expr_neg(
6651 __isl_take isl_ast_expr *expr);
6652 __isl_give isl_ast_expr *isl_ast_expr_address_of(
6653 __isl_take isl_ast_expr *expr);
6654 __isl_give isl_ast_expr *isl_ast_expr_add(
6655 __isl_take isl_ast_expr *expr1,
6656 __isl_take isl_ast_expr *expr2);
6657 __isl_give isl_ast_expr *isl_ast_expr_sub(
6658 __isl_take isl_ast_expr *expr1,
6659 __isl_take isl_ast_expr *expr2);
6660 __isl_give isl_ast_expr *isl_ast_expr_mul(
6661 __isl_take isl_ast_expr *expr1,
6662 __isl_take isl_ast_expr *expr2);
6663 __isl_give isl_ast_expr *isl_ast_expr_div(
6664 __isl_take isl_ast_expr *expr1,
6665 __isl_take isl_ast_expr *expr2);
6666 __isl_give isl_ast_expr *isl_ast_expr_and(
6667 __isl_take isl_ast_expr *expr1,
6668 __isl_take isl_ast_expr *expr2)
6669 __isl_give isl_ast_expr *isl_ast_expr_or(
6670 __isl_take isl_ast_expr *expr1,
6671 __isl_take isl_ast_expr *expr2)
6672 __isl_give isl_ast_expr *isl_ast_expr_eq(
6673 __isl_take isl_ast_expr *expr1,
6674 __isl_take isl_ast_expr *expr2);
6675 __isl_give isl_ast_expr *isl_ast_expr_le(
6676 __isl_take isl_ast_expr *expr1,
6677 __isl_take isl_ast_expr *expr2);
6678 __isl_give isl_ast_expr *isl_ast_expr_lt(
6679 __isl_take isl_ast_expr *expr1,
6680 __isl_take isl_ast_expr *expr2);
6681 __isl_give isl_ast_expr *isl_ast_expr_ge(
6682 __isl_take isl_ast_expr *expr1,
6683 __isl_take isl_ast_expr *expr2);
6684 __isl_give isl_ast_expr *isl_ast_expr_gt(
6685 __isl_take isl_ast_expr *expr1,
6686 __isl_take isl_ast_expr *expr2);
6687 __isl_give isl_ast_expr *isl_ast_expr_access(
6688 __isl_take isl_ast_expr *array,
6689 __isl_take isl_ast_expr_list *indices);
6691 The function C<isl_ast_expr_address_of> can be applied to an
6692 C<isl_ast_expr> of type C<isl_ast_op_access> only. It is meant
6693 to represent the address of the C<isl_ast_expr_access>.
6695 #include <isl/ast_build.h>
6696 __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff(
6697 __isl_keep isl_ast_build *build,
6698 __isl_take isl_pw_aff *pa);
6699 __isl_give isl_ast_expr *
6700 isl_ast_build_access_from_pw_multi_aff(
6701 __isl_keep isl_ast_build *build,
6702 __isl_take isl_pw_multi_aff *pma);
6703 __isl_give isl_ast_expr *
6704 isl_ast_build_access_from_multi_pw_aff(
6705 __isl_keep isl_ast_build *build,
6706 __isl_take isl_multi_pw_aff *mpa);
6707 __isl_give isl_ast_expr *
6708 isl_ast_build_call_from_pw_multi_aff(
6709 __isl_keep isl_ast_build *build,
6710 __isl_take isl_pw_multi_aff *pma);
6711 __isl_give isl_ast_expr *
6712 isl_ast_build_call_from_multi_pw_aff(
6713 __isl_keep isl_ast_build *build,
6714 __isl_take isl_multi_pw_aff *mpa);
6716 The domains of C<pa>, C<mpa> and C<pma> should correspond
6717 to the schedule space of C<build>.
6718 The tuple id of C<mpa> or C<pma> is used as the array being accessed or
6719 the function being called.
6720 If the accessed space is a nested relation, then it is taken
6721 to represent an access of the member specified by the range
6722 of this nested relation of the structure specified by the domain
6723 of the nested relation.
6725 The following functions can be used to modify an C<isl_ast_expr>.
6727 #include <isl/ast.h>
6728 __isl_give isl_ast_expr *isl_ast_expr_set_op_arg(
6729 __isl_take isl_ast_expr *expr, int pos,
6730 __isl_take isl_ast_expr *arg);
6732 Replace the argument of C<expr> at position C<pos> by C<arg>.
6734 #include <isl/ast.h>
6735 __isl_give isl_ast_expr *isl_ast_expr_substitute_ids(
6736 __isl_take isl_ast_expr *expr,
6737 __isl_take isl_id_to_ast_expr *id2expr);
6739 The function C<isl_ast_expr_substitute_ids> replaces the
6740 subexpressions of C<expr> of type C<isl_ast_expr_id>
6741 by the corresponding expression in C<id2expr>, if there is any.
6744 User specified data can be attached to an C<isl_ast_node> and obtained
6745 from the same C<isl_ast_node> using the following functions.
6747 #include <isl/ast.h>
6748 __isl_give isl_ast_node *isl_ast_node_set_annotation(
6749 __isl_take isl_ast_node *node,
6750 __isl_take isl_id *annotation);
6751 __isl_give isl_id *isl_ast_node_get_annotation(
6752 __isl_keep isl_ast_node *node);
6754 Basic printing can be performed using the following functions.
6756 #include <isl/ast.h>
6757 __isl_give isl_printer *isl_printer_print_ast_expr(
6758 __isl_take isl_printer *p,
6759 __isl_keep isl_ast_expr *expr);
6760 __isl_give isl_printer *isl_printer_print_ast_node(
6761 __isl_take isl_printer *p,
6762 __isl_keep isl_ast_node *node);
6764 More advanced printing can be performed using the following functions.
6766 #include <isl/ast.h>
6767 __isl_give isl_printer *isl_ast_op_type_print_macro(
6768 enum isl_ast_op_type type,
6769 __isl_take isl_printer *p);
6770 __isl_give isl_printer *isl_ast_node_print_macros(
6771 __isl_keep isl_ast_node *node,
6772 __isl_take isl_printer *p);
6773 __isl_give isl_printer *isl_ast_node_print(
6774 __isl_keep isl_ast_node *node,
6775 __isl_take isl_printer *p,
6776 __isl_take isl_ast_print_options *options);
6777 __isl_give isl_printer *isl_ast_node_for_print(
6778 __isl_keep isl_ast_node *node,
6779 __isl_take isl_printer *p,
6780 __isl_take isl_ast_print_options *options);
6781 __isl_give isl_printer *isl_ast_node_if_print(
6782 __isl_keep isl_ast_node *node,
6783 __isl_take isl_printer *p,
6784 __isl_take isl_ast_print_options *options);
6786 While printing an C<isl_ast_node> in C<ISL_FORMAT_C>,
6787 C<isl> may print out an AST that makes use of macros such
6788 as C<floord>, C<min> and C<max>.
6789 C<isl_ast_op_type_print_macro> prints out the macro
6790 corresponding to a specific C<isl_ast_op_type>.
6791 C<isl_ast_node_print_macros> scans the C<isl_ast_node>
6792 for expressions where these macros would be used and prints
6793 out the required macro definitions.
6794 Essentially, C<isl_ast_node_print_macros> calls
6795 C<isl_ast_node_foreach_ast_op_type> with C<isl_ast_op_type_print_macro>
6796 as function argument.
6797 C<isl_ast_node_print>, C<isl_ast_node_for_print> and
6798 C<isl_ast_node_if_print> print an C<isl_ast_node>
6799 in C<ISL_FORMAT_C>, but allow for some extra control
6800 through an C<isl_ast_print_options> object.
6801 This object can be created using the following functions.
6803 #include <isl/ast.h>
6804 __isl_give isl_ast_print_options *
6805 isl_ast_print_options_alloc(isl_ctx *ctx);
6806 __isl_give isl_ast_print_options *
6807 isl_ast_print_options_copy(
6808 __isl_keep isl_ast_print_options *options);
6809 __isl_null isl_ast_print_options *
6810 isl_ast_print_options_free(
6811 __isl_take isl_ast_print_options *options);
6813 __isl_give isl_ast_print_options *
6814 isl_ast_print_options_set_print_user(
6815 __isl_take isl_ast_print_options *options,
6816 __isl_give isl_printer *(*print_user)(
6817 __isl_take isl_printer *p,
6818 __isl_take isl_ast_print_options *options,
6819 __isl_keep isl_ast_node *node, void *user),
6821 __isl_give isl_ast_print_options *
6822 isl_ast_print_options_set_print_for(
6823 __isl_take isl_ast_print_options *options,
6824 __isl_give isl_printer *(*print_for)(
6825 __isl_take isl_printer *p,
6826 __isl_take isl_ast_print_options *options,
6827 __isl_keep isl_ast_node *node, void *user),
6830 The callback set by C<isl_ast_print_options_set_print_user>
6831 is called whenever a node of type C<isl_ast_node_user> needs to
6833 The callback set by C<isl_ast_print_options_set_print_for>
6834 is called whenever a node of type C<isl_ast_node_for> needs to
6836 Note that C<isl_ast_node_for_print> will I<not> call the
6837 callback set by C<isl_ast_print_options_set_print_for> on the node
6838 on which C<isl_ast_node_for_print> is called, but only on nested
6839 nodes of type C<isl_ast_node_for>. It is therefore safe to
6840 call C<isl_ast_node_for_print> from within the callback set by
6841 C<isl_ast_print_options_set_print_for>.
6843 The following option determines the type to be used for iterators
6844 while printing the AST.
6846 int isl_options_set_ast_iterator_type(
6847 isl_ctx *ctx, const char *val);
6848 const char *isl_options_get_ast_iterator_type(
6851 The AST printer only prints body nodes as blocks if these
6852 blocks cannot be safely omitted.
6853 For example, a C<for> node with one body node will not be
6854 surrounded with braces in C<ISL_FORMAT_C>.
6855 A block will always be printed by setting the following option.
6857 int isl_options_set_ast_always_print_block(isl_ctx *ctx,
6859 int isl_options_get_ast_always_print_block(isl_ctx *ctx);
6863 #include <isl/ast_build.h>
6864 int isl_options_set_ast_build_atomic_upper_bound(
6865 isl_ctx *ctx, int val);
6866 int isl_options_get_ast_build_atomic_upper_bound(
6868 int isl_options_set_ast_build_prefer_pdiv(isl_ctx *ctx,
6870 int isl_options_get_ast_build_prefer_pdiv(isl_ctx *ctx);
6871 int isl_options_set_ast_build_exploit_nested_bounds(
6872 isl_ctx *ctx, int val);
6873 int isl_options_get_ast_build_exploit_nested_bounds(
6875 int isl_options_set_ast_build_group_coscheduled(
6876 isl_ctx *ctx, int val);
6877 int isl_options_get_ast_build_group_coscheduled(
6879 int isl_options_set_ast_build_scale_strides(
6880 isl_ctx *ctx, int val);
6881 int isl_options_get_ast_build_scale_strides(
6883 int isl_options_set_ast_build_allow_else(isl_ctx *ctx,
6885 int isl_options_get_ast_build_allow_else(isl_ctx *ctx);
6886 int isl_options_set_ast_build_allow_or(isl_ctx *ctx,
6888 int isl_options_get_ast_build_allow_or(isl_ctx *ctx);
6892 =item * ast_build_atomic_upper_bound
6894 Generate loop upper bounds that consist of the current loop iterator,
6895 an operator and an expression not involving the iterator.
6896 If this option is not set, then the current loop iterator may appear
6897 several times in the upper bound.
6898 For example, when this option is turned off, AST generation
6901 [n] -> { A[i] -> [i] : 0 <= i <= 100, n }
6905 for (int c0 = 0; c0 <= 100 && n >= c0; c0 += 1)
6908 When the option is turned on, the following AST is generated
6910 for (int c0 = 0; c0 <= min(100, n); c0 += 1)
6913 =item * ast_build_prefer_pdiv
6915 If this option is turned off, then the AST generation will
6916 produce ASTs that may only contain C<isl_ast_op_fdiv_q>
6917 operators, but no C<isl_ast_op_pdiv_q> or
6918 C<isl_ast_op_pdiv_r> operators.
6919 If this options is turned on, then C<isl> will try to convert
6920 some of the C<isl_ast_op_fdiv_q> operators to (expressions containing)
6921 C<isl_ast_op_pdiv_q> or C<isl_ast_op_pdiv_r> operators.
6923 =item * ast_build_exploit_nested_bounds
6925 Simplify conditions based on bounds of nested for loops.
6926 In particular, remove conditions that are implied by the fact
6927 that one or more nested loops have at least one iteration,
6928 meaning that the upper bound is at least as large as the lower bound.
6929 For example, when this option is turned off, AST generation
6932 [N,M] -> { A[i,j] -> [i,j] : 0 <= i <= N and
6938 for (int c0 = 0; c0 <= N; c0 += 1)
6939 for (int c1 = 0; c1 <= M; c1 += 1)
6942 When the option is turned on, the following AST is generated
6944 for (int c0 = 0; c0 <= N; c0 += 1)
6945 for (int c1 = 0; c1 <= M; c1 += 1)
6948 =item * ast_build_group_coscheduled
6950 If two domain elements are assigned the same schedule point, then
6951 they may be executed in any order and they may even appear in different
6952 loops. If this options is set, then the AST generator will make
6953 sure that coscheduled domain elements do not appear in separate parts
6954 of the AST. This is useful in case of nested AST generation
6955 if the outer AST generation is given only part of a schedule
6956 and the inner AST generation should handle the domains that are
6957 coscheduled by this initial part of the schedule together.
6958 For example if an AST is generated for a schedule
6960 { A[i] -> [0]; B[i] -> [0] }
6962 then the C<isl_ast_build_set_create_leaf> callback described
6963 below may get called twice, once for each domain.
6964 Setting this option ensures that the callback is only called once
6965 on both domains together.
6967 =item * ast_build_separation_bounds
6969 This option specifies which bounds to use during separation.
6970 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT>
6971 then all (possibly implicit) bounds on the current dimension will
6972 be used during separation.
6973 If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT>
6974 then only those bounds that are explicitly available will
6975 be used during separation.
6977 =item * ast_build_scale_strides
6979 This option specifies whether the AST generator is allowed
6980 to scale down iterators of strided loops.
6982 =item * ast_build_allow_else
6984 This option specifies whether the AST generator is allowed
6985 to construct if statements with else branches.
6987 =item * ast_build_allow_or
6989 This option specifies whether the AST generator is allowed
6990 to construct if conditions with disjunctions.
6994 =head3 Fine-grained Control over AST Generation
6996 Besides specifying the constraints on the parameters,
6997 an C<isl_ast_build> object can be used to control
6998 various aspects of the AST generation process.
6999 The most prominent way of control is through ``options'',
7000 which can be set using the following function.
7002 #include <isl/ast_build.h>
7003 __isl_give isl_ast_build *
7004 isl_ast_build_set_options(
7005 __isl_take isl_ast_build *control,
7006 __isl_take isl_union_map *options);
7008 The options are encoded in an C<isl_union_map>.
7009 The domain of this union relation refers to the schedule domain,
7010 i.e., the range of the schedule passed to C<isl_ast_build_ast_from_schedule>.
7011 In the case of nested AST generation (see L</"Nested AST Generation">),
7012 the domain of C<options> should refer to the extra piece of the schedule.
7013 That is, it should be equal to the range of the wrapped relation in the
7014 range of the schedule.
7015 The range of the options can consist of elements in one or more spaces,
7016 the names of which determine the effect of the option.
7017 The values of the range typically also refer to the schedule dimension
7018 to which the option applies. In case of nested AST generation
7019 (see L</"Nested AST Generation">), these values refer to the position
7020 of the schedule dimension within the innermost AST generation.
7021 The constraints on the domain elements of
7022 the option should only refer to this dimension and earlier dimensions.
7023 We consider the following spaces.
7027 =item C<separation_class>
7029 This space is a wrapped relation between two one dimensional spaces.
7030 The input space represents the schedule dimension to which the option
7031 applies and the output space represents the separation class.
7032 While constructing a loop corresponding to the specified schedule
7033 dimension(s), the AST generator will try to generate separate loops
7034 for domain elements that are assigned different classes.
7035 If only some of the elements are assigned a class, then those elements
7036 that are not assigned any class will be treated as belonging to a class
7037 that is separate from the explicitly assigned classes.
7038 The typical use case for this option is to separate full tiles from
7040 The other options, described below, are applied after the separation
7043 As an example, consider the separation into full and partial tiles
7044 of a tiling of a triangular domain.
7045 Take, for example, the domain
7047 { A[i,j] : 0 <= i,j and i + j <= 100 }
7049 and a tiling into tiles of 10 by 10. The input to the AST generator
7050 is then the schedule
7052 { A[i,j] -> [([i/10]),[j/10],i,j] : 0 <= i,j and
7055 Without any options, the following AST is generated
7057 for (int c0 = 0; c0 <= 10; c0 += 1)
7058 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7059 for (int c2 = 10 * c0;
7060 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7062 for (int c3 = 10 * c1;
7063 c3 <= min(10 * c1 + 9, -c2 + 100);
7067 Separation into full and partial tiles can be obtained by assigning
7068 a class, say C<0>, to the full tiles. The full tiles are represented by those
7069 values of the first and second schedule dimensions for which there are
7070 values of the third and fourth dimensions to cover an entire tile.
7071 That is, we need to specify the following option
7073 { [a,b,c,d] -> separation_class[[0]->[0]] :
7074 exists b': 0 <= 10a,10b' and
7075 10a+9+10b'+9 <= 100;
7076 [a,b,c,d] -> separation_class[[1]->[0]] :
7077 0 <= 10a,10b and 10a+9+10b+9 <= 100 }
7081 { [a, b, c, d] -> separation_class[[1] -> [0]] :
7082 a >= 0 and b >= 0 and b <= 8 - a;
7083 [a, b, c, d] -> separation_class[[0] -> [0]] :
7086 With this option, the generated AST is as follows
7089 for (int c0 = 0; c0 <= 8; c0 += 1) {
7090 for (int c1 = 0; c1 <= -c0 + 8; c1 += 1)
7091 for (int c2 = 10 * c0;
7092 c2 <= 10 * c0 + 9; c2 += 1)
7093 for (int c3 = 10 * c1;
7094 c3 <= 10 * c1 + 9; c3 += 1)
7096 for (int c1 = -c0 + 9; c1 <= -c0 + 10; c1 += 1)
7097 for (int c2 = 10 * c0;
7098 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7100 for (int c3 = 10 * c1;
7101 c3 <= min(-c2 + 100, 10 * c1 + 9);
7105 for (int c0 = 9; c0 <= 10; c0 += 1)
7106 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1)
7107 for (int c2 = 10 * c0;
7108 c2 <= min(-10 * c1 + 100, 10 * c0 + 9);
7110 for (int c3 = 10 * c1;
7111 c3 <= min(10 * c1 + 9, -c2 + 100);
7118 This is a single-dimensional space representing the schedule dimension(s)
7119 to which ``separation'' should be applied. Separation tries to split
7120 a loop into several pieces if this can avoid the generation of guards
7122 See also the C<atomic> option.
7126 This is a single-dimensional space representing the schedule dimension(s)
7127 for which the domains should be considered ``atomic''. That is, the
7128 AST generator will make sure that any given domain space will only appear
7129 in a single loop at the specified level.
7131 Consider the following schedule
7133 { a[i] -> [i] : 0 <= i < 10;
7134 b[i] -> [i+1] : 0 <= i < 10 }
7136 If the following option is specified
7138 { [i] -> separate[x] }
7140 then the following AST will be generated
7144 for (int c0 = 1; c0 <= 9; c0 += 1) {
7151 If, on the other hand, the following option is specified
7153 { [i] -> atomic[x] }
7155 then the following AST will be generated
7157 for (int c0 = 0; c0 <= 10; c0 += 1) {
7164 If neither C<atomic> nor C<separate> is specified, then the AST generator
7165 may produce either of these two results or some intermediate form.
7169 This is a single-dimensional space representing the schedule dimension(s)
7170 that should be I<completely> unrolled.
7171 To obtain a partial unrolling, the user should apply an additional
7172 strip-mining to the schedule and fully unroll the inner loop.
7176 Additional control is available through the following functions.
7178 #include <isl/ast_build.h>
7179 __isl_give isl_ast_build *
7180 isl_ast_build_set_iterators(
7181 __isl_take isl_ast_build *control,
7182 __isl_take isl_id_list *iterators);
7184 The function C<isl_ast_build_set_iterators> allows the user to
7185 specify a list of iterator C<isl_id>s to be used as iterators.
7186 If the input schedule is injective, then
7187 the number of elements in this list should be as large as the dimension
7188 of the schedule space, but no direct correspondence should be assumed
7189 between dimensions and elements.
7190 If the input schedule is not injective, then an additional number
7191 of C<isl_id>s equal to the largest dimension of the input domains
7193 If the number of provided C<isl_id>s is insufficient, then additional
7194 names are automatically generated.
7196 #include <isl/ast_build.h>
7197 __isl_give isl_ast_build *
7198 isl_ast_build_set_create_leaf(
7199 __isl_take isl_ast_build *control,
7200 __isl_give isl_ast_node *(*fn)(
7201 __isl_take isl_ast_build *build,
7202 void *user), void *user);
7205 C<isl_ast_build_set_create_leaf> function allows for the
7206 specification of a callback that should be called whenever the AST
7207 generator arrives at an element of the schedule domain.
7208 The callback should return an AST node that should be inserted
7209 at the corresponding position of the AST. The default action (when
7210 the callback is not set) is to continue generating parts of the AST to scan
7211 all the domain elements associated to the schedule domain element
7212 and to insert user nodes, ``calling'' the domain element, for each of them.
7213 The C<build> argument contains the current state of the C<isl_ast_build>.
7214 To ease nested AST generation (see L</"Nested AST Generation">),
7215 all control information that is
7216 specific to the current AST generation such as the options and
7217 the callbacks has been removed from this C<isl_ast_build>.
7218 The callback would typically return the result of a nested
7220 user defined node created using the following function.
7222 #include <isl/ast.h>
7223 __isl_give isl_ast_node *isl_ast_node_alloc_user(
7224 __isl_take isl_ast_expr *expr);
7226 #include <isl/ast_build.h>
7227 __isl_give isl_ast_build *
7228 isl_ast_build_set_at_each_domain(
7229 __isl_take isl_ast_build *build,
7230 __isl_give isl_ast_node *(*fn)(
7231 __isl_take isl_ast_node *node,
7232 __isl_keep isl_ast_build *build,
7233 void *user), void *user);
7234 __isl_give isl_ast_build *
7235 isl_ast_build_set_before_each_for(
7236 __isl_take isl_ast_build *build,
7237 __isl_give isl_id *(*fn)(
7238 __isl_keep isl_ast_build *build,
7239 void *user), void *user);
7240 __isl_give isl_ast_build *
7241 isl_ast_build_set_after_each_for(
7242 __isl_take isl_ast_build *build,
7243 __isl_give isl_ast_node *(*fn)(
7244 __isl_take isl_ast_node *node,
7245 __isl_keep isl_ast_build *build,
7246 void *user), void *user);
7248 The callback set by C<isl_ast_build_set_at_each_domain> will
7249 be called for each domain AST node.
7250 The callbacks set by C<isl_ast_build_set_before_each_for>
7251 and C<isl_ast_build_set_after_each_for> will be called
7252 for each for AST node. The first will be called in depth-first
7253 pre-order, while the second will be called in depth-first post-order.
7254 Since C<isl_ast_build_set_before_each_for> is called before the for
7255 node is actually constructed, it is only passed an C<isl_ast_build>.
7256 The returned C<isl_id> will be added as an annotation (using
7257 C<isl_ast_node_set_annotation>) to the constructed for node.
7258 In particular, if the user has also specified an C<after_each_for>
7259 callback, then the annotation can be retrieved from the node passed to
7260 that callback using C<isl_ast_node_get_annotation>.
7261 All callbacks should C<NULL> on failure.
7262 The given C<isl_ast_build> can be used to create new
7263 C<isl_ast_expr> objects using C<isl_ast_build_expr_from_pw_aff>
7264 or C<isl_ast_build_call_from_pw_multi_aff>.
7266 =head3 Nested AST Generation
7268 C<isl> allows the user to create an AST within the context
7269 of another AST. These nested ASTs are created using the
7270 same C<isl_ast_build_ast_from_schedule> function that is used to create the
7271 outer AST. The C<build> argument should be an C<isl_ast_build>
7272 passed to a callback set by
7273 C<isl_ast_build_set_create_leaf>.
7274 The space of the range of the C<schedule> argument should refer
7275 to this build. In particular, the space should be a wrapped
7276 relation and the domain of this wrapped relation should be the
7277 same as that of the range of the schedule returned by
7278 C<isl_ast_build_get_schedule> below.
7279 In practice, the new schedule is typically
7280 created by calling C<isl_union_map_range_product> on the old schedule
7281 and some extra piece of the schedule.
7282 The space of the schedule domain is also available from
7283 the C<isl_ast_build>.
7285 #include <isl/ast_build.h>
7286 __isl_give isl_union_map *isl_ast_build_get_schedule(
7287 __isl_keep isl_ast_build *build);
7288 __isl_give isl_space *isl_ast_build_get_schedule_space(
7289 __isl_keep isl_ast_build *build);
7290 __isl_give isl_ast_build *isl_ast_build_restrict(
7291 __isl_take isl_ast_build *build,
7292 __isl_take isl_set *set);
7294 The C<isl_ast_build_get_schedule> function returns a (partial)
7295 schedule for the domains elements for which part of the AST still needs to
7296 be generated in the current build.
7297 In particular, the domain elements are mapped to those iterations of the loops
7298 enclosing the current point of the AST generation inside which
7299 the domain elements are executed.
7300 No direct correspondence between
7301 the input schedule and this schedule should be assumed.
7302 The space obtained from C<isl_ast_build_get_schedule_space> can be used
7303 to create a set for C<isl_ast_build_restrict> to intersect
7304 with the current build. In particular, the set passed to
7305 C<isl_ast_build_restrict> can have additional parameters.
7306 The ids of the set dimensions in the space returned by
7307 C<isl_ast_build_get_schedule_space> correspond to the
7308 iterators of the already generated loops.
7309 The user should not rely on the ids of the output dimensions
7310 of the relations in the union relation returned by
7311 C<isl_ast_build_get_schedule> having any particular value.
7315 Although C<isl> is mainly meant to be used as a library,
7316 it also contains some basic applications that use some
7317 of the functionality of C<isl>.
7318 The input may be specified in either the L<isl format>
7319 or the L<PolyLib format>.
7321 =head2 C<isl_polyhedron_sample>
7323 C<isl_polyhedron_sample> takes a polyhedron as input and prints
7324 an integer element of the polyhedron, if there is any.
7325 The first column in the output is the denominator and is always
7326 equal to 1. If the polyhedron contains no integer points,
7327 then a vector of length zero is printed.
7331 C<isl_pip> takes the same input as the C<example> program
7332 from the C<piplib> distribution, i.e., a set of constraints
7333 on the parameters, a line containing only -1 and finally a set
7334 of constraints on a parametric polyhedron.
7335 The coefficients of the parameters appear in the last columns
7336 (but before the final constant column).
7337 The output is the lexicographic minimum of the parametric polyhedron.
7338 As C<isl> currently does not have its own output format, the output
7339 is just a dump of the internal state.
7341 =head2 C<isl_polyhedron_minimize>
7343 C<isl_polyhedron_minimize> computes the minimum of some linear
7344 or affine objective function over the integer points in a polyhedron.
7345 If an affine objective function
7346 is given, then the constant should appear in the last column.
7348 =head2 C<isl_polytope_scan>
7350 Given a polytope, C<isl_polytope_scan> prints
7351 all integer points in the polytope.
7353 =head2 C<isl_codegen>
7355 Given a schedule, a context set and an options relation,
7356 C<isl_codegen> prints out an AST that scans the domain elements
7357 of the schedule in the order of their image(s) taking into account
7358 the constraints in the context set.