1=head1 Introduction 2 3C<isl> is a thread-safe C library for manipulating 4sets and relations of integer points bounded by affine constraints. 5The descriptions of the sets and relations may involve 6both parameters and existentially quantified variables. 7All computations are performed in exact integer arithmetic 8using C<GMP>. 9The C<isl> library offers functionality that is similar 10to that offered by the C<Omega> and C<Omega+> libraries, 11but the underlying algorithms are in most cases completely different. 12 13The library is by no means complete and some fairly basic 14functionality is still missing. 15Still, even in its current form, the library has been successfully 16used as a backend polyhedral library for the polyhedral 17scanner C<CLooG> and as part of an equivalence checker of 18static affine programs. 19For bug reports, feature requests and questions, 20visit the the discussion group at 21L<http://groups.google.com/group/isl-development>. 22 23=head2 Backward Incompatible Changes 24 25=head3 Changes since isl-0.02 26 27=over 28 29=item * The old printing functions have been deprecated 30and replaced by C<isl_printer> functions, see L<Input and Output>. 31 32=item * Most functions related to dependence analysis have acquired 33an extra C<must> argument. To obtain the old behavior, this argument 34should be given the value 1. See L<Dependence Analysis>. 35 36=back 37 38=head3 Changes since isl-0.03 39 40=over 41 42=item * The function C<isl_pw_qpolynomial_fold_add> has been 43renamed to C<isl_pw_qpolynomial_fold_fold>. 44Similarly, C<isl_union_pw_qpolynomial_fold_add> has been 45renamed to C<isl_union_pw_qpolynomial_fold_fold>. 46 47=back 48 49=head3 Changes since isl-0.04 50 51=over 52 53=item * All header files have been renamed from C<isl_header.h> 54to C<isl/header.h>. 55 56=back 57 58=head3 Changes since isl-0.05 59 60=over 61 62=item * The functions C<isl_printer_print_basic_set> and 63C<isl_printer_print_basic_map> no longer print a newline. 64 65=item * The functions C<isl_flow_get_no_source> 66and C<isl_union_map_compute_flow> now return 67the accesses for which no source could be found instead of 68the iterations where those accesses occur. 69 70=item * The functions C<isl_basic_map_identity> and 71C<isl_map_identity> now take a B<map> space as input. An old call 72C<isl_map_identity(space)> can be rewritten to 73C<isl_map_identity(isl_space_map_from_set(space))>. 74 75=item * The function C<isl_map_power> no longer takes 76a parameter position as input. Instead, the exponent 77is now expressed as the domain of the resulting relation. 78 79=back 80 81=head3 Changes since isl-0.06 82 83=over 84 85=item * The format of C<isl_printer_print_qpolynomial>'s 86C<ISL_FORMAT_ISL> output has changed. 87Use C<ISL_FORMAT_C> to obtain the old output. 88 89=item * The C<*_fast_*> functions have been renamed to C<*_plain_*>. 90Some of the old names have been kept for backward compatibility, 91but they will be removed in the future. 92 93=back 94 95=head3 Changes since isl-0.07 96 97=over 98 99=item * The function C<isl_pw_aff_max> has been renamed to 100C<isl_pw_aff_union_max>. 101Similarly, the function C<isl_pw_aff_add> has been renamed to 102C<isl_pw_aff_union_add>. 103 104=item * The C<isl_dim> type has been renamed to C<isl_space> 105along with the associated functions. 106Some of the old names have been kept for backward compatibility, 107but they will be removed in the future. 108 109=item * Spaces of maps, sets and parameter domains are now 110treated differently. The distinction between map spaces and set spaces 111has always been made on a conceptual level, but proper use of such spaces 112was never checked. Furthermore, up until isl-0.07 there was no way 113of explicitly creating a parameter space. These can now be created 114directly using C<isl_space_params_alloc> or from other spaces using 115C<isl_space_params>. 116 117=item * The space in which C<isl_aff>, C<isl_pw_aff>, C<isl_qpolynomial>, 118C<isl_pw_qpolynomial>, C<isl_qpolynomial_fold> and C<isl_pw_qpolynomial_fold> 119objects live is now a map space 120instead of a set space. This means, for example, that the dimensions 121of the domain of an C<isl_aff> are now considered to be of type 122C<isl_dim_in> instead of C<isl_dim_set>. Extra functions have been 123added to obtain the domain space. Some of the constructors still 124take a domain space and have therefore been renamed. 125 126=item * The functions C<isl_equality_alloc> and C<isl_inequality_alloc> 127now take an C<isl_local_space> instead of an C<isl_space>. 128An C<isl_local_space> can be created from an C<isl_space> 129using C<isl_local_space_from_space>. 130 131=item * The C<isl_div> type has been removed. Functions that used 132to return an C<isl_div> now return an C<isl_aff>. 133Note that the space of an C<isl_aff> is that of relation. 134When replacing a call to C<isl_div_get_coefficient> by a call to 135C<isl_aff_get_coefficient> any C<isl_dim_set> argument needs 136to be replaced by C<isl_dim_in>. 137A call to C<isl_aff_from_div> can be replaced by a call 138to C<isl_aff_floor>. 139A call to C<isl_qpolynomial_div(div)> call be replaced by 140the nested call 141 142 isl_qpolynomial_from_aff(isl_aff_floor(div)) 143 144The function C<isl_constraint_div> has also been renamed 145to C<isl_constraint_get_div>. 146 147=item * The C<nparam> argument has been removed from 148C<isl_map_read_from_str> and similar functions. 149When reading input in the original PolyLib format, 150the result will have no parameters. 151If parameters are expected, the caller may want to perform 152dimension manipulation on the result. 153 154=back 155 156=head3 Changes since isl-0.09 157 158=over 159 160=item * The C<schedule_split_parallel> option has been replaced 161by the C<schedule_split_scaled> option. 162 163=item * The first argument of C<isl_pw_aff_cond> is now 164an C<isl_pw_aff> instead of an C<isl_set>. 165A call C<isl_pw_aff_cond(a, b, c)> can be replaced by 166 167 isl_pw_aff_cond(isl_set_indicator_function(a), b, c) 168 169=back 170 171=head3 Changes since isl-0.10 172 173=over 174 175=item * The functions C<isl_set_dim_has_lower_bound> and 176C<isl_set_dim_has_upper_bound> have been renamed to 177C<isl_set_dim_has_any_lower_bound> and 178C<isl_set_dim_has_any_upper_bound>. 179The new C<isl_set_dim_has_lower_bound> and 180C<isl_set_dim_has_upper_bound> have slightly different meanings. 181 182=back 183 184=head1 License 185 186C<isl> is released under the MIT license. 187 188=over 189 190Permission is hereby granted, free of charge, to any person obtaining a copy of 191this software and associated documentation files (the "Software"), to deal in 192the Software without restriction, including without limitation the rights to 193use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 194of the Software, and to permit persons to whom the Software is furnished to do 195so, subject to the following conditions: 196 197The above copyright notice and this permission notice shall be included in all 198copies or substantial portions of the Software. 199 200THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 201IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 202FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 203AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 204LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 205OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 206SOFTWARE. 207 208=back 209 210Note that C<isl> currently requires C<GMP>, which is released 211under the GNU Lesser General Public License (LGPL). This means 212that code linked against C<isl> is also linked against LGPL code. 213 214=head1 Installation 215 216The source of C<isl> can be obtained either as a tarball 217or from the git repository. Both are available from 218L<http://freshmeat.net/projects/isl/>. 219The installation process depends on how you obtained 220the source. 221 222=head2 Installation from the git repository 223 224=over 225 226=item 1 Clone or update the repository 227 228The first time the source is obtained, you need to clone 229the repository. 230 231 git clone git://repo.or.cz/isl.git 232 233To obtain updates, you need to pull in the latest changes 234 235 git pull 236 237=item 2 Generate C<configure> 238 239 ./autogen.sh 240 241=back 242 243After performing the above steps, continue 244with the L<Common installation instructions>. 245 246=head2 Common installation instructions 247 248=over 249 250=item 1 Obtain C<GMP> 251 252Building C<isl> requires C<GMP>, including its headers files. 253Your distribution may not provide these header files by default 254and you may need to install a package called C<gmp-devel> or something 255similar. Alternatively, C<GMP> can be built from 256source, available from L<http://gmplib.org/>. 257 258=item 2 Configure 259 260C<isl> uses the standard C<autoconf> C<configure> script. 261To run it, just type 262 263 ./configure 264 265optionally followed by some configure options. 266A complete list of options can be obtained by running 267 268 ./configure --help 269 270Below we discuss some of the more common options. 271 272C<isl> can optionally use C<piplib>, but no 273C<piplib> functionality is currently used by default. 274The C<--with-piplib> option can 275be used to specify which C<piplib> 276library to use, either an installed version (C<system>), 277an externally built version (C<build>) 278or no version (C<no>). The option C<build> is mostly useful 279in C<configure> scripts of larger projects that bundle both C<isl> 280and C<piplib>. 281 282=over 283 284=item C<--prefix> 285 286Installation prefix for C<isl> 287 288=item C<--with-gmp-prefix> 289 290Installation prefix for C<GMP> (architecture-independent files). 291 292=item C<--with-gmp-exec-prefix> 293 294Installation prefix for C<GMP> (architecture-dependent files). 295 296=item C<--with-piplib> 297 298Which copy of C<piplib> to use, either C<no> (default), C<system> or C<build>. 299 300=item C<--with-piplib-prefix> 301 302Installation prefix for C<system> C<piplib> (architecture-independent files). 303 304=item C<--with-piplib-exec-prefix> 305 306Installation prefix for C<system> C<piplib> (architecture-dependent files). 307 308=item C<--with-piplib-builddir> 309 310Location where C<build> C<piplib> was built. 311 312=back 313 314=item 3 Compile 315 316 make 317 318=item 4 Install (optional) 319 320 make install 321 322=back 323 324=head1 Integer Set Library 325 326=head2 Initialization 327 328All manipulations of integer sets and relations occur within 329the context of an C<isl_ctx>. 330A given C<isl_ctx> can only be used within a single thread. 331All arguments of a function are required to have been allocated 332within the same context. 333There are currently no functions available for moving an object 334from one C<isl_ctx> to another C<isl_ctx>. This means that 335there is currently no way of safely moving an object from one 336thread to another, unless the whole C<isl_ctx> is moved. 337 338An C<isl_ctx> can be allocated using C<isl_ctx_alloc> and 339freed using C<isl_ctx_free>. 340All objects allocated within an C<isl_ctx> should be freed 341before the C<isl_ctx> itself is freed. 342 343 isl_ctx *isl_ctx_alloc(); 344 void isl_ctx_free(isl_ctx *ctx); 345 346=head2 Values 347 348An C<isl_val> represents an integer value, a rational value 349or one of three special values, infinity, negative infinity and NaN. 350Some predefined values can be created using the following functions. 351 352 #include <isl/val.h> 353 __isl_give isl_val *isl_val_zero(isl_ctx *ctx); 354 __isl_give isl_val *isl_val_one(isl_ctx *ctx); 355 __isl_give isl_val *isl_val_nan(isl_ctx *ctx); 356 __isl_give isl_val *isl_val_infty(isl_ctx *ctx); 357 __isl_give isl_val *isl_val_neginfty(isl_ctx *ctx); 358 359Specific integer values can be created using the following functions. 360 361 #include <isl/val.h> 362 __isl_give isl_val *isl_val_int_from_si(isl_ctx *ctx, 363 long i); 364 __isl_give isl_val *isl_val_int_from_ui(isl_ctx *ctx, 365 unsigned long u); 366 __isl_give isl_val *isl_val_int_from_chunks(isl_ctx *ctx, 367 size_t n, size_t size, const void *chunks); 368 369The function C<isl_val_int_from_chunks> constructs an C<isl_val> 370from the C<n> I<digits>, each consisting of C<size> bytes, stored at C<chunks>. 371The least significant digit is assumed to be stored first. 372 373Value objects can be copied and freed using the following functions. 374 375 #include <isl/val.h> 376 __isl_give isl_val *isl_val_copy(__isl_keep isl_val *v); 377 void *isl_val_free(__isl_take isl_val *v); 378 379They can be inspected using the following functions. 380 381 #include <isl/val.h> 382 isl_ctx *isl_val_get_ctx(__isl_keep isl_val *val); 383 long isl_val_get_num_si(__isl_keep isl_val *v); 384 long isl_val_get_den_si(__isl_keep isl_val *v); 385 double isl_val_get_d(__isl_keep isl_val *v); 386 size_t isl_val_n_abs_num_chunks(__isl_keep isl_val *v, 387 size_t size); 388 int isl_val_get_abs_num_chunks(__isl_keep isl_val *v, 389 size_t size, void *chunks); 390 391C<isl_val_n_abs_num_chunks> returns the number of I<digits> 392of C<size> bytes needed to store the absolute value of the 393numerator of C<v>. 394C<isl_val_get_abs_num_chunks> stores these digits at C<chunks>, 395which is assumed to have been preallocated by the caller. 396The least significant digit is stored first. 397Note that C<isl_val_get_num_si>, C<isl_val_get_den_si>, 398C<isl_val_get_d>, C<isl_val_n_abs_num_chunks> 399and C<isl_val_get_abs_num_chunks> can only be applied to rational values. 400 401An C<isl_val> can be modified using the following function. 402 403 #include <isl/val.h> 404 __isl_give isl_val *isl_val_set_si(__isl_take isl_val *v, 405 long i); 406 407The following unary properties are defined on C<isl_val>s. 408 409 #include <isl/val.h> 410 int isl_val_sgn(__isl_keep isl_val *v); 411 int isl_val_is_zero(__isl_keep isl_val *v); 412 int isl_val_is_one(__isl_keep isl_val *v); 413 int isl_val_is_negone(__isl_keep isl_val *v); 414 int isl_val_is_nonneg(__isl_keep isl_val *v); 415 int isl_val_is_nonpos(__isl_keep isl_val *v); 416 int isl_val_is_pos(__isl_keep isl_val *v); 417 int isl_val_is_neg(__isl_keep isl_val *v); 418 int isl_val_is_int(__isl_keep isl_val *v); 419 int isl_val_is_rat(__isl_keep isl_val *v); 420 int isl_val_is_nan(__isl_keep isl_val *v); 421 int isl_val_is_infty(__isl_keep isl_val *v); 422 int isl_val_is_neginfty(__isl_keep isl_val *v); 423 424Note that the sign of NaN is undefined. 425 426The following binary properties are defined on pairs of C<isl_val>s. 427 428 #include <isl/val.h> 429 int isl_val_lt(__isl_keep isl_val *v1, 430 __isl_keep isl_val *v2); 431 int isl_val_le(__isl_keep isl_val *v1, 432 __isl_keep isl_val *v2); 433 int isl_val_gt(__isl_keep isl_val *v1, 434 __isl_keep isl_val *v2); 435 int isl_val_ge(__isl_keep isl_val *v1, 436 __isl_keep isl_val *v2); 437 int isl_val_eq(__isl_keep isl_val *v1, 438 __isl_keep isl_val *v2); 439 int isl_val_ne(__isl_keep isl_val *v1, 440 __isl_keep isl_val *v2); 441 442For integer C<isl_val>s we additionally have the following binary property. 443 444 #include <isl/val.h> 445 int isl_val_is_divisible_by(__isl_keep isl_val *v1, 446 __isl_keep isl_val *v2); 447 448An C<isl_val> can also be compared to an integer using the following 449function. The result is undefined for NaN. 450 451 #include <isl/val.h> 452 int isl_val_cmp_si(__isl_keep isl_val *v, long i); 453 454The following unary operations are available on C<isl_val>s. 455 456 #include <isl/val.h> 457 __isl_give isl_val *isl_val_abs(__isl_take isl_val *v); 458 __isl_give isl_val *isl_val_neg(__isl_take isl_val *v); 459 __isl_give isl_val *isl_val_floor(__isl_take isl_val *v); 460 __isl_give isl_val *isl_val_ceil(__isl_take isl_val *v); 461 __isl_give isl_val *isl_val_trunc(__isl_take isl_val *v); 462 463The following binary operations are available on C<isl_val>s. 464 465 #include <isl/val.h> 466 __isl_give isl_val *isl_val_abs(__isl_take isl_val *v); 467 __isl_give isl_val *isl_val_neg(__isl_take isl_val *v); 468 __isl_give isl_val *isl_val_floor(__isl_take isl_val *v); 469 __isl_give isl_val *isl_val_ceil(__isl_take isl_val *v); 470 __isl_give isl_val *isl_val_trunc(__isl_take isl_val *v); 471 __isl_give isl_val *isl_val_2exp(__isl_take isl_val *v); 472 __isl_give isl_val *isl_val_min(__isl_take isl_val *v1, 473 __isl_take isl_val *v2); 474 __isl_give isl_val *isl_val_max(__isl_take isl_val *v1, 475 __isl_take isl_val *v2); 476 __isl_give isl_val *isl_val_add(__isl_take isl_val *v1, 477 __isl_take isl_val *v2); 478 __isl_give isl_val *isl_val_add_ui(__isl_take isl_val *v1, 479 unsigned long v2); 480 __isl_give isl_val *isl_val_sub(__isl_take isl_val *v1, 481 __isl_take isl_val *v2); 482 __isl_give isl_val *isl_val_sub_ui(__isl_take isl_val *v1, 483 unsigned long v2); 484 __isl_give isl_val *isl_val_mul(__isl_take isl_val *v1, 485 __isl_take isl_val *v2); 486 __isl_give isl_val *isl_val_mul_ui(__isl_take isl_val *v1, 487 unsigned long v2); 488 __isl_give isl_val *isl_val_div(__isl_take isl_val *v1, 489 __isl_take isl_val *v2); 490 491On integer values, we additionally have the following operations. 492 493 #include <isl/val.h> 494 __isl_give isl_val *isl_val_2exp(__isl_take isl_val *v); 495 __isl_give isl_val *isl_val_mod(__isl_take isl_val *v1, 496 __isl_take isl_val *v2); 497 __isl_give isl_val *isl_val_gcd(__isl_take isl_val *v1, 498 __isl_take isl_val *v2); 499 __isl_give isl_val *isl_val_gcdext(__isl_take isl_val *v1, 500 __isl_take isl_val *v2, __isl_give isl_val **x, 501 __isl_give isl_val **y); 502 503The function C<isl_val_gcdext> returns the greatest common divisor g 504of C<v1> and C<v2> as well as two integers C<*x> and C<*y> such 505that C<*x> * C<v1> + C<*y> * C<v2> = g. 506 507A value can be read from input using 508 509 #include <isl/val.h> 510 __isl_give isl_val *isl_val_read_from_str(isl_ctx *ctx, 511 const char *str); 512 513A value can be printed using 514 515 #include <isl/val.h> 516 __isl_give isl_printer *isl_printer_print_val( 517 __isl_take isl_printer *p, __isl_keep isl_val *v); 518 519=head3 GMP specific functions 520 521These functions are only available if C<isl> has been compiled with C<GMP> 522support. 523 524Specific integer and rational values can be created from C<GMP> values using 525the following functions. 526 527 #include <isl/val_gmp.h> 528 __isl_give isl_val *isl_val_int_from_gmp(isl_ctx *ctx, 529 mpz_t z); 530 __isl_give isl_val *isl_val_from_gmp(isl_ctx *ctx, 531 const mpz_t n, const mpz_t d); 532 533The numerator and denominator of a rational value can be extracted as 534C<GMP> values using the following functions. 535 536 #include <isl/val_gmp.h> 537 int isl_val_get_num_gmp(__isl_keep isl_val *v, mpz_t z); 538 int isl_val_get_den_gmp(__isl_keep isl_val *v, mpz_t z); 539 540=head3 Conversion from C<isl_int> 541 542The following functions are only temporarily available to ease 543the transition from C<isl_int> to C<isl_val>. They will be removed 544in the next release. 545 546 #include <isl/val_int.h> 547 __isl_give isl_val *isl_val_int_from_isl_int(isl_ctx *ctx, 548 isl_int n); 549 int isl_val_get_num_isl_int(__isl_keep isl_val *v, 550 isl_int *n); 551 552=head2 Integers (obsolescent) 553 554In previous versions of C<isl>, integers were represented 555in the external interface using the C<isl_int> type. 556This type has now been superseded by C<isl_val>. 557The C<isl_int> type will be removed from the external interface 558in future releases. New code should not use C<isl_int>. 559 560The operations below are currently available on C<isl_int>s. 561The meanings of these operations are essentially the same 562as their C<GMP> C<mpz_> counterparts. 563As always with C<GMP> types, C<isl_int>s need to be 564initialized with C<isl_int_init> before they can be used 565and they need to be released with C<isl_int_clear> 566after the last use. 567The user should not assume that an C<isl_int> is represented 568as a C<mpz_t>, but should instead explicitly convert between 569C<mpz_t>s and C<isl_int>s using C<isl_int_set_gmp> and 570C<isl_int_get_gmp> whenever a C<mpz_t> is required. 571 572=over 573 574=item isl_int_init(i) 575 576=item isl_int_clear(i) 577 578=item isl_int_set(r,i) 579 580=item isl_int_set_si(r,i) 581 582=item isl_int_set_gmp(r,g) 583 584=item isl_int_get_gmp(i,g) 585 586=item isl_int_abs(r,i) 587 588=item isl_int_neg(r,i) 589 590=item isl_int_swap(i,j) 591 592=item isl_int_swap_or_set(i,j) 593 594=item isl_int_add_ui(r,i,j) 595 596=item isl_int_sub_ui(r,i,j) 597 598=item isl_int_add(r,i,j) 599 600=item isl_int_sub(r,i,j) 601 602=item isl_int_mul(r,i,j) 603 604=item isl_int_mul_ui(r,i,j) 605 606=item isl_int_addmul(r,i,j) 607 608=item isl_int_submul(r,i,j) 609 610=item isl_int_gcd(r,i,j) 611 612=item isl_int_lcm(r,i,j) 613 614=item isl_int_divexact(r,i,j) 615 616=item isl_int_cdiv_q(r,i,j) 617 618=item isl_int_fdiv_q(r,i,j) 619 620=item isl_int_fdiv_r(r,i,j) 621 622=item isl_int_fdiv_q_ui(r,i,j) 623 624=item isl_int_read(r,s) 625 626=item isl_int_print(out,i,width) 627 628=item isl_int_sgn(i) 629 630=item isl_int_cmp(i,j) 631 632=item isl_int_cmp_si(i,si) 633 634=item isl_int_eq(i,j) 635 636=item isl_int_ne(i,j) 637 638=item isl_int_lt(i,j) 639 640=item isl_int_le(i,j) 641 642=item isl_int_gt(i,j) 643 644=item isl_int_ge(i,j) 645 646=item isl_int_abs_eq(i,j) 647 648=item isl_int_abs_ne(i,j) 649 650=item isl_int_abs_lt(i,j) 651 652=item isl_int_abs_gt(i,j) 653 654=item isl_int_abs_ge(i,j) 655 656=item isl_int_is_zero(i) 657 658=item isl_int_is_one(i) 659 660=item isl_int_is_negone(i) 661 662=item isl_int_is_pos(i) 663 664=item isl_int_is_neg(i) 665 666=item isl_int_is_nonpos(i) 667 668=item isl_int_is_nonneg(i) 669 670=item isl_int_is_divisible_by(i,j) 671 672=back 673 674=head2 Sets and Relations 675 676C<isl> uses six types of objects for representing sets and relations, 677C<isl_basic_set>, C<isl_basic_map>, C<isl_set>, C<isl_map>, 678C<isl_union_set> and C<isl_union_map>. 679C<isl_basic_set> and C<isl_basic_map> represent sets and relations that 680can be described as a conjunction of affine constraints, while 681C<isl_set> and C<isl_map> represent unions of 682C<isl_basic_set>s and C<isl_basic_map>s, respectively. 683However, all C<isl_basic_set>s or C<isl_basic_map>s in the union need 684to live in the same space. C<isl_union_set>s and C<isl_union_map>s 685represent unions of C<isl_set>s or C<isl_map>s in I<different> spaces, 686where spaces are considered different if they have a different number 687of dimensions and/or different names (see L<"Spaces">). 688The difference between sets and relations (maps) is that sets have 689one set of variables, while relations have two sets of variables, 690input variables and output variables. 691 692=head2 Memory Management 693 694Since a high-level operation on sets and/or relations usually involves 695several substeps and since the user is usually not interested in 696the intermediate results, most functions that return a new object 697will also release all the objects passed as arguments. 698If the user still wants to use one or more of these arguments 699after the function call, she should pass along a copy of the 700object rather than the object itself. 701The user is then responsible for making sure that the original 702object gets used somewhere else or is explicitly freed. 703 704The arguments and return values of all documented functions are 705annotated to make clear which arguments are released and which 706arguments are preserved. In particular, the following annotations 707are used 708 709=over 710 711=item C<__isl_give> 712 713C<__isl_give> means that a new object is returned. 714The user should make sure that the returned pointer is 715used exactly once as a value for an C<__isl_take> argument. 716In between, it can be used as a value for as many 717C<__isl_keep> arguments as the user likes. 718There is one exception, and that is the case where the 719pointer returned is C<NULL>. Is this case, the user 720is free to use it as an C<__isl_take> argument or not. 721 722=item C<__isl_take> 723 724C<__isl_take> means that the object the argument points to 725is taken over by the function and may no longer be used 726by the user as an argument to any other function. 727The pointer value must be one returned by a function 728returning an C<__isl_give> pointer. 729If the user passes in a C<NULL> value, then this will 730be treated as an error in the sense that the function will 731not perform its usual operation. However, it will still 732make sure that all the other C<__isl_take> arguments 733are released. 734 735=item C<__isl_keep> 736 737C<__isl_keep> means that the function will only use the object 738temporarily. After the function has finished, the user 739can still use it as an argument to other functions. 740A C<NULL> value will be treated in the same way as 741a C<NULL> value for an C<__isl_take> argument. 742 743=back 744 745=head2 Error Handling 746 747C<isl> supports different ways to react in case a runtime error is triggered. 748Runtime errors arise, e.g., if a function such as C<isl_map_intersect> is called 749with two maps that have incompatible spaces. There are three possible ways 750to react on error: to warn, to continue or to abort. 751 752The default behavior is to warn. In this mode, C<isl> prints a warning, stores 753the last error in the corresponding C<isl_ctx> and the function in which the 754error was triggered returns C<NULL>. An error does not corrupt internal state, 755such that isl can continue to be used. C<isl> also provides functions to 756read the last error and to reset the memory that stores the last error. The 757last error is only stored for information purposes. Its presence does not 758change the behavior of C<isl>. Hence, resetting an error is not required to 759continue to use isl, but only to observe new errors. 760 761 #include <isl/ctx.h> 762 enum isl_error isl_ctx_last_error(isl_ctx *ctx); 763 void isl_ctx_reset_error(isl_ctx *ctx); 764 765Another option is to continue on error. This is similar to warn on error mode, 766except that C<isl> does not print any warning. This allows a program to 767implement its own error reporting. 768 769The last option is to directly abort the execution of the program from within 770the isl library. This makes it obviously impossible to recover from an error, 771but it allows to directly spot the error location. By aborting on error, 772debuggers break at the location the error occurred and can provide a stack 773trace. Other tools that automatically provide stack traces on abort or that do 774not want to continue execution after an error was triggered may also prefer to 775abort on error. 776 777The on error behavior of isl can be specified by calling 778C<isl_options_set_on_error> or by setting the command line option 779C<--isl-on-error>. Valid arguments for the function call are 780C<ISL_ON_ERROR_WARN>, C<ISL_ON_ERROR_CONTINUE> and C<ISL_ON_ERROR_ABORT>. The 781choices for the command line option are C<warn>, C<continue> and C<abort>. 782It is also possible to query the current error mode. 783 784 #include <isl/options.h> 785 int isl_options_set_on_error(isl_ctx *ctx, int val); 786 int isl_options_get_on_error(isl_ctx *ctx); 787 788=head2 Identifiers 789 790Identifiers are used to identify both individual dimensions 791and tuples of dimensions. They consist of an optional name and an optional 792user pointer. The name and the user pointer cannot both be C<NULL>, however. 793Identifiers with the same name but different pointer values 794are considered to be distinct. 795Similarly, identifiers with different names but the same pointer value 796are also considered to be distinct. 797Equal identifiers are represented using the same object. 798Pairs of identifiers can therefore be tested for equality using the 799C<==> operator. 800Identifiers can be constructed, copied, freed, inspected and printed 801using the following functions. 802 803 #include <isl/id.h> 804 __isl_give isl_id *isl_id_alloc(isl_ctx *ctx, 805 __isl_keep const char *name, void *user); 806 __isl_give isl_id *isl_id_set_free_user( 807 __isl_take isl_id *id, 808 __isl_give void (*free_user)(void *user)); 809 __isl_give isl_id *isl_id_copy(isl_id *id); 810 void *isl_id_free(__isl_take isl_id *id); 811 812 isl_ctx *isl_id_get_ctx(__isl_keep isl_id *id); 813 void *isl_id_get_user(__isl_keep isl_id *id); 814 __isl_keep const char *isl_id_get_name(__isl_keep isl_id *id); 815 816 __isl_give isl_printer *isl_printer_print_id( 817 __isl_take isl_printer *p, __isl_keep isl_id *id); 818 819The callback set by C<isl_id_set_free_user> is called on the user 820pointer when the last reference to the C<isl_id> is freed. 821Note that C<isl_id_get_name> returns a pointer to some internal 822data structure, so the result can only be used while the 823corresponding C<isl_id> is alive. 824 825=head2 Spaces 826 827Whenever a new set, relation or similiar object is created from scratch, 828the space in which it lives needs to be specified using an C<isl_space>. 829Each space involves zero or more parameters and zero, one or two 830tuples of set or input/output dimensions. The parameters and dimensions 831are identified by an C<isl_dim_type> and a position. 832The type C<isl_dim_param> refers to parameters, 833the type C<isl_dim_set> refers to set dimensions (for spaces 834with a single tuple of dimensions) and the types C<isl_dim_in> 835and C<isl_dim_out> refer to input and output dimensions 836(for spaces with two tuples of dimensions). 837Local spaces (see L</"Local Spaces">) also contain dimensions 838of type C<isl_dim_div>. 839Note that parameters are only identified by their position within 840a given object. Across different objects, parameters are (usually) 841identified by their names or identifiers. Only unnamed parameters 842are identified by their positions across objects. The use of unnamed 843parameters is discouraged. 844 845 #include <isl/space.h> 846 __isl_give isl_space *isl_space_alloc(isl_ctx *ctx, 847 unsigned nparam, unsigned n_in, unsigned n_out); 848 __isl_give isl_space *isl_space_params_alloc(isl_ctx *ctx, 849 unsigned nparam); 850 __isl_give isl_space *isl_space_set_alloc(isl_ctx *ctx, 851 unsigned nparam, unsigned dim); 852 __isl_give isl_space *isl_space_copy(__isl_keep isl_space *space); 853 void *isl_space_free(__isl_take isl_space *space); 854 unsigned isl_space_dim(__isl_keep isl_space *space, 855 enum isl_dim_type type); 856 857The space used for creating a parameter domain 858needs to be created using C<isl_space_params_alloc>. 859For other sets, the space 860needs to be created using C<isl_space_set_alloc>, while 861for a relation, the space 862needs to be created using C<isl_space_alloc>. 863C<isl_space_dim> can be used 864to find out the number of dimensions of each type in 865a space, where type may be 866C<isl_dim_param>, C<isl_dim_in> (only for relations), 867C<isl_dim_out> (only for relations), C<isl_dim_set> 868(only for sets) or C<isl_dim_all>. 869 870To check whether a given space is that of a set or a map 871or whether it is a parameter space, use these functions: 872 873 #include <isl/space.h> 874 int isl_space_is_params(__isl_keep isl_space *space); 875 int isl_space_is_set(__isl_keep isl_space *space); 876 int isl_space_is_map(__isl_keep isl_space *space); 877 878Spaces can be compared using the following functions: 879 880 #include <isl/space.h> 881 int isl_space_is_equal(__isl_keep isl_space *space1, 882 __isl_keep isl_space *space2); 883 int isl_space_is_domain(__isl_keep isl_space *space1, 884 __isl_keep isl_space *space2); 885 int isl_space_is_range(__isl_keep isl_space *space1, 886 __isl_keep isl_space *space2); 887 888C<isl_space_is_domain> checks whether the first argument is equal 889to the domain of the second argument. This requires in particular that 890the first argument is a set space and that the second argument 891is a map space. 892 893It is often useful to create objects that live in the 894same space as some other object. This can be accomplished 895by creating the new objects 896(see L<Creating New Sets and Relations> or 897L<Creating New (Piecewise) Quasipolynomials>) based on the space 898of the original object. 899 900 #include <isl/set.h> 901 __isl_give isl_space *isl_basic_set_get_space( 902 __isl_keep isl_basic_set *bset); 903 __isl_give isl_space *isl_set_get_space(__isl_keep isl_set *set); 904 905 #include <isl/union_set.h> 906 __isl_give isl_space *isl_union_set_get_space( 907 __isl_keep isl_union_set *uset); 908 909 #include <isl/map.h> 910 __isl_give isl_space *isl_basic_map_get_space( 911 __isl_keep isl_basic_map *bmap); 912 __isl_give isl_space *isl_map_get_space(__isl_keep isl_map *map); 913 914 #include <isl/union_map.h> 915 __isl_give isl_space *isl_union_map_get_space( 916 __isl_keep isl_union_map *umap); 917 918 #include <isl/constraint.h> 919 __isl_give isl_space *isl_constraint_get_space( 920 __isl_keep isl_constraint *constraint); 921 922 #include <isl/polynomial.h> 923 __isl_give isl_space *isl_qpolynomial_get_domain_space( 924 __isl_keep isl_qpolynomial *qp); 925 __isl_give isl_space *isl_qpolynomial_get_space( 926 __isl_keep isl_qpolynomial *qp); 927 __isl_give isl_space *isl_qpolynomial_fold_get_space( 928 __isl_keep isl_qpolynomial_fold *fold); 929 __isl_give isl_space *isl_pw_qpolynomial_get_domain_space( 930 __isl_keep isl_pw_qpolynomial *pwqp); 931 __isl_give isl_space *isl_pw_qpolynomial_get_space( 932 __isl_keep isl_pw_qpolynomial *pwqp); 933 __isl_give isl_space *isl_pw_qpolynomial_fold_get_domain_space( 934 __isl_keep isl_pw_qpolynomial_fold *pwf); 935 __isl_give isl_space *isl_pw_qpolynomial_fold_get_space( 936 __isl_keep isl_pw_qpolynomial_fold *pwf); 937 __isl_give isl_space *isl_union_pw_qpolynomial_get_space( 938 __isl_keep isl_union_pw_qpolynomial *upwqp); 939 __isl_give isl_space *isl_union_pw_qpolynomial_fold_get_space( 940 __isl_keep isl_union_pw_qpolynomial_fold *upwf); 941 942 #include <isl/val.h> 943 __isl_give isl_space *isl_multi_val_get_space( 944 __isl_keep isl_multi_val *mv); 945 946 #include <isl/aff.h> 947 __isl_give isl_space *isl_aff_get_domain_space( 948 __isl_keep isl_aff *aff); 949 __isl_give isl_space *isl_aff_get_space( 950 __isl_keep isl_aff *aff); 951 __isl_give isl_space *isl_pw_aff_get_domain_space( 952 __isl_keep isl_pw_aff *pwaff); 953 __isl_give isl_space *isl_pw_aff_get_space( 954 __isl_keep isl_pw_aff *pwaff); 955 __isl_give isl_space *isl_multi_aff_get_domain_space( 956 __isl_keep isl_multi_aff *maff); 957 __isl_give isl_space *isl_multi_aff_get_space( 958 __isl_keep isl_multi_aff *maff); 959 __isl_give isl_space *isl_pw_multi_aff_get_domain_space( 960 __isl_keep isl_pw_multi_aff *pma); 961 __isl_give isl_space *isl_pw_multi_aff_get_space( 962 __isl_keep isl_pw_multi_aff *pma); 963 __isl_give isl_space *isl_union_pw_multi_aff_get_space( 964 __isl_keep isl_union_pw_multi_aff *upma); 965 __isl_give isl_space *isl_multi_pw_aff_get_domain_space( 966 __isl_keep isl_multi_pw_aff *mpa); 967 __isl_give isl_space *isl_multi_pw_aff_get_space( 968 __isl_keep isl_multi_pw_aff *mpa); 969 970 #include <isl/point.h> 971 __isl_give isl_space *isl_point_get_space( 972 __isl_keep isl_point *pnt); 973 974The identifiers or names of the individual dimensions may be set or read off 975using the following functions. 976 977 #include <isl/space.h> 978 __isl_give isl_space *isl_space_set_dim_id( 979 __isl_take isl_space *space, 980 enum isl_dim_type type, unsigned pos, 981 __isl_take isl_id *id); 982 int isl_space_has_dim_id(__isl_keep isl_space *space, 983 enum isl_dim_type type, unsigned pos); 984 __isl_give isl_id *isl_space_get_dim_id( 985 __isl_keep isl_space *space, 986 enum isl_dim_type type, unsigned pos); 987 __isl_give isl_space *isl_space_set_dim_name( 988 __isl_take isl_space *space, 989 enum isl_dim_type type, unsigned pos, 990 __isl_keep const char *name); 991 int isl_space_has_dim_name(__isl_keep isl_space *space, 992 enum isl_dim_type type, unsigned pos); 993 __isl_keep const char *isl_space_get_dim_name( 994 __isl_keep isl_space *space, 995 enum isl_dim_type type, unsigned pos); 996 997Note that C<isl_space_get_name> returns a pointer to some internal 998data structure, so the result can only be used while the 999corresponding C<isl_space> is alive. 1000Also note that every function that operates on two sets or relations 1001requires that both arguments have the same parameters. This also 1002means that if one of the arguments has named parameters, then the 1003other needs to have named parameters too and the names need to match. 1004Pairs of C<isl_set>, C<isl_map>, C<isl_union_set> and/or C<isl_union_map> 1005arguments may have different parameters (as long as they are named), 1006in which case the result will have as parameters the union of the parameters of 1007the arguments. 1008 1009Given the identifier or name of a dimension (typically a parameter), 1010its position can be obtained from the following function. 1011 1012 #include <isl/space.h> 1013 int isl_space_find_dim_by_id(__isl_keep isl_space *space, 1014 enum isl_dim_type type, __isl_keep isl_id *id); 1015 int isl_space_find_dim_by_name(__isl_keep isl_space *space, 1016 enum isl_dim_type type, const char *name); 1017 1018The identifiers or names of entire spaces may be set or read off 1019using the following functions. 1020 1021 #include <isl/space.h> 1022 __isl_give isl_space *isl_space_set_tuple_id( 1023 __isl_take isl_space *space, 1024 enum isl_dim_type type, __isl_take isl_id *id); 1025 __isl_give isl_space *isl_space_reset_tuple_id( 1026 __isl_take isl_space *space, enum isl_dim_type type); 1027 int isl_space_has_tuple_id(__isl_keep isl_space *space, 1028 enum isl_dim_type type); 1029 __isl_give isl_id *isl_space_get_tuple_id( 1030 __isl_keep isl_space *space, enum isl_dim_type type); 1031 __isl_give isl_space *isl_space_set_tuple_name( 1032 __isl_take isl_space *space, 1033 enum isl_dim_type type, const char *s); 1034 int isl_space_has_tuple_name(__isl_keep isl_space *space, 1035 enum isl_dim_type type); 1036 const char *isl_space_get_tuple_name(__isl_keep isl_space *space, 1037 enum isl_dim_type type); 1038 1039The C<type> argument needs to be one of C<isl_dim_in>, C<isl_dim_out> 1040or C<isl_dim_set>. As with C<isl_space_get_name>, 1041the C<isl_space_get_tuple_name> function returns a pointer to some internal 1042data structure. 1043Binary operations require the corresponding spaces of their arguments 1044to have the same name. 1045 1046Spaces can be nested. In particular, the domain of a set or 1047the domain or range of a relation can be a nested relation. 1048The following functions can be used to construct and deconstruct 1049such nested spaces. 1050 1051 #include <isl/space.h> 1052 int isl_space_is_wrapping(__isl_keep isl_space *space); 1053 __isl_give isl_space *isl_space_wrap(__isl_take isl_space *space); 1054 __isl_give isl_space *isl_space_unwrap(__isl_take isl_space *space); 1055 1056The input to C<isl_space_is_wrapping> and C<isl_space_unwrap> should 1057be the space of a set, while that of 1058C<isl_space_wrap> should be the space of a relation. 1059Conversely, the output of C<isl_space_unwrap> is the space 1060of a relation, while that of C<isl_space_wrap> is the space of a set. 1061 1062Spaces can be created from other spaces 1063using the following functions. 1064 1065 __isl_give isl_space *isl_space_domain(__isl_take isl_space *space); 1066 __isl_give isl_space *isl_space_from_domain(__isl_take isl_space *space); 1067 __isl_give isl_space *isl_space_range(__isl_take isl_space *space); 1068 __isl_give isl_space *isl_space_from_range(__isl_take isl_space *space); 1069 __isl_give isl_space *isl_space_params( 1070 __isl_take isl_space *space); 1071 __isl_give isl_space *isl_space_set_from_params( 1072 __isl_take isl_space *space); 1073 __isl_give isl_space *isl_space_reverse(__isl_take isl_space *space); 1074 __isl_give isl_space *isl_space_join(__isl_take isl_space *left, 1075 __isl_take isl_space *right); 1076 __isl_give isl_space *isl_space_align_params( 1077 __isl_take isl_space *space1, __isl_take isl_space *space2) 1078 __isl_give isl_space *isl_space_insert_dims(__isl_take isl_space *space, 1079 enum isl_dim_type type, unsigned pos, unsigned n); 1080 __isl_give isl_space *isl_space_add_dims(__isl_take isl_space *space, 1081 enum isl_dim_type type, unsigned n); 1082 __isl_give isl_space *isl_space_drop_dims(__isl_take isl_space *space, 1083 enum isl_dim_type type, unsigned first, unsigned n); 1084 __isl_give isl_space *isl_space_move_dims(__isl_take isl_space *space, 1085 enum isl_dim_type dst_type, unsigned dst_pos, 1086 enum isl_dim_type src_type, unsigned src_pos, 1087 unsigned n); 1088 __isl_give isl_space *isl_space_map_from_set( 1089 __isl_take isl_space *space); 1090 __isl_give isl_space *isl_space_map_from_domain_and_range( 1091 __isl_take isl_space *domain, 1092 __isl_take isl_space *range); 1093 __isl_give isl_space *isl_space_zip(__isl_take isl_space *space); 1094 __isl_give isl_space *isl_space_curry( 1095 __isl_take isl_space *space); 1096 __isl_give isl_space *isl_space_uncurry( 1097 __isl_take isl_space *space); 1098 1099Note that if dimensions are added or removed from a space, then 1100the name and the internal structure are lost. 1101 1102=head2 Local Spaces 1103 1104A local space is essentially a space with 1105zero or more existentially quantified variables. 1106The local space of a (constraint of a) basic set or relation can be obtained 1107using the following functions. 1108 1109 #include <isl/constraint.h> 1110 __isl_give isl_local_space *isl_constraint_get_local_space( 1111 __isl_keep isl_constraint *constraint); 1112 1113 #include <isl/set.h> 1114 __isl_give isl_local_space *isl_basic_set_get_local_space( 1115 __isl_keep isl_basic_set *bset); 1116 1117 #include <isl/map.h> 1118 __isl_give isl_local_space *isl_basic_map_get_local_space( 1119 __isl_keep isl_basic_map *bmap); 1120 1121A new local space can be created from a space using 1122 1123 #include <isl/local_space.h> 1124 __isl_give isl_local_space *isl_local_space_from_space( 1125 __isl_take isl_space *space); 1126 1127They can be inspected, modified, copied and freed using the following functions. 1128 1129 #include <isl/local_space.h> 1130 isl_ctx *isl_local_space_get_ctx( 1131 __isl_keep isl_local_space *ls); 1132 int isl_local_space_is_set(__isl_keep isl_local_space *ls); 1133 int isl_local_space_dim(__isl_keep isl_local_space *ls, 1134 enum isl_dim_type type); 1135 int isl_local_space_has_dim_id( 1136 __isl_keep isl_local_space *ls, 1137 enum isl_dim_type type, unsigned pos); 1138 __isl_give isl_id *isl_local_space_get_dim_id( 1139 __isl_keep isl_local_space *ls, 1140 enum isl_dim_type type, unsigned pos); 1141 int isl_local_space_has_dim_name( 1142 __isl_keep isl_local_space *ls, 1143 enum isl_dim_type type, unsigned pos) 1144 const char *isl_local_space_get_dim_name( 1145 __isl_keep isl_local_space *ls, 1146 enum isl_dim_type type, unsigned pos); 1147 __isl_give isl_local_space *isl_local_space_set_dim_name( 1148 __isl_take isl_local_space *ls, 1149 enum isl_dim_type type, unsigned pos, const char *s); 1150 __isl_give isl_local_space *isl_local_space_set_dim_id( 1151 __isl_take isl_local_space *ls, 1152 enum isl_dim_type type, unsigned pos, 1153 __isl_take isl_id *id); 1154 __isl_give isl_space *isl_local_space_get_space( 1155 __isl_keep isl_local_space *ls); 1156 __isl_give isl_aff *isl_local_space_get_div( 1157 __isl_keep isl_local_space *ls, int pos); 1158 __isl_give isl_local_space *isl_local_space_copy( 1159 __isl_keep isl_local_space *ls); 1160 void *isl_local_space_free(__isl_take isl_local_space *ls); 1161 1162Note that C<isl_local_space_get_div> can only be used on local spaces 1163of sets. 1164 1165Two local spaces can be compared using 1166 1167 int isl_local_space_is_equal(__isl_keep isl_local_space *ls1, 1168 __isl_keep isl_local_space *ls2); 1169 1170Local spaces can be created from other local spaces 1171using the following functions. 1172 1173 __isl_give isl_local_space *isl_local_space_domain( 1174 __isl_take isl_local_space *ls); 1175 __isl_give isl_local_space *isl_local_space_range( 1176 __isl_take isl_local_space *ls); 1177 __isl_give isl_local_space *isl_local_space_from_domain( 1178 __isl_take isl_local_space *ls); 1179 __isl_give isl_local_space *isl_local_space_intersect( 1180 __isl_take isl_local_space *ls1, 1181 __isl_take isl_local_space *ls2); 1182 __isl_give isl_local_space *isl_local_space_add_dims( 1183 __isl_take isl_local_space *ls, 1184 enum isl_dim_type type, unsigned n); 1185 __isl_give isl_local_space *isl_local_space_insert_dims( 1186 __isl_take isl_local_space *ls, 1187 enum isl_dim_type type, unsigned first, unsigned n); 1188 __isl_give isl_local_space *isl_local_space_drop_dims( 1189 __isl_take isl_local_space *ls, 1190 enum isl_dim_type type, unsigned first, unsigned n); 1191 1192=head2 Input and Output 1193 1194C<isl> supports its own input/output format, which is similar 1195to the C<Omega> format, but also supports the C<PolyLib> format 1196in some cases. 1197 1198=head3 C<isl> format 1199 1200The C<isl> format is similar to that of C<Omega>, but has a different 1201syntax for describing the parameters and allows for the definition 1202of an existentially quantified variable as the integer division 1203of an affine expression. 1204For example, the set of integers C<i> between C<0> and C<n> 1205such that C<i % 10 <= 6> can be described as 1206 1207 [n] -> { [i] : exists (a = [i/10] : 0 <= i and i <= n and 1208 i - 10 a <= 6) } 1209 1210A set or relation can have several disjuncts, separated 1211by the keyword C<or>. Each disjunct is either a conjunction 1212of constraints or a projection (C<exists>) of a conjunction 1213of constraints. The constraints are separated by the keyword 1214C<and>. 1215 1216=head3 C<PolyLib> format 1217 1218If the represented set is a union, then the first line 1219contains a single number representing the number of disjuncts. 1220Otherwise, a line containing the number C<1> is optional. 1221 1222Each disjunct is represented by a matrix of constraints. 1223The first line contains two numbers representing 1224the number of rows and columns, 1225where the number of rows is equal to the number of constraints 1226and the number of columns is equal to two plus the number of variables. 1227The following lines contain the actual rows of the constraint matrix. 1228In each row, the first column indicates whether the constraint 1229is an equality (C<0>) or inequality (C<1>). The final column 1230corresponds to the constant term. 1231 1232If the set is parametric, then the coefficients of the parameters 1233appear in the last columns before the constant column. 1234The coefficients of any existentially quantified variables appear 1235between those of the set variables and those of the parameters. 1236 1237=head3 Extended C<PolyLib> format 1238 1239The extended C<PolyLib> format is nearly identical to the 1240C<PolyLib> format. The only difference is that the line 1241containing the number of rows and columns of a constraint matrix 1242also contains four additional numbers: 1243the number of output dimensions, the number of input dimensions, 1244the number of local dimensions (i.e., the number of existentially 1245quantified variables) and the number of parameters. 1246For sets, the number of ``output'' dimensions is equal 1247to the number of set dimensions, while the number of ``input'' 1248dimensions is zero. 1249 1250=head3 Input 1251 1252 #include <isl/set.h> 1253 __isl_give isl_basic_set *isl_basic_set_read_from_file( 1254 isl_ctx *ctx, FILE *input); 1255 __isl_give isl_basic_set *isl_basic_set_read_from_str( 1256 isl_ctx *ctx, const char *str); 1257 __isl_give isl_set *isl_set_read_from_file(isl_ctx *ctx, 1258 FILE *input); 1259 __isl_give isl_set *isl_set_read_from_str(isl_ctx *ctx, 1260 const char *str); 1261 1262 #include <isl/map.h> 1263 __isl_give isl_basic_map *isl_basic_map_read_from_file( 1264 isl_ctx *ctx, FILE *input); 1265 __isl_give isl_basic_map *isl_basic_map_read_from_str( 1266 isl_ctx *ctx, const char *str); 1267 __isl_give isl_map *isl_map_read_from_file( 1268 isl_ctx *ctx, FILE *input); 1269 __isl_give isl_map *isl_map_read_from_str(isl_ctx *ctx, 1270 const char *str); 1271 1272 #include <isl/union_set.h> 1273 __isl_give isl_union_set *isl_union_set_read_from_file( 1274 isl_ctx *ctx, FILE *input); 1275 __isl_give isl_union_set *isl_union_set_read_from_str( 1276 isl_ctx *ctx, const char *str); 1277 1278 #include <isl/union_map.h> 1279 __isl_give isl_union_map *isl_union_map_read_from_file( 1280 isl_ctx *ctx, FILE *input); 1281 __isl_give isl_union_map *isl_union_map_read_from_str( 1282 isl_ctx *ctx, const char *str); 1283 1284The input format is autodetected and may be either the C<PolyLib> format 1285or the C<isl> format. 1286 1287=head3 Output 1288 1289Before anything can be printed, an C<isl_printer> needs to 1290be created. 1291 1292 __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx, 1293 FILE *file); 1294 __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx); 1295 void *isl_printer_free(__isl_take isl_printer *printer); 1296 __isl_give char *isl_printer_get_str( 1297 __isl_keep isl_printer *printer); 1298 1299The printer can be inspected using the following functions. 1300 1301 FILE *isl_printer_get_file( 1302 __isl_keep isl_printer *printer); 1303 int isl_printer_get_output_format( 1304 __isl_keep isl_printer *p); 1305 1306The behavior of the printer can be modified in various ways 1307 1308 __isl_give isl_printer *isl_printer_set_output_format( 1309 __isl_take isl_printer *p, int output_format); 1310 __isl_give isl_printer *isl_printer_set_indent( 1311 __isl_take isl_printer *p, int indent); 1312 __isl_give isl_printer *isl_printer_indent( 1313 __isl_take isl_printer *p, int indent); 1314 __isl_give isl_printer *isl_printer_set_prefix( 1315 __isl_take isl_printer *p, const char *prefix); 1316 __isl_give isl_printer *isl_printer_set_suffix( 1317 __isl_take isl_printer *p, const char *suffix); 1318 1319The C<output_format> may be either C<ISL_FORMAT_ISL>, C<ISL_FORMAT_OMEGA>, 1320C<ISL_FORMAT_POLYLIB>, C<ISL_FORMAT_EXT_POLYLIB> or C<ISL_FORMAT_LATEX> 1321and defaults to C<ISL_FORMAT_ISL>. 1322Each line in the output is indented by C<indent> (set by 1323C<isl_printer_set_indent>) spaces 1324(default: 0), prefixed by C<prefix> and suffixed by C<suffix>. 1325In the C<PolyLib> format output, 1326the coefficients of the existentially quantified variables 1327appear between those of the set variables and those 1328of the parameters. 1329The function C<isl_printer_indent> increases the indentation 1330by the specified amount (which may be negative). 1331 1332To actually print something, use 1333 1334 #include <isl/printer.h> 1335 __isl_give isl_printer *isl_printer_print_double( 1336 __isl_take isl_printer *p, double d); 1337 1338 #include <isl/set.h> 1339 __isl_give isl_printer *isl_printer_print_basic_set( 1340 __isl_take isl_printer *printer, 1341 __isl_keep isl_basic_set *bset); 1342 __isl_give isl_printer *isl_printer_print_set( 1343 __isl_take isl_printer *printer, 1344 __isl_keep isl_set *set); 1345 1346 #include <isl/map.h> 1347 __isl_give isl_printer *isl_printer_print_basic_map( 1348 __isl_take isl_printer *printer, 1349 __isl_keep isl_basic_map *bmap); 1350 __isl_give isl_printer *isl_printer_print_map( 1351 __isl_take isl_printer *printer, 1352 __isl_keep isl_map *map); 1353 1354 #include <isl/union_set.h> 1355 __isl_give isl_printer *isl_printer_print_union_set( 1356 __isl_take isl_printer *p, 1357 __isl_keep isl_union_set *uset); 1358 1359 #include <isl/union_map.h> 1360 __isl_give isl_printer *isl_printer_print_union_map( 1361 __isl_take isl_printer *p, 1362 __isl_keep isl_union_map *umap); 1363 1364When called on a file printer, the following function flushes 1365the file. When called on a string printer, the buffer is cleared. 1366 1367 __isl_give isl_printer *isl_printer_flush( 1368 __isl_take isl_printer *p); 1369 1370=head2 Creating New Sets and Relations 1371 1372C<isl> has functions for creating some standard sets and relations. 1373 1374=over 1375 1376=item * Empty sets and relations 1377 1378 __isl_give isl_basic_set *isl_basic_set_empty( 1379 __isl_take isl_space *space); 1380 __isl_give isl_basic_map *isl_basic_map_empty( 1381 __isl_take isl_space *space); 1382 __isl_give isl_set *isl_set_empty( 1383 __isl_take isl_space *space); 1384 __isl_give isl_map *isl_map_empty( 1385 __isl_take isl_space *space); 1386 __isl_give isl_union_set *isl_union_set_empty( 1387 __isl_take isl_space *space); 1388 __isl_give isl_union_map *isl_union_map_empty( 1389 __isl_take isl_space *space); 1390 1391For C<isl_union_set>s and C<isl_union_map>s, the space 1392is only used to specify the parameters. 1393 1394=item * Universe sets and relations 1395 1396 __isl_give isl_basic_set *isl_basic_set_universe( 1397 __isl_take isl_space *space); 1398 __isl_give isl_basic_map *isl_basic_map_universe( 1399 __isl_take isl_space *space); 1400 __isl_give isl_set *isl_set_universe( 1401 __isl_take isl_space *space); 1402 __isl_give isl_map *isl_map_universe( 1403 __isl_take isl_space *space); 1404 __isl_give isl_union_set *isl_union_set_universe( 1405 __isl_take isl_union_set *uset); 1406 __isl_give isl_union_map *isl_union_map_universe( 1407 __isl_take isl_union_map *umap); 1408 1409The sets and relations constructed by the functions above 1410contain all integer values, while those constructed by the 1411functions below only contain non-negative values. 1412 1413 __isl_give isl_basic_set *isl_basic_set_nat_universe( 1414 __isl_take isl_space *space); 1415 __isl_give isl_basic_map *isl_basic_map_nat_universe( 1416 __isl_take isl_space *space); 1417 __isl_give isl_set *isl_set_nat_universe( 1418 __isl_take isl_space *space); 1419 __isl_give isl_map *isl_map_nat_universe( 1420 __isl_take isl_space *space); 1421 1422=item * Identity relations 1423 1424 __isl_give isl_basic_map *isl_basic_map_identity( 1425 __isl_take isl_space *space); 1426 __isl_give isl_map *isl_map_identity( 1427 __isl_take isl_space *space); 1428 1429The number of input and output dimensions in C<space> needs 1430to be the same. 1431 1432=item * Lexicographic order 1433 1434 __isl_give isl_map *isl_map_lex_lt( 1435 __isl_take isl_space *set_space); 1436 __isl_give isl_map *isl_map_lex_le( 1437 __isl_take isl_space *set_space); 1438 __isl_give isl_map *isl_map_lex_gt( 1439 __isl_take isl_space *set_space); 1440 __isl_give isl_map *isl_map_lex_ge( 1441 __isl_take isl_space *set_space); 1442 __isl_give isl_map *isl_map_lex_lt_first( 1443 __isl_take isl_space *space, unsigned n); 1444 __isl_give isl_map *isl_map_lex_le_first( 1445 __isl_take isl_space *space, unsigned n); 1446 __isl_give isl_map *isl_map_lex_gt_first( 1447 __isl_take isl_space *space, unsigned n); 1448 __isl_give isl_map *isl_map_lex_ge_first( 1449 __isl_take isl_space *space, unsigned n); 1450 1451The first four functions take a space for a B<set> 1452and return relations that express that the elements in the domain 1453are lexicographically less 1454(C<isl_map_lex_lt>), less or equal (C<isl_map_lex_le>), 1455greater (C<isl_map_lex_gt>) or greater or equal (C<isl_map_lex_ge>) 1456than the elements in the range. 1457The last four functions take a space for a map 1458and return relations that express that the first C<n> dimensions 1459in the domain are lexicographically less 1460(C<isl_map_lex_lt_first>), less or equal (C<isl_map_lex_le_first>), 1461greater (C<isl_map_lex_gt_first>) or greater or equal (C<isl_map_lex_ge_first>) 1462than the first C<n> dimensions in the range. 1463 1464=back 1465 1466A basic set or relation can be converted to a set or relation 1467using the following functions. 1468 1469 __isl_give isl_set *isl_set_from_basic_set( 1470 __isl_take isl_basic_set *bset); 1471 __isl_give isl_map *isl_map_from_basic_map( 1472 __isl_take isl_basic_map *bmap); 1473 1474Sets and relations can be converted to union sets and relations 1475using the following functions. 1476 1477 __isl_give isl_union_set *isl_union_set_from_basic_set( 1478 __isl_take isl_basic_set *bset); 1479 __isl_give isl_union_map *isl_union_map_from_basic_map( 1480 __isl_take isl_basic_map *bmap); 1481 __isl_give isl_union_set *isl_union_set_from_set( 1482 __isl_take isl_set *set); 1483 __isl_give isl_union_map *isl_union_map_from_map( 1484 __isl_take isl_map *map); 1485 1486The inverse conversions below can only be used if the input 1487union set or relation is known to contain elements in exactly one 1488space. 1489 1490 __isl_give isl_set *isl_set_from_union_set( 1491 __isl_take isl_union_set *uset); 1492 __isl_give isl_map *isl_map_from_union_map( 1493 __isl_take isl_union_map *umap); 1494 1495A zero-dimensional (basic) set can be constructed on a given parameter domain 1496using the following function. 1497 1498 __isl_give isl_basic_set *isl_basic_set_from_params( 1499 __isl_take isl_basic_set *bset); 1500 __isl_give isl_set *isl_set_from_params( 1501 __isl_take isl_set *set); 1502 1503Sets and relations can be copied and freed again using the following 1504functions. 1505 1506 __isl_give isl_basic_set *isl_basic_set_copy( 1507 __isl_keep isl_basic_set *bset); 1508 __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set); 1509 __isl_give isl_union_set *isl_union_set_copy( 1510 __isl_keep isl_union_set *uset); 1511 __isl_give isl_basic_map *isl_basic_map_copy( 1512 __isl_keep isl_basic_map *bmap); 1513 __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map); 1514 __isl_give isl_union_map *isl_union_map_copy( 1515 __isl_keep isl_union_map *umap); 1516 void *isl_basic_set_free(__isl_take isl_basic_set *bset); 1517 void *isl_set_free(__isl_take isl_set *set); 1518 void *isl_union_set_free(__isl_take isl_union_set *uset); 1519 void *isl_basic_map_free(__isl_take isl_basic_map *bmap); 1520 void *isl_map_free(__isl_take isl_map *map); 1521 void *isl_union_map_free(__isl_take isl_union_map *umap); 1522 1523Other sets and relations can be constructed by starting 1524from a universe set or relation, adding equality and/or 1525inequality constraints and then projecting out the 1526existentially quantified variables, if any. 1527Constraints can be constructed, manipulated and 1528added to (or removed from) (basic) sets and relations 1529using the following functions. 1530 1531 #include <isl/constraint.h> 1532 __isl_give isl_constraint *isl_equality_alloc( 1533 __isl_take isl_local_space *ls); 1534 __isl_give isl_constraint *isl_inequality_alloc( 1535 __isl_take isl_local_space *ls); 1536 __isl_give isl_constraint *isl_constraint_set_constant( 1537 __isl_take isl_constraint *constraint, isl_int v); 1538 __isl_give isl_constraint *isl_constraint_set_constant_si( 1539 __isl_take isl_constraint *constraint, int v); 1540 __isl_give isl_constraint *isl_constraint_set_constant_val( 1541 __isl_take isl_constraint *constraint, 1542 __isl_take isl_val *v); 1543 __isl_give isl_constraint *isl_constraint_set_coefficient( 1544 __isl_take isl_constraint *constraint, 1545 enum isl_dim_type type, int pos, isl_int v); 1546 __isl_give isl_constraint *isl_constraint_set_coefficient_si( 1547 __isl_take isl_constraint *constraint, 1548 enum isl_dim_type type, int pos, int v); 1549 __isl_give isl_constraint * 1550 isl_constraint_set_coefficient_val( 1551 __isl_take isl_constraint *constraint, 1552 enum isl_dim_type type, int pos, isl_val *v); 1553 __isl_give isl_basic_map *isl_basic_map_add_constraint( 1554 __isl_take isl_basic_map *bmap, 1555 __isl_take isl_constraint *constraint); 1556 __isl_give isl_basic_set *isl_basic_set_add_constraint( 1557 __isl_take isl_basic_set *bset, 1558 __isl_take isl_constraint *constraint); 1559 __isl_give isl_map *isl_map_add_constraint( 1560 __isl_take isl_map *map, 1561 __isl_take isl_constraint *constraint); 1562 __isl_give isl_set *isl_set_add_constraint( 1563 __isl_take isl_set *set, 1564 __isl_take isl_constraint *constraint); 1565 __isl_give isl_basic_set *isl_basic_set_drop_constraint( 1566 __isl_take isl_basic_set *bset, 1567 __isl_take isl_constraint *constraint); 1568 1569For example, to create a set containing the even integers 1570between 10 and 42, you would use the following code. 1571 1572 isl_space *space; 1573 isl_local_space *ls; 1574 isl_constraint *c; 1575 isl_basic_set *bset; 1576 1577 space = isl_space_set_alloc(ctx, 0, 2); 1578 bset = isl_basic_set_universe(isl_space_copy(space)); 1579 ls = isl_local_space_from_space(space); 1580 1581 c = isl_equality_alloc(isl_local_space_copy(ls)); 1582 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1); 1583 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 1, 2); 1584 bset = isl_basic_set_add_constraint(bset, c); 1585 1586 c = isl_inequality_alloc(isl_local_space_copy(ls)); 1587 c = isl_constraint_set_constant_si(c, -10); 1588 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, 1); 1589 bset = isl_basic_set_add_constraint(bset, c); 1590 1591 c = isl_inequality_alloc(ls); 1592 c = isl_constraint_set_constant_si(c, 42); 1593 c = isl_constraint_set_coefficient_si(c, isl_dim_set, 0, -1); 1594 bset = isl_basic_set_add_constraint(bset, c); 1595 1596 bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 1); 1597 1598Or, alternatively, 1599 1600 isl_basic_set *bset; 1601 bset = isl_basic_set_read_from_str(ctx, 1602 "{[i] : exists (a : i = 2a and i >= 10 and i <= 42)}"); 1603 1604A basic set or relation can also be constructed from two matrices 1605describing the equalities and the inequalities. 1606 1607 __isl_give isl_basic_set *isl_basic_set_from_constraint_matrices( 1608 __isl_take isl_space *space, 1609 __isl_take isl_mat *eq, __isl_take isl_mat *ineq, 1610 enum isl_dim_type c1, 1611 enum isl_dim_type c2, enum isl_dim_type c3, 1612 enum isl_dim_type c4); 1613 __isl_give isl_basic_map *isl_basic_map_from_constraint_matrices( 1614 __isl_take isl_space *space, 1615 __isl_take isl_mat *eq, __isl_take isl_mat *ineq, 1616 enum isl_dim_type c1, 1617 enum isl_dim_type c2, enum isl_dim_type c3, 1618 enum isl_dim_type c4, enum isl_dim_type c5); 1619 1620The C<isl_dim_type> arguments indicate the order in which 1621different kinds of variables appear in the input matrices 1622and should be a permutation of C<isl_dim_cst>, C<isl_dim_param>, 1623C<isl_dim_set> and C<isl_dim_div> for sets and 1624of C<isl_dim_cst>, C<isl_dim_param>, 1625C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div> for relations. 1626 1627A (basic or union) set or relation can also be constructed from a 1628(union) (piecewise) (multiple) affine expression 1629or a list of affine expressions 1630(See L<"Piecewise Quasi Affine Expressions"> and 1631L<"Piecewise Multiple Quasi Affine Expressions">). 1632 1633 __isl_give isl_basic_map *isl_basic_map_from_aff( 1634 __isl_take isl_aff *aff); 1635 __isl_give isl_map *isl_map_from_aff( 1636 __isl_take isl_aff *aff); 1637 __isl_give isl_set *isl_set_from_pw_aff( 1638 __isl_take isl_pw_aff *pwaff); 1639 __isl_give isl_map *isl_map_from_pw_aff( 1640 __isl_take isl_pw_aff *pwaff); 1641 __isl_give isl_basic_map *isl_basic_map_from_aff_list( 1642 __isl_take isl_space *domain_space, 1643 __isl_take isl_aff_list *list); 1644 __isl_give isl_basic_map *isl_basic_map_from_multi_aff( 1645 __isl_take isl_multi_aff *maff) 1646 __isl_give isl_map *isl_map_from_multi_aff( 1647 __isl_take isl_multi_aff *maff) 1648 __isl_give isl_set *isl_set_from_pw_multi_aff( 1649 __isl_take isl_pw_multi_aff *pma); 1650 __isl_give isl_map *isl_map_from_pw_multi_aff( 1651 __isl_take isl_pw_multi_aff *pma); 1652 __isl_give isl_union_map * 1653 isl_union_map_from_union_pw_multi_aff( 1654 __isl_take isl_union_pw_multi_aff *upma); 1655 1656The C<domain_dim> argument describes the domain of the resulting 1657basic relation. It is required because the C<list> may consist 1658of zero affine expressions. 1659 1660=head2 Inspecting Sets and Relations 1661 1662Usually, the user should not have to care about the actual constraints 1663of the sets and maps, but should instead apply the abstract operations 1664explained in the following sections. 1665Occasionally, however, it may be required to inspect the individual 1666coefficients of the constraints. This section explains how to do so. 1667In these cases, it may also be useful to have C<isl> compute 1668an explicit representation of the existentially quantified variables. 1669 1670 __isl_give isl_set *isl_set_compute_divs( 1671 __isl_take isl_set *set); 1672 __isl_give isl_map *isl_map_compute_divs( 1673 __isl_take isl_map *map); 1674 __isl_give isl_union_set *isl_union_set_compute_divs( 1675 __isl_take isl_union_set *uset); 1676 __isl_give isl_union_map *isl_union_map_compute_divs( 1677 __isl_take isl_union_map *umap); 1678 1679This explicit representation defines the existentially quantified 1680variables as integer divisions of the other variables, possibly 1681including earlier existentially quantified variables. 1682An explicitly represented existentially quantified variable therefore 1683has a unique value when the values of the other variables are known. 1684If, furthermore, the same existentials, i.e., existentials 1685with the same explicit representations, should appear in the 1686same order in each of the disjuncts of a set or map, then the user should call 1687either of the following functions. 1688 1689 __isl_give isl_set *isl_set_align_divs( 1690 __isl_take isl_set *set); 1691 __isl_give isl_map *isl_map_align_divs( 1692 __isl_take isl_map *map); 1693 1694Alternatively, the existentially quantified variables can be removed 1695using the following functions, which compute an overapproximation. 1696 1697 __isl_give isl_basic_set *isl_basic_set_remove_divs( 1698 __isl_take isl_basic_set *bset); 1699 __isl_give isl_basic_map *isl_basic_map_remove_divs( 1700 __isl_take isl_basic_map *bmap); 1701 __isl_give isl_set *isl_set_remove_divs( 1702 __isl_take isl_set *set); 1703 __isl_give isl_map *isl_map_remove_divs( 1704 __isl_take isl_map *map); 1705 1706It is also possible to only remove those divs that are defined 1707in terms of a given range of dimensions or only those for which 1708no explicit representation is known. 1709 1710 __isl_give isl_basic_set * 1711 isl_basic_set_remove_divs_involving_dims( 1712 __isl_take isl_basic_set *bset, 1713 enum isl_dim_type type, 1714 unsigned first, unsigned n); 1715 __isl_give isl_basic_map * 1716 isl_basic_map_remove_divs_involving_dims( 1717 __isl_take isl_basic_map *bmap, 1718 enum isl_dim_type type, 1719 unsigned first, unsigned n); 1720 __isl_give isl_set *isl_set_remove_divs_involving_dims( 1721 __isl_take isl_set *set, enum isl_dim_type type, 1722 unsigned first, unsigned n); 1723 __isl_give isl_map *isl_map_remove_divs_involving_dims( 1724 __isl_take isl_map *map, enum isl_dim_type type, 1725 unsigned first, unsigned n); 1726 1727 __isl_give isl_basic_set * 1728 isl_basic_set_remove_unknown_divs( 1729 __isl_take isl_basic_set *bset); 1730 __isl_give isl_set *isl_set_remove_unknown_divs( 1731 __isl_take isl_set *set); 1732 __isl_give isl_map *isl_map_remove_unknown_divs( 1733 __isl_take isl_map *map); 1734 1735To iterate over all the sets or maps in a union set or map, use 1736 1737 int isl_union_set_foreach_set(__isl_keep isl_union_set *uset, 1738 int (*fn)(__isl_take isl_set *set, void *user), 1739 void *user); 1740 int isl_union_map_foreach_map(__isl_keep isl_union_map *umap, 1741 int (*fn)(__isl_take isl_map *map, void *user), 1742 void *user); 1743 1744The number of sets or maps in a union set or map can be obtained 1745from 1746 1747 int isl_union_set_n_set(__isl_keep isl_union_set *uset); 1748 int isl_union_map_n_map(__isl_keep isl_union_map *umap); 1749 1750To extract the set or map in a given space from a union, use 1751 1752 __isl_give isl_set *isl_union_set_extract_set( 1753 __isl_keep isl_union_set *uset, 1754 __isl_take isl_space *space); 1755 __isl_give isl_map *isl_union_map_extract_map( 1756 __isl_keep isl_union_map *umap, 1757 __isl_take isl_space *space); 1758 1759To iterate over all the basic sets or maps in a set or map, use 1760 1761 int isl_set_foreach_basic_set(__isl_keep isl_set *set, 1762 int (*fn)(__isl_take isl_basic_set *bset, void *user), 1763 void *user); 1764 int isl_map_foreach_basic_map(__isl_keep isl_map *map, 1765 int (*fn)(__isl_take isl_basic_map *bmap, void *user), 1766 void *user); 1767 1768The callback function C<fn> should return 0 if successful and 1769-1 if an error occurs. In the latter case, or if any other error 1770occurs, the above functions will return -1. 1771 1772It should be noted that C<isl> does not guarantee that 1773the basic sets or maps passed to C<fn> are disjoint. 1774If this is required, then the user should call one of 1775the following functions first. 1776 1777 __isl_give isl_set *isl_set_make_disjoint( 1778 __isl_take isl_set *set); 1779 __isl_give isl_map *isl_map_make_disjoint( 1780 __isl_take isl_map *map); 1781 1782The number of basic sets in a set can be obtained 1783from 1784 1785 int isl_set_n_basic_set(__isl_keep isl_set *set); 1786 1787To iterate over the constraints of a basic set or map, use 1788 1789 #include <isl/constraint.h> 1790 1791 int isl_basic_set_n_constraint( 1792 __isl_keep isl_basic_set *bset); 1793 int isl_basic_set_foreach_constraint( 1794 __isl_keep isl_basic_set *bset, 1795 int (*fn)(__isl_take isl_constraint *c, void *user), 1796 void *user); 1797 int isl_basic_map_foreach_constraint( 1798 __isl_keep isl_basic_map *bmap, 1799 int (*fn)(__isl_take isl_constraint *c, void *user), 1800 void *user); 1801 void *isl_constraint_free(__isl_take isl_constraint *c); 1802 1803Again, the callback function C<fn> should return 0 if successful and 1804-1 if an error occurs. In the latter case, or if any other error 1805occurs, the above functions will return -1. 1806The constraint C<c> represents either an equality or an inequality. 1807Use the following function to find out whether a constraint 1808represents an equality. If not, it represents an inequality. 1809 1810 int isl_constraint_is_equality( 1811 __isl_keep isl_constraint *constraint); 1812 1813The coefficients of the constraints can be inspected using 1814the following functions. 1815 1816 int isl_constraint_is_lower_bound( 1817 __isl_keep isl_constraint *constraint, 1818 enum isl_dim_type type, unsigned pos); 1819 int isl_constraint_is_upper_bound( 1820 __isl_keep isl_constraint *constraint, 1821 enum isl_dim_type type, unsigned pos); 1822 void isl_constraint_get_constant( 1823 __isl_keep isl_constraint *constraint, isl_int *v); 1824 __isl_give isl_val *isl_constraint_get_constant_val( 1825 __isl_keep isl_constraint *constraint); 1826 void isl_constraint_get_coefficient( 1827 __isl_keep isl_constraint *constraint, 1828 enum isl_dim_type type, int pos, isl_int *v); 1829 __isl_give isl_val *isl_constraint_get_coefficient_val( 1830 __isl_keep isl_constraint *constraint, 1831 enum isl_dim_type type, int pos); 1832 int isl_constraint_involves_dims( 1833 __isl_keep isl_constraint *constraint, 1834 enum isl_dim_type type, unsigned first, unsigned n); 1835 1836The explicit representations of the existentially quantified 1837variables can be inspected using the following function. 1838Note that the user is only allowed to use this function 1839if the inspected set or map is the result of a call 1840to C<isl_set_compute_divs> or C<isl_map_compute_divs>. 1841The existentially quantified variable is equal to the floor 1842of the returned affine expression. The affine expression 1843itself can be inspected using the functions in 1844L<"Piecewise Quasi Affine Expressions">. 1845 1846 __isl_give isl_aff *isl_constraint_get_div( 1847 __isl_keep isl_constraint *constraint, int pos); 1848 1849To obtain the constraints of a basic set or map in matrix 1850form, use the following functions. 1851 1852 __isl_give isl_mat *isl_basic_set_equalities_matrix( 1853 __isl_keep isl_basic_set *bset, 1854 enum isl_dim_type c1, enum isl_dim_type c2, 1855 enum isl_dim_type c3, enum isl_dim_type c4); 1856 __isl_give isl_mat *isl_basic_set_inequalities_matrix( 1857 __isl_keep isl_basic_set *bset, 1858 enum isl_dim_type c1, enum isl_dim_type c2, 1859 enum isl_dim_type c3, enum isl_dim_type c4); 1860 __isl_give isl_mat *isl_basic_map_equalities_matrix( 1861 __isl_keep isl_basic_map *bmap, 1862 enum isl_dim_type c1, 1863 enum isl_dim_type c2, enum isl_dim_type c3, 1864 enum isl_dim_type c4, enum isl_dim_type c5); 1865 __isl_give isl_mat *isl_basic_map_inequalities_matrix( 1866 __isl_keep isl_basic_map *bmap, 1867 enum isl_dim_type c1, 1868 enum isl_dim_type c2, enum isl_dim_type c3, 1869 enum isl_dim_type c4, enum isl_dim_type c5); 1870 1871The C<isl_dim_type> arguments dictate the order in which 1872different kinds of variables appear in the resulting matrix 1873and should be a permutation of C<isl_dim_cst>, C<isl_dim_param>, 1874C<isl_dim_in>, C<isl_dim_out> and C<isl_dim_div>. 1875 1876The number of parameters, input, output or set dimensions can 1877be obtained using the following functions. 1878 1879 unsigned isl_basic_set_dim(__isl_keep isl_basic_set *bset, 1880 enum isl_dim_type type); 1881 unsigned isl_basic_map_dim(__isl_keep isl_basic_map *bmap, 1882 enum isl_dim_type type); 1883 unsigned isl_set_dim(__isl_keep isl_set *set, 1884 enum isl_dim_type type); 1885 unsigned isl_map_dim(__isl_keep isl_map *map, 1886 enum isl_dim_type type); 1887 1888To check whether the description of a set or relation depends 1889on one or more given dimensions, it is not necessary to iterate over all 1890constraints. Instead the following functions can be used. 1891 1892 int isl_basic_set_involves_dims( 1893 __isl_keep isl_basic_set *bset, 1894 enum isl_dim_type type, unsigned first, unsigned n); 1895 int isl_set_involves_dims(__isl_keep isl_set *set, 1896 enum isl_dim_type type, unsigned first, unsigned n); 1897 int isl_basic_map_involves_dims( 1898 __isl_keep isl_basic_map *bmap, 1899 enum isl_dim_type type, unsigned first, unsigned n); 1900 int isl_map_involves_dims(__isl_keep isl_map *map, 1901 enum isl_dim_type type, unsigned first, unsigned n); 1902 1903Similarly, the following functions can be used to check whether 1904a given dimension is involved in any lower or upper bound. 1905 1906 int isl_set_dim_has_any_lower_bound(__isl_keep isl_set *set, 1907 enum isl_dim_type type, unsigned pos); 1908 int isl_set_dim_has_any_upper_bound(__isl_keep isl_set *set, 1909 enum isl_dim_type type, unsigned pos); 1910 1911Note that these functions return true even if there is a bound on 1912the dimension on only some of the basic sets of C<set>. 1913To check if they have a bound for all of the basic sets in C<set>, 1914use the following functions instead. 1915 1916 int isl_set_dim_has_lower_bound(__isl_keep isl_set *set, 1917 enum isl_dim_type type, unsigned pos); 1918 int isl_set_dim_has_upper_bound(__isl_keep isl_set *set, 1919 enum isl_dim_type type, unsigned pos); 1920 1921The identifiers or names of the domain and range spaces of a set 1922or relation can be read off or set using the following functions. 1923 1924 __isl_give isl_set *isl_set_set_tuple_id( 1925 __isl_take isl_set *set, __isl_take isl_id *id); 1926 __isl_give isl_set *isl_set_reset_tuple_id( 1927 __isl_take isl_set *set); 1928 int isl_set_has_tuple_id(__isl_keep isl_set *set); 1929 __isl_give isl_id *isl_set_get_tuple_id( 1930 __isl_keep isl_set *set); 1931 __isl_give isl_map *isl_map_set_tuple_id( 1932 __isl_take isl_map *map, enum isl_dim_type type, 1933 __isl_take isl_id *id); 1934 __isl_give isl_map *isl_map_reset_tuple_id( 1935 __isl_take isl_map *map, enum isl_dim_type type); 1936 int isl_map_has_tuple_id(__isl_keep isl_map *map, 1937 enum isl_dim_type type); 1938 __isl_give isl_id *isl_map_get_tuple_id( 1939 __isl_keep isl_map *map, enum isl_dim_type type); 1940 1941 const char *isl_basic_set_get_tuple_name( 1942 __isl_keep isl_basic_set *bset); 1943 __isl_give isl_basic_set *isl_basic_set_set_tuple_name( 1944 __isl_take isl_basic_set *set, const char *s); 1945 int isl_set_has_tuple_name(__isl_keep isl_set *set); 1946 const char *isl_set_get_tuple_name( 1947 __isl_keep isl_set *set); 1948 const char *isl_basic_map_get_tuple_name( 1949 __isl_keep isl_basic_map *bmap, 1950 enum isl_dim_type type); 1951 __isl_give isl_basic_map *isl_basic_map_set_tuple_name( 1952 __isl_take isl_basic_map *bmap, 1953 enum isl_dim_type type, const char *s); 1954 int isl_map_has_tuple_name(__isl_keep isl_map *map, 1955 enum isl_dim_type type); 1956 const char *isl_map_get_tuple_name( 1957 __isl_keep isl_map *map, 1958 enum isl_dim_type type); 1959 1960As with C<isl_space_get_tuple_name>, the value returned points to 1961an internal data structure. 1962The identifiers, positions or names of individual dimensions can be 1963read off using the following functions. 1964 1965 __isl_give isl_id *isl_basic_set_get_dim_id( 1966 __isl_keep isl_basic_set *bset, 1967 enum isl_dim_type type, unsigned pos); 1968 __isl_give isl_set *isl_set_set_dim_id( 1969 __isl_take isl_set *set, enum isl_dim_type type, 1970 unsigned pos, __isl_take isl_id *id); 1971 int isl_set_has_dim_id(__isl_keep isl_set *set, 1972 enum isl_dim_type type, unsigned pos); 1973 __isl_give isl_id *isl_set_get_dim_id( 1974 __isl_keep isl_set *set, enum isl_dim_type type, 1975 unsigned pos); 1976 int isl_basic_map_has_dim_id( 1977 __isl_keep isl_basic_map *bmap, 1978 enum isl_dim_type type, unsigned pos); 1979 __isl_give isl_map *isl_map_set_dim_id( 1980 __isl_take isl_map *map, enum isl_dim_type type, 1981 unsigned pos, __isl_take isl_id *id); 1982 int isl_map_has_dim_id(__isl_keep isl_map *map, 1983 enum isl_dim_type type, unsigned pos); 1984 __isl_give isl_id *isl_map_get_dim_id( 1985 __isl_keep isl_map *map, enum isl_dim_type type, 1986 unsigned pos); 1987 1988 int isl_set_find_dim_by_id(__isl_keep isl_set *set, 1989 enum isl_dim_type type, __isl_keep isl_id *id); 1990 int isl_map_find_dim_by_id(__isl_keep isl_map *map, 1991 enum isl_dim_type type, __isl_keep isl_id *id); 1992 int isl_set_find_dim_by_name(__isl_keep isl_set *set, 1993 enum isl_dim_type type, const char *name); 1994 int isl_map_find_dim_by_name(__isl_keep isl_map *map, 1995 enum isl_dim_type type, const char *name); 1996 1997 const char *isl_constraint_get_dim_name( 1998 __isl_keep isl_constraint *constraint, 1999 enum isl_dim_type type, unsigned pos); 2000 const char *isl_basic_set_get_dim_name( 2001 __isl_keep isl_basic_set *bset, 2002 enum isl_dim_type type, unsigned pos); 2003 int isl_set_has_dim_name(__isl_keep isl_set *set, 2004 enum isl_dim_type type, unsigned pos); 2005 const char *isl_set_get_dim_name( 2006 __isl_keep isl_set *set, 2007 enum isl_dim_type type, unsigned pos); 2008 const char *isl_basic_map_get_dim_name( 2009 __isl_keep isl_basic_map *bmap, 2010 enum isl_dim_type type, unsigned pos); 2011 int isl_map_has_dim_name(__isl_keep isl_map *map, 2012 enum isl_dim_type type, unsigned pos); 2013 const char *isl_map_get_dim_name( 2014 __isl_keep isl_map *map, 2015 enum isl_dim_type type, unsigned pos); 2016 2017These functions are mostly useful to obtain the identifiers, positions 2018or names of the parameters. Identifiers of individual dimensions are 2019essentially only useful for printing. They are ignored by all other 2020operations and may not be preserved across those operations. 2021 2022=head2 Properties 2023 2024=head3 Unary Properties 2025 2026=over 2027 2028=item * Emptiness 2029 2030The following functions test whether the given set or relation 2031contains any integer points. The ``plain'' variants do not perform 2032any computations, but simply check if the given set or relation 2033is already known to be empty. 2034 2035 int isl_basic_set_plain_is_empty(__isl_keep isl_basic_set *bset); 2036 int isl_basic_set_is_empty(__isl_keep isl_basic_set *bset); 2037 int isl_set_plain_is_empty(__isl_keep isl_set *set); 2038 int isl_set_is_empty(__isl_keep isl_set *set); 2039 int isl_union_set_is_empty(__isl_keep isl_union_set *uset); 2040 int isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap); 2041 int isl_basic_map_is_empty(__isl_keep isl_basic_map *bmap); 2042 int isl_map_plain_is_empty(__isl_keep isl_map *map); 2043 int isl_map_is_empty(__isl_keep isl_map *map); 2044 int isl_union_map_is_empty(__isl_keep isl_union_map *umap); 2045 2046=item * Universality 2047 2048 int isl_basic_set_is_universe(__isl_keep isl_basic_set *bset); 2049 int isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap); 2050 int isl_set_plain_is_universe(__isl_keep isl_set *set); 2051 2052=item * Single-valuedness 2053 2054 int isl_basic_map_is_single_valued( 2055 __isl_keep isl_basic_map *bmap); 2056 int isl_map_plain_is_single_valued( 2057 __isl_keep isl_map *map); 2058 int isl_map_is_single_valued(__isl_keep isl_map *map); 2059 int isl_union_map_is_single_valued(__isl_keep isl_union_map *umap); 2060 2061=item * Injectivity 2062 2063 int isl_map_plain_is_injective(__isl_keep isl_map *map); 2064 int isl_map_is_injective(__isl_keep isl_map *map); 2065 int isl_union_map_plain_is_injective( 2066 __isl_keep isl_union_map *umap); 2067 int isl_union_map_is_injective( 2068 __isl_keep isl_union_map *umap); 2069 2070=item * Bijectivity 2071 2072 int isl_map_is_bijective(__isl_keep isl_map *map); 2073 int isl_union_map_is_bijective(__isl_keep isl_union_map *umap); 2074 2075=item * Position 2076 2077 int isl_basic_map_plain_is_fixed( 2078 __isl_keep isl_basic_map *bmap, 2079 enum isl_dim_type type, unsigned pos, 2080 isl_int *val); 2081 int isl_set_plain_is_fixed(__isl_keep isl_set *set, 2082 enum isl_dim_type type, unsigned pos, 2083 isl_int *val); 2084 int isl_map_plain_is_fixed(__isl_keep isl_map *map, 2085 enum isl_dim_type type, unsigned pos, 2086 isl_int *val); 2087 2088Check if the relation obviously lies on a hyperplane where the given dimension 2089has a fixed value and if so, return that value in C<*val>. 2090 2091 __isl_give isl_val * 2092 isl_basic_map_plain_get_val_if_fixed( 2093 __isl_keep isl_basic_map *bmap, 2094 enum isl_dim_type type, unsigned pos); 2095 __isl_give isl_val *isl_set_plain_get_val_if_fixed( 2096 __isl_keep isl_set *set, 2097 enum isl_dim_type type, unsigned pos); 2098 __isl_give isl_val *isl_map_plain_get_val_if_fixed( 2099 __isl_keep isl_map *map, 2100 enum isl_dim_type type, unsigned pos); 2101 2102If the set or relation obviously lies on a hyperplane where the given dimension 2103has a fixed value, then return that value. 2104Otherwise return NaN. 2105 2106=item * Stride 2107 2108 int isl_set_dim_residue_class_val( 2109 __isl_keep isl_set *set, 2110 int pos, __isl_give isl_val **modulo, 2111 __isl_give isl_val **residue); 2112 2113Check if the values of the given set dimension are equal to a fixed 2114value modulo some integer value. If so, assign the modulo to C<*modulo> 2115and the fixed value to C<*residue>. If the given dimension attains only 2116a single value, then assign C<0> to C<*modulo> and the fixed value to 2117C<*residue>. 2118If the dimension does not attain only a single value and if no modulo 2119can be found then assign C<1> to C<*modulo> and C<1> to C<*residue>. 2120 2121=item * Space 2122 2123To check whether a set is a parameter domain, use this function: 2124 2125 int isl_set_is_params(__isl_keep isl_set *set); 2126 int isl_union_set_is_params( 2127 __isl_keep isl_union_set *uset); 2128 2129=item * Wrapping 2130 2131The following functions check whether the domain of the given 2132(basic) set is a wrapped relation. 2133 2134 int isl_basic_set_is_wrapping( 2135 __isl_keep isl_basic_set *bset); 2136 int isl_set_is_wrapping(__isl_keep isl_set *set); 2137 2138=item * Internal Product 2139 2140 int isl_basic_map_can_zip( 2141 __isl_keep isl_basic_map *bmap); 2142 int isl_map_can_zip(__isl_keep isl_map *map); 2143 2144Check whether the product of domain and range of the given relation 2145can be computed, 2146i.e., whether both domain and range are nested relations. 2147 2148=item * Currying 2149 2150 int isl_basic_map_can_curry( 2151 __isl_keep isl_basic_map *bmap); 2152 int isl_map_can_curry(__isl_keep isl_map *map); 2153 2154Check whether the domain of the (basic) relation is a wrapped relation. 2155 2156 int isl_basic_map_can_uncurry( 2157 __isl_keep isl_basic_map *bmap); 2158 int isl_map_can_uncurry(__isl_keep isl_map *map); 2159 2160Check whether the range of the (basic) relation is a wrapped relation. 2161 2162=back 2163 2164=head3 Binary Properties 2165 2166=over 2167 2168=item * Equality 2169 2170 int isl_set_plain_is_equal(__isl_keep isl_set *set1, 2171 __isl_keep isl_set *set2); 2172 int isl_set_is_equal(__isl_keep isl_set *set1, 2173 __isl_keep isl_set *set2); 2174 int isl_union_set_is_equal( 2175 __isl_keep isl_union_set *uset1, 2176 __isl_keep isl_union_set *uset2); 2177 int isl_basic_map_is_equal( 2178 __isl_keep isl_basic_map *bmap1, 2179 __isl_keep isl_basic_map *bmap2); 2180 int isl_map_is_equal(__isl_keep isl_map *map1, 2181 __isl_keep isl_map *map2); 2182 int isl_map_plain_is_equal(__isl_keep isl_map *map1, 2183 __isl_keep isl_map *map2); 2184 int isl_union_map_is_equal( 2185 __isl_keep isl_union_map *umap1, 2186 __isl_keep isl_union_map *umap2); 2187 2188=item * Disjointness 2189 2190 int isl_set_plain_is_disjoint(__isl_keep isl_set *set1, 2191 __isl_keep isl_set *set2); 2192 int isl_set_is_disjoint(__isl_keep isl_set *set1, 2193 __isl_keep isl_set *set2); 2194 int isl_map_is_disjoint(__isl_keep isl_map *map1, 2195 __isl_keep isl_map *map2); 2196 2197=item * Subset 2198 2199 int isl_basic_set_is_subset( 2200 __isl_keep isl_basic_set *bset1, 2201 __isl_keep isl_basic_set *bset2); 2202 int isl_set_is_subset(__isl_keep isl_set *set1, 2203 __isl_keep isl_set *set2); 2204 int isl_set_is_strict_subset( 2205 __isl_keep isl_set *set1, 2206 __isl_keep isl_set *set2); 2207 int isl_union_set_is_subset( 2208 __isl_keep isl_union_set *uset1, 2209 __isl_keep isl_union_set *uset2); 2210 int isl_union_set_is_strict_subset( 2211 __isl_keep isl_union_set *uset1, 2212 __isl_keep isl_union_set *uset2); 2213 int isl_basic_map_is_subset( 2214 __isl_keep isl_basic_map *bmap1, 2215 __isl_keep isl_basic_map *bmap2); 2216 int isl_basic_map_is_strict_subset( 2217 __isl_keep isl_basic_map *bmap1, 2218 __isl_keep isl_basic_map *bmap2); 2219 int isl_map_is_subset( 2220 __isl_keep isl_map *map1, 2221 __isl_keep isl_map *map2); 2222 int isl_map_is_strict_subset( 2223 __isl_keep isl_map *map1, 2224 __isl_keep isl_map *map2); 2225 int isl_union_map_is_subset( 2226 __isl_keep isl_union_map *umap1, 2227 __isl_keep isl_union_map *umap2); 2228 int isl_union_map_is_strict_subset( 2229 __isl_keep isl_union_map *umap1, 2230 __isl_keep isl_union_map *umap2); 2231 2232Check whether the first argument is a (strict) subset of the 2233second argument. 2234 2235=item * Order 2236 2237 int isl_set_plain_cmp(__isl_keep isl_set *set1, 2238 __isl_keep isl_set *set2); 2239 2240This function is useful for sorting C<isl_set>s. 2241The order depends on the internal representation of the inputs. 2242The order is fixed over different calls to the function (assuming 2243the internal representation of the inputs has not changed), but may 2244change over different versions of C<isl>. 2245 2246=back 2247 2248=head2 Unary Operations 2249 2250=over 2251 2252=item * Complement 2253 2254 __isl_give isl_set *isl_set_complement( 2255 __isl_take isl_set *set); 2256 __isl_give isl_map *isl_map_complement( 2257 __isl_take isl_map *map); 2258 2259=item * Inverse map 2260 2261 __isl_give isl_basic_map *isl_basic_map_reverse( 2262 __isl_take isl_basic_map *bmap); 2263 __isl_give isl_map *isl_map_reverse( 2264 __isl_take isl_map *map); 2265 __isl_give isl_union_map *isl_union_map_reverse( 2266 __isl_take isl_union_map *umap); 2267 2268=item * Projection 2269 2270 __isl_give isl_basic_set *isl_basic_set_project_out( 2271 __isl_take isl_basic_set *bset, 2272 enum isl_dim_type type, unsigned first, unsigned n); 2273 __isl_give isl_basic_map *isl_basic_map_project_out( 2274 __isl_take isl_basic_map *bmap, 2275 enum isl_dim_type type, unsigned first, unsigned n); 2276 __isl_give isl_set *isl_set_project_out(__isl_take isl_set *set, 2277 enum isl_dim_type type, unsigned first, unsigned n); 2278 __isl_give isl_map *isl_map_project_out(__isl_take isl_map *map, 2279 enum isl_dim_type type, unsigned first, unsigned n); 2280 __isl_give isl_basic_set *isl_basic_set_params( 2281 __isl_take isl_basic_set *bset); 2282 __isl_give isl_basic_set *isl_basic_map_domain( 2283 __isl_take isl_basic_map *bmap); 2284 __isl_give isl_basic_set *isl_basic_map_range( 2285 __isl_take isl_basic_map *bmap); 2286 __isl_give isl_set *isl_set_params(__isl_take isl_set *set); 2287 __isl_give isl_set *isl_map_params(__isl_take isl_map *map); 2288 __isl_give isl_set *isl_map_domain( 2289 __isl_take isl_map *bmap); 2290 __isl_give isl_set *isl_map_range( 2291 __isl_take isl_map *map); 2292 __isl_give isl_set *isl_union_set_params( 2293 __isl_take isl_union_set *uset); 2294 __isl_give isl_set *isl_union_map_params( 2295 __isl_take isl_union_map *umap); 2296 __isl_give isl_union_set *isl_union_map_domain( 2297 __isl_take isl_union_map *umap); 2298 __isl_give isl_union_set *isl_union_map_range( 2299 __isl_take isl_union_map *umap); 2300 2301 __isl_give isl_basic_map *isl_basic_map_domain_map( 2302 __isl_take isl_basic_map *bmap); 2303 __isl_give isl_basic_map *isl_basic_map_range_map( 2304 __isl_take isl_basic_map *bmap); 2305 __isl_give isl_map *isl_map_domain_map(__isl_take isl_map *map); 2306 __isl_give isl_map *isl_map_range_map(__isl_take isl_map *map); 2307 __isl_give isl_union_map *isl_union_map_domain_map( 2308 __isl_take isl_union_map *umap); 2309 __isl_give isl_union_map *isl_union_map_range_map( 2310 __isl_take isl_union_map *umap); 2311 2312The functions above construct a (basic, regular or union) relation 2313that maps (a wrapped version of) the input relation to its domain or range. 2314 2315=item * Elimination 2316 2317 __isl_give isl_basic_set *isl_basic_set_eliminate( 2318 __isl_take isl_basic_set *bset, 2319 enum isl_dim_type type, 2320 unsigned first, unsigned n); 2321 __isl_give isl_set *isl_set_eliminate( 2322 __isl_take isl_set *set, enum isl_dim_type type, 2323 unsigned first, unsigned n); 2324 __isl_give isl_basic_map *isl_basic_map_eliminate( 2325 __isl_take isl_basic_map *bmap, 2326 enum isl_dim_type type, 2327 unsigned first, unsigned n); 2328 __isl_give isl_map *isl_map_eliminate( 2329 __isl_take isl_map *map, enum isl_dim_type type, 2330 unsigned first, unsigned n); 2331 2332Eliminate the coefficients for the given dimensions from the constraints, 2333without removing the dimensions. 2334 2335=item * Slicing 2336 2337 __isl_give isl_basic_set *isl_basic_set_fix( 2338 __isl_take isl_basic_set *bset, 2339 enum isl_dim_type type, unsigned pos, 2340 isl_int value); 2341 __isl_give isl_basic_set *isl_basic_set_fix_si( 2342 __isl_take isl_basic_set *bset, 2343 enum isl_dim_type type, unsigned pos, int value); 2344 __isl_give isl_basic_set *isl_basic_set_fix_val( 2345 __isl_take isl_basic_set *bset, 2346 enum isl_dim_type type, unsigned pos, 2347 __isl_take isl_val *v); 2348 __isl_give isl_set *isl_set_fix(__isl_take isl_set *set, 2349 enum isl_dim_type type, unsigned pos, 2350 isl_int value); 2351 __isl_give isl_set *isl_set_fix_si(__isl_take isl_set *set, 2352 enum isl_dim_type type, unsigned pos, int value); 2353 __isl_give isl_set *isl_set_fix_val( 2354 __isl_take isl_set *set, 2355 enum isl_dim_type type, unsigned pos, 2356 __isl_take isl_val *v); 2357 __isl_give isl_basic_map *isl_basic_map_fix_si( 2358 __isl_take isl_basic_map *bmap, 2359 enum isl_dim_type type, unsigned pos, int value); 2360 __isl_give isl_basic_map *isl_basic_map_fix_val( 2361 __isl_take isl_basic_map *bmap, 2362 enum isl_dim_type type, unsigned pos, 2363 __isl_take isl_val *v); 2364 __isl_give isl_map *isl_map_fix(__isl_take isl_map *map, 2365 enum isl_dim_type type, unsigned pos, 2366 isl_int value); 2367 __isl_give isl_map *isl_map_fix_si(__isl_take isl_map *map, 2368 enum isl_dim_type type, unsigned pos, int value); 2369 __isl_give isl_map *isl_map_fix_val( 2370 __isl_take isl_map *map, 2371 enum isl_dim_type type, unsigned pos, 2372 __isl_take isl_val *v); 2373 2374Intersect the set or relation with the hyperplane where the given 2375dimension has the fixed given value. 2376 2377 __isl_give isl_basic_map *isl_basic_map_lower_bound_si( 2378 __isl_take isl_basic_map *bmap, 2379 enum isl_dim_type type, unsigned pos, int value); 2380 __isl_give isl_basic_map *isl_basic_map_upper_bound_si( 2381 __isl_take isl_basic_map *bmap, 2382 enum isl_dim_type type, unsigned pos, int value); 2383 __isl_give isl_set *isl_set_lower_bound( 2384 __isl_take isl_set *set, 2385 enum isl_dim_type type, unsigned pos, 2386 isl_int value); 2387 __isl_give isl_set *isl_set_lower_bound_si( 2388 __isl_take isl_set *set, 2389 enum isl_dim_type type, unsigned pos, int value); 2390 __isl_give isl_set *isl_set_lower_bound_val( 2391 __isl_take isl_set *set, 2392 enum isl_dim_type type, unsigned pos, 2393 __isl_take isl_val *value); 2394 __isl_give isl_map *isl_map_lower_bound_si( 2395 __isl_take isl_map *map, 2396 enum isl_dim_type type, unsigned pos, int value); 2397 __isl_give isl_set *isl_set_upper_bound( 2398 __isl_take isl_set *set, 2399 enum isl_dim_type type, unsigned pos, 2400 isl_int value); 2401 __isl_give isl_set *isl_set_upper_bound_si( 2402 __isl_take isl_set *set, 2403 enum isl_dim_type type, unsigned pos, int value); 2404 __isl_give isl_set *isl_set_upper_bound_val( 2405 __isl_take isl_set *set, 2406 enum isl_dim_type type, unsigned pos, 2407 __isl_take isl_val *value); 2408 __isl_give isl_map *isl_map_upper_bound_si( 2409 __isl_take isl_map *map, 2410 enum isl_dim_type type, unsigned pos, int value); 2411 2412Intersect the set or relation with the half-space where the given 2413dimension has a value bounded by the fixed given integer value. 2414 2415 __isl_give isl_set *isl_set_equate(__isl_take isl_set *set, 2416 enum isl_dim_type type1, int pos1, 2417 enum isl_dim_type type2, int pos2); 2418 __isl_give isl_basic_map *isl_basic_map_equate( 2419 __isl_take isl_basic_map *bmap, 2420 enum isl_dim_type type1, int pos1, 2421 enum isl_dim_type type2, int pos2); 2422 __isl_give isl_map *isl_map_equate(__isl_take isl_map *map, 2423 enum isl_dim_type type1, int pos1, 2424 enum isl_dim_type type2, int pos2); 2425 2426Intersect the set or relation with the hyperplane where the given 2427dimensions are equal to each other. 2428 2429 __isl_give isl_map *isl_map_oppose(__isl_take isl_map *map, 2430 enum isl_dim_type type1, int pos1, 2431 enum isl_dim_type type2, int pos2); 2432 2433Intersect the relation with the hyperplane where the given 2434dimensions have opposite values. 2435 2436 __isl_give isl_basic_map *isl_basic_map_order_ge( 2437 __isl_take isl_basic_map *bmap, 2438 enum isl_dim_type type1, int pos1, 2439 enum isl_dim_type type2, int pos2); 2440 __isl_give isl_map *isl_map_order_lt(__isl_take isl_map *map, 2441 enum isl_dim_type type1, int pos1, 2442 enum isl_dim_type type2, int pos2); 2443 __isl_give isl_basic_map *isl_basic_map_order_gt( 2444 __isl_take isl_basic_map *bmap, 2445 enum isl_dim_type type1, int pos1, 2446 enum isl_dim_type type2, int pos2); 2447 __isl_give isl_map *isl_map_order_gt(__isl_take isl_map *map, 2448 enum isl_dim_type type1, int pos1, 2449 enum isl_dim_type type2, int pos2); 2450 2451Intersect the relation with the half-space where the given 2452dimensions satisfy the given ordering. 2453 2454=item * Identity 2455 2456 __isl_give isl_map *isl_set_identity( 2457 __isl_take isl_set *set); 2458 __isl_give isl_union_map *isl_union_set_identity( 2459 __isl_take isl_union_set *uset); 2460 2461Construct an identity relation on the given (union) set. 2462 2463=item * Deltas 2464 2465 __isl_give isl_basic_set *isl_basic_map_deltas( 2466 __isl_take isl_basic_map *bmap); 2467 __isl_give isl_set *isl_map_deltas(__isl_take isl_map *map); 2468 __isl_give isl_union_set *isl_union_map_deltas( 2469 __isl_take isl_union_map *umap); 2470 2471These functions return a (basic) set containing the differences 2472between image elements and corresponding domain elements in the input. 2473 2474 __isl_give isl_basic_map *isl_basic_map_deltas_map( 2475 __isl_take isl_basic_map *bmap); 2476 __isl_give isl_map *isl_map_deltas_map( 2477 __isl_take isl_map *map); 2478 __isl_give isl_union_map *isl_union_map_deltas_map( 2479 __isl_take isl_union_map *umap); 2480 2481The functions above construct a (basic, regular or union) relation 2482that maps (a wrapped version of) the input relation to its delta set. 2483 2484=item * Coalescing 2485 2486Simplify the representation of a set or relation by trying 2487to combine pairs of basic sets or relations into a single 2488basic set or relation. 2489 2490 __isl_give isl_set *isl_set_coalesce(__isl_take isl_set *set); 2491 __isl_give isl_map *isl_map_coalesce(__isl_take isl_map *map); 2492 __isl_give isl_union_set *isl_union_set_coalesce( 2493 __isl_take isl_union_set *uset); 2494 __isl_give isl_union_map *isl_union_map_coalesce( 2495 __isl_take isl_union_map *umap); 2496 2497One of the methods for combining pairs of basic sets or relations 2498can result in coefficients that are much larger than those that appear 2499in the constraints of the input. By default, the coefficients are 2500not allowed to grow larger, but this can be changed by unsetting 2501the following option. 2502 2503 int isl_options_set_coalesce_bounded_wrapping( 2504 isl_ctx *ctx, int val); 2505 int isl_options_get_coalesce_bounded_wrapping( 2506 isl_ctx *ctx); 2507 2508=item * Detecting equalities 2509 2510 __isl_give isl_basic_set *isl_basic_set_detect_equalities( 2511 __isl_take isl_basic_set *bset); 2512 __isl_give isl_basic_map *isl_basic_map_detect_equalities( 2513 __isl_take isl_basic_map *bmap); 2514 __isl_give isl_set *isl_set_detect_equalities( 2515 __isl_take isl_set *set); 2516 __isl_give isl_map *isl_map_detect_equalities( 2517 __isl_take isl_map *map); 2518 __isl_give isl_union_set *isl_union_set_detect_equalities( 2519 __isl_take isl_union_set *uset); 2520 __isl_give isl_union_map *isl_union_map_detect_equalities( 2521 __isl_take isl_union_map *umap); 2522 2523Simplify the representation of a set or relation by detecting implicit 2524equalities. 2525 2526=item * Removing redundant constraints 2527 2528 __isl_give isl_basic_set *isl_basic_set_remove_redundancies( 2529 __isl_take isl_basic_set *bset); 2530 __isl_give isl_set *isl_set_remove_redundancies( 2531 __isl_take isl_set *set); 2532 __isl_give isl_basic_map *isl_basic_map_remove_redundancies( 2533 __isl_take isl_basic_map *bmap); 2534 __isl_give isl_map *isl_map_remove_redundancies( 2535 __isl_take isl_map *map); 2536 2537=item * Convex hull 2538 2539 __isl_give isl_basic_set *isl_set_convex_hull( 2540 __isl_take isl_set *set); 2541 __isl_give isl_basic_map *isl_map_convex_hull( 2542 __isl_take isl_map *map); 2543 2544If the input set or relation has any existentially quantified 2545variables, then the result of these operations is currently undefined. 2546 2547=item * Simple hull 2548 2549 __isl_give isl_basic_set * 2550 isl_set_unshifted_simple_hull( 2551 __isl_take isl_set *set); 2552 __isl_give isl_basic_map * 2553 isl_map_unshifted_simple_hull( 2554 __isl_take isl_map *map); 2555 __isl_give isl_basic_set *isl_set_simple_hull( 2556 __isl_take isl_set *set); 2557 __isl_give isl_basic_map *isl_map_simple_hull( 2558 __isl_take isl_map *map); 2559 __isl_give isl_union_map *isl_union_map_simple_hull( 2560 __isl_take isl_union_map *umap); 2561 2562These functions compute a single basic set or relation 2563that contains the whole input set or relation. 2564In particular, the output is described by translates 2565of the constraints describing the basic sets or relations in the input. 2566In case of C<isl_set_unshifted_simple_hull>, only the original 2567constraints are used, without any translation. 2568 2569=begin latex 2570 2571(See \autoref{s:simple hull}.) 2572 2573=end latex 2574 2575=item * Affine hull 2576 2577 __isl_give isl_basic_set *isl_basic_set_affine_hull( 2578 __isl_take isl_basic_set *bset); 2579 __isl_give isl_basic_set *isl_set_affine_hull( 2580 __isl_take isl_set *set); 2581 __isl_give isl_union_set *isl_union_set_affine_hull( 2582 __isl_take isl_union_set *uset); 2583 __isl_give isl_basic_map *isl_basic_map_affine_hull( 2584 __isl_take isl_basic_map *bmap); 2585 __isl_give isl_basic_map *isl_map_affine_hull( 2586 __isl_take isl_map *map); 2587 __isl_give isl_union_map *isl_union_map_affine_hull( 2588 __isl_take isl_union_map *umap); 2589 2590In case of union sets and relations, the affine hull is computed 2591per space. 2592 2593=item * Polyhedral hull 2594 2595 __isl_give isl_basic_set *isl_set_polyhedral_hull( 2596 __isl_take isl_set *set); 2597 __isl_give isl_basic_map *isl_map_polyhedral_hull( 2598 __isl_take isl_map *map); 2599 __isl_give isl_union_set *isl_union_set_polyhedral_hull( 2600 __isl_take isl_union_set *uset); 2601 __isl_give isl_union_map *isl_union_map_polyhedral_hull( 2602 __isl_take isl_union_map *umap); 2603 2604These functions compute a single basic set or relation 2605not involving any existentially quantified variables 2606that contains the whole input set or relation. 2607In case of union sets and relations, the polyhedral hull is computed 2608per space. 2609 2610=item * Other approximations 2611 2612 __isl_give isl_basic_set * 2613 isl_basic_set_drop_constraints_involving_dims( 2614 __isl_take isl_basic_set *bset, 2615 enum isl_dim_type type, 2616 unsigned first, unsigned n); 2617 __isl_give isl_basic_map * 2618 isl_basic_map_drop_constraints_involving_dims( 2619 __isl_take isl_basic_map *bmap, 2620 enum isl_dim_type type, 2621 unsigned first, unsigned n); 2622 __isl_give isl_basic_set * 2623 isl_basic_set_drop_constraints_not_involving_dims( 2624 __isl_take isl_basic_set *bset, 2625 enum isl_dim_type type, 2626 unsigned first, unsigned n); 2627 __isl_give isl_set * 2628 isl_set_drop_constraints_involving_dims( 2629 __isl_take isl_set *set, 2630 enum isl_dim_type type, 2631 unsigned first, unsigned n); 2632 __isl_give isl_map * 2633 isl_map_drop_constraints_involving_dims( 2634 __isl_take isl_map *map, 2635 enum isl_dim_type type, 2636 unsigned first, unsigned n); 2637 2638These functions drop any constraints (not) involving the specified dimensions. 2639Note that the result depends on the representation of the input. 2640 2641=item * Feasibility 2642 2643 __isl_give isl_basic_set *isl_basic_set_sample( 2644 __isl_take isl_basic_set *bset); 2645 __isl_give isl_basic_set *isl_set_sample( 2646 __isl_take isl_set *set); 2647 __isl_give isl_basic_map *isl_basic_map_sample( 2648 __isl_take isl_basic_map *bmap); 2649 __isl_give isl_basic_map *isl_map_sample( 2650 __isl_take isl_map *map); 2651 2652If the input (basic) set or relation is non-empty, then return 2653a singleton subset of the input. Otherwise, return an empty set. 2654 2655=item * Optimization 2656 2657 #include <isl/ilp.h> 2658 enum isl_lp_result isl_basic_set_max( 2659 __isl_keep isl_basic_set *bset, 2660 __isl_keep isl_aff *obj, isl_int *opt) 2661 __isl_give isl_val *isl_basic_set_max_val( 2662 __isl_keep isl_basic_set *bset, 2663 __isl_keep isl_aff *obj); 2664 enum isl_lp_result isl_set_min(__isl_keep isl_set *set, 2665 __isl_keep isl_aff *obj, isl_int *opt); 2666 __isl_give isl_val *isl_set_min_val( 2667 __isl_keep isl_set *set, 2668 __isl_keep isl_aff *obj); 2669 enum isl_lp_result isl_set_max(__isl_keep isl_set *set, 2670 __isl_keep isl_aff *obj, isl_int *opt); 2671 __isl_give isl_val *isl_set_max_val( 2672 __isl_keep isl_set *set, 2673 __isl_keep isl_aff *obj); 2674 2675Compute the minimum or maximum of the integer affine expression C<obj> 2676over the points in C<set>, returning the result in C<opt>. 2677The return value may be one of C<isl_lp_error>, 2678C<isl_lp_ok>, C<isl_lp_unbounded> or C<isl_lp_empty>, in case of 2679an C<isl_lp_result>. If the result is an C<isl_val> then 2680the result is C<NULL> in case of an error, the optimal value in case 2681there is one, negative infinity or infinity if the problem is unbounded and 2682NaN if the problem is empty. 2683 2684=item * Parametric optimization 2685 2686 __isl_give isl_pw_aff *isl_set_dim_min( 2687 __isl_take isl_set *set, int pos); 2688 __isl_give isl_pw_aff *isl_set_dim_max( 2689 __isl_take isl_set *set, int pos); 2690 __isl_give isl_pw_aff *isl_map_dim_max( 2691 __isl_take isl_map *map, int pos); 2692 2693Compute the minimum or maximum of the given set or output dimension 2694as a function of the parameters (and input dimensions), but independently 2695of the other set or output dimensions. 2696For lexicographic optimization, see L<"Lexicographic Optimization">. 2697 2698=item * Dual 2699 2700The following functions compute either the set of (rational) coefficient 2701values of valid constraints for the given set or the set of (rational) 2702values satisfying the constraints with coefficients from the given set. 2703Internally, these two sets of functions perform essentially the 2704same operations, except that the set of coefficients is assumed to 2705be a cone, while the set of values may be any polyhedron. 2706The current implementation is based on the Farkas lemma and 2707Fourier-Motzkin elimination, but this may change or be made optional 2708in future. In particular, future implementations may use different 2709dualization algorithms or skip the elimination step. 2710 2711 __isl_give isl_basic_set *isl_basic_set_coefficients( 2712 __isl_take isl_basic_set *bset); 2713 __isl_give isl_basic_set *isl_set_coefficients( 2714 __isl_take isl_set *set); 2715 __isl_give isl_union_set *isl_union_set_coefficients( 2716 __isl_take isl_union_set *bset); 2717 __isl_give isl_basic_set *isl_basic_set_solutions( 2718 __isl_take isl_basic_set *bset); 2719 __isl_give isl_basic_set *isl_set_solutions( 2720 __isl_take isl_set *set); 2721 __isl_give isl_union_set *isl_union_set_solutions( 2722 __isl_take isl_union_set *bset); 2723 2724=item * Power 2725 2726 __isl_give isl_map *isl_map_fixed_power( 2727 __isl_take isl_map *map, isl_int exp); 2728 __isl_give isl_map *isl_map_fixed_power_val( 2729 __isl_take isl_map *map, 2730 __isl_take isl_val *exp); 2731 __isl_give isl_union_map *isl_union_map_fixed_power( 2732 __isl_take isl_union_map *umap, isl_int exp); 2733 __isl_give isl_union_map * 2734 isl_union_map_fixed_power_val( 2735 __isl_take isl_union_map *umap, 2736 __isl_take isl_val *exp); 2737 2738Compute the given power of C<map>, where C<exp> is assumed to be non-zero. 2739If the exponent C<exp> is negative, then the -C<exp> th power of the inverse 2740of C<map> is computed. 2741 2742 __isl_give isl_map *isl_map_power(__isl_take isl_map *map, 2743 int *exact); 2744 __isl_give isl_union_map *isl_union_map_power( 2745 __isl_take isl_union_map *umap, int *exact); 2746 2747Compute a parametric representation for all positive powers I<k> of C<map>. 2748The result maps I<k> to a nested relation corresponding to the 2749I<k>th power of C<map>. 2750The result may be an overapproximation. If the result is known to be exact, 2751then C<*exact> is set to C<1>. 2752 2753=item * Transitive closure 2754 2755 __isl_give isl_map *isl_map_transitive_closure( 2756 __isl_take isl_map *map, int *exact); 2757 __isl_give isl_union_map *isl_union_map_transitive_closure( 2758 __isl_take isl_union_map *umap, int *exact); 2759 2760Compute the transitive closure of C<map>. 2761The result may be an overapproximation. If the result is known to be exact, 2762then C<*exact> is set to C<1>. 2763 2764=item * Reaching path lengths 2765 2766 __isl_give isl_map *isl_map_reaching_path_lengths( 2767 __isl_take isl_map *map, int *exact); 2768 2769Compute a relation that maps each element in the range of C<map> 2770to the lengths of all paths composed of edges in C<map> that 2771end up in the given element. 2772The result may be an overapproximation. If the result is known to be exact, 2773then C<*exact> is set to C<1>. 2774To compute the I<maximal> path length, the resulting relation 2775should be postprocessed by C<isl_map_lexmax>. 2776In particular, if the input relation is a dependence relation 2777(mapping sources to sinks), then the maximal path length corresponds 2778to the free schedule. 2779Note, however, that C<isl_map_lexmax> expects the maximum to be 2780finite, so if the path lengths are unbounded (possibly due to 2781the overapproximation), then you will get an error message. 2782 2783=item * Wrapping 2784 2785 __isl_give isl_basic_set *isl_basic_map_wrap( 2786 __isl_take isl_basic_map *bmap); 2787 __isl_give isl_set *isl_map_wrap( 2788 __isl_take isl_map *map); 2789 __isl_give isl_union_set *isl_union_map_wrap( 2790 __isl_take isl_union_map *umap); 2791 __isl_give isl_basic_map *isl_basic_set_unwrap( 2792 __isl_take isl_basic_set *bset); 2793 __isl_give isl_map *isl_set_unwrap( 2794 __isl_take isl_set *set); 2795 __isl_give isl_union_map *isl_union_set_unwrap( 2796 __isl_take isl_union_set *uset); 2797 2798=item * Flattening 2799 2800Remove any internal structure of domain (and range) of the given 2801set or relation. If there is any such internal structure in the input, 2802then the name of the space is also removed. 2803 2804 __isl_give isl_basic_set *isl_basic_set_flatten( 2805 __isl_take isl_basic_set *bset); 2806 __isl_give isl_set *isl_set_flatten( 2807 __isl_take isl_set *set); 2808 __isl_give isl_basic_map *isl_basic_map_flatten_domain( 2809 __isl_take isl_basic_map *bmap); 2810 __isl_give isl_basic_map *isl_basic_map_flatten_range( 2811 __isl_take isl_basic_map *bmap); 2812 __isl_give isl_map *isl_map_flatten_range( 2813 __isl_take isl_map *map); 2814 __isl_give isl_map *isl_map_flatten_domain( 2815 __isl_take isl_map *map); 2816 __isl_give isl_basic_map *isl_basic_map_flatten( 2817 __isl_take isl_basic_map *bmap); 2818 __isl_give isl_map *isl_map_flatten( 2819 __isl_take isl_map *map); 2820 2821 __isl_give isl_map *isl_set_flatten_map( 2822 __isl_take isl_set *set); 2823 2824The function above constructs a relation 2825that maps the input set to a flattened version of the set. 2826 2827=item * Lifting 2828 2829Lift the input set to a space with extra dimensions corresponding 2830to the existentially quantified variables in the input. 2831In particular, the result lives in a wrapped map where the domain 2832is the original space and the range corresponds to the original 2833existentially quantified variables. 2834 2835 __isl_give isl_basic_set *isl_basic_set_lift( 2836 __isl_take isl_basic_set *bset); 2837 __isl_give isl_set *isl_set_lift( 2838 __isl_take isl_set *set); 2839 __isl_give isl_union_set *isl_union_set_lift( 2840 __isl_take isl_union_set *uset); 2841 2842Given a local space that contains the existentially quantified 2843variables of a set, a basic relation that, when applied to 2844a basic set, has essentially the same effect as C<isl_basic_set_lift>, 2845can be constructed using the following function. 2846 2847 #include <isl/local_space.h> 2848 __isl_give isl_basic_map *isl_local_space_lifting( 2849 __isl_take isl_local_space *ls); 2850 2851=item * Internal Product 2852 2853 __isl_give isl_basic_map *isl_basic_map_zip( 2854 __isl_take isl_basic_map *bmap); 2855 __isl_give isl_map *isl_map_zip( 2856 __isl_take isl_map *map); 2857 __isl_give isl_union_map *isl_union_map_zip( 2858 __isl_take isl_union_map *umap); 2859 2860Given a relation with nested relations for domain and range, 2861interchange the range of the domain with the domain of the range. 2862 2863=item * Currying 2864 2865 __isl_give isl_basic_map *isl_basic_map_curry( 2866 __isl_take isl_basic_map *bmap); 2867 __isl_give isl_basic_map *isl_basic_map_uncurry( 2868 __isl_take isl_basic_map *bmap); 2869 __isl_give isl_map *isl_map_curry( 2870 __isl_take isl_map *map); 2871 __isl_give isl_map *isl_map_uncurry( 2872 __isl_take isl_map *map); 2873 __isl_give isl_union_map *isl_union_map_curry( 2874 __isl_take isl_union_map *umap); 2875 __isl_give isl_union_map *isl_union_map_uncurry( 2876 __isl_take isl_union_map *umap); 2877 2878Given a relation with a nested relation for domain, 2879the C<curry> functions 2880move the range of the nested relation out of the domain 2881and use it as the domain of a nested relation in the range, 2882with the original range as range of this nested relation. 2883The C<uncurry> functions perform the inverse operation. 2884 2885=item * Aligning parameters 2886 2887 __isl_give isl_basic_set *isl_basic_set_align_params( 2888 __isl_take isl_basic_set *bset, 2889 __isl_take isl_space *model); 2890 __isl_give isl_set *isl_set_align_params( 2891 __isl_take isl_set *set, 2892 __isl_take isl_space *model); 2893 __isl_give isl_basic_map *isl_basic_map_align_params( 2894 __isl_take isl_basic_map *bmap, 2895 __isl_take isl_space *model); 2896 __isl_give isl_map *isl_map_align_params( 2897 __isl_take isl_map *map, 2898 __isl_take isl_space *model); 2899 2900Change the order of the parameters of the given set or relation 2901such that the first parameters match those of C<model>. 2902This may involve the introduction of extra parameters. 2903All parameters need to be named. 2904 2905=item * Dimension manipulation 2906 2907 __isl_give isl_basic_set *isl_basic_set_add_dims( 2908 __isl_take isl_basic_set *bset, 2909 enum isl_dim_type type, unsigned n); 2910 __isl_give isl_set *isl_set_add_dims( 2911 __isl_take isl_set *set, 2912 enum isl_dim_type type, unsigned n); 2913 __isl_give isl_map *isl_map_add_dims( 2914 __isl_take isl_map *map, 2915 enum isl_dim_type type, unsigned n); 2916 __isl_give isl_basic_set *isl_basic_set_insert_dims( 2917 __isl_take isl_basic_set *bset, 2918 enum isl_dim_type type, unsigned pos, 2919 unsigned n); 2920 __isl_give isl_basic_map *isl_basic_map_insert_dims( 2921 __isl_take isl_basic_map *bmap, 2922 enum isl_dim_type type, unsigned pos, 2923 unsigned n); 2924 __isl_give isl_set *isl_set_insert_dims( 2925 __isl_take isl_set *set, 2926 enum isl_dim_type type, unsigned pos, unsigned n); 2927 __isl_give isl_map *isl_map_insert_dims( 2928 __isl_take isl_map *map, 2929 enum isl_dim_type type, unsigned pos, unsigned n); 2930 __isl_give isl_basic_set *isl_basic_set_move_dims( 2931 __isl_take isl_basic_set *bset, 2932 enum isl_dim_type dst_type, unsigned dst_pos, 2933 enum isl_dim_type src_type, unsigned src_pos, 2934 unsigned n); 2935 __isl_give isl_basic_map *isl_basic_map_move_dims( 2936 __isl_take isl_basic_map *bmap, 2937 enum isl_dim_type dst_type, unsigned dst_pos, 2938 enum isl_dim_type src_type, unsigned src_pos, 2939 unsigned n); 2940 __isl_give isl_set *isl_set_move_dims( 2941 __isl_take isl_set *set, 2942 enum isl_dim_type dst_type, unsigned dst_pos, 2943 enum isl_dim_type src_type, unsigned src_pos, 2944 unsigned n); 2945 __isl_give isl_map *isl_map_move_dims( 2946 __isl_take isl_map *map, 2947 enum isl_dim_type dst_type, unsigned dst_pos, 2948 enum isl_dim_type src_type, unsigned src_pos, 2949 unsigned n); 2950 2951It is usually not advisable to directly change the (input or output) 2952space of a set or a relation as this removes the name and the internal 2953structure of the space. However, the above functions can be useful 2954to add new parameters, assuming 2955C<isl_set_align_params> and C<isl_map_align_params> 2956are not sufficient. 2957 2958=back 2959 2960=head2 Binary Operations 2961 2962The two arguments of a binary operation not only need to live 2963in the same C<isl_ctx>, they currently also need to have 2964the same (number of) parameters. 2965 2966=head3 Basic Operations 2967 2968=over 2969 2970=item * Intersection 2971 2972 __isl_give isl_basic_set *isl_basic_set_intersect_params( 2973 __isl_take isl_basic_set *bset1, 2974 __isl_take isl_basic_set *bset2); 2975 __isl_give isl_basic_set *isl_basic_set_intersect( 2976 __isl_take isl_basic_set *bset1, 2977 __isl_take isl_basic_set *bset2); 2978 __isl_give isl_set *isl_set_intersect_params( 2979 __isl_take isl_set *set, 2980 __isl_take isl_set *params); 2981 __isl_give isl_set *isl_set_intersect( 2982 __isl_take isl_set *set1, 2983 __isl_take isl_set *set2); 2984 __isl_give isl_union_set *isl_union_set_intersect_params( 2985 __isl_take isl_union_set *uset, 2986 __isl_take isl_set *set); 2987 __isl_give isl_union_map *isl_union_map_intersect_params( 2988 __isl_take isl_union_map *umap, 2989 __isl_take isl_set *set); 2990 __isl_give isl_union_set *isl_union_set_intersect( 2991 __isl_take isl_union_set *uset1, 2992 __isl_take isl_union_set *uset2); 2993 __isl_give isl_basic_map *isl_basic_map_intersect_domain( 2994 __isl_take isl_basic_map *bmap, 2995 __isl_take isl_basic_set *bset); 2996 __isl_give isl_basic_map *isl_basic_map_intersect_range( 2997 __isl_take isl_basic_map *bmap, 2998 __isl_take isl_basic_set *bset); 2999 __isl_give isl_basic_map *isl_basic_map_intersect( 3000 __isl_take isl_basic_map *bmap1, 3001 __isl_take isl_basic_map *bmap2); 3002 __isl_give isl_map *isl_map_intersect_params( 3003 __isl_take isl_map *map, 3004 __isl_take isl_set *params); 3005 __isl_give isl_map *isl_map_intersect_domain( 3006 __isl_take isl_map *map, 3007 __isl_take isl_set *set); 3008 __isl_give isl_map *isl_map_intersect_range( 3009 __isl_take isl_map *map, 3010 __isl_take isl_set *set); 3011 __isl_give isl_map *isl_map_intersect( 3012 __isl_take isl_map *map1, 3013 __isl_take isl_map *map2); 3014 __isl_give isl_union_map *isl_union_map_intersect_domain( 3015 __isl_take isl_union_map *umap, 3016 __isl_take isl_union_set *uset); 3017 __isl_give isl_union_map *isl_union_map_intersect_range( 3018 __isl_take isl_union_map *umap, 3019 __isl_take isl_union_set *uset); 3020 __isl_give isl_union_map *isl_union_map_intersect( 3021 __isl_take isl_union_map *umap1, 3022 __isl_take isl_union_map *umap2); 3023 3024The second argument to the C<_params> functions needs to be 3025a parametric (basic) set. For the other functions, a parametric set 3026for either argument is only allowed if the other argument is 3027a parametric set as well. 3028 3029=item * Union 3030 3031 __isl_give isl_set *isl_basic_set_union( 3032 __isl_take isl_basic_set *bset1, 3033 __isl_take isl_basic_set *bset2); 3034 __isl_give isl_map *isl_basic_map_union( 3035 __isl_take isl_basic_map *bmap1, 3036 __isl_take isl_basic_map *bmap2); 3037 __isl_give isl_set *isl_set_union( 3038 __isl_take isl_set *set1, 3039 __isl_take isl_set *set2); 3040 __isl_give isl_map *isl_map_union( 3041 __isl_take isl_map *map1, 3042 __isl_take isl_map *map2); 3043 __isl_give isl_union_set *isl_union_set_union( 3044 __isl_take isl_union_set *uset1, 3045 __isl_take isl_union_set *uset2); 3046 __isl_give isl_union_map *isl_union_map_union( 3047 __isl_take isl_union_map *umap1, 3048 __isl_take isl_union_map *umap2); 3049 3050=item * Set difference 3051 3052 __isl_give isl_set *isl_set_subtract( 3053 __isl_take isl_set *set1, 3054 __isl_take isl_set *set2); 3055 __isl_give isl_map *isl_map_subtract( 3056 __isl_take isl_map *map1, 3057 __isl_take isl_map *map2); 3058 __isl_give isl_map *isl_map_subtract_domain( 3059 __isl_take isl_map *map, 3060 __isl_take isl_set *dom); 3061 __isl_give isl_map *isl_map_subtract_range( 3062 __isl_take isl_map *map, 3063 __isl_take isl_set *dom); 3064 __isl_give isl_union_set *isl_union_set_subtract( 3065 __isl_take isl_union_set *uset1, 3066 __isl_take isl_union_set *uset2); 3067 __isl_give isl_union_map *isl_union_map_subtract( 3068 __isl_take isl_union_map *umap1, 3069 __isl_take isl_union_map *umap2); 3070 __isl_give isl_union_map *isl_union_map_subtract_domain( 3071 __isl_take isl_union_map *umap, 3072 __isl_take isl_union_set *dom); 3073 __isl_give isl_union_map *isl_union_map_subtract_range( 3074 __isl_take isl_union_map *umap, 3075 __isl_take isl_union_set *dom); 3076 3077=item * Application 3078 3079 __isl_give isl_basic_set *isl_basic_set_apply( 3080 __isl_take isl_basic_set *bset, 3081 __isl_take isl_basic_map *bmap); 3082 __isl_give isl_set *isl_set_apply( 3083 __isl_take isl_set *set, 3084 __isl_take isl_map *map); 3085 __isl_give isl_union_set *isl_union_set_apply( 3086 __isl_take isl_union_set *uset, 3087 __isl_take isl_union_map *umap); 3088 __isl_give isl_basic_map *isl_basic_map_apply_domain( 3089 __isl_take isl_basic_map *bmap1, 3090 __isl_take isl_basic_map *bmap2); 3091 __isl_give isl_basic_map *isl_basic_map_apply_range( 3092 __isl_take isl_basic_map *bmap1, 3093 __isl_take isl_basic_map *bmap2); 3094 __isl_give isl_map *isl_map_apply_domain( 3095 __isl_take isl_map *map1, 3096 __isl_take isl_map *map2); 3097 __isl_give isl_union_map *isl_union_map_apply_domain( 3098 __isl_take isl_union_map *umap1, 3099 __isl_take isl_union_map *umap2); 3100 __isl_give isl_map *isl_map_apply_range( 3101 __isl_take isl_map *map1, 3102 __isl_take isl_map *map2); 3103 __isl_give isl_union_map *isl_union_map_apply_range( 3104 __isl_take isl_union_map *umap1, 3105 __isl_take isl_union_map *umap2); 3106 3107=item * Preimage 3108 3109 __isl_give isl_basic_set * 3110 isl_basic_set_preimage_multi_aff( 3111 __isl_take isl_basic_set *bset, 3112 __isl_take isl_multi_aff *ma); 3113 __isl_give isl_set *isl_set_preimage_multi_aff( 3114 __isl_take isl_set *set, 3115 __isl_take isl_multi_aff *ma); 3116 __isl_give isl_set *isl_set_preimage_pw_multi_aff( 3117 __isl_take isl_set *set, 3118 __isl_take isl_pw_multi_aff *pma); 3119 __isl_give isl_map *isl_map_preimage_domain_multi_aff( 3120 __isl_take isl_map *map, 3121 __isl_take isl_multi_aff *ma); 3122 __isl_give isl_union_map * 3123 isl_union_map_preimage_domain_multi_aff( 3124 __isl_take isl_union_map *umap, 3125 __isl_take isl_multi_aff *ma); 3126 3127These functions compute the preimage of the given set or map domain under 3128the given function. In other words, the expression is plugged 3129into the set description or into the domain of the map. 3130Objects of types C<isl_multi_aff> and C<isl_pw_multi_aff> are described in 3131L</"Piecewise Multiple Quasi Affine Expressions">. 3132 3133=item * Cartesian Product 3134 3135 __isl_give isl_set *isl_set_product( 3136 __isl_take isl_set *set1, 3137 __isl_take isl_set *set2); 3138 __isl_give isl_union_set *isl_union_set_product( 3139 __isl_take isl_union_set *uset1, 3140 __isl_take isl_union_set *uset2); 3141 __isl_give isl_basic_map *isl_basic_map_domain_product( 3142 __isl_take isl_basic_map *bmap1, 3143 __isl_take isl_basic_map *bmap2); 3144 __isl_give isl_basic_map *isl_basic_map_range_product( 3145 __isl_take isl_basic_map *bmap1, 3146 __isl_take isl_basic_map *bmap2); 3147 __isl_give isl_basic_map *isl_basic_map_product( 3148 __isl_take isl_basic_map *bmap1, 3149 __isl_take isl_basic_map *bmap2); 3150 __isl_give isl_map *isl_map_domain_product( 3151 __isl_take isl_map *map1, 3152 __isl_take isl_map *map2); 3153 __isl_give isl_map *isl_map_range_product( 3154 __isl_take isl_map *map1, 3155 __isl_take isl_map *map2); 3156 __isl_give isl_union_map *isl_union_map_domain_product( 3157 __isl_take isl_union_map *umap1, 3158 __isl_take isl_union_map *umap2); 3159 __isl_give isl_union_map *isl_union_map_range_product( 3160 __isl_take isl_union_map *umap1, 3161 __isl_take isl_union_map *umap2); 3162 __isl_give isl_map *isl_map_product( 3163 __isl_take isl_map *map1, 3164 __isl_take isl_map *map2); 3165 __isl_give isl_union_map *isl_union_map_product( 3166 __isl_take isl_union_map *umap1, 3167 __isl_take isl_union_map *umap2); 3168 3169The above functions compute the cross product of the given 3170sets or relations. The domains and ranges of the results 3171are wrapped maps between domains and ranges of the inputs. 3172To obtain a ``flat'' product, use the following functions 3173instead. 3174 3175 __isl_give isl_basic_set *isl_basic_set_flat_product( 3176 __isl_take isl_basic_set *bset1, 3177 __isl_take isl_basic_set *bset2); 3178 __isl_give isl_set *isl_set_flat_product( 3179 __isl_take isl_set *set1, 3180 __isl_take isl_set *set2); 3181 __isl_give isl_basic_map *isl_basic_map_flat_range_product( 3182 __isl_take isl_basic_map *bmap1, 3183 __isl_take isl_basic_map *bmap2); 3184 __isl_give isl_map *isl_map_flat_domain_product( 3185 __isl_take isl_map *map1, 3186 __isl_take isl_map *map2); 3187 __isl_give isl_map *isl_map_flat_range_product( 3188 __isl_take isl_map *map1, 3189 __isl_take isl_map *map2); 3190 __isl_give isl_union_map *isl_union_map_flat_range_product( 3191 __isl_take isl_union_map *umap1, 3192 __isl_take isl_union_map *umap2); 3193 __isl_give isl_basic_map *isl_basic_map_flat_product( 3194 __isl_take isl_basic_map *bmap1, 3195 __isl_take isl_basic_map *bmap2); 3196 __isl_give isl_map *isl_map_flat_product( 3197 __isl_take isl_map *map1, 3198 __isl_take isl_map *map2); 3199 3200=item * Simplification 3201 3202 __isl_give isl_basic_set *isl_basic_set_gist( 3203 __isl_take isl_basic_set *bset, 3204 __isl_take isl_basic_set *context); 3205 __isl_give isl_set *isl_set_gist(__isl_take isl_set *set, 3206 __isl_take isl_set *context); 3207 __isl_give isl_set *isl_set_gist_params( 3208 __isl_take isl_set *set, 3209 __isl_take isl_set *context); 3210 __isl_give isl_union_set *isl_union_set_gist( 3211 __isl_take isl_union_set *uset, 3212 __isl_take isl_union_set *context); 3213 __isl_give isl_union_set *isl_union_set_gist_params( 3214 __isl_take isl_union_set *uset, 3215 __isl_take isl_set *set); 3216 __isl_give isl_basic_map *isl_basic_map_gist( 3217 __isl_take isl_basic_map *bmap, 3218 __isl_take isl_basic_map *context); 3219 __isl_give isl_map *isl_map_gist(__isl_take isl_map *map, 3220 __isl_take isl_map *context); 3221 __isl_give isl_map *isl_map_gist_params( 3222 __isl_take isl_map *map, 3223 __isl_take isl_set *context); 3224 __isl_give isl_map *isl_map_gist_domain( 3225 __isl_take isl_map *map, 3226 __isl_take isl_set *context); 3227 __isl_give isl_map *isl_map_gist_range( 3228 __isl_take isl_map *map, 3229 __isl_take isl_set *context); 3230 __isl_give isl_union_map *isl_union_map_gist( 3231 __isl_take isl_union_map *umap, 3232 __isl_take isl_union_map *context); 3233 __isl_give isl_union_map *isl_union_map_gist_params( 3234 __isl_take isl_union_map *umap, 3235 __isl_take isl_set *set); 3236 __isl_give isl_union_map *isl_union_map_gist_domain( 3237 __isl_take isl_union_map *umap, 3238 __isl_take isl_union_set *uset); 3239 __isl_give isl_union_map *isl_union_map_gist_range( 3240 __isl_take isl_union_map *umap, 3241 __isl_take isl_union_set *uset); 3242 3243The gist operation returns a set or relation that has the 3244same intersection with the context as the input set or relation. 3245Any implicit equality in the intersection is made explicit in the result, 3246while all inequalities that are redundant with respect to the intersection 3247are removed. 3248In case of union sets and relations, the gist operation is performed 3249per space. 3250 3251=back 3252 3253=head3 Lexicographic Optimization 3254 3255Given a (basic) set C<set> (or C<bset>) and a zero-dimensional domain C<dom>, 3256the following functions 3257compute a set that contains the lexicographic minimum or maximum 3258of the elements in C<set> (or C<bset>) for those values of the parameters 3259that satisfy C<dom>. 3260If C<empty> is not C<NULL>, then C<*empty> is assigned a set 3261that contains the parameter values in C<dom> for which C<set> (or C<bset>) 3262has no elements. 3263In other words, the union of the parameter values 3264for which the result is non-empty and of C<*empty> 3265is equal to C<dom>. 3266 3267 __isl_give isl_set *isl_basic_set_partial_lexmin( 3268 __isl_take isl_basic_set *bset, 3269 __isl_take isl_basic_set *dom, 3270 __isl_give isl_set **empty); 3271 __isl_give isl_set *isl_basic_set_partial_lexmax( 3272 __isl_take isl_basic_set *bset, 3273 __isl_take isl_basic_set *dom, 3274 __isl_give isl_set **empty); 3275 __isl_give isl_set *isl_set_partial_lexmin( 3276 __isl_take isl_set *set, __isl_take isl_set *dom, 3277 __isl_give isl_set **empty); 3278 __isl_give isl_set *isl_set_partial_lexmax( 3279 __isl_take isl_set *set, __isl_take isl_set *dom, 3280 __isl_give isl_set **empty); 3281 3282Given a (basic) set C<set> (or C<bset>), the following functions simply 3283return a set containing the lexicographic minimum or maximum 3284of the elements in C<set> (or C<bset>). 3285In case of union sets, the optimum is computed per space. 3286 3287 __isl_give isl_set *isl_basic_set_lexmin( 3288 __isl_take isl_basic_set *bset); 3289 __isl_give isl_set *isl_basic_set_lexmax( 3290 __isl_take isl_basic_set *bset); 3291 __isl_give isl_set *isl_set_lexmin( 3292 __isl_take isl_set *set); 3293 __isl_give isl_set *isl_set_lexmax( 3294 __isl_take isl_set *set); 3295 __isl_give isl_union_set *isl_union_set_lexmin( 3296 __isl_take isl_union_set *uset); 3297 __isl_give isl_union_set *isl_union_set_lexmax( 3298 __isl_take isl_union_set *uset); 3299 3300Given a (basic) relation C<map> (or C<bmap>) and a domain C<dom>, 3301the following functions 3302compute a relation that maps each element of C<dom> 3303to the single lexicographic minimum or maximum 3304of the elements that are associated to that same 3305element in C<map> (or C<bmap>). 3306If C<empty> is not C<NULL>, then C<*empty> is assigned a set 3307that contains the elements in C<dom> that do not map 3308to any elements in C<map> (or C<bmap>). 3309In other words, the union of the domain of the result and of C<*empty> 3310is equal to C<dom>. 3311 3312 __isl_give isl_map *isl_basic_map_partial_lexmax( 3313 __isl_take isl_basic_map *bmap, 3314 __isl_take isl_basic_set *dom, 3315 __isl_give isl_set **empty); 3316 __isl_give isl_map *isl_basic_map_partial_lexmin( 3317 __isl_take isl_basic_map *bmap, 3318 __isl_take isl_basic_set *dom, 3319 __isl_give isl_set **empty); 3320 __isl_give isl_map *isl_map_partial_lexmax( 3321 __isl_take isl_map *map, __isl_take isl_set *dom, 3322 __isl_give isl_set **empty); 3323 __isl_give isl_map *isl_map_partial_lexmin( 3324 __isl_take isl_map *map, __isl_take isl_set *dom, 3325 __isl_give isl_set **empty); 3326 3327Given a (basic) map C<map> (or C<bmap>), the following functions simply 3328return a map mapping each element in the domain of 3329C<map> (or C<bmap>) to the lexicographic minimum or maximum 3330of all elements associated to that element. 3331In case of union relations, the optimum is computed per space. 3332 3333 __isl_give isl_map *isl_basic_map_lexmin( 3334 __isl_take isl_basic_map *bmap); 3335 __isl_give isl_map *isl_basic_map_lexmax( 3336 __isl_take isl_basic_map *bmap); 3337 __isl_give isl_map *isl_map_lexmin( 3338 __isl_take isl_map *map); 3339 __isl_give isl_map *isl_map_lexmax( 3340 __isl_take isl_map *map); 3341 __isl_give isl_union_map *isl_union_map_lexmin( 3342 __isl_take isl_union_map *umap); 3343 __isl_give isl_union_map *isl_union_map_lexmax( 3344 __isl_take isl_union_map *umap); 3345 3346The following functions return their result in the form of 3347a piecewise multi-affine expression 3348(See L<"Piecewise Multiple Quasi Affine Expressions">), 3349but are otherwise equivalent to the corresponding functions 3350returning a basic set or relation. 3351 3352 __isl_give isl_pw_multi_aff * 3353 isl_basic_map_lexmin_pw_multi_aff( 3354 __isl_take isl_basic_map *bmap); 3355 __isl_give isl_pw_multi_aff * 3356 isl_basic_set_partial_lexmin_pw_multi_aff( 3357 __isl_take isl_basic_set *bset, 3358 __isl_take isl_basic_set *dom, 3359 __isl_give isl_set **empty); 3360 __isl_give isl_pw_multi_aff * 3361 isl_basic_set_partial_lexmax_pw_multi_aff( 3362 __isl_take isl_basic_set *bset, 3363 __isl_take isl_basic_set *dom, 3364 __isl_give isl_set **empty); 3365 __isl_give isl_pw_multi_aff * 3366 isl_basic_map_partial_lexmin_pw_multi_aff( 3367 __isl_take isl_basic_map *bmap, 3368 __isl_take isl_basic_set *dom, 3369 __isl_give isl_set **empty); 3370 __isl_give isl_pw_multi_aff * 3371 isl_basic_map_partial_lexmax_pw_multi_aff( 3372 __isl_take isl_basic_map *bmap, 3373 __isl_take isl_basic_set *dom, 3374 __isl_give isl_set **empty); 3375 __isl_give isl_pw_multi_aff *isl_set_lexmin_pw_multi_aff( 3376 __isl_take isl_set *set); 3377 __isl_give isl_pw_multi_aff *isl_set_lexmax_pw_multi_aff( 3378 __isl_take isl_set *set); 3379 __isl_give isl_pw_multi_aff *isl_map_lexmin_pw_multi_aff( 3380 __isl_take isl_map *map); 3381 __isl_give isl_pw_multi_aff *isl_map_lexmax_pw_multi_aff( 3382 __isl_take isl_map *map); 3383 3384=head2 Lists 3385 3386Lists are defined over several element types, including 3387C<isl_val>, C<isl_id>, C<isl_aff>, C<isl_pw_aff>, C<isl_constraint>, 3388C<isl_basic_set>, C<isl_set>, C<isl_ast_expr> and C<isl_ast_node>. 3389Here we take lists of C<isl_set>s as an example. 3390Lists can be created, copied, modified and freed using the following functions. 3391 3392 #include <isl/list.h> 3393 __isl_give isl_set_list *isl_set_list_from_set( 3394 __isl_take isl_set *el); 3395 __isl_give isl_set_list *isl_set_list_alloc( 3396 isl_ctx *ctx, int n); 3397 __isl_give isl_set_list *isl_set_list_copy( 3398 __isl_keep isl_set_list *list); 3399 __isl_give isl_set_list *isl_set_list_insert( 3400 __isl_take isl_set_list *list, unsigned pos, 3401 __isl_take isl_set *el); 3402 __isl_give isl_set_list *isl_set_list_add( 3403 __isl_take isl_set_list *list, 3404 __isl_take isl_set *el); 3405 __isl_give isl_set_list *isl_set_list_drop( 3406 __isl_take isl_set_list *list, 3407 unsigned first, unsigned n); 3408 __isl_give isl_set_list *isl_set_list_set_set( 3409 __isl_take isl_set_list *list, int index, 3410 __isl_take isl_set *set); 3411 __isl_give isl_set_list *isl_set_list_concat( 3412 __isl_take isl_set_list *list1, 3413 __isl_take isl_set_list *list2); 3414 __isl_give isl_set_list *isl_set_list_sort( 3415 __isl_take isl_set_list *list, 3416 int (*cmp)(__isl_keep isl_set *a, 3417 __isl_keep isl_set *b, void *user), 3418 void *user); 3419 void *isl_set_list_free(__isl_take isl_set_list *list); 3420 3421C<isl_set_list_alloc> creates an empty list with a capacity for 3422C<n> elements. C<isl_set_list_from_set> creates a list with a single 3423element. 3424 3425Lists can be inspected using the following functions. 3426 3427 #include <isl/list.h> 3428 isl_ctx *isl_set_list_get_ctx(__isl_keep isl_set_list *list); 3429 int isl_set_list_n_set(__isl_keep isl_set_list *list); 3430 __isl_give isl_set *isl_set_list_get_set( 3431 __isl_keep isl_set_list *list, int index); 3432 int isl_set_list_foreach(__isl_keep isl_set_list *list, 3433 int (*fn)(__isl_take isl_set *el, void *user), 3434 void *user); 3435 int isl_set_list_foreach_scc(__isl_keep isl_set_list *list, 3436 int (*follows)(__isl_keep isl_set *a, 3437 __isl_keep isl_set *b, void *user), 3438 void *follows_user 3439 int (*fn)(__isl_take isl_set *el, void *user), 3440 void *fn_user); 3441 3442The function C<isl_set_list_foreach_scc> calls C<fn> on each of the 3443strongly connected components of the graph with as vertices the elements 3444of C<list> and a directed edge from vertex C<b> to vertex C<a> 3445iff C<follows(a, b)> returns C<1>. The callbacks C<follows> and C<fn> 3446should return C<-1> on error. 3447 3448Lists can be printed using 3449 3450 #include <isl/list.h> 3451 __isl_give isl_printer *isl_printer_print_set_list( 3452 __isl_take isl_printer *p, 3453 __isl_keep isl_set_list *list); 3454 3455=head2 Multiple Values 3456 3457An C<isl_multi_val> object represents a sequence of zero or more values, 3458living in a set space. 3459 3460An C<isl_multi_val> can be constructed from an C<isl_val_list> 3461using the following function 3462 3463 #include <isl/val.h> 3464 __isl_give isl_multi_val *isl_multi_val_from_val_list( 3465 __isl_take isl_space *space, 3466 __isl_take isl_val_list *list); 3467 3468The zero multiple value (with value zero for each set dimension) 3469can be created using the following function. 3470 3471 #include <isl/val.h> 3472 __isl_give isl_multi_val *isl_multi_val_zero( 3473 __isl_take isl_space *space); 3474 3475Multiple values can be copied and freed using 3476 3477 #include <isl/val.h> 3478 __isl_give isl_multi_val *isl_multi_val_copy( 3479 __isl_keep isl_multi_val *mv); 3480 void *isl_multi_val_free(__isl_take isl_multi_val *mv); 3481 3482They can be inspected using 3483 3484 #include <isl/val.h> 3485 isl_ctx *isl_multi_val_get_ctx( 3486 __isl_keep isl_multi_val *mv); 3487 unsigned isl_multi_val_dim(__isl_keep isl_multi_val *mv, 3488 enum isl_dim_type type); 3489 __isl_give isl_val *isl_multi_val_get_val( 3490 __isl_keep isl_multi_val *mv, int pos); 3491 const char *isl_multi_val_get_tuple_name( 3492 __isl_keep isl_multi_val *mv, 3493 enum isl_dim_type type); 3494 3495They can be modified using 3496 3497 #include <isl/val.h> 3498 __isl_give isl_multi_val *isl_multi_val_set_val( 3499 __isl_take isl_multi_val *mv, int pos, 3500 __isl_take isl_val *val); 3501 __isl_give isl_multi_val *isl_multi_val_set_dim_name( 3502 __isl_take isl_multi_val *mv, 3503 enum isl_dim_type type, unsigned pos, const char *s); 3504 __isl_give isl_multi_val *isl_multi_val_set_tuple_name( 3505 __isl_take isl_multi_val *mv, 3506 enum isl_dim_type type, const char *s); 3507 __isl_give isl_multi_val *isl_multi_val_set_tuple_id( 3508 __isl_take isl_multi_val *mv, 3509 enum isl_dim_type type, __isl_take isl_id *id); 3510 3511 __isl_give isl_multi_val *isl_multi_val_insert_dims( 3512 __isl_take isl_multi_val *mv, 3513 enum isl_dim_type type, unsigned first, unsigned n); 3514 __isl_give isl_multi_val *isl_multi_val_add_dims( 3515 __isl_take isl_multi_val *mv, 3516 enum isl_dim_type type, unsigned n); 3517 __isl_give isl_multi_val *isl_multi_val_drop_dims( 3518 __isl_take isl_multi_val *mv, 3519 enum isl_dim_type type, unsigned first, unsigned n); 3520 3521Operations include 3522 3523 #include <isl/val.h> 3524 __isl_give isl_multi_val *isl_multi_val_align_params( 3525 __isl_take isl_multi_val *mv, 3526 __isl_take isl_space *model); 3527 __isl_give isl_multi_val *isl_multi_val_range_splice( 3528 __isl_take isl_multi_val *mv1, unsigned pos, 3529 __isl_take isl_multi_val *mv2); 3530 __isl_give isl_multi_val *isl_multi_val_range_product( 3531 __isl_take isl_multi_val *mv1, 3532 __isl_take isl_multi_val *mv2); 3533 __isl_give isl_multi_val *isl_multi_val_flat_range_product( 3534 __isl_take isl_multi_val *mv1, 3535 __isl_take isl_multi_aff *mv2); 3536 __isl_give isl_multi_val *isl_multi_val_add_val( 3537 __isl_take isl_multi_val *mv, 3538 __isl_take isl_val *v); 3539 __isl_give isl_multi_val *isl_multi_val_mod_val( 3540 __isl_take isl_multi_val *mv, 3541 __isl_take isl_val *v); 3542 __isl_give isl_multi_val *isl_multi_val_scale_val( 3543 __isl_take isl_multi_val *mv, 3544 __isl_take isl_val *v); 3545 __isl_give isl_multi_val *isl_multi_val_scale_multi_val( 3546 __isl_take isl_multi_val *mv1, 3547 __isl_take isl_multi_val *mv2); 3548 3549=head2 Vectors 3550 3551Vectors can be created, copied and freed using the following functions. 3552 3553 #include <isl/vec.h> 3554 __isl_give isl_vec *isl_vec_alloc(isl_ctx *ctx, 3555 unsigned size); 3556 __isl_give isl_vec *isl_vec_copy(__isl_keep isl_vec *vec); 3557 void *isl_vec_free(__isl_take isl_vec *vec); 3558 3559Note that the elements of a newly created vector may have arbitrary values. 3560The elements can be changed and inspected using the following functions. 3561 3562 isl_ctx *isl_vec_get_ctx(__isl_keep isl_vec *vec); 3563 int isl_vec_size(__isl_keep isl_vec *vec); 3564 int isl_vec_get_element(__isl_keep isl_vec *vec, 3565 int pos, isl_int *v); 3566 __isl_give isl_val *isl_vec_get_element_val( 3567 __isl_keep isl_vec *vec, int pos); 3568 __isl_give isl_vec *isl_vec_set_element( 3569 __isl_take isl_vec *vec, int pos, isl_int v); 3570 __isl_give isl_vec *isl_vec_set_element_si( 3571 __isl_take isl_vec *vec, int pos, int v); 3572 __isl_give isl_vec *isl_vec_set_element_val( 3573 __isl_take isl_vec *vec, int pos, 3574 __isl_take isl_val *v); 3575 __isl_give isl_vec *isl_vec_set(__isl_take isl_vec *vec, 3576 isl_int v); 3577 __isl_give isl_vec *isl_vec_set_si(__isl_take isl_vec *vec, 3578 int v); 3579 __isl_give isl_vec *isl_vec_set_val( 3580 __isl_take isl_vec *vec, __isl_take isl_val *v); 3581 int isl_vec_cmp_element(__isl_keep isl_vec *vec1, 3582 __isl_keep isl_vec *vec2, int pos); 3583 __isl_give isl_vec *isl_vec_fdiv_r(__isl_take isl_vec *vec, 3584 isl_int m); 3585 3586C<isl_vec_get_element> will return a negative value if anything went wrong. 3587In that case, the value of C<*v> is undefined. 3588 3589The following function can be used to concatenate two vectors. 3590 3591 __isl_give isl_vec *isl_vec_concat(__isl_take isl_vec *vec1, 3592 __isl_take isl_vec *vec2); 3593 3594=head2 Matrices 3595 3596Matrices can be created, copied and freed using the following functions. 3597 3598 #include <isl/mat.h> 3599 __isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx, 3600 unsigned n_row, unsigned n_col); 3601 __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat); 3602 void *isl_mat_free(__isl_take isl_mat *mat); 3603 3604Note that the elements of a newly created matrix may have arbitrary values. 3605The elements can be changed and inspected using the following functions. 3606 3607 isl_ctx *isl_mat_get_ctx(__isl_keep isl_mat *mat); 3608 int isl_mat_rows(__isl_keep isl_mat *mat); 3609 int isl_mat_cols(__isl_keep isl_mat *mat); 3610 int isl_mat_get_element(__isl_keep isl_mat *mat, 3611 int row, int col, isl_int *v); 3612 __isl_give isl_val *isl_mat_get_element_val( 3613 __isl_keep isl_mat *mat, int row, int col); 3614 __isl_give isl_mat *isl_mat_set_element(__isl_take isl_mat *mat, 3615 int row, int col, isl_int v); 3616 __isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat, 3617 int row, int col, int v); 3618 __isl_give isl_mat *isl_mat_set_element_val( 3619 __isl_take isl_mat *mat, int row, int col, 3620 __isl_take isl_val *v); 3621 3622C<isl_mat_get_element> will return a negative value if anything went wrong. 3623In that case, the value of C<*v> is undefined. 3624 3625The following function can be used to compute the (right) inverse 3626of a matrix, i.e., a matrix such that the product of the original 3627and the inverse (in that order) is a multiple of the identity matrix. 3628The input matrix is assumed to be of full row-rank. 3629 3630 __isl_give isl_mat *isl_mat_right_inverse(__isl_take isl_mat *mat); 3631 3632The following function can be used to compute the (right) kernel 3633(or null space) of a matrix, i.e., a matrix such that the product of 3634the original and the kernel (in that order) is the zero matrix. 3635 3636 __isl_give isl_mat *isl_mat_right_kernel(__isl_take isl_mat *mat); 3637 3638=head2 Piecewise Quasi Affine Expressions 3639 3640The zero quasi affine expression or the quasi affine expression 3641that is equal to a specified dimension on a given domain can be created using 3642 3643 __isl_give isl_aff *isl_aff_zero_on_domain( 3644 __isl_take isl_local_space *ls); 3645 __isl_give isl_pw_aff *isl_pw_aff_zero_on_domain( 3646 __isl_take isl_local_space *ls); 3647 __isl_give isl_aff *isl_aff_var_on_domain( 3648 __isl_take isl_local_space *ls, 3649 enum isl_dim_type type, unsigned pos); 3650 __isl_give isl_pw_aff *isl_pw_aff_var_on_domain( 3651 __isl_take isl_local_space *ls, 3652 enum isl_dim_type type, unsigned pos); 3653 3654Note that the space in which the resulting objects live is a map space 3655with the given space as domain and a one-dimensional range. 3656 3657An empty piecewise quasi affine expression (one with no cells) 3658or a piecewise quasi affine expression with a single cell can 3659be created using the following functions. 3660 3661 #include <isl/aff.h> 3662 __isl_give isl_pw_aff *isl_pw_aff_empty( 3663 __isl_take isl_space *space); 3664 __isl_give isl_pw_aff *isl_pw_aff_alloc( 3665 __isl_take isl_set *set, __isl_take isl_aff *aff); 3666 __isl_give isl_pw_aff *isl_pw_aff_from_aff( 3667 __isl_take isl_aff *aff); 3668 3669A piecewise quasi affine expression that is equal to 1 on a set 3670and 0 outside the set can be created using the following function. 3671 3672 #include <isl/aff.h> 3673 __isl_give isl_pw_aff *isl_set_indicator_function( 3674 __isl_take isl_set *set); 3675 3676Quasi affine expressions can be copied and freed using 3677 3678 #include <isl/aff.h> 3679 __isl_give isl_aff *isl_aff_copy(__isl_keep isl_aff *aff); 3680 void *isl_aff_free(__isl_take isl_aff *aff); 3681 3682 __isl_give isl_pw_aff *isl_pw_aff_copy( 3683 __isl_keep isl_pw_aff *pwaff); 3684 void *isl_pw_aff_free(__isl_take isl_pw_aff *pwaff); 3685 3686A (rational) bound on a dimension can be extracted from an C<isl_constraint> 3687using the following function. The constraint is required to have 3688a non-zero coefficient for the specified dimension. 3689 3690 #include <isl/constraint.h> 3691 __isl_give isl_aff *isl_constraint_get_bound( 3692 __isl_keep isl_constraint *constraint, 3693 enum isl_dim_type type, int pos); 3694 3695The entire affine expression of the constraint can also be extracted 3696using the following function. 3697 3698 #include <isl/constraint.h> 3699 __isl_give isl_aff *isl_constraint_get_aff( 3700 __isl_keep isl_constraint *constraint); 3701 3702Conversely, an equality constraint equating 3703the affine expression to zero or an inequality constraint enforcing 3704the affine expression to be non-negative, can be constructed using 3705 3706 __isl_give isl_constraint *isl_equality_from_aff( 3707 __isl_take isl_aff *aff); 3708 __isl_give isl_constraint *isl_inequality_from_aff( 3709 __isl_take isl_aff *aff); 3710 3711The expression can be inspected using 3712 3713 #include <isl/aff.h> 3714 isl_ctx *isl_aff_get_ctx(__isl_keep isl_aff *aff); 3715 int isl_aff_dim(__isl_keep isl_aff *aff, 3716 enum isl_dim_type type); 3717 __isl_give isl_local_space *isl_aff_get_domain_local_space( 3718 __isl_keep isl_aff *aff); 3719 __isl_give isl_local_space *isl_aff_get_local_space( 3720 __isl_keep isl_aff *aff); 3721 const char *isl_aff_get_dim_name(__isl_keep isl_aff *aff, 3722 enum isl_dim_type type, unsigned pos); 3723 const char *isl_pw_aff_get_dim_name( 3724 __isl_keep isl_pw_aff *pa, 3725 enum isl_dim_type type, unsigned pos); 3726 int isl_pw_aff_has_dim_id(__isl_keep isl_pw_aff *pa, 3727 enum isl_dim_type type, unsigned pos); 3728 __isl_give isl_id *isl_pw_aff_get_dim_id( 3729 __isl_keep isl_pw_aff *pa, 3730 enum isl_dim_type type, unsigned pos); 3731 __isl_give isl_id *isl_pw_aff_get_tuple_id( 3732 __isl_keep isl_pw_aff *pa, 3733 enum isl_dim_type type); 3734 int isl_aff_get_constant(__isl_keep isl_aff *aff, 3735 isl_int *v); 3736 __isl_give isl_val *isl_aff_get_constant_val( 3737 __isl_keep isl_aff *aff); 3738 int isl_aff_get_coefficient(__isl_keep isl_aff *aff, 3739 enum isl_dim_type type, int pos, isl_int *v); 3740 __isl_give isl_val *isl_aff_get_coefficient_val( 3741 __isl_keep isl_aff *aff, 3742 enum isl_dim_type type, int pos); 3743 int isl_aff_get_denominator(__isl_keep isl_aff *aff, 3744 isl_int *v); 3745 __isl_give isl_val *isl_aff_get_denominator_val( 3746 __isl_keep isl_aff *aff); 3747 __isl_give isl_aff *isl_aff_get_div( 3748 __isl_keep isl_aff *aff, int pos); 3749 3750 int isl_pw_aff_n_piece(__isl_keep isl_pw_aff *pwaff); 3751 int isl_pw_aff_foreach_piece(__isl_keep isl_pw_aff *pwaff, 3752 int (*fn)(__isl_take isl_set *set, 3753 __isl_take isl_aff *aff, 3754 void *user), void *user); 3755 3756 int isl_aff_is_cst(__isl_keep isl_aff *aff); 3757 int isl_pw_aff_is_cst(__isl_keep isl_pw_aff *pwaff); 3758 3759 int isl_aff_involves_dims(__isl_keep isl_aff *aff, 3760 enum isl_dim_type type, unsigned first, unsigned n); 3761 int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff, 3762 enum isl_dim_type type, unsigned first, unsigned n); 3763 3764 isl_ctx *isl_pw_aff_get_ctx(__isl_keep isl_pw_aff *pwaff); 3765 unsigned isl_pw_aff_dim(__isl_keep isl_pw_aff *pwaff, 3766 enum isl_dim_type type); 3767 int isl_pw_aff_is_empty(__isl_keep isl_pw_aff *pwaff); 3768 3769It can be modified using 3770 3771 #include <isl/aff.h> 3772 __isl_give isl_pw_aff *isl_pw_aff_set_tuple_id( 3773 __isl_take isl_pw_aff *pwaff, 3774 enum isl_dim_type type, __isl_take isl_id *id); 3775 __isl_give isl_aff *isl_aff_set_dim_name( 3776 __isl_take isl_aff *aff, enum isl_dim_type type, 3777 unsigned pos, const char *s); 3778 __isl_give isl_aff *isl_aff_set_dim_id( 3779 __isl_take isl_aff *aff, enum isl_dim_type type, 3780 unsigned pos, __isl_take isl_id *id); 3781 __isl_give isl_pw_aff *isl_pw_aff_set_dim_id( 3782 __isl_take isl_pw_aff *pma, 3783 enum isl_dim_type type, unsigned pos, 3784 __isl_take isl_id *id); 3785 __isl_give isl_aff *isl_aff_set_constant( 3786 __isl_take isl_aff *aff, isl_int v); 3787 __isl_give isl_aff *isl_aff_set_constant_si( 3788 __isl_take isl_aff *aff, int v); 3789 __isl_give isl_aff *isl_aff_set_constant_val( 3790 __isl_take isl_aff *aff, __isl_take isl_val *v); 3791 __isl_give isl_aff *isl_aff_set_coefficient( 3792 __isl_take isl_aff *aff, 3793 enum isl_dim_type type, int pos, isl_int v); 3794 __isl_give isl_aff *isl_aff_set_coefficient_si( 3795 __isl_take isl_aff *aff, 3796 enum isl_dim_type type, int pos, int v); 3797 __isl_give isl_aff *isl_aff_set_coefficient_val( 3798 __isl_take isl_aff *aff, 3799 enum isl_dim_type type, int pos, 3800 __isl_take isl_val *v); 3801 __isl_give isl_aff *isl_aff_set_denominator( 3802 __isl_take isl_aff *aff, isl_int v); 3803 3804 __isl_give isl_aff *isl_aff_add_constant( 3805 __isl_take isl_aff *aff, isl_int v); 3806 __isl_give isl_aff *isl_aff_add_constant_si( 3807 __isl_take isl_aff *aff, int v); 3808 __isl_give isl_aff *isl_aff_add_constant_val( 3809 __isl_take isl_aff *aff, __isl_take isl_val *v); 3810 __isl_give isl_aff *isl_aff_add_constant_num( 3811 __isl_take isl_aff *aff, isl_int v); 3812 __isl_give isl_aff *isl_aff_add_constant_num_si( 3813 __isl_take isl_aff *aff, int v); 3814 __isl_give isl_aff *isl_aff_add_coefficient( 3815 __isl_take isl_aff *aff, 3816 enum isl_dim_type type, int pos, isl_int v); 3817 __isl_give isl_aff *isl_aff_add_coefficient_si( 3818 __isl_take isl_aff *aff, 3819 enum isl_dim_type type, int pos, int v); 3820 __isl_give isl_aff *isl_aff_add_coefficient_val( 3821 __isl_take isl_aff *aff, 3822 enum isl_dim_type type, int pos, 3823 __isl_take isl_val *v); 3824 3825 __isl_give isl_aff *isl_aff_insert_dims( 3826 __isl_take isl_aff *aff, 3827 enum isl_dim_type type, unsigned first, unsigned n); 3828 __isl_give isl_pw_aff *isl_pw_aff_insert_dims( 3829 __isl_take isl_pw_aff *pwaff, 3830 enum isl_dim_type type, unsigned first, unsigned n); 3831 __isl_give isl_aff *isl_aff_add_dims( 3832 __isl_take isl_aff *aff, 3833 enum isl_dim_type type, unsigned n); 3834 __isl_give isl_pw_aff *isl_pw_aff_add_dims( 3835 __isl_take isl_pw_aff *pwaff, 3836 enum isl_dim_type type, unsigned n); 3837 __isl_give isl_aff *isl_aff_drop_dims( 3838 __isl_take isl_aff *aff, 3839 enum isl_dim_type type, unsigned first, unsigned n); 3840 __isl_give isl_pw_aff *isl_pw_aff_drop_dims( 3841 __isl_take isl_pw_aff *pwaff, 3842 enum isl_dim_type type, unsigned first, unsigned n); 3843 3844Note that C<isl_aff_set_constant>, C<isl_aff_set_constant_si>, 3845C<isl_aff_set_coefficient> and C<isl_aff_set_coefficient_si> 3846set the I<numerator> of the constant or coefficient, while 3847C<isl_aff_set_constant_val> and C<isl_aff_set_coefficient_val> set 3848the constant or coefficient as a whole. 3849The C<add_constant> and C<add_coefficient> functions add an integer 3850or rational value to 3851the possibly rational constant or coefficient. 3852The C<add_constant_num> functions add an integer value to 3853the numerator. 3854 3855To check whether an affine expressions is obviously zero 3856or obviously equal to some other affine expression, use 3857 3858 #include <isl/aff.h> 3859 int isl_aff_plain_is_zero(__isl_keep isl_aff *aff); 3860 int isl_aff_plain_is_equal(__isl_keep isl_aff *aff1, 3861 __isl_keep isl_aff *aff2); 3862 int isl_pw_aff_plain_is_equal( 3863 __isl_keep isl_pw_aff *pwaff1, 3864 __isl_keep isl_pw_aff *pwaff2); 3865 3866Operations include 3867 3868 #include <isl/aff.h> 3869 __isl_give isl_aff *isl_aff_add(__isl_take isl_aff *aff1, 3870 __isl_take isl_aff *aff2); 3871 __isl_give isl_pw_aff *isl_pw_aff_add( 3872 __isl_take isl_pw_aff *pwaff1, 3873 __isl_take isl_pw_aff *pwaff2); 3874 __isl_give isl_pw_aff *isl_pw_aff_min( 3875 __isl_take isl_pw_aff *pwaff1, 3876 __isl_take isl_pw_aff *pwaff2); 3877 __isl_give isl_pw_aff *isl_pw_aff_max( 3878 __isl_take isl_pw_aff *pwaff1, 3879 __isl_take isl_pw_aff *pwaff2); 3880 __isl_give isl_aff *isl_aff_sub(__isl_take isl_aff *aff1, 3881 __isl_take isl_aff *aff2); 3882 __isl_give isl_pw_aff *isl_pw_aff_sub( 3883 __isl_take isl_pw_aff *pwaff1, 3884 __isl_take isl_pw_aff *pwaff2); 3885 __isl_give isl_aff *isl_aff_neg(__isl_take isl_aff *aff); 3886 __isl_give isl_pw_aff *isl_pw_aff_neg( 3887 __isl_take isl_pw_aff *pwaff); 3888 __isl_give isl_aff *isl_aff_ceil(__isl_take isl_aff *aff); 3889 __isl_give isl_pw_aff *isl_pw_aff_ceil( 3890 __isl_take isl_pw_aff *pwaff); 3891 __isl_give isl_aff *isl_aff_floor(__isl_take isl_aff *aff); 3892 __isl_give isl_pw_aff *isl_pw_aff_floor( 3893 __isl_take isl_pw_aff *pwaff); 3894 __isl_give isl_aff *isl_aff_mod(__isl_take isl_aff *aff, 3895 isl_int mod); 3896 __isl_give isl_aff *isl_aff_mod_val(__isl_take isl_aff *aff, 3897 __isl_take isl_val *mod); 3898 __isl_give isl_pw_aff *isl_pw_aff_mod( 3899 __isl_take isl_pw_aff *pwaff, isl_int mod); 3900 __isl_give isl_pw_aff *isl_pw_aff_mod_val( 3901 __isl_take isl_pw_aff *pa, 3902 __isl_take isl_val *mod); 3903 __isl_give isl_aff *isl_aff_scale(__isl_take isl_aff *aff, 3904 isl_int f); 3905 __isl_give isl_aff *isl_aff_scale_val(__isl_take isl_aff *aff, 3906 __isl_take isl_val *v); 3907 __isl_give isl_pw_aff *isl_pw_aff_scale( 3908 __isl_take isl_pw_aff *pwaff, isl_int f); 3909 __isl_give isl_pw_aff *isl_pw_aff_scale_val( 3910 __isl_take isl_pw_aff *pa, __isl_take isl_val *v); 3911 __isl_give isl_aff *isl_aff_scale_down(__isl_take isl_aff *aff, 3912 isl_int f); 3913 __isl_give isl_aff *isl_aff_scale_down_ui( 3914 __isl_take isl_aff *aff, unsigned f); 3915 __isl_give isl_aff *isl_aff_scale_down_val( 3916 __isl_take isl_aff *aff, __isl_take isl_val *v); 3917 __isl_give isl_pw_aff *isl_pw_aff_scale_down( 3918 __isl_take isl_pw_aff *pwaff, isl_int f); 3919 __isl_give isl_pw_aff *isl_pw_aff_scale_down_val( 3920 __isl_take isl_pw_aff *pa, 3921 __isl_take isl_val *f); 3922 3923 __isl_give isl_pw_aff *isl_pw_aff_list_min( 3924 __isl_take isl_pw_aff_list *list); 3925 __isl_give isl_pw_aff *isl_pw_aff_list_max( 3926 __isl_take isl_pw_aff_list *list); 3927 3928 __isl_give isl_pw_aff *isl_pw_aff_coalesce( 3929 __isl_take isl_pw_aff *pwqp); 3930 3931 __isl_give isl_aff *isl_aff_align_params( 3932 __isl_take isl_aff *aff, 3933 __isl_take isl_space *model); 3934 __isl_give isl_pw_aff *isl_pw_aff_align_params( 3935 __isl_take isl_pw_aff *pwaff, 3936 __isl_take isl_space *model); 3937 3938 __isl_give isl_aff *isl_aff_project_domain_on_params( 3939 __isl_take isl_aff *aff); 3940 3941 __isl_give isl_aff *isl_aff_gist_params( 3942 __isl_take isl_aff *aff, 3943 __isl_take isl_set *context); 3944 __isl_give isl_aff *isl_aff_gist(__isl_take isl_aff *aff, 3945 __isl_take isl_set *context); 3946 __isl_give isl_pw_aff *isl_pw_aff_gist_params( 3947 __isl_take isl_pw_aff *pwaff, 3948 __isl_take isl_set *context); 3949 __isl_give isl_pw_aff *isl_pw_aff_gist( 3950 __isl_take isl_pw_aff *pwaff, 3951 __isl_take isl_set *context); 3952 3953 __isl_give isl_set *isl_pw_aff_domain( 3954 __isl_take isl_pw_aff *pwaff); 3955 __isl_give isl_pw_aff *isl_pw_aff_intersect_domain( 3956 __isl_take isl_pw_aff *pa, 3957 __isl_take isl_set *set); 3958 __isl_give isl_pw_aff *isl_pw_aff_intersect_params( 3959 __isl_take isl_pw_aff *pa, 3960 __isl_take isl_set *set); 3961 3962 __isl_give isl_aff *isl_aff_mul(__isl_take isl_aff *aff1, 3963 __isl_take isl_aff *aff2); 3964 __isl_give isl_aff *isl_aff_div(__isl_take isl_aff *aff1, 3965 __isl_take isl_aff *aff2); 3966 __isl_give isl_pw_aff *isl_pw_aff_mul( 3967 __isl_take isl_pw_aff *pwaff1, 3968 __isl_take isl_pw_aff *pwaff2); 3969 __isl_give isl_pw_aff *isl_pw_aff_div( 3970 __isl_take isl_pw_aff *pa1, 3971 __isl_take isl_pw_aff *pa2); 3972 __isl_give isl_pw_aff *isl_pw_aff_tdiv_q( 3973 __isl_take isl_pw_aff *pa1, 3974 __isl_take isl_pw_aff *pa2); 3975 __isl_give isl_pw_aff *isl_pw_aff_tdiv_r( 3976 __isl_take isl_pw_aff *pa1, 3977 __isl_take isl_pw_aff *pa2); 3978 3979When multiplying two affine expressions, at least one of the two needs 3980to be a constant. Similarly, when dividing an affine expression by another, 3981the second expression needs to be a constant. 3982C<isl_pw_aff_tdiv_q> computes the quotient of an integer division with 3983rounding towards zero. C<isl_pw_aff_tdiv_r> computes the corresponding 3984remainder. 3985 3986 #include <isl/aff.h> 3987 __isl_give isl_aff *isl_aff_pullback_multi_aff( 3988 __isl_take isl_aff *aff, 3989 __isl_take isl_multi_aff *ma); 3990 __isl_give isl_pw_aff *isl_pw_aff_pullback_multi_aff( 3991 __isl_take isl_pw_aff *pa, 3992 __isl_take isl_multi_aff *ma); 3993 __isl_give isl_pw_aff *isl_pw_aff_pullback_pw_multi_aff( 3994 __isl_take isl_pw_aff *pa, 3995 __isl_take isl_pw_multi_aff *pma); 3996 3997These functions precompose the input expression by the given 3998C<isl_multi_aff> or C<isl_pw_multi_aff>. In other words, 3999the C<isl_multi_aff> or C<isl_pw_multi_aff> is plugged 4000into the (piecewise) affine expression. 4001Objects of type C<isl_multi_aff> are described in 4002L</"Piecewise Multiple Quasi Affine Expressions">. 4003 4004 #include <isl/aff.h> 4005 __isl_give isl_basic_set *isl_aff_zero_basic_set( 4006 __isl_take isl_aff *aff); 4007 __isl_give isl_basic_set *isl_aff_neg_basic_set( 4008 __isl_take isl_aff *aff); 4009 __isl_give isl_basic_set *isl_aff_le_basic_set( 4010 __isl_take isl_aff *aff1, __isl_take isl_aff *aff2); 4011 __isl_give isl_basic_set *isl_aff_ge_basic_set( 4012 __isl_take isl_aff *aff1, __isl_take isl_aff *aff2); 4013 __isl_give isl_set *isl_pw_aff_eq_set( 4014 __isl_take isl_pw_aff *pwaff1, 4015 __isl_take isl_pw_aff *pwaff2); 4016 __isl_give isl_set *isl_pw_aff_ne_set( 4017 __isl_take isl_pw_aff *pwaff1, 4018 __isl_take isl_pw_aff *pwaff2); 4019 __isl_give isl_set *isl_pw_aff_le_set( 4020 __isl_take isl_pw_aff *pwaff1, 4021 __isl_take isl_pw_aff *pwaff2); 4022 __isl_give isl_set *isl_pw_aff_lt_set( 4023 __isl_take isl_pw_aff *pwaff1, 4024 __isl_take isl_pw_aff *pwaff2); 4025 __isl_give isl_set *isl_pw_aff_ge_set( 4026 __isl_take isl_pw_aff *pwaff1, 4027 __isl_take isl_pw_aff *pwaff2); 4028 __isl_give isl_set *isl_pw_aff_gt_set( 4029 __isl_take isl_pw_aff *pwaff1, 4030 __isl_take isl_pw_aff *pwaff2); 4031 4032 __isl_give isl_set *isl_pw_aff_list_eq_set( 4033 __isl_take isl_pw_aff_list *list1, 4034 __isl_take isl_pw_aff_list *list2); 4035 __isl_give isl_set *isl_pw_aff_list_ne_set( 4036 __isl_take isl_pw_aff_list *list1, 4037 __isl_take isl_pw_aff_list *list2); 4038 __isl_give isl_set *isl_pw_aff_list_le_set( 4039 __isl_take isl_pw_aff_list *list1, 4040 __isl_take isl_pw_aff_list *list2); 4041 __isl_give isl_set *isl_pw_aff_list_lt_set( 4042 __isl_take isl_pw_aff_list *list1, 4043 __isl_take isl_pw_aff_list *list2); 4044 __isl_give isl_set *isl_pw_aff_list_ge_set( 4045 __isl_take isl_pw_aff_list *list1, 4046 __isl_take isl_pw_aff_list *list2); 4047 __isl_give isl_set *isl_pw_aff_list_gt_set( 4048 __isl_take isl_pw_aff_list *list1, 4049 __isl_take isl_pw_aff_list *list2); 4050 4051The function C<isl_aff_neg_basic_set> returns a basic set 4052containing those elements in the domain space 4053of C<aff> where C<aff> is negative. 4054The function C<isl_aff_ge_basic_set> returns a basic set 4055containing those elements in the shared space 4056of C<aff1> and C<aff2> where C<aff1> is greater than or equal to C<aff2>. 4057The function C<isl_pw_aff_ge_set> returns a set 4058containing those elements in the shared domain 4059of C<pwaff1> and C<pwaff2> where C<pwaff1> is greater than or equal to C<pwaff2>. 4060The functions operating on C<isl_pw_aff_list> apply the corresponding 4061C<isl_pw_aff> function to each pair of elements in the two lists. 4062 4063 #include <isl/aff.h> 4064 __isl_give isl_set *isl_pw_aff_nonneg_set( 4065 __isl_take isl_pw_aff *pwaff); 4066 __isl_give isl_set *isl_pw_aff_zero_set( 4067 __isl_take isl_pw_aff *pwaff); 4068 __isl_give isl_set *isl_pw_aff_non_zero_set( 4069 __isl_take isl_pw_aff *pwaff); 4070 4071The function C<isl_pw_aff_nonneg_set> returns a set 4072containing those elements in the domain 4073of C<pwaff> where C<pwaff> is non-negative. 4074 4075 #include <isl/aff.h> 4076 __isl_give isl_pw_aff *isl_pw_aff_cond( 4077 __isl_take isl_pw_aff *cond, 4078 __isl_take isl_pw_aff *pwaff_true, 4079 __isl_take isl_pw_aff *pwaff_false); 4080 4081The function C<isl_pw_aff_cond> performs a conditional operator 4082and returns an expression that is equal to C<pwaff_true> 4083for elements where C<cond> is non-zero and equal to C<pwaff_false> for elements 4084where C<cond> is zero. 4085 4086 #include <isl/aff.h> 4087 __isl_give isl_pw_aff *isl_pw_aff_union_min( 4088 __isl_take isl_pw_aff *pwaff1, 4089 __isl_take isl_pw_aff *pwaff2); 4090 __isl_give isl_pw_aff *isl_pw_aff_union_max( 4091 __isl_take isl_pw_aff *pwaff1, 4092 __isl_take isl_pw_aff *pwaff2); 4093 __isl_give isl_pw_aff *isl_pw_aff_union_add( 4094 __isl_take isl_pw_aff *pwaff1, 4095 __isl_take isl_pw_aff *pwaff2); 4096 4097The function C<isl_pw_aff_union_max> computes a piecewise quasi-affine 4098expression with a domain that is the union of those of C<pwaff1> and 4099C<pwaff2> and such that on each cell, the quasi-affine expression is 4100the maximum of those of C<pwaff1> and C<pwaff2>. If only one of 4101C<pwaff1> or C<pwaff2> is defined on a given cell, then the 4102associated expression is the defined one. 4103 4104An expression can be read from input using 4105 4106 #include <isl/aff.h> 4107 __isl_give isl_aff *isl_aff_read_from_str( 4108 isl_ctx *ctx, const char *str); 4109 __isl_give isl_pw_aff *isl_pw_aff_read_from_str( 4110 isl_ctx *ctx, const char *str); 4111 4112An expression can be printed using 4113 4114 #include <isl/aff.h> 4115 __isl_give isl_printer *isl_printer_print_aff( 4116 __isl_take isl_printer *p, __isl_keep isl_aff *aff); 4117 4118 __isl_give isl_printer *isl_printer_print_pw_aff( 4119 __isl_take isl_printer *p, 4120 __isl_keep isl_pw_aff *pwaff); 4121 4122=head2 Piecewise Multiple Quasi Affine Expressions 4123 4124An C<isl_multi_aff> object represents a sequence of 4125zero or more affine expressions, all defined on the same domain space. 4126Similarly, an C<isl_multi_pw_aff> object represents a sequence of 4127zero or more piecewise affine expressions. 4128 4129An C<isl_multi_aff> can be constructed from a single 4130C<isl_aff> or an C<isl_aff_list> using the 4131following functions. Similarly for C<isl_multi_pw_aff>. 4132 4133 #include <isl/aff.h> 4134 __isl_give isl_multi_aff *isl_multi_aff_from_aff( 4135 __isl_take isl_aff *aff); 4136 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_from_pw_aff( 4137 __isl_take isl_pw_aff *pa); 4138 __isl_give isl_multi_aff *isl_multi_aff_from_aff_list( 4139 __isl_take isl_space *space, 4140 __isl_take isl_aff_list *list); 4141 4142An empty piecewise multiple quasi affine expression (one with no cells), 4143the zero piecewise multiple quasi affine expression (with value zero 4144for each output dimension), 4145a piecewise multiple quasi affine expression with a single cell (with 4146either a universe or a specified domain) or 4147a zero-dimensional piecewise multiple quasi affine expression 4148on a given domain 4149can be created using the following functions. 4150 4151 #include <isl/aff.h> 4152 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_empty( 4153 __isl_take isl_space *space); 4154 __isl_give isl_multi_aff *isl_multi_aff_zero( 4155 __isl_take isl_space *space); 4156 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_zero( 4157 __isl_take isl_space *space); 4158 __isl_give isl_multi_aff *isl_multi_aff_identity( 4159 __isl_take isl_space *space); 4160 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_identity( 4161 __isl_take isl_space *space); 4162 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_identity( 4163 __isl_take isl_space *space); 4164 __isl_give isl_pw_multi_aff * 4165 isl_pw_multi_aff_from_multi_aff( 4166 __isl_take isl_multi_aff *ma); 4167 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_alloc( 4168 __isl_take isl_set *set, 4169 __isl_take isl_multi_aff *maff); 4170 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_domain( 4171 __isl_take isl_set *set); 4172 4173 __isl_give isl_union_pw_multi_aff * 4174 isl_union_pw_multi_aff_empty( 4175 __isl_take isl_space *space); 4176 __isl_give isl_union_pw_multi_aff * 4177 isl_union_pw_multi_aff_add_pw_multi_aff( 4178 __isl_take isl_union_pw_multi_aff *upma, 4179 __isl_take isl_pw_multi_aff *pma); 4180 __isl_give isl_union_pw_multi_aff * 4181 isl_union_pw_multi_aff_from_domain( 4182 __isl_take isl_union_set *uset); 4183 4184A piecewise multiple quasi affine expression can also be initialized 4185from an C<isl_set> or C<isl_map>, provided the C<isl_set> is a singleton 4186and the C<isl_map> is single-valued. 4187In case of a conversion from an C<isl_union_set> or an C<isl_union_map> 4188to an C<isl_union_pw_multi_aff>, these properties need to hold in each space. 4189 4190 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_set( 4191 __isl_take isl_set *set); 4192 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_from_map( 4193 __isl_take isl_map *map); 4194 4195 __isl_give isl_union_pw_multi_aff * 4196 isl_union_pw_multi_aff_from_union_set( 4197 __isl_take isl_union_set *uset); 4198 __isl_give isl_union_pw_multi_aff * 4199 isl_union_pw_multi_aff_from_union_map( 4200 __isl_take isl_union_map *umap); 4201 4202Multiple quasi affine expressions can be copied and freed using 4203 4204 #include <isl/aff.h> 4205 __isl_give isl_multi_aff *isl_multi_aff_copy( 4206 __isl_keep isl_multi_aff *maff); 4207 void *isl_multi_aff_free(__isl_take isl_multi_aff *maff); 4208 4209 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_copy( 4210 __isl_keep isl_pw_multi_aff *pma); 4211 void *isl_pw_multi_aff_free( 4212 __isl_take isl_pw_multi_aff *pma); 4213 4214 __isl_give isl_union_pw_multi_aff * 4215 isl_union_pw_multi_aff_copy( 4216 __isl_keep isl_union_pw_multi_aff *upma); 4217 void *isl_union_pw_multi_aff_free( 4218 __isl_take isl_union_pw_multi_aff *upma); 4219 4220 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_copy( 4221 __isl_keep isl_multi_pw_aff *mpa); 4222 void *isl_multi_pw_aff_free( 4223 __isl_take isl_multi_pw_aff *mpa); 4224 4225The expression can be inspected using 4226 4227 #include <isl/aff.h> 4228 isl_ctx *isl_multi_aff_get_ctx( 4229 __isl_keep isl_multi_aff *maff); 4230 isl_ctx *isl_pw_multi_aff_get_ctx( 4231 __isl_keep isl_pw_multi_aff *pma); 4232 isl_ctx *isl_union_pw_multi_aff_get_ctx( 4233 __isl_keep isl_union_pw_multi_aff *upma); 4234 isl_ctx *isl_multi_pw_aff_get_ctx( 4235 __isl_keep isl_multi_pw_aff *mpa); 4236 unsigned isl_multi_aff_dim(__isl_keep isl_multi_aff *maff, 4237 enum isl_dim_type type); 4238 unsigned isl_pw_multi_aff_dim( 4239 __isl_keep isl_pw_multi_aff *pma, 4240 enum isl_dim_type type); 4241 unsigned isl_multi_pw_aff_dim( 4242 __isl_keep isl_multi_pw_aff *mpa, 4243 enum isl_dim_type type); 4244 __isl_give isl_aff *isl_multi_aff_get_aff( 4245 __isl_keep isl_multi_aff *multi, int pos); 4246 __isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff( 4247 __isl_keep isl_pw_multi_aff *pma, int pos); 4248 __isl_give isl_pw_aff *isl_multi_pw_aff_get_pw_aff( 4249 __isl_keep isl_multi_pw_aff *mpa, int pos); 4250 const char *isl_pw_multi_aff_get_dim_name( 4251 __isl_keep isl_pw_multi_aff *pma, 4252 enum isl_dim_type type, unsigned pos); 4253 __isl_give isl_id *isl_pw_multi_aff_get_dim_id( 4254 __isl_keep isl_pw_multi_aff *pma, 4255 enum isl_dim_type type, unsigned pos); 4256 const char *isl_multi_aff_get_tuple_name( 4257 __isl_keep isl_multi_aff *multi, 4258 enum isl_dim_type type); 4259 int isl_pw_multi_aff_has_tuple_name( 4260 __isl_keep isl_pw_multi_aff *pma, 4261 enum isl_dim_type type); 4262 const char *isl_pw_multi_aff_get_tuple_name( 4263 __isl_keep isl_pw_multi_aff *pma, 4264 enum isl_dim_type type); 4265 int isl_pw_multi_aff_has_tuple_id( 4266 __isl_keep isl_pw_multi_aff *pma, 4267 enum isl_dim_type type); 4268 __isl_give isl_id *isl_pw_multi_aff_get_tuple_id( 4269 __isl_keep isl_pw_multi_aff *pma, 4270 enum isl_dim_type type); 4271 4272 int isl_pw_multi_aff_foreach_piece( 4273 __isl_keep isl_pw_multi_aff *pma, 4274 int (*fn)(__isl_take isl_set *set, 4275 __isl_take isl_multi_aff *maff, 4276 void *user), void *user); 4277 4278 int isl_union_pw_multi_aff_foreach_pw_multi_aff( 4279 __isl_keep isl_union_pw_multi_aff *upma, 4280 int (*fn)(__isl_take isl_pw_multi_aff *pma, 4281 void *user), void *user); 4282 4283It can be modified using 4284 4285 #include <isl/aff.h> 4286 __isl_give isl_multi_aff *isl_multi_aff_set_aff( 4287 __isl_take isl_multi_aff *multi, int pos, 4288 __isl_take isl_aff *aff); 4289 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_pw_aff( 4290 __isl_take isl_pw_multi_aff *pma, unsigned pos, 4291 __isl_take isl_pw_aff *pa); 4292 __isl_give isl_multi_aff *isl_multi_aff_set_dim_name( 4293 __isl_take isl_multi_aff *maff, 4294 enum isl_dim_type type, unsigned pos, const char *s); 4295 __isl_give isl_multi_aff *isl_multi_aff_set_tuple_name( 4296 __isl_take isl_multi_aff *maff, 4297 enum isl_dim_type type, const char *s); 4298 __isl_give isl_multi_aff *isl_multi_aff_set_tuple_id( 4299 __isl_take isl_multi_aff *maff, 4300 enum isl_dim_type type, __isl_take isl_id *id); 4301 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_set_tuple_id( 4302 __isl_take isl_pw_multi_aff *pma, 4303 enum isl_dim_type type, __isl_take isl_id *id); 4304 4305 __isl_give isl_multi_pw_aff * 4306 isl_multi_pw_aff_set_dim_name( 4307 __isl_take isl_multi_pw_aff *mpa, 4308 enum isl_dim_type type, unsigned pos, const char *s); 4309 __isl_give isl_multi_pw_aff * 4310 isl_multi_pw_aff_set_tuple_name( 4311 __isl_take isl_multi_pw_aff *mpa, 4312 enum isl_dim_type type, const char *s); 4313 4314 __isl_give isl_multi_aff *isl_multi_aff_insert_dims( 4315 __isl_take isl_multi_aff *ma, 4316 enum isl_dim_type type, unsigned first, unsigned n); 4317 __isl_give isl_multi_aff *isl_multi_aff_add_dims( 4318 __isl_take isl_multi_aff *ma, 4319 enum isl_dim_type type, unsigned n); 4320 __isl_give isl_multi_aff *isl_multi_aff_drop_dims( 4321 __isl_take isl_multi_aff *maff, 4322 enum isl_dim_type type, unsigned first, unsigned n); 4323 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_drop_dims( 4324 __isl_take isl_pw_multi_aff *pma, 4325 enum isl_dim_type type, unsigned first, unsigned n); 4326 4327 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_insert_dims( 4328 __isl_take isl_multi_pw_aff *mpa, 4329 enum isl_dim_type type, unsigned first, unsigned n); 4330 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_add_dims( 4331 __isl_take isl_multi_pw_aff *mpa, 4332 enum isl_dim_type type, unsigned n); 4333 4334To check whether two multiple affine expressions are 4335obviously equal to each other, use 4336 4337 int isl_multi_aff_plain_is_equal(__isl_keep isl_multi_aff *maff1, 4338 __isl_keep isl_multi_aff *maff2); 4339 int isl_pw_multi_aff_plain_is_equal( 4340 __isl_keep isl_pw_multi_aff *pma1, 4341 __isl_keep isl_pw_multi_aff *pma2); 4342 4343Operations include 4344 4345 #include <isl/aff.h> 4346 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmin( 4347 __isl_take isl_pw_multi_aff *pma1, 4348 __isl_take isl_pw_multi_aff *pma2); 4349 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_lexmax( 4350 __isl_take isl_pw_multi_aff *pma1, 4351 __isl_take isl_pw_multi_aff *pma2); 4352 __isl_give isl_multi_aff *isl_multi_aff_add( 4353 __isl_take isl_multi_aff *maff1, 4354 __isl_take isl_multi_aff *maff2); 4355 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_add( 4356 __isl_take isl_pw_multi_aff *pma1, 4357 __isl_take isl_pw_multi_aff *pma2); 4358 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_add( 4359 __isl_take isl_union_pw_multi_aff *upma1, 4360 __isl_take isl_union_pw_multi_aff *upma2); 4361 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_union_add( 4362 __isl_take isl_pw_multi_aff *pma1, 4363 __isl_take isl_pw_multi_aff *pma2); 4364 __isl_give isl_multi_aff *isl_multi_aff_sub( 4365 __isl_take isl_multi_aff *ma1, 4366 __isl_take isl_multi_aff *ma2); 4367 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_sub( 4368 __isl_take isl_pw_multi_aff *pma1, 4369 __isl_take isl_pw_multi_aff *pma2); 4370 __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_sub( 4371 __isl_take isl_union_pw_multi_aff *upma1, 4372 __isl_take isl_union_pw_multi_aff *upma2); 4373 4374C<isl_multi_aff_sub> subtracts the second argument from the first. 4375 4376 __isl_give isl_multi_aff *isl_multi_aff_scale( 4377 __isl_take isl_multi_aff *maff, 4378 isl_int f); 4379 __isl_give isl_multi_aff *isl_multi_aff_scale_val( 4380 __isl_take isl_multi_aff *ma, 4381 __isl_take isl_val *v); 4382 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_val( 4383 __isl_take isl_pw_multi_aff *pma, 4384 __isl_take isl_val *v); 4385 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_scale_val( 4386 __isl_take isl_multi_pw_aff *mpa, 4387 __isl_take isl_val *v); 4388 __isl_give isl_multi_aff *isl_multi_aff_scale_multi_val( 4389 __isl_take isl_multi_aff *ma, 4390 __isl_take isl_multi_val *mv); 4391 __isl_give isl_pw_multi_aff * 4392 isl_pw_multi_aff_scale_multi_val( 4393 __isl_take isl_pw_multi_aff *pma, 4394 __isl_take isl_multi_val *mv); 4395 __isl_give isl_multi_pw_aff * 4396 isl_multi_pw_aff_scale_multi_val( 4397 __isl_take isl_multi_pw_aff *mpa, 4398 __isl_take isl_multi_val *mv); 4399 __isl_give isl_union_pw_multi_aff * 4400 isl_union_pw_multi_aff_scale_multi_val( 4401 __isl_take isl_union_pw_multi_aff *upma, 4402 __isl_take isl_multi_val *mv); 4403 4404C<isl_multi_aff_scale_multi_val> scales the elements of C<ma> 4405by the corresponding elements of C<mv>. 4406 4407 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_params( 4408 __isl_take isl_pw_multi_aff *pma, 4409 __isl_take isl_set *set); 4410 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_intersect_domain( 4411 __isl_take isl_pw_multi_aff *pma, 4412 __isl_take isl_set *set); 4413 __isl_give isl_union_pw_multi_aff * 4414 isl_union_pw_multi_aff_intersect_domain( 4415 __isl_take isl_union_pw_multi_aff *upma, 4416 __isl_take isl_union_set *uset); 4417 __isl_give isl_multi_aff *isl_multi_aff_lift( 4418 __isl_take isl_multi_aff *maff, 4419 __isl_give isl_local_space **ls); 4420 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_coalesce( 4421 __isl_take isl_pw_multi_aff *pma); 4422 __isl_give isl_multi_aff *isl_multi_aff_align_params( 4423 __isl_take isl_multi_aff *multi, 4424 __isl_take isl_space *model); 4425 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_align_params( 4426 __isl_take isl_pw_multi_aff *pma, 4427 __isl_take isl_space *model); 4428 __isl_give isl_pw_multi_aff * 4429 isl_pw_multi_aff_project_domain_on_params( 4430 __isl_take isl_pw_multi_aff *pma); 4431 __isl_give isl_multi_aff *isl_multi_aff_gist_params( 4432 __isl_take isl_multi_aff *maff, 4433 __isl_take isl_set *context); 4434 __isl_give isl_multi_aff *isl_multi_aff_gist( 4435 __isl_take isl_multi_aff *maff, 4436 __isl_take isl_set *context); 4437 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist_params( 4438 __isl_take isl_pw_multi_aff *pma, 4439 __isl_take isl_set *set); 4440 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_gist( 4441 __isl_take isl_pw_multi_aff *pma, 4442 __isl_take isl_set *set); 4443 __isl_give isl_set *isl_pw_multi_aff_domain( 4444 __isl_take isl_pw_multi_aff *pma); 4445 __isl_give isl_union_set *isl_union_pw_multi_aff_domain( 4446 __isl_take isl_union_pw_multi_aff *upma); 4447 __isl_give isl_multi_aff *isl_multi_aff_range_splice( 4448 __isl_take isl_multi_aff *ma1, unsigned pos, 4449 __isl_take isl_multi_aff *ma2); 4450 __isl_give isl_multi_aff *isl_multi_aff_splice( 4451 __isl_take isl_multi_aff *ma1, 4452 unsigned in_pos, unsigned out_pos, 4453 __isl_take isl_multi_aff *ma2); 4454 __isl_give isl_multi_aff *isl_multi_aff_range_product( 4455 __isl_take isl_multi_aff *ma1, 4456 __isl_take isl_multi_aff *ma2); 4457 __isl_give isl_multi_aff *isl_multi_aff_flat_range_product( 4458 __isl_take isl_multi_aff *ma1, 4459 __isl_take isl_multi_aff *ma2); 4460 __isl_give isl_multi_aff *isl_multi_aff_product( 4461 __isl_take isl_multi_aff *ma1, 4462 __isl_take isl_multi_aff *ma2); 4463 __isl_give isl_pw_multi_aff * 4464 isl_pw_multi_aff_range_product( 4465 __isl_take isl_pw_multi_aff *pma1, 4466 __isl_take isl_pw_multi_aff *pma2); 4467 __isl_give isl_pw_multi_aff * 4468 isl_pw_multi_aff_flat_range_product( 4469 __isl_take isl_pw_multi_aff *pma1, 4470 __isl_take isl_pw_multi_aff *pma2); 4471 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_product( 4472 __isl_take isl_pw_multi_aff *pma1, 4473 __isl_take isl_pw_multi_aff *pma2); 4474 __isl_give isl_union_pw_multi_aff * 4475 isl_union_pw_multi_aff_flat_range_product( 4476 __isl_take isl_union_pw_multi_aff *upma1, 4477 __isl_take isl_union_pw_multi_aff *upma2); 4478 __isl_give isl_multi_pw_aff * 4479 isl_multi_pw_aff_range_splice( 4480 __isl_take isl_multi_pw_aff *mpa1, unsigned pos, 4481 __isl_take isl_multi_pw_aff *mpa2); 4482 __isl_give isl_multi_pw_aff *isl_multi_pw_aff_splice( 4483 __isl_take isl_multi_pw_aff *mpa1, 4484 unsigned in_pos, unsigned out_pos, 4485 __isl_take isl_multi_pw_aff *mpa2); 4486 __isl_give isl_multi_pw_aff * 4487 isl_multi_pw_aff_range_product( 4488 __isl_take isl_multi_pw_aff *mpa1, 4489 __isl_take isl_multi_pw_aff *mpa2); 4490 __isl_give isl_multi_pw_aff * 4491 isl_multi_pw_aff_flat_range_product( 4492 __isl_take isl_multi_pw_aff *mpa1, 4493 __isl_take isl_multi_pw_aff *mpa2); 4494 4495If the C<ls> argument of C<isl_multi_aff_lift> is not C<NULL>, 4496then it is assigned the local space that lies at the basis of 4497the lifting applied. 4498 4499 #include <isl/aff.h> 4500 __isl_give isl_multi_aff *isl_multi_aff_pullback_multi_aff( 4501 __isl_take isl_multi_aff *ma1, 4502 __isl_take isl_multi_aff *ma2); 4503 __isl_give isl_pw_multi_aff * 4504 isl_pw_multi_aff_pullback_multi_aff( 4505 __isl_take isl_pw_multi_aff *pma, 4506 __isl_take isl_multi_aff *ma); 4507 __isl_give isl_pw_multi_aff * 4508 isl_pw_multi_aff_pullback_pw_multi_aff( 4509 __isl_take isl_pw_multi_aff *pma1, 4510 __isl_take isl_pw_multi_aff *pma2); 4511 4512The function C<isl_multi_aff_pullback_multi_aff> precomposes C<ma1> by C<ma2>. 4513In other words, C<ma2> is plugged 4514into C<ma1>. 4515 4516 __isl_give isl_set *isl_multi_aff_lex_le_set( 4517 __isl_take isl_multi_aff *ma1, 4518 __isl_take isl_multi_aff *ma2); 4519 __isl_give isl_set *isl_multi_aff_lex_ge_set( 4520 __isl_take isl_multi_aff *ma1, 4521 __isl_take isl_multi_aff *ma2); 4522 4523The function C<isl_multi_aff_lex_le_set> returns a set 4524containing those elements in the shared domain space 4525where C<ma1> is lexicographically smaller than or 4526equal to C<ma2>. 4527 4528An expression can be read from input using 4529 4530 #include <isl/aff.h> 4531 __isl_give isl_multi_aff *isl_multi_aff_read_from_str( 4532 isl_ctx *ctx, const char *str); 4533 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str( 4534 isl_ctx *ctx, const char *str); 4535 __isl_give isl_union_pw_multi_aff * 4536 isl_union_pw_multi_aff_read_from_str( 4537 isl_ctx *ctx, const char *str); 4538 4539An expression can be printed using 4540 4541 #include <isl/aff.h> 4542 __isl_give isl_printer *isl_printer_print_multi_aff( 4543 __isl_take isl_printer *p, 4544 __isl_keep isl_multi_aff *maff); 4545 __isl_give isl_printer *isl_printer_print_pw_multi_aff( 4546 __isl_take isl_printer *p, 4547 __isl_keep isl_pw_multi_aff *pma); 4548 __isl_give isl_printer *isl_printer_print_union_pw_multi_aff( 4549 __isl_take isl_printer *p, 4550 __isl_keep isl_union_pw_multi_aff *upma); 4551 __isl_give isl_printer *isl_printer_print_multi_pw_aff( 4552 __isl_take isl_printer *p, 4553 __isl_keep isl_multi_pw_aff *mpa); 4554 4555=head2 Points 4556 4557Points are elements of a set. They can be used to construct 4558simple sets (boxes) or they can be used to represent the 4559individual elements of a set. 4560The zero point (the origin) can be created using 4561 4562 __isl_give isl_point *isl_point_zero(__isl_take isl_space *space); 4563 4564The coordinates of a point can be inspected, set and changed 4565using 4566 4567 int isl_point_get_coordinate(__isl_keep isl_point *pnt, 4568 enum isl_dim_type type, int pos, isl_int *v); 4569 __isl_give isl_val *isl_point_get_coordinate_val( 4570 __isl_keep isl_point *pnt, 4571 enum isl_dim_type type, int pos); 4572 __isl_give isl_point *isl_point_set_coordinate( 4573 __isl_take isl_point *pnt, 4574 enum isl_dim_type type, int pos, isl_int v); 4575 __isl_give isl_point *isl_point_set_coordinate_val( 4576 __isl_take isl_point *pnt, 4577 enum isl_dim_type type, int pos, 4578 __isl_take isl_val *v); 4579 4580 __isl_give isl_point *isl_point_add_ui( 4581 __isl_take isl_point *pnt, 4582 enum isl_dim_type type, int pos, unsigned val); 4583 __isl_give isl_point *isl_point_sub_ui( 4584 __isl_take isl_point *pnt, 4585 enum isl_dim_type type, int pos, unsigned val); 4586 4587Other properties can be obtained using 4588 4589 isl_ctx *isl_point_get_ctx(__isl_keep isl_point *pnt); 4590 4591Points can be copied or freed using 4592 4593 __isl_give isl_point *isl_point_copy( 4594 __isl_keep isl_point *pnt); 4595 void isl_point_free(__isl_take isl_point *pnt); 4596 4597A singleton set can be created from a point using 4598 4599 __isl_give isl_basic_set *isl_basic_set_from_point( 4600 __isl_take isl_point *pnt); 4601 __isl_give isl_set *isl_set_from_point( 4602 __isl_take isl_point *pnt); 4603 4604and a box can be created from two opposite extremal points using 4605 4606 __isl_give isl_basic_set *isl_basic_set_box_from_points( 4607 __isl_take isl_point *pnt1, 4608 __isl_take isl_point *pnt2); 4609 __isl_give isl_set *isl_set_box_from_points( 4610 __isl_take isl_point *pnt1, 4611 __isl_take isl_point *pnt2); 4612 4613All elements of a B<bounded> (union) set can be enumerated using 4614the following functions. 4615 4616 int isl_set_foreach_point(__isl_keep isl_set *set, 4617 int (*fn)(__isl_take isl_point *pnt, void *user), 4618 void *user); 4619 int isl_union_set_foreach_point(__isl_keep isl_union_set *uset, 4620 int (*fn)(__isl_take isl_point *pnt, void *user), 4621 void *user); 4622 4623The function C<fn> is called for each integer point in 4624C<set> with as second argument the last argument of 4625the C<isl_set_foreach_point> call. The function C<fn> 4626should return C<0> on success and C<-1> on failure. 4627In the latter case, C<isl_set_foreach_point> will stop 4628enumerating and return C<-1> as well. 4629If the enumeration is performed successfully and to completion, 4630then C<isl_set_foreach_point> returns C<0>. 4631 4632To obtain a single point of a (basic) set, use 4633 4634 __isl_give isl_point *isl_basic_set_sample_point( 4635 __isl_take isl_basic_set *bset); 4636 __isl_give isl_point *isl_set_sample_point( 4637 __isl_take isl_set *set); 4638 4639If C<set> does not contain any (integer) points, then the 4640resulting point will be ``void'', a property that can be 4641tested using 4642 4643 int isl_point_is_void(__isl_keep isl_point *pnt); 4644 4645=head2 Piecewise Quasipolynomials 4646 4647A piecewise quasipolynomial is a particular kind of function that maps 4648a parametric point to a rational value. 4649More specifically, a quasipolynomial is a polynomial expression in greatest 4650integer parts of affine expressions of parameters and variables. 4651A piecewise quasipolynomial is a subdivision of a given parametric 4652domain into disjoint cells with a quasipolynomial associated to 4653each cell. The value of the piecewise quasipolynomial at a given 4654point is the value of the quasipolynomial associated to the cell 4655that contains the point. Outside of the union of cells, 4656the value is assumed to be zero. 4657For example, the piecewise quasipolynomial 4658 4659 [n] -> { [x] -> ((1 + n) - x) : x <= n and x >= 0 } 4660 4661maps C<x> to C<1 + n - x> for values of C<x> between C<0> and C<n>. 4662A given piecewise quasipolynomial has a fixed domain dimension. 4663Union piecewise quasipolynomials are used to contain piecewise quasipolynomials 4664defined over different domains. 4665Piecewise quasipolynomials are mainly used by the C<barvinok> 4666library for representing the number of elements in a parametric set or map. 4667For example, the piecewise quasipolynomial above represents 4668the number of points in the map 4669 4670 [n] -> { [x] -> [y] : x,y >= 0 and 0 <= x + y <= n } 4671 4672=head3 Input and Output 4673 4674Piecewise quasipolynomials can be read from input using 4675 4676 __isl_give isl_union_pw_qpolynomial * 4677 isl_union_pw_qpolynomial_read_from_str( 4678 isl_ctx *ctx, const char *str); 4679 4680Quasipolynomials and piecewise quasipolynomials can be printed 4681using the following functions. 4682 4683 __isl_give isl_printer *isl_printer_print_qpolynomial( 4684 __isl_take isl_printer *p, 4685 __isl_keep isl_qpolynomial *qp); 4686 4687 __isl_give isl_printer *isl_printer_print_pw_qpolynomial( 4688 __isl_take isl_printer *p, 4689 __isl_keep isl_pw_qpolynomial *pwqp); 4690 4691 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial( 4692 __isl_take isl_printer *p, 4693 __isl_keep isl_union_pw_qpolynomial *upwqp); 4694 4695The output format of the printer 4696needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>. 4697For C<isl_printer_print_union_pw_qpolynomial>, only C<ISL_FORMAT_ISL> 4698is supported. 4699In case of printing in C<ISL_FORMAT_C>, the user may want 4700to set the names of all dimensions 4701 4702 __isl_give isl_qpolynomial *isl_qpolynomial_set_dim_name( 4703 __isl_take isl_qpolynomial *qp, 4704 enum isl_dim_type type, unsigned pos, 4705 const char *s); 4706 __isl_give isl_pw_qpolynomial * 4707 isl_pw_qpolynomial_set_dim_name( 4708 __isl_take isl_pw_qpolynomial *pwqp, 4709 enum isl_dim_type type, unsigned pos, 4710 const char *s); 4711 4712=head3 Creating New (Piecewise) Quasipolynomials 4713 4714Some simple quasipolynomials can be created using the following functions. 4715More complicated quasipolynomials can be created by applying 4716operations such as addition and multiplication 4717on the resulting quasipolynomials 4718 4719 __isl_give isl_qpolynomial *isl_qpolynomial_zero_on_domain( 4720 __isl_take isl_space *domain); 4721 __isl_give isl_qpolynomial *isl_qpolynomial_one_on_domain( 4722 __isl_take isl_space *domain); 4723 __isl_give isl_qpolynomial *isl_qpolynomial_infty_on_domain( 4724 __isl_take isl_space *domain); 4725 __isl_give isl_qpolynomial *isl_qpolynomial_neginfty_on_domain( 4726 __isl_take isl_space *domain); 4727 __isl_give isl_qpolynomial *isl_qpolynomial_nan_on_domain( 4728 __isl_take isl_space *domain); 4729 __isl_give isl_qpolynomial *isl_qpolynomial_rat_cst_on_domain( 4730 __isl_take isl_space *domain, 4731 const isl_int n, const isl_int d); 4732 __isl_give isl_qpolynomial *isl_qpolynomial_val_on_domain( 4733 __isl_take isl_space *domain, 4734 __isl_take isl_val *val); 4735 __isl_give isl_qpolynomial *isl_qpolynomial_var_on_domain( 4736 __isl_take isl_space *domain, 4737 enum isl_dim_type type, unsigned pos); 4738 __isl_give isl_qpolynomial *isl_qpolynomial_from_aff( 4739 __isl_take isl_aff *aff); 4740 4741Note that the space in which a quasipolynomial lives is a map space 4742with a one-dimensional range. The C<domain> argument in some of 4743the functions above corresponds to the domain of this map space. 4744 4745The zero piecewise quasipolynomial or a piecewise quasipolynomial 4746with a single cell can be created using the following functions. 4747Multiple of these single cell piecewise quasipolynomials can 4748be combined to create more complicated piecewise quasipolynomials. 4749 4750 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_zero( 4751 __isl_take isl_space *space); 4752 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_alloc( 4753 __isl_take isl_set *set, 4754 __isl_take isl_qpolynomial *qp); 4755 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial( 4756 __isl_take isl_qpolynomial *qp); 4757 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_pw_aff( 4758 __isl_take isl_pw_aff *pwaff); 4759 4760 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_zero( 4761 __isl_take isl_space *space); 4762 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_from_pw_qpolynomial( 4763 __isl_take isl_pw_qpolynomial *pwqp); 4764 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add_pw_qpolynomial( 4765 __isl_take isl_union_pw_qpolynomial *upwqp, 4766 __isl_take isl_pw_qpolynomial *pwqp); 4767 4768Quasipolynomials can be copied and freed again using the following 4769functions. 4770 4771 __isl_give isl_qpolynomial *isl_qpolynomial_copy( 4772 __isl_keep isl_qpolynomial *qp); 4773 void *isl_qpolynomial_free(__isl_take isl_qpolynomial *qp); 4774 4775 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy( 4776 __isl_keep isl_pw_qpolynomial *pwqp); 4777 void *isl_pw_qpolynomial_free( 4778 __isl_take isl_pw_qpolynomial *pwqp); 4779 4780 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_copy( 4781 __isl_keep isl_union_pw_qpolynomial *upwqp); 4782 void *isl_union_pw_qpolynomial_free( 4783 __isl_take isl_union_pw_qpolynomial *upwqp); 4784 4785=head3 Inspecting (Piecewise) Quasipolynomials 4786 4787To iterate over all piecewise quasipolynomials in a union 4788piecewise quasipolynomial, use the following function 4789 4790 int isl_union_pw_qpolynomial_foreach_pw_qpolynomial( 4791 __isl_keep isl_union_pw_qpolynomial *upwqp, 4792 int (*fn)(__isl_take isl_pw_qpolynomial *pwqp, void *user), 4793 void *user); 4794 4795To extract the piecewise quasipolynomial in a given space from a union, use 4796 4797 __isl_give isl_pw_qpolynomial * 4798 isl_union_pw_qpolynomial_extract_pw_qpolynomial( 4799 __isl_keep isl_union_pw_qpolynomial *upwqp, 4800 __isl_take isl_space *space); 4801 4802To iterate over the cells in a piecewise quasipolynomial, 4803use either of the following two functions 4804 4805 int isl_pw_qpolynomial_foreach_piece( 4806 __isl_keep isl_pw_qpolynomial *pwqp, 4807 int (*fn)(__isl_take isl_set *set, 4808 __isl_take isl_qpolynomial *qp, 4809 void *user), void *user); 4810 int isl_pw_qpolynomial_foreach_lifted_piece( 4811 __isl_keep isl_pw_qpolynomial *pwqp, 4812 int (*fn)(__isl_take isl_set *set, 4813 __isl_take isl_qpolynomial *qp, 4814 void *user), void *user); 4815 4816As usual, the function C<fn> should return C<0> on success 4817and C<-1> on failure. The difference between 4818C<isl_pw_qpolynomial_foreach_piece> and 4819C<isl_pw_qpolynomial_foreach_lifted_piece> is that 4820C<isl_pw_qpolynomial_foreach_lifted_piece> will first 4821compute unique representations for all existentially quantified 4822variables and then turn these existentially quantified variables 4823into extra set variables, adapting the associated quasipolynomial 4824accordingly. This means that the C<set> passed to C<fn> 4825will not have any existentially quantified variables, but that 4826the dimensions of the sets may be different for different 4827invocations of C<fn>. 4828 4829The constant term of a quasipolynomial can be extracted using 4830 4831 __isl_give isl_val *isl_qpolynomial_get_constant_val( 4832 __isl_keep isl_qpolynomial *qp); 4833 4834To iterate over all terms in a quasipolynomial, 4835use 4836 4837 int isl_qpolynomial_foreach_term( 4838 __isl_keep isl_qpolynomial *qp, 4839 int (*fn)(__isl_take isl_term *term, 4840 void *user), void *user); 4841 4842The terms themselves can be inspected and freed using 4843these functions 4844 4845 unsigned isl_term_dim(__isl_keep isl_term *term, 4846 enum isl_dim_type type); 4847 void isl_term_get_num(__isl_keep isl_term *term, 4848 isl_int *n); 4849 void isl_term_get_den(__isl_keep isl_term *term, 4850 isl_int *d); 4851 __isl_give isl_val *isl_term_get_coefficient_val( 4852 __isl_keep isl_term *term); 4853 int isl_term_get_exp(__isl_keep isl_term *term, 4854 enum isl_dim_type type, unsigned pos); 4855 __isl_give isl_aff *isl_term_get_div( 4856 __isl_keep isl_term *term, unsigned pos); 4857 void isl_term_free(__isl_take isl_term *term); 4858 4859Each term is a product of parameters, set variables and 4860integer divisions. The function C<isl_term_get_exp> 4861returns the exponent of a given dimensions in the given term. 4862The C<isl_int>s in the arguments of C<isl_term_get_num> 4863and C<isl_term_get_den> need to have been initialized 4864using C<isl_int_init> before calling these functions. 4865 4866=head3 Properties of (Piecewise) Quasipolynomials 4867 4868To check whether a quasipolynomial is actually a constant, 4869use the following function. 4870 4871 int isl_qpolynomial_is_cst(__isl_keep isl_qpolynomial *qp, 4872 isl_int *n, isl_int *d); 4873 4874If C<qp> is a constant and if C<n> and C<d> are not C<NULL> 4875then the numerator and denominator of the constant 4876are returned in C<*n> and C<*d>, respectively. 4877 4878To check whether two union piecewise quasipolynomials are 4879obviously equal, use 4880 4881 int isl_union_pw_qpolynomial_plain_is_equal( 4882 __isl_keep isl_union_pw_qpolynomial *upwqp1, 4883 __isl_keep isl_union_pw_qpolynomial *upwqp2); 4884 4885=head3 Operations on (Piecewise) Quasipolynomials 4886 4887 __isl_give isl_qpolynomial *isl_qpolynomial_scale( 4888 __isl_take isl_qpolynomial *qp, isl_int v); 4889 __isl_give isl_qpolynomial *isl_qpolynomial_scale_val( 4890 __isl_take isl_qpolynomial *qp, 4891 __isl_take isl_val *v); 4892 __isl_give isl_qpolynomial *isl_qpolynomial_neg( 4893 __isl_take isl_qpolynomial *qp); 4894 __isl_give isl_qpolynomial *isl_qpolynomial_add( 4895 __isl_take isl_qpolynomial *qp1, 4896 __isl_take isl_qpolynomial *qp2); 4897 __isl_give isl_qpolynomial *isl_qpolynomial_sub( 4898 __isl_take isl_qpolynomial *qp1, 4899 __isl_take isl_qpolynomial *qp2); 4900 __isl_give isl_qpolynomial *isl_qpolynomial_mul( 4901 __isl_take isl_qpolynomial *qp1, 4902 __isl_take isl_qpolynomial *qp2); 4903 __isl_give isl_qpolynomial *isl_qpolynomial_pow( 4904 __isl_take isl_qpolynomial *qp, unsigned exponent); 4905 4906 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_fix_val( 4907 __isl_take isl_pw_qpolynomial *pwqp, 4908 enum isl_dim_type type, unsigned n, 4909 __isl_take isl_val *v); 4910 __isl_give isl_pw_qpolynomial * 4911 isl_pw_qpolynomial_scale_val( 4912 __isl_take isl_pw_qpolynomial *pwqp, 4913 __isl_take isl_val *v); 4914 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add( 4915 __isl_take isl_pw_qpolynomial *pwqp1, 4916 __isl_take isl_pw_qpolynomial *pwqp2); 4917 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_sub( 4918 __isl_take isl_pw_qpolynomial *pwqp1, 4919 __isl_take isl_pw_qpolynomial *pwqp2); 4920 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_add_disjoint( 4921 __isl_take isl_pw_qpolynomial *pwqp1, 4922 __isl_take isl_pw_qpolynomial *pwqp2); 4923 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_neg( 4924 __isl_take isl_pw_qpolynomial *pwqp); 4925 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_mul( 4926 __isl_take isl_pw_qpolynomial *pwqp1, 4927 __isl_take isl_pw_qpolynomial *pwqp2); 4928 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_pow( 4929 __isl_take isl_pw_qpolynomial *pwqp, unsigned exponent); 4930 4931 __isl_give isl_union_pw_qpolynomial * 4932 isl_union_pw_qpolynomial_scale_val( 4933 __isl_take isl_union_pw_qpolynomial *upwqp, 4934 __isl_take isl_val *v); 4935 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add( 4936 __isl_take isl_union_pw_qpolynomial *upwqp1, 4937 __isl_take isl_union_pw_qpolynomial *upwqp2); 4938 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_sub( 4939 __isl_take isl_union_pw_qpolynomial *upwqp1, 4940 __isl_take isl_union_pw_qpolynomial *upwqp2); 4941 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_mul( 4942 __isl_take isl_union_pw_qpolynomial *upwqp1, 4943 __isl_take isl_union_pw_qpolynomial *upwqp2); 4944 4945 __isl_give isl_qpolynomial *isl_pw_qpolynomial_eval( 4946 __isl_take isl_pw_qpolynomial *pwqp, 4947 __isl_take isl_point *pnt); 4948 4949 __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_eval( 4950 __isl_take isl_union_pw_qpolynomial *upwqp, 4951 __isl_take isl_point *pnt); 4952 4953 __isl_give isl_set *isl_pw_qpolynomial_domain( 4954 __isl_take isl_pw_qpolynomial *pwqp); 4955 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_domain( 4956 __isl_take isl_pw_qpolynomial *pwpq, 4957 __isl_take isl_set *set); 4958 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_intersect_params( 4959 __isl_take isl_pw_qpolynomial *pwpq, 4960 __isl_take isl_set *set); 4961 4962 __isl_give isl_union_set *isl_union_pw_qpolynomial_domain( 4963 __isl_take isl_union_pw_qpolynomial *upwqp); 4964 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_intersect_domain( 4965 __isl_take isl_union_pw_qpolynomial *upwpq, 4966 __isl_take isl_union_set *uset); 4967 __isl_give isl_union_pw_qpolynomial * 4968 isl_union_pw_qpolynomial_intersect_params( 4969 __isl_take isl_union_pw_qpolynomial *upwpq, 4970 __isl_take isl_set *set); 4971 4972 __isl_give isl_qpolynomial *isl_qpolynomial_align_params( 4973 __isl_take isl_qpolynomial *qp, 4974 __isl_take isl_space *model); 4975 4976 __isl_give isl_qpolynomial *isl_qpolynomial_project_domain_on_params( 4977 __isl_take isl_qpolynomial *qp); 4978 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_project_domain_on_params( 4979 __isl_take isl_pw_qpolynomial *pwqp); 4980 4981 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_coalesce( 4982 __isl_take isl_union_pw_qpolynomial *upwqp); 4983 4984 __isl_give isl_qpolynomial *isl_qpolynomial_gist_params( 4985 __isl_take isl_qpolynomial *qp, 4986 __isl_take isl_set *context); 4987 __isl_give isl_qpolynomial *isl_qpolynomial_gist( 4988 __isl_take isl_qpolynomial *qp, 4989 __isl_take isl_set *context); 4990 4991 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist_params( 4992 __isl_take isl_pw_qpolynomial *pwqp, 4993 __isl_take isl_set *context); 4994 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_gist( 4995 __isl_take isl_pw_qpolynomial *pwqp, 4996 __isl_take isl_set *context); 4997 4998 __isl_give isl_union_pw_qpolynomial * 4999 isl_union_pw_qpolynomial_gist_params( 5000 __isl_take isl_union_pw_qpolynomial *upwqp, 5001 __isl_take isl_set *context); 5002 __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_gist( 5003 __isl_take isl_union_pw_qpolynomial *upwqp, 5004 __isl_take isl_union_set *context); 5005 5006The gist operation applies the gist operation to each of 5007the cells in the domain of the input piecewise quasipolynomial. 5008The context is also exploited 5009to simplify the quasipolynomials associated to each cell. 5010 5011 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_to_polynomial( 5012 __isl_take isl_pw_qpolynomial *pwqp, int sign); 5013 __isl_give isl_union_pw_qpolynomial * 5014 isl_union_pw_qpolynomial_to_polynomial( 5015 __isl_take isl_union_pw_qpolynomial *upwqp, int sign); 5016 5017Approximate each quasipolynomial by a polynomial. If C<sign> is positive, 5018the polynomial will be an overapproximation. If C<sign> is negative, 5019it will be an underapproximation. If C<sign> is zero, the approximation 5020will lie somewhere in between. 5021 5022=head2 Bounds on Piecewise Quasipolynomials and Piecewise Quasipolynomial Reductions 5023 5024A piecewise quasipolynomial reduction is a piecewise 5025reduction (or fold) of quasipolynomials. 5026In particular, the reduction can be maximum or a minimum. 5027The objects are mainly used to represent the result of 5028an upper or lower bound on a quasipolynomial over its domain, 5029i.e., as the result of the following function. 5030 5031 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound( 5032 __isl_take isl_pw_qpolynomial *pwqp, 5033 enum isl_fold type, int *tight); 5034 5035 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_bound( 5036 __isl_take isl_union_pw_qpolynomial *upwqp, 5037 enum isl_fold type, int *tight); 5038 5039The C<type> argument may be either C<isl_fold_min> or C<isl_fold_max>. 5040If C<tight> is not C<NULL>, then C<*tight> is set to C<1> 5041is the returned bound is known be tight, i.e., for each value 5042of the parameters there is at least 5043one element in the domain that reaches the bound. 5044If the domain of C<pwqp> is not wrapping, then the bound is computed 5045over all elements in that domain and the result has a purely parametric 5046domain. If the domain of C<pwqp> is wrapping, then the bound is 5047computed over the range of the wrapped relation. The domain of the 5048wrapped relation becomes the domain of the result. 5049 5050A (piecewise) quasipolynomial reduction can be copied or freed using the 5051following functions. 5052 5053 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_copy( 5054 __isl_keep isl_qpolynomial_fold *fold); 5055 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_copy( 5056 __isl_keep isl_pw_qpolynomial_fold *pwf); 5057 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_copy( 5058 __isl_keep isl_union_pw_qpolynomial_fold *upwf); 5059 void isl_qpolynomial_fold_free( 5060 __isl_take isl_qpolynomial_fold *fold); 5061 void *isl_pw_qpolynomial_fold_free( 5062 __isl_take isl_pw_qpolynomial_fold *pwf); 5063 void *isl_union_pw_qpolynomial_fold_free( 5064 __isl_take isl_union_pw_qpolynomial_fold *upwf); 5065 5066=head3 Printing Piecewise Quasipolynomial Reductions 5067 5068Piecewise quasipolynomial reductions can be printed 5069using the following function. 5070 5071 __isl_give isl_printer *isl_printer_print_pw_qpolynomial_fold( 5072 __isl_take isl_printer *p, 5073 __isl_keep isl_pw_qpolynomial_fold *pwf); 5074 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial_fold( 5075 __isl_take isl_printer *p, 5076 __isl_keep isl_union_pw_qpolynomial_fold *upwf); 5077 5078For C<isl_printer_print_pw_qpolynomial_fold>, 5079output format of the printer 5080needs to be set to either C<ISL_FORMAT_ISL> or C<ISL_FORMAT_C>. 5081For C<isl_printer_print_union_pw_qpolynomial_fold>, 5082output format of the printer 5083needs to be set to C<ISL_FORMAT_ISL>. 5084In case of printing in C<ISL_FORMAT_C>, the user may want 5085to set the names of all dimensions 5086 5087 __isl_give isl_pw_qpolynomial_fold * 5088 isl_pw_qpolynomial_fold_set_dim_name( 5089 __isl_take isl_pw_qpolynomial_fold *pwf, 5090 enum isl_dim_type type, unsigned pos, 5091 const char *s); 5092 5093=head3 Inspecting (Piecewise) Quasipolynomial Reductions 5094 5095To iterate over all piecewise quasipolynomial reductions in a union 5096piecewise quasipolynomial reduction, use the following function 5097 5098 int isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold( 5099 __isl_keep isl_union_pw_qpolynomial_fold *upwf, 5100 int (*fn)(__isl_take isl_pw_qpolynomial_fold *pwf, 5101 void *user), void *user); 5102 5103To iterate over the cells in a piecewise quasipolynomial reduction, 5104use either of the following two functions 5105 5106 int isl_pw_qpolynomial_fold_foreach_piece( 5107 __isl_keep isl_pw_qpolynomial_fold *pwf, 5108 int (*fn)(__isl_take isl_set *set, 5109 __isl_take isl_qpolynomial_fold *fold, 5110 void *user), void *user); 5111 int isl_pw_qpolynomial_fold_foreach_lifted_piece( 5112 __isl_keep isl_pw_qpolynomial_fold *pwf, 5113 int (*fn)(__isl_take isl_set *set, 5114 __isl_take isl_qpolynomial_fold *fold, 5115 void *user), void *user); 5116 5117See L<Inspecting (Piecewise) Quasipolynomials> for an explanation 5118of the difference between these two functions. 5119 5120To iterate over all quasipolynomials in a reduction, use 5121 5122 int isl_qpolynomial_fold_foreach_qpolynomial( 5123 __isl_keep isl_qpolynomial_fold *fold, 5124 int (*fn)(__isl_take isl_qpolynomial *qp, 5125 void *user), void *user); 5126 5127=head3 Properties of Piecewise Quasipolynomial Reductions 5128 5129To check whether two union piecewise quasipolynomial reductions are 5130obviously equal, use 5131 5132 int isl_union_pw_qpolynomial_fold_plain_is_equal( 5133 __isl_keep isl_union_pw_qpolynomial_fold *upwf1, 5134 __isl_keep isl_union_pw_qpolynomial_fold *upwf2); 5135 5136=head3 Operations on Piecewise Quasipolynomial Reductions 5137 5138 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_scale( 5139 __isl_take isl_qpolynomial_fold *fold, isl_int v); 5140 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_scale_val( 5141 __isl_take isl_qpolynomial_fold *fold, 5142 __isl_take isl_val *v); 5143 __isl_give isl_pw_qpolynomial_fold * 5144 isl_pw_qpolynomial_fold_scale_val( 5145 __isl_take isl_pw_qpolynomial_fold *pwf, 5146 __isl_take isl_val *v); 5147 __isl_give isl_union_pw_qpolynomial_fold * 5148 isl_union_pw_qpolynomial_fold_scale_val( 5149 __isl_take isl_union_pw_qpolynomial_fold *upwf, 5150 __isl_take isl_val *v); 5151 5152 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_add( 5153 __isl_take isl_pw_qpolynomial_fold *pwf1, 5154 __isl_take isl_pw_qpolynomial_fold *pwf2); 5155 5156 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_fold( 5157 __isl_take isl_pw_qpolynomial_fold *pwf1, 5158 __isl_take isl_pw_qpolynomial_fold *pwf2); 5159 5160 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_fold( 5161 __isl_take isl_union_pw_qpolynomial_fold *upwf1, 5162 __isl_take isl_union_pw_qpolynomial_fold *upwf2); 5163 5164 __isl_give isl_qpolynomial *isl_pw_qpolynomial_fold_eval( 5165 __isl_take isl_pw_qpolynomial_fold *pwf, 5166 __isl_take isl_point *pnt); 5167 5168 __isl_give isl_qpolynomial *isl_union_pw_qpolynomial_fold_eval( 5169 __isl_take isl_union_pw_qpolynomial_fold *upwf, 5170 __isl_take isl_point *pnt); 5171 5172 __isl_give isl_pw_qpolynomial_fold * 5173 isl_pw_qpolynomial_fold_intersect_params( 5174 __isl_take isl_pw_qpolynomial_fold *pwf, 5175 __isl_take isl_set *set); 5176 5177 __isl_give isl_union_set *isl_union_pw_qpolynomial_fold_domain( 5178 __isl_take isl_union_pw_qpolynomial_fold *upwf); 5179 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_intersect_domain( 5180 __isl_take isl_union_pw_qpolynomial_fold *upwf, 5181 __isl_take isl_union_set *uset); 5182 __isl_give isl_union_pw_qpolynomial_fold * 5183 isl_union_pw_qpolynomial_fold_intersect_params( 5184 __isl_take isl_union_pw_qpolynomial_fold *upwf, 5185 __isl_take isl_set *set); 5186 5187 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_project_domain_on_params( 5188 __isl_take isl_pw_qpolynomial_fold *pwf); 5189 5190 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_coalesce( 5191 __isl_take isl_pw_qpolynomial_fold *pwf); 5192 5193 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_coalesce( 5194 __isl_take isl_union_pw_qpolynomial_fold *upwf); 5195 5196 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist_params( 5197 __isl_take isl_qpolynomial_fold *fold, 5198 __isl_take isl_set *context); 5199 __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist( 5200 __isl_take isl_qpolynomial_fold *fold, 5201 __isl_take isl_set *context); 5202 5203 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist( 5204 __isl_take isl_pw_qpolynomial_fold *pwf, 5205 __isl_take isl_set *context); 5206 __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_gist_params( 5207 __isl_take isl_pw_qpolynomial_fold *pwf, 5208 __isl_take isl_set *context); 5209 5210 __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_gist( 5211 __isl_take isl_union_pw_qpolynomial_fold *upwf, 5212 __isl_take isl_union_set *context); 5213 __isl_give isl_union_pw_qpolynomial_fold * 5214 isl_union_pw_qpolynomial_fold_gist_params( 5215 __isl_take isl_union_pw_qpolynomial_fold *upwf, 5216 __isl_take isl_set *context); 5217 5218The gist operation applies the gist operation to each of 5219the cells in the domain of the input piecewise quasipolynomial reduction. 5220In future, the operation will also exploit the context 5221to simplify the quasipolynomial reductions associated to each cell. 5222 5223 __isl_give isl_pw_qpolynomial_fold * 5224 isl_set_apply_pw_qpolynomial_fold( 5225 __isl_take isl_set *set, 5226 __isl_take isl_pw_qpolynomial_fold *pwf, 5227 int *tight); 5228 __isl_give isl_pw_qpolynomial_fold * 5229 isl_map_apply_pw_qpolynomial_fold( 5230 __isl_take isl_map *map, 5231 __isl_take isl_pw_qpolynomial_fold *pwf, 5232 int *tight); 5233 __isl_give isl_union_pw_qpolynomial_fold * 5234 isl_union_set_apply_union_pw_qpolynomial_fold( 5235 __isl_take isl_union_set *uset, 5236 __isl_take isl_union_pw_qpolynomial_fold *upwf, 5237 int *tight); 5238 __isl_give isl_union_pw_qpolynomial_fold * 5239 isl_union_map_apply_union_pw_qpolynomial_fold( 5240 __isl_take isl_union_map *umap, 5241 __isl_take isl_union_pw_qpolynomial_fold *upwf, 5242 int *tight); 5243 5244The functions taking a map 5245compose the given map with the given piecewise quasipolynomial reduction. 5246That is, compute a bound (of the same type as C<pwf> or C<upwf> itself) 5247over all elements in the intersection of the range of the map 5248and the domain of the piecewise quasipolynomial reduction 5249as a function of an element in the domain of the map. 5250The functions taking a set compute a bound over all elements in the 5251intersection of the set and the domain of the 5252piecewise quasipolynomial reduction. 5253 5254=head2 Parametric Vertex Enumeration 5255 5256The parametric vertex enumeration described in this section 5257is mainly intended to be used internally and by the C<barvinok> 5258library. 5259 5260 #include <isl/vertices.h> 5261 __isl_give isl_vertices *isl_basic_set_compute_vertices( 5262 __isl_keep isl_basic_set *bset); 5263 5264The function C<isl_basic_set_compute_vertices> performs the 5265actual computation of the parametric vertices and the chamber 5266decomposition and store the result in an C<isl_vertices> object. 5267This information can be queried by either iterating over all 5268the vertices or iterating over all the chambers or cells 5269and then iterating over all vertices that are active on the chamber. 5270 5271 int isl_vertices_foreach_vertex( 5272 __isl_keep isl_vertices *vertices, 5273 int (*fn)(__isl_take isl_vertex *vertex, void *user), 5274 void *user); 5275 5276 int isl_vertices_foreach_cell( 5277 __isl_keep isl_vertices *vertices, 5278 int (*fn)(__isl_take isl_cell *cell, void *user), 5279 void *user); 5280 int isl_cell_foreach_vertex(__isl_keep isl_cell *cell, 5281 int (*fn)(__isl_take isl_vertex *vertex, void *user), 5282 void *user); 5283 5284Other operations that can be performed on an C<isl_vertices> object are 5285the following. 5286 5287 isl_ctx *isl_vertices_get_ctx( 5288 __isl_keep isl_vertices *vertices); 5289 int isl_vertices_get_n_vertices( 5290 __isl_keep isl_vertices *vertices); 5291 void isl_vertices_free(__isl_take isl_vertices *vertices); 5292 5293Vertices can be inspected and destroyed using the following functions. 5294 5295 isl_ctx *isl_vertex_get_ctx(__isl_keep isl_vertex *vertex); 5296 int isl_vertex_get_id(__isl_keep isl_vertex *vertex); 5297 __isl_give isl_basic_set *isl_vertex_get_domain( 5298 __isl_keep isl_vertex *vertex); 5299 __isl_give isl_basic_set *isl_vertex_get_expr( 5300 __isl_keep isl_vertex *vertex); 5301 void isl_vertex_free(__isl_take isl_vertex *vertex); 5302 5303C<isl_vertex_get_expr> returns a singleton parametric set describing 5304the vertex, while C<isl_vertex_get_domain> returns the activity domain 5305of the vertex. 5306Note that C<isl_vertex_get_domain> and C<isl_vertex_get_expr> return 5307B<rational> basic sets, so they should mainly be used for inspection 5308and should not be mixed with integer sets. 5309 5310Chambers can be inspected and destroyed using the following functions. 5311 5312 isl_ctx *isl_cell_get_ctx(__isl_keep isl_cell *cell); 5313 __isl_give isl_basic_set *isl_cell_get_domain( 5314 __isl_keep isl_cell *cell); 5315 void isl_cell_free(__isl_take isl_cell *cell); 5316 5317=head1 Polyhedral Compilation Library 5318 5319This section collects functionality in C<isl> that has been specifically 5320designed for use during polyhedral compilation. 5321 5322=head2 Dependence Analysis 5323 5324C<isl> contains specialized functionality for performing 5325array dataflow analysis. That is, given a I<sink> access relation 5326and a collection of possible I<source> access relations, 5327C<isl> can compute relations that describe 5328for each iteration of the sink access, which iteration 5329of which of the source access relations was the last 5330to access the same data element before the given iteration 5331of the sink access. 5332The resulting dependence relations map source iterations 5333to the corresponding sink iterations. 5334To compute standard flow dependences, the sink should be 5335a read, while the sources should be writes. 5336If any of the source accesses are marked as being I<may> 5337accesses, then there will be a dependence from the last 5338I<must> access B<and> from any I<may> access that follows 5339this last I<must> access. 5340In particular, if I<all> sources are I<may> accesses, 5341then memory based dependence analysis is performed. 5342If, on the other hand, all sources are I<must> accesses, 5343then value based dependence analysis is performed. 5344 5345 #include <isl/flow.h> 5346 5347 typedef int (*isl_access_level_before)(void *first, void *second); 5348 5349 __isl_give isl_access_info *isl_access_info_alloc( 5350 __isl_take isl_map *sink, 5351 void *sink_user, isl_access_level_before fn, 5352 int max_source); 5353 __isl_give isl_access_info *isl_access_info_add_source( 5354 __isl_take isl_access_info *acc, 5355 __isl_take isl_map *source, int must, 5356 void *source_user); 5357 void *isl_access_info_free(__isl_take isl_access_info *acc); 5358 5359 __isl_give isl_flow *isl_access_info_compute_flow( 5360 __isl_take isl_access_info *acc); 5361 5362 int isl_flow_foreach(__isl_keep isl_flow *deps, 5363 int (*fn)(__isl_take isl_map *dep, int must, 5364 void *dep_user, void *user), 5365 void *user); 5366 __isl_give isl_map *isl_flow_get_no_source( 5367 __isl_keep isl_flow *deps, int must); 5368 void isl_flow_free(__isl_take isl_flow *deps); 5369 5370The function C<isl_access_info_compute_flow> performs the actual 5371dependence analysis. The other functions are used to construct 5372the input for this function or to read off the output. 5373 5374The input is collected in an C<isl_access_info>, which can 5375be created through a call to C<isl_access_info_alloc>. 5376The arguments to this functions are the sink access relation 5377C<sink>, a token C<sink_user> used to identify the sink 5378access to the user, a callback function for specifying the 5379relative order of source and sink accesses, and the number 5380of source access relations that will be added. 5381The callback function has type C<int (*)(void *first, void *second)>. 5382The function is called with two user supplied tokens identifying 5383either a source or the sink and it should return the shared nesting 5384level and the relative order of the two accesses. 5385In particular, let I<n> be the number of loops shared by 5386the two accesses. If C<first> precedes C<second> textually, 5387then the function should return I<2 * n + 1>; otherwise, 5388it should return I<2 * n>. 5389The sources can be added to the C<isl_access_info> by performing 5390(at most) C<max_source> calls to C<isl_access_info_add_source>. 5391C<must> indicates whether the source is a I<must> access 5392or a I<may> access. Note that a multi-valued access relation 5393should only be marked I<must> if every iteration in the domain 5394of the relation accesses I<all> elements in its image. 5395The C<source_user> token is again used to identify 5396the source access. The range of the source access relation 5397C<source> should have the same dimension as the range 5398of the sink access relation. 5399The C<isl_access_info_free> function should usually not be 5400called explicitly, because it is called implicitly by 5401C<isl_access_info_compute_flow>. 5402 5403The result of the dependence analysis is collected in an 5404C<isl_flow>. There may be elements of 5405the sink access for which no preceding source access could be 5406found or for which all preceding sources are I<may> accesses. 5407The relations containing these elements can be obtained through 5408calls to C<isl_flow_get_no_source>, the first with C<must> set 5409and the second with C<must> unset. 5410In the case of standard flow dependence analysis, 5411with the sink a read and the sources I<must> writes, 5412the first relation corresponds to the reads from uninitialized 5413array elements and the second relation is empty. 5414The actual flow dependences can be extracted using 5415C<isl_flow_foreach>. This function will call the user-specified 5416callback function C<fn> for each B<non-empty> dependence between 5417a source and the sink. The callback function is called 5418with four arguments, the actual flow dependence relation 5419mapping source iterations to sink iterations, a boolean that 5420indicates whether it is a I<must> or I<may> dependence, a token 5421identifying the source and an additional C<void *> with value 5422equal to the third argument of the C<isl_flow_foreach> call. 5423A dependence is marked I<must> if it originates from a I<must> 5424source and if it is not followed by any I<may> sources. 5425 5426After finishing with an C<isl_flow>, the user should call 5427C<isl_flow_free> to free all associated memory. 5428 5429A higher-level interface to dependence analysis is provided 5430by the following function. 5431 5432 #include <isl/flow.h> 5433 5434 int isl_union_map_compute_flow(__isl_take isl_union_map *sink, 5435 __isl_take isl_union_map *must_source, 5436 __isl_take isl_union_map *may_source, 5437 __isl_take isl_union_map *schedule, 5438 __isl_give isl_union_map **must_dep, 5439 __isl_give isl_union_map **may_dep, 5440 __isl_give isl_union_map **must_no_source, 5441 __isl_give isl_union_map **may_no_source); 5442 5443The arrays are identified by the tuple names of the ranges 5444of the accesses. The iteration domains by the tuple names 5445of the domains of the accesses and of the schedule. 5446The relative order of the iteration domains is given by the 5447schedule. The relations returned through C<must_no_source> 5448and C<may_no_source> are subsets of C<sink>. 5449Any of C<must_dep>, C<may_dep>, C<must_no_source> 5450or C<may_no_source> may be C<NULL>, but a C<NULL> value for 5451any of the other arguments is treated as an error. 5452 5453=head3 Interaction with Dependence Analysis 5454 5455During the dependence analysis, we frequently need to perform 5456the following operation. Given a relation between sink iterations 5457and potential source iterations from a particular source domain, 5458what is the last potential source iteration corresponding to each 5459sink iteration. It can sometimes be convenient to adjust 5460the set of potential source iterations before or after each such operation. 5461The prototypical example is fuzzy array dataflow analysis, 5462where we need to analyze if, based on data-dependent constraints, 5463the sink iteration can ever be executed without one or more of 5464the corresponding potential source iterations being executed. 5465If so, we can introduce extra parameters and select an unknown 5466but fixed source iteration from the potential source iterations. 5467To be able to perform such manipulations, C<isl> provides the following 5468function. 5469 5470 #include <isl/flow.h> 5471 5472 typedef __isl_give isl_restriction *(*isl_access_restrict)( 5473 __isl_keep isl_map *source_map, 5474 __isl_keep isl_set *sink, void *source_user, 5475 void *user); 5476 __isl_give isl_access_info *isl_access_info_set_restrict( 5477 __isl_take isl_access_info *acc, 5478 isl_access_restrict fn, void *user); 5479 5480The function C<isl_access_info_set_restrict> should be called 5481before calling C<isl_access_info_compute_flow> and registers a callback function 5482that will be called any time C<isl> is about to compute the last 5483potential source. The first argument is the (reverse) proto-dependence, 5484mapping sink iterations to potential source iterations. 5485The second argument represents the sink iterations for which 5486we want to compute the last source iteration. 5487The third argument is the token corresponding to the source 5488and the final argument is the token passed to C<isl_access_info_set_restrict>. 5489The callback is expected to return a restriction on either the input or 5490the output of the operation computing the last potential source. 5491If the input needs to be restricted then restrictions are needed 5492for both the source and the sink iterations. The sink iterations 5493and the potential source iterations will be intersected with these sets. 5494If the output needs to be restricted then only a restriction on the source 5495iterations is required. 5496If any error occurs, the callback should return C<NULL>. 5497An C<isl_restriction> object can be created, freed and inspected 5498using the following functions. 5499 5500 #include <isl/flow.h> 5501 5502 __isl_give isl_restriction *isl_restriction_input( 5503 __isl_take isl_set *source_restr, 5504 __isl_take isl_set *sink_restr); 5505 __isl_give isl_restriction *isl_restriction_output( 5506 __isl_take isl_set *source_restr); 5507 __isl_give isl_restriction *isl_restriction_none( 5508 __isl_take isl_map *source_map); 5509 __isl_give isl_restriction *isl_restriction_empty( 5510 __isl_take isl_map *source_map); 5511 void *isl_restriction_free( 5512 __isl_take isl_restriction *restr); 5513 isl_ctx *isl_restriction_get_ctx( 5514 __isl_keep isl_restriction *restr); 5515 5516C<isl_restriction_none> and C<isl_restriction_empty> are special 5517cases of C<isl_restriction_input>. C<isl_restriction_none> 5518is essentially equivalent to 5519 5520 isl_restriction_input(isl_set_universe( 5521 isl_space_range(isl_map_get_space(source_map))), 5522 isl_set_universe( 5523 isl_space_domain(isl_map_get_space(source_map)))); 5524 5525whereas C<isl_restriction_empty> is essentially equivalent to 5526 5527 isl_restriction_input(isl_set_empty( 5528 isl_space_range(isl_map_get_space(source_map))), 5529 isl_set_universe( 5530 isl_space_domain(isl_map_get_space(source_map)))); 5531 5532=head2 Scheduling 5533 5534B<The functionality described in this section is fairly new 5535and may be subject to change.> 5536 5537The following function can be used to compute a schedule 5538for a union of domains. 5539By default, the algorithm used to construct the schedule is similar 5540to that of C<Pluto>. 5541Alternatively, Feautrier's multi-dimensional scheduling algorithm can 5542be selected. 5543The generated schedule respects all C<validity> dependences. 5544That is, all dependence distances over these dependences in the 5545scheduled space are lexicographically positive. 5546The default algorithm tries to minimize the dependence distances over 5547C<proximity> dependences. 5548Moreover, it tries to obtain sequences (bands) of schedule dimensions 5549for groups of domains where the dependence distances have only 5550non-negative values. 5551When using Feautrier's algorithm, the C<proximity> dependence 5552distances are only minimized during the extension to a 5553full-dimensional schedule. 5554 5555 #include <isl/schedule.h> 5556 __isl_give isl_schedule *isl_union_set_compute_schedule( 5557 __isl_take isl_union_set *domain, 5558 __isl_take isl_union_map *validity, 5559 __isl_take isl_union_map *proximity); 5560 void *isl_schedule_free(__isl_take isl_schedule *sched); 5561 5562A mapping from the domains to the scheduled space can be obtained 5563from an C<isl_schedule> using the following function. 5564 5565 __isl_give isl_union_map *isl_schedule_get_map( 5566 __isl_keep isl_schedule *sched); 5567 5568A representation of the schedule can be printed using 5569 5570 __isl_give isl_printer *isl_printer_print_schedule( 5571 __isl_take isl_printer *p, 5572 __isl_keep isl_schedule *schedule); 5573 5574A representation of the schedule as a forest of bands can be obtained 5575using the following function. 5576 5577 __isl_give isl_band_list *isl_schedule_get_band_forest( 5578 __isl_keep isl_schedule *schedule); 5579 5580The individual bands can be visited in depth-first post-order 5581using the following function. 5582 5583 #include <isl/schedule.h> 5584 int isl_schedule_foreach_band( 5585 __isl_keep isl_schedule *sched, 5586 int (*fn)(__isl_keep isl_band *band, void *user), 5587 void *user); 5588 5589The list can be manipulated as explained in L<"Lists">. 5590The bands inside the list can be copied and freed using the following 5591functions. 5592 5593 #include <isl/band.h> 5594 __isl_give isl_band *isl_band_copy( 5595 __isl_keep isl_band *band); 5596 void *isl_band_free(__isl_take isl_band *band); 5597 5598Each band contains zero or more scheduling dimensions. 5599These are referred to as the members of the band. 5600The section of the schedule that corresponds to the band is 5601referred to as the partial schedule of the band. 5602For those nodes that participate in a band, the outer scheduling 5603dimensions form the prefix schedule, while the inner scheduling 5604dimensions form the suffix schedule. 5605That is, if we take a cut of the band forest, then the union of 5606the concatenations of the prefix, partial and suffix schedules of 5607each band in the cut is equal to the entire schedule (modulo 5608some possible padding at the end with zero scheduling dimensions). 5609The properties of a band can be inspected using the following functions. 5610 5611 #include <isl/band.h> 5612 isl_ctx *isl_band_get_ctx(__isl_keep isl_band *band); 5613 5614 int isl_band_has_children(__isl_keep isl_band *band); 5615 __isl_give isl_band_list *isl_band_get_children( 5616 __isl_keep isl_band *band); 5617 5618 __isl_give isl_union_map *isl_band_get_prefix_schedule( 5619 __isl_keep isl_band *band); 5620 __isl_give isl_union_map *isl_band_get_partial_schedule( 5621 __isl_keep isl_band *band); 5622 __isl_give isl_union_map *isl_band_get_suffix_schedule( 5623 __isl_keep isl_band *band); 5624 5625 int isl_band_n_member(__isl_keep isl_band *band); 5626 int isl_band_member_is_zero_distance( 5627 __isl_keep isl_band *band, int pos); 5628 5629 int isl_band_list_foreach_band( 5630 __isl_keep isl_band_list *list, 5631 int (*fn)(__isl_keep isl_band *band, void *user), 5632 void *user); 5633 5634Note that a scheduling dimension is considered to be ``zero 5635distance'' if it does not carry any proximity dependences 5636within its band. 5637That is, if the dependence distances of the proximity 5638dependences are all zero in that direction (for fixed 5639iterations of outer bands). 5640Like C<isl_schedule_foreach_band>, 5641the function C<isl_band_list_foreach_band> calls C<fn> on the bands 5642in depth-first post-order. 5643 5644A band can be tiled using the following function. 5645 5646 #include <isl/band.h> 5647 int isl_band_tile(__isl_keep isl_band *band, 5648 __isl_take isl_vec *sizes); 5649 5650 int isl_options_set_tile_scale_tile_loops(isl_ctx *ctx, 5651 int val); 5652 int isl_options_get_tile_scale_tile_loops(isl_ctx *ctx); 5653 int isl_options_set_tile_shift_point_loops(isl_ctx *ctx, 5654 int val); 5655 int isl_options_get_tile_shift_point_loops(isl_ctx *ctx); 5656 5657The C<isl_band_tile> function tiles the band using the given tile sizes 5658inside its schedule. 5659A new child band is created to represent the point loops and it is 5660inserted between the modified band and its children. 5661The C<tile_scale_tile_loops> option specifies whether the tile 5662loops iterators should be scaled by the tile sizes. 5663If the C<tile_shift_point_loops> option is set, then the point loops 5664are shifted to start at zero. 5665 5666A band can be split into two nested bands using the following function. 5667 5668 int isl_band_split(__isl_keep isl_band *band, int pos); 5669 5670The resulting outer band contains the first C<pos> dimensions of C<band> 5671while the inner band contains the remaining dimensions. 5672 5673A representation of the band can be printed using 5674 5675 #include <isl/band.h> 5676 __isl_give isl_printer *isl_printer_print_band( 5677 __isl_take isl_printer *p, 5678 __isl_keep isl_band *band); 5679 5680=head3 Options 5681 5682 #include <isl/schedule.h> 5683 int isl_options_set_schedule_max_coefficient( 5684 isl_ctx *ctx, int val); 5685 int isl_options_get_schedule_max_coefficient( 5686 isl_ctx *ctx); 5687 int isl_options_set_schedule_max_constant_term( 5688 isl_ctx *ctx, int val); 5689 int isl_options_get_schedule_max_constant_term( 5690 isl_ctx *ctx); 5691 int isl_options_set_schedule_fuse(isl_ctx *ctx, int val); 5692 int isl_options_get_schedule_fuse(isl_ctx *ctx); 5693 int isl_options_set_schedule_maximize_band_depth( 5694 isl_ctx *ctx, int val); 5695 int isl_options_get_schedule_maximize_band_depth( 5696 isl_ctx *ctx); 5697 int isl_options_set_schedule_outer_zero_distance( 5698 isl_ctx *ctx, int val); 5699 int isl_options_get_schedule_outer_zero_distance( 5700 isl_ctx *ctx); 5701 int isl_options_set_schedule_split_scaled( 5702 isl_ctx *ctx, int val); 5703 int isl_options_get_schedule_split_scaled( 5704 isl_ctx *ctx); 5705 int isl_options_set_schedule_algorithm( 5706 isl_ctx *ctx, int val); 5707 int isl_options_get_schedule_algorithm( 5708 isl_ctx *ctx); 5709 int isl_options_set_schedule_separate_components( 5710 isl_ctx *ctx, int val); 5711 int isl_options_get_schedule_separate_components( 5712 isl_ctx *ctx); 5713 5714=over 5715 5716=item * schedule_max_coefficient 5717 5718This option enforces that the coefficients for variable and parameter 5719dimensions in the calculated schedule are not larger than the specified value. 5720This option can significantly increase the speed of the scheduling calculation 5721and may also prevent fusing of unrelated dimensions. A value of -1 means that 5722this option does not introduce bounds on the variable or parameter 5723coefficients. 5724 5725=item * schedule_max_constant_term 5726 5727This option enforces that the constant coefficients in the calculated schedule 5728are not larger than the maximal constant term. This option can significantly 5729increase the speed of the scheduling calculation and may also prevent fusing of 5730unrelated dimensions. A value of -1 means that this option does not introduce 5731bounds on the constant coefficients. 5732 5733=item * schedule_fuse 5734 5735This option controls the level of fusion. 5736If this option is set to C<ISL_SCHEDULE_FUSE_MIN>, then loops in the 5737resulting schedule will be distributed as much as possible. 5738If this option is set to C<ISL_SCHEDULE_FUSE_MAX>, then C<isl> will 5739try to fuse loops in the resulting schedule. 5740 5741=item * schedule_maximize_band_depth 5742 5743If this option is set, we do not split bands at the point 5744where we detect splitting is necessary. Instead, we 5745backtrack and split bands as early as possible. This 5746reduces the number of splits and maximizes the width of 5747the bands. Wider bands give more possibilities for tiling. 5748Note that if the C<schedule_fuse> option is set to C<ISL_SCHEDULE_FUSE_MIN>, 5749then bands will be split as early as possible, even if there is no need. 5750The C<schedule_maximize_band_depth> option therefore has no effect in this case. 5751 5752=item * schedule_outer_zero_distance 5753 5754If this option is set, then we try to construct schedules 5755where the outermost scheduling dimension in each band 5756results in a zero dependence distance over the proximity 5757dependences. 5758 5759=item * schedule_split_scaled 5760 5761If this option is set, then we try to construct schedules in which the 5762constant term is split off from the linear part if the linear parts of 5763the scheduling rows for all nodes in the graphs have a common non-trivial 5764divisor. 5765The constant term is then placed in a separate band and the linear 5766part is reduced. 5767 5768=item * schedule_algorithm 5769 5770Selects the scheduling algorithm to be used. 5771Available scheduling algorithms are C<ISL_SCHEDULE_ALGORITHM_ISL> 5772and C<ISL_SCHEDULE_ALGORITHM_FEAUTRIER>. 5773 5774=item * schedule_separate_components 5775 5776If at any point the dependence graph contains any (weakly connected) components, 5777then these components are scheduled separately. 5778If this option is not set, then some iterations of the domains 5779in these components may be scheduled together. 5780If this option is set, then the components are given consecutive 5781schedules. 5782 5783=back 5784 5785=head2 AST Generation 5786 5787This section describes the C<isl> functionality for generating 5788ASTs that visit all the elements 5789in a domain in an order specified by a schedule. 5790In particular, given a C<isl_union_map>, an AST is generated 5791that visits all the elements in the domain of the C<isl_union_map> 5792according to the lexicographic order of the corresponding image 5793element(s). If the range of the C<isl_union_map> consists of 5794elements in more than one space, then each of these spaces is handled 5795separately in an arbitrary order. 5796It should be noted that the image elements only specify the I<order> 5797in which the corresponding domain elements should be visited. 5798No direct relation between the image elements and the loop iterators 5799in the generated AST should be assumed. 5800 5801Each AST is generated within a build. The initial build 5802simply specifies the constraints on the parameters (if any) 5803and can be created, inspected, copied and freed using the following functions. 5804 5805 #include <isl/ast_build.h> 5806 __isl_give isl_ast_build *isl_ast_build_from_context( 5807 __isl_take isl_set *set); 5808 isl_ctx *isl_ast_build_get_ctx( 5809 __isl_keep isl_ast_build *build); 5810 __isl_give isl_ast_build *isl_ast_build_copy( 5811 __isl_keep isl_ast_build *build); 5812 void *isl_ast_build_free( 5813 __isl_take isl_ast_build *build); 5814 5815The C<set> argument is usually a parameter set with zero or more parameters. 5816More C<isl_ast_build> functions are described in L</"Nested AST Generation"> 5817and L</"Fine-grained Control over AST Generation">. 5818Finally, the AST itself can be constructed using the following 5819function. 5820 5821 #include <isl/ast_build.h> 5822 __isl_give isl_ast_node *isl_ast_build_ast_from_schedule( 5823 __isl_keep isl_ast_build *build, 5824 __isl_take isl_union_map *schedule); 5825 5826=head3 Inspecting the AST 5827 5828The basic properties of an AST node can be obtained as follows. 5829 5830 #include <isl/ast.h> 5831 isl_ctx *isl_ast_node_get_ctx( 5832 __isl_keep isl_ast_node *node); 5833 enum isl_ast_node_type isl_ast_node_get_type( 5834 __isl_keep isl_ast_node *node); 5835 5836The type of an AST node is one of 5837C<isl_ast_node_for>, 5838C<isl_ast_node_if>, 5839C<isl_ast_node_block> or 5840C<isl_ast_node_user>. 5841An C<isl_ast_node_for> represents a for node. 5842An C<isl_ast_node_if> represents an if node. 5843An C<isl_ast_node_block> represents a compound node. 5844An C<isl_ast_node_user> represents an expression statement. 5845An expression statement typically corresponds to a domain element, i.e., 5846one of the elements that is visited by the AST. 5847 5848Each type of node has its own additional properties. 5849 5850 #include <isl/ast.h> 5851 __isl_give isl_ast_expr *isl_ast_node_for_get_iterator( 5852 __isl_keep isl_ast_node *node); 5853 __isl_give isl_ast_expr *isl_ast_node_for_get_init( 5854 __isl_keep isl_ast_node *node); 5855 __isl_give isl_ast_expr *isl_ast_node_for_get_cond( 5856 __isl_keep isl_ast_node *node); 5857 __isl_give isl_ast_expr *isl_ast_node_for_get_inc( 5858 __isl_keep isl_ast_node *node); 5859 __isl_give isl_ast_node *isl_ast_node_for_get_body( 5860 __isl_keep isl_ast_node *node); 5861 int isl_ast_node_for_is_degenerate( 5862 __isl_keep isl_ast_node *node); 5863 5864An C<isl_ast_for> is considered degenerate if it is known to execute 5865exactly once. 5866 5867 #include <isl/ast.h> 5868 __isl_give isl_ast_expr *isl_ast_node_if_get_cond( 5869 __isl_keep isl_ast_node *node); 5870 __isl_give isl_ast_node *isl_ast_node_if_get_then( 5871 __isl_keep isl_ast_node *node); 5872 int isl_ast_node_if_has_else( 5873 __isl_keep isl_ast_node *node); 5874 __isl_give isl_ast_node *isl_ast_node_if_get_else( 5875 __isl_keep isl_ast_node *node); 5876 5877 __isl_give isl_ast_node_list * 5878 isl_ast_node_block_get_children( 5879 __isl_keep isl_ast_node *node); 5880 5881 __isl_give isl_ast_expr *isl_ast_node_user_get_expr( 5882 __isl_keep isl_ast_node *node); 5883 5884Each of the returned C<isl_ast_expr>s can in turn be inspected using 5885the following functions. 5886 5887 #include <isl/ast.h> 5888 isl_ctx *isl_ast_expr_get_ctx( 5889 __isl_keep isl_ast_expr *expr); 5890 enum isl_ast_expr_type isl_ast_expr_get_type( 5891 __isl_keep isl_ast_expr *expr); 5892 5893The type of an AST expression is one of 5894C<isl_ast_expr_op>, 5895C<isl_ast_expr_id> or 5896C<isl_ast_expr_int>. 5897An C<isl_ast_expr_op> represents the result of an operation. 5898An C<isl_ast_expr_id> represents an identifier. 5899An C<isl_ast_expr_int> represents an integer value. 5900 5901Each type of expression has its own additional properties. 5902 5903 #include <isl/ast.h> 5904 enum isl_ast_op_type isl_ast_expr_get_op_type( 5905 __isl_keep isl_ast_expr *expr); 5906 int isl_ast_expr_get_op_n_arg(__isl_keep isl_ast_expr *expr); 5907 __isl_give isl_ast_expr *isl_ast_expr_get_op_arg( 5908 __isl_keep isl_ast_expr *expr, int pos); 5909 int isl_ast_node_foreach_ast_op_type( 5910 __isl_keep isl_ast_node *node, 5911 int (*fn)(enum isl_ast_op_type type, void *user), 5912 void *user); 5913 5914C<isl_ast_expr_get_op_type> returns the type of the operation 5915performed. C<isl_ast_expr_get_op_n_arg> returns the number of 5916arguments. C<isl_ast_expr_get_op_arg> returns the specified 5917argument. 5918C<isl_ast_node_foreach_ast_op_type> calls C<fn> for each distinct 5919C<isl_ast_op_type> that appears in C<node>. 5920The operation type is one of the following. 5921 5922=over 5923 5924=item C<isl_ast_op_and> 5925 5926Logical I<and> of two arguments. 5927Both arguments can be evaluated. 5928 5929=item C<isl_ast_op_and_then> 5930 5931Logical I<and> of two arguments. 5932The second argument can only be evaluated if the first evaluates to true. 5933 5934=item C<isl_ast_op_or> 5935 5936Logical I<or> of two arguments. 5937Both arguments can be evaluated. 5938 5939=item C<isl_ast_op_or_else> 5940 5941Logical I<or> of two arguments. 5942The second argument can only be evaluated if the first evaluates to false. 5943 5944=item C<isl_ast_op_max> 5945 5946Maximum of two or more arguments. 5947 5948=item C<isl_ast_op_min> 5949 5950Minimum of two or more arguments. 5951 5952=item C<isl_ast_op_minus> 5953 5954Change sign. 5955 5956=item C<isl_ast_op_add> 5957 5958Sum of two arguments. 5959 5960=item C<isl_ast_op_sub> 5961 5962Difference of two arguments. 5963 5964=item C<isl_ast_op_mul> 5965 5966Product of two arguments. 5967 5968=item C<isl_ast_op_div> 5969 5970Exact division. That is, the result is known to be an integer. 5971 5972=item C<isl_ast_op_fdiv_q> 5973 5974Result of integer division, rounded towards negative 5975infinity. 5976 5977=item C<isl_ast_op_pdiv_q> 5978 5979Result of integer division, where dividend is known to be non-negative. 5980 5981=item C<isl_ast_op_pdiv_r> 5982 5983Remainder of integer division, where dividend is known to be non-negative. 5984 5985=item C<isl_ast_op_cond> 5986 5987Conditional operator defined on three arguments. 5988If the first argument evaluates to true, then the result 5989is equal to the second argument. Otherwise, the result 5990is equal to the third argument. 5991The second and third argument may only be evaluated if 5992the first argument evaluates to true and false, respectively. 5993Corresponds to C<a ? b : c> in C. 5994 5995=item C<isl_ast_op_select> 5996 5997Conditional operator defined on three arguments. 5998If the first argument evaluates to true, then the result 5999is equal to the second argument. Otherwise, the result 6000is equal to the third argument. 6001The second and third argument may be evaluated independently 6002of the value of the first argument. 6003Corresponds to C<a * b + (1 - a) * c> in C. 6004 6005=item C<isl_ast_op_eq> 6006 6007Equality relation. 6008 6009=item C<isl_ast_op_le> 6010 6011Less than or equal relation. 6012 6013=item C<isl_ast_op_lt> 6014 6015Less than relation. 6016 6017=item C<isl_ast_op_ge> 6018 6019Greater than or equal relation. 6020 6021=item C<isl_ast_op_gt> 6022 6023Greater than relation. 6024 6025=item C<isl_ast_op_call> 6026 6027A function call. 6028The number of arguments of the C<isl_ast_expr> is one more than 6029the number of arguments in the function call, the first argument 6030representing the function being called. 6031 6032=back 6033 6034 #include <isl/ast.h> 6035 __isl_give isl_id *isl_ast_expr_get_id( 6036 __isl_keep isl_ast_expr *expr); 6037 6038Return the identifier represented by the AST expression. 6039 6040 #include <isl/ast.h> 6041 int isl_ast_expr_get_int(__isl_keep isl_ast_expr *expr, 6042 isl_int *v); 6043 __isl_give isl_val *isl_ast_expr_get_val( 6044 __isl_keep isl_ast_expr *expr); 6045 6046Return the integer represented by the AST expression. 6047Note that the integer is returned by C<isl_ast_expr_get_int> 6048through the C<v> argument. 6049The return value of this function itself indicates whether the 6050operation was performed successfully. 6051 6052=head3 Manipulating and printing the AST 6053 6054AST nodes can be copied and freed using the following functions. 6055 6056 #include <isl/ast.h> 6057 __isl_give isl_ast_node *isl_ast_node_copy( 6058 __isl_keep isl_ast_node *node); 6059 void *isl_ast_node_free(__isl_take isl_ast_node *node); 6060 6061AST expressions can be copied and freed using the following functions. 6062 6063 #include <isl/ast.h> 6064 __isl_give isl_ast_expr *isl_ast_expr_copy( 6065 __isl_keep isl_ast_expr *expr); 6066 void *isl_ast_expr_free(__isl_take isl_ast_expr *expr); 6067 6068New AST expressions can be created either directly or within 6069the context of an C<isl_ast_build>. 6070 6071 #include <isl/ast.h> 6072 __isl_give isl_ast_expr *isl_ast_expr_from_val( 6073 __isl_take isl_val *v); 6074 __isl_give isl_ast_expr *isl_ast_expr_from_id( 6075 __isl_take isl_id *id); 6076 __isl_give isl_ast_expr *isl_ast_expr_neg( 6077 __isl_take isl_ast_expr *expr); 6078 __isl_give isl_ast_expr *isl_ast_expr_add( 6079 __isl_take isl_ast_expr *expr1, 6080 __isl_take isl_ast_expr *expr2); 6081 __isl_give isl_ast_expr *isl_ast_expr_sub( 6082 __isl_take isl_ast_expr *expr1, 6083 __isl_take isl_ast_expr *expr2); 6084 __isl_give isl_ast_expr *isl_ast_expr_mul( 6085 __isl_take isl_ast_expr *expr1, 6086 __isl_take isl_ast_expr *expr2); 6087 __isl_give isl_ast_expr *isl_ast_expr_div( 6088 __isl_take isl_ast_expr *expr1, 6089 __isl_take isl_ast_expr *expr2); 6090 __isl_give isl_ast_expr *isl_ast_expr_and( 6091 __isl_take isl_ast_expr *expr1, 6092 __isl_take isl_ast_expr *expr2) 6093 __isl_give isl_ast_expr *isl_ast_expr_or( 6094 __isl_take isl_ast_expr *expr1, 6095 __isl_take isl_ast_expr *expr2) 6096 6097 #include <isl/ast_build.h> 6098 __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff( 6099 __isl_keep isl_ast_build *build, 6100 __isl_take isl_pw_aff *pa); 6101 __isl_give isl_ast_expr * 6102 isl_ast_build_call_from_pw_multi_aff( 6103 __isl_keep isl_ast_build *build, 6104 __isl_take isl_pw_multi_aff *pma); 6105 6106The domains of C<pa> and C<pma> should correspond 6107to the schedule space of C<build>. 6108The tuple id of C<pma> is used as the function being called. 6109 6110User specified data can be attached to an C<isl_ast_node> and obtained 6111from the same C<isl_ast_node> using the following functions. 6112 6113 #include <isl/ast.h> 6114 __isl_give isl_ast_node *isl_ast_node_set_annotation( 6115 __isl_take isl_ast_node *node, 6116 __isl_take isl_id *annotation); 6117 __isl_give isl_id *isl_ast_node_get_annotation( 6118 __isl_keep isl_ast_node *node); 6119 6120Basic printing can be performed using the following functions. 6121 6122 #include <isl/ast.h> 6123 __isl_give isl_printer *isl_printer_print_ast_expr( 6124 __isl_take isl_printer *p, 6125 __isl_keep isl_ast_expr *expr); 6126 __isl_give isl_printer *isl_printer_print_ast_node( 6127 __isl_take isl_printer *p, 6128 __isl_keep isl_ast_node *node); 6129 6130More advanced printing can be performed using the following functions. 6131 6132 #include <isl/ast.h> 6133 __isl_give isl_printer *isl_ast_op_type_print_macro( 6134 enum isl_ast_op_type type, 6135 __isl_take isl_printer *p); 6136 __isl_give isl_printer *isl_ast_node_print_macros( 6137 __isl_keep isl_ast_node *node, 6138 __isl_take isl_printer *p); 6139 __isl_give isl_printer *isl_ast_node_print( 6140 __isl_keep isl_ast_node *node, 6141 __isl_take isl_printer *p, 6142 __isl_take isl_ast_print_options *options); 6143 __isl_give isl_printer *isl_ast_node_for_print( 6144 __isl_keep isl_ast_node *node, 6145 __isl_take isl_printer *p, 6146 __isl_take isl_ast_print_options *options); 6147 __isl_give isl_printer *isl_ast_node_if_print( 6148 __isl_keep isl_ast_node *node, 6149 __isl_take isl_printer *p, 6150 __isl_take isl_ast_print_options *options); 6151 6152While printing an C<isl_ast_node> in C<ISL_FORMAT_C>, 6153C<isl> may print out an AST that makes use of macros such 6154as C<floord>, C<min> and C<max>. 6155C<isl_ast_op_type_print_macro> prints out the macro 6156corresponding to a specific C<isl_ast_op_type>. 6157C<isl_ast_node_print_macros> scans the C<isl_ast_node> 6158for expressions where these macros would be used and prints 6159out the required macro definitions. 6160Essentially, C<isl_ast_node_print_macros> calls 6161C<isl_ast_node_foreach_ast_op_type> with C<isl_ast_op_type_print_macro> 6162as function argument. 6163C<isl_ast_node_print>, C<isl_ast_node_for_print> and 6164C<isl_ast_node_if_print> print an C<isl_ast_node> 6165in C<ISL_FORMAT_C>, but allow for some extra control 6166through an C<isl_ast_print_options> object. 6167This object can be created using the following functions. 6168 6169 #include <isl/ast.h> 6170 __isl_give isl_ast_print_options * 6171 isl_ast_print_options_alloc(isl_ctx *ctx); 6172 __isl_give isl_ast_print_options * 6173 isl_ast_print_options_copy( 6174 __isl_keep isl_ast_print_options *options); 6175 void *isl_ast_print_options_free( 6176 __isl_take isl_ast_print_options *options); 6177 6178 __isl_give isl_ast_print_options * 6179 isl_ast_print_options_set_print_user( 6180 __isl_take isl_ast_print_options *options, 6181 __isl_give isl_printer *(*print_user)( 6182 __isl_take isl_printer *p, 6183 __isl_take isl_ast_print_options *options, 6184 __isl_keep isl_ast_node *node, void *user), 6185 void *user); 6186 __isl_give isl_ast_print_options * 6187 isl_ast_print_options_set_print_for( 6188 __isl_take isl_ast_print_options *options, 6189 __isl_give isl_printer *(*print_for)( 6190 __isl_take isl_printer *p, 6191 __isl_take isl_ast_print_options *options, 6192 __isl_keep isl_ast_node *node, void *user), 6193 void *user); 6194 6195The callback set by C<isl_ast_print_options_set_print_user> 6196is called whenever a node of type C<isl_ast_node_user> needs to 6197be printed. 6198The callback set by C<isl_ast_print_options_set_print_for> 6199is called whenever a node of type C<isl_ast_node_for> needs to 6200be printed. 6201Note that C<isl_ast_node_for_print> will I<not> call the 6202callback set by C<isl_ast_print_options_set_print_for> on the node 6203on which C<isl_ast_node_for_print> is called, but only on nested 6204nodes of type C<isl_ast_node_for>. It is therefore safe to 6205call C<isl_ast_node_for_print> from within the callback set by 6206C<isl_ast_print_options_set_print_for>. 6207 6208The following option determines the type to be used for iterators 6209while printing the AST. 6210 6211 int isl_options_set_ast_iterator_type( 6212 isl_ctx *ctx, const char *val); 6213 const char *isl_options_get_ast_iterator_type( 6214 isl_ctx *ctx); 6215 6216=head3 Options 6217 6218 #include <isl/ast_build.h> 6219 int isl_options_set_ast_build_atomic_upper_bound( 6220 isl_ctx *ctx, int val); 6221 int isl_options_get_ast_build_atomic_upper_bound( 6222 isl_ctx *ctx); 6223 int isl_options_set_ast_build_prefer_pdiv(isl_ctx *ctx, 6224 int val); 6225 int isl_options_get_ast_build_prefer_pdiv(isl_ctx *ctx); 6226 int isl_options_set_ast_build_exploit_nested_bounds( 6227 isl_ctx *ctx, int val); 6228 int isl_options_get_ast_build_exploit_nested_bounds( 6229 isl_ctx *ctx); 6230 int isl_options_set_ast_build_group_coscheduled( 6231 isl_ctx *ctx, int val); 6232 int isl_options_get_ast_build_group_coscheduled( 6233 isl_ctx *ctx); 6234 int isl_options_set_ast_build_scale_strides( 6235 isl_ctx *ctx, int val); 6236 int isl_options_get_ast_build_scale_strides( 6237 isl_ctx *ctx); 6238 int isl_options_set_ast_build_allow_else(isl_ctx *ctx, 6239 int val); 6240 int isl_options_get_ast_build_allow_else(isl_ctx *ctx); 6241 int isl_options_set_ast_build_allow_or(isl_ctx *ctx, 6242 int val); 6243 int isl_options_get_ast_build_allow_or(isl_ctx *ctx); 6244 6245=over 6246 6247=item * ast_build_atomic_upper_bound 6248 6249Generate loop upper bounds that consist of the current loop iterator, 6250an operator and an expression not involving the iterator. 6251If this option is not set, then the current loop iterator may appear 6252several times in the upper bound. 6253For example, when this option is turned off, AST generation 6254for the schedule 6255 6256 [n] -> { A[i] -> [i] : 0 <= i <= 100, n } 6257 6258produces 6259 6260 for (int c0 = 0; c0 <= 100 && n >= c0; c0 += 1) 6261 A(c0); 6262 6263When the option is turned on, the following AST is generated 6264 6265 for (int c0 = 0; c0 <= min(100, n); c0 += 1) 6266 A(c0); 6267 6268=item * ast_build_prefer_pdiv 6269 6270If this option is turned off, then the AST generation will 6271produce ASTs that may only contain C<isl_ast_op_fdiv_q> 6272operators, but no C<isl_ast_op_pdiv_q> or 6273C<isl_ast_op_pdiv_r> operators. 6274If this options is turned on, then C<isl> will try to convert 6275some of the C<isl_ast_op_fdiv_q> operators to (expressions containing) 6276C<isl_ast_op_pdiv_q> or C<isl_ast_op_pdiv_r> operators. 6277 6278=item * ast_build_exploit_nested_bounds 6279 6280Simplify conditions based on bounds of nested for loops. 6281In particular, remove conditions that are implied by the fact 6282that one or more nested loops have at least one iteration, 6283meaning that the upper bound is at least as large as the lower bound. 6284For example, when this option is turned off, AST generation 6285for the schedule 6286 6287 [N,M] -> { A[i,j] -> [i,j] : 0 <= i <= N and 6288 0 <= j <= M } 6289 6290produces 6291 6292 if (M >= 0) 6293 for (int c0 = 0; c0 <= N; c0 += 1) 6294 for (int c1 = 0; c1 <= M; c1 += 1) 6295 A(c0, c1); 6296 6297When the option is turned on, the following AST is generated 6298 6299 for (int c0 = 0; c0 <= N; c0 += 1) 6300 for (int c1 = 0; c1 <= M; c1 += 1) 6301 A(c0, c1); 6302 6303=item * ast_build_group_coscheduled 6304 6305If two domain elements are assigned the same schedule point, then 6306they may be executed in any order and they may even appear in different 6307loops. If this options is set, then the AST generator will make 6308sure that coscheduled domain elements do not appear in separate parts 6309of the AST. This is useful in case of nested AST generation 6310if the outer AST generation is given only part of a schedule 6311and the inner AST generation should handle the domains that are 6312coscheduled by this initial part of the schedule together. 6313For example if an AST is generated for a schedule 6314 6315 { A[i] -> [0]; B[i] -> [0] } 6316 6317then the C<isl_ast_build_set_create_leaf> callback described 6318below may get called twice, once for each domain. 6319Setting this option ensures that the callback is only called once 6320on both domains together. 6321 6322=item * ast_build_separation_bounds 6323 6324This option specifies which bounds to use during separation. 6325If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT> 6326then all (possibly implicit) bounds on the current dimension will 6327be used during separation. 6328If this option is set to C<ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT> 6329then only those bounds that are explicitly available will 6330be used during separation. 6331 6332=item * ast_build_scale_strides 6333 6334This option specifies whether the AST generator is allowed 6335to scale down iterators of strided loops. 6336 6337=item * ast_build_allow_else 6338 6339This option specifies whether the AST generator is allowed 6340to construct if statements with else branches. 6341 6342=item * ast_build_allow_or 6343 6344This option specifies whether the AST generator is allowed 6345to construct if conditions with disjunctions. 6346 6347=back 6348 6349=head3 Fine-grained Control over AST Generation 6350 6351Besides specifying the constraints on the parameters, 6352an C<isl_ast_build> object can be used to control 6353various aspects of the AST generation process. 6354The most prominent way of control is through ``options'', 6355which can be set using the following function. 6356 6357 #include <isl/ast_build.h> 6358 __isl_give isl_ast_build * 6359 isl_ast_build_set_options( 6360 __isl_take isl_ast_build *control, 6361 __isl_take isl_union_map *options); 6362 6363The options are encoded in an <isl_union_map>. 6364The domain of this union relation refers to the schedule domain, 6365i.e., the range of the schedule passed to C<isl_ast_build_ast_from_schedule>. 6366In the case of nested AST generation (see L</"Nested AST Generation">), 6367the domain of C<options> should refer to the extra piece of the schedule. 6368That is, it should be equal to the range of the wrapped relation in the 6369range of the schedule. 6370The range of the options can consist of elements in one or more spaces, 6371the names of which determine the effect of the option. 6372The values of the range typically also refer to the schedule dimension 6373to which the option applies. In case of nested AST generation 6374(see L</"Nested AST Generation">), these values refer to the position 6375of the schedule dimension within the innermost AST generation. 6376The constraints on the domain elements of 6377the option should only refer to this dimension and earlier dimensions. 6378We consider the following spaces. 6379 6380=over 6381 6382=item C<separation_class> 6383 6384This space is a wrapped relation between two one dimensional spaces. 6385The input space represents the schedule dimension to which the option 6386applies and the output space represents the separation class. 6387While constructing a loop corresponding to the specified schedule 6388dimension(s), the AST generator will try to generate separate loops 6389for domain elements that are assigned different classes. 6390If only some of the elements are assigned a class, then those elements 6391that are not assigned any class will be treated as belonging to a class 6392that is separate from the explicitly assigned classes. 6393The typical use case for this option is to separate full tiles from 6394partial tiles. 6395The other options, described below, are applied after the separation 6396into classes. 6397 6398As an example, consider the separation into full and partial tiles 6399of a tiling of a triangular domain. 6400Take, for example, the domain 6401 6402 { A[i,j] : 0 <= i,j and i + j <= 100 } 6403 6404and a tiling into tiles of 10 by 10. The input to the AST generator 6405is then the schedule 6406 6407 { A[i,j] -> [([i/10]),[j/10],i,j] : 0 <= i,j and 6408 i + j <= 100 } 6409 6410Without any options, the following AST is generated 6411 6412 for (int c0 = 0; c0 <= 10; c0 += 1) 6413 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1) 6414 for (int c2 = 10 * c0; 6415 c2 <= min(-10 * c1 + 100, 10 * c0 + 9); 6416 c2 += 1) 6417 for (int c3 = 10 * c1; 6418 c3 <= min(10 * c1 + 9, -c2 + 100); 6419 c3 += 1) 6420 A(c2, c3); 6421 6422Separation into full and partial tiles can be obtained by assigning 6423a class, say C<0>, to the full tiles. The full tiles are represented by those 6424values of the first and second schedule dimensions for which there are 6425values of the third and fourth dimensions to cover an entire tile. 6426That is, we need to specify the following option 6427 6428 { [a,b,c,d] -> separation_class[[0]->[0]] : 6429 exists b': 0 <= 10a,10b' and 6430 10a+9+10b'+9 <= 100; 6431 [a,b,c,d] -> separation_class[[1]->[0]] : 6432 0 <= 10a,10b and 10a+9+10b+9 <= 100 } 6433 6434which simplifies to 6435 6436 { [a, b, c, d] -> separation_class[[1] -> [0]] : 6437 a >= 0 and b >= 0 and b <= 8 - a; 6438 [a, b, c, d] -> separation_class[[0] -> [0]] : 6439 a >= 0 and a <= 8 } 6440 6441With this option, the generated AST is as follows 6442 6443 { 6444 for (int c0 = 0; c0 <= 8; c0 += 1) { 6445 for (int c1 = 0; c1 <= -c0 + 8; c1 += 1) 6446 for (int c2 = 10 * c0; 6447 c2 <= 10 * c0 + 9; c2 += 1) 6448 for (int c3 = 10 * c1; 6449 c3 <= 10 * c1 + 9; c3 += 1) 6450 A(c2, c3); 6451 for (int c1 = -c0 + 9; c1 <= -c0 + 10; c1 += 1) 6452 for (int c2 = 10 * c0; 6453 c2 <= min(-10 * c1 + 100, 10 * c0 + 9); 6454 c2 += 1) 6455 for (int c3 = 10 * c1; 6456 c3 <= min(-c2 + 100, 10 * c1 + 9); 6457 c3 += 1) 6458 A(c2, c3); 6459 } 6460 for (int c0 = 9; c0 <= 10; c0 += 1) 6461 for (int c1 = 0; c1 <= -c0 + 10; c1 += 1) 6462 for (int c2 = 10 * c0; 6463 c2 <= min(-10 * c1 + 100, 10 * c0 + 9); 6464 c2 += 1) 6465 for (int c3 = 10 * c1; 6466 c3 <= min(10 * c1 + 9, -c2 + 100); 6467 c3 += 1) 6468 A(c2, c3); 6469 } 6470 6471=item C<separate> 6472 6473This is a single-dimensional space representing the schedule dimension(s) 6474to which ``separation'' should be applied. Separation tries to split 6475a loop into several pieces if this can avoid the generation of guards 6476inside the loop. 6477See also the C<atomic> option. 6478 6479=item C<atomic> 6480 6481This is a single-dimensional space representing the schedule dimension(s) 6482for which the domains should be considered ``atomic''. That is, the 6483AST generator will make sure that any given domain space will only appear 6484in a single loop at the specified level. 6485 6486Consider the following schedule 6487 6488 { a[i] -> [i] : 0 <= i < 10; 6489 b[i] -> [i+1] : 0 <= i < 10 } 6490 6491If the following option is specified 6492 6493 { [i] -> separate[x] } 6494 6495then the following AST will be generated 6496 6497 { 6498 a(0); 6499 for (int c0 = 1; c0 <= 9; c0 += 1) { 6500 a(c0); 6501 b(c0 - 1); 6502 } 6503 b(9); 6504 } 6505 6506If, on the other hand, the following option is specified 6507 6508 { [i] -> atomic[x] } 6509 6510then the following AST will be generated 6511 6512 for (int c0 = 0; c0 <= 10; c0 += 1) { 6513 if (c0 <= 9) 6514 a(c0); 6515 if (c0 >= 1) 6516 b(c0 - 1); 6517 } 6518 6519If neither C<atomic> nor C<separate> is specified, then the AST generator 6520may produce either of these two results or some intermediate form. 6521 6522=item C<unroll> 6523 6524This is a single-dimensional space representing the schedule dimension(s) 6525that should be I<completely> unrolled. 6526To obtain a partial unrolling, the user should apply an additional 6527strip-mining to the schedule and fully unroll the inner loop. 6528 6529=back 6530 6531Additional control is available through the following functions. 6532 6533 #include <isl/ast_build.h> 6534 __isl_give isl_ast_build * 6535 isl_ast_build_set_iterators( 6536 __isl_take isl_ast_build *control, 6537 __isl_take isl_id_list *iterators); 6538 6539The function C<isl_ast_build_set_iterators> allows the user to 6540specify a list of iterator C<isl_id>s to be used as iterators. 6541If the input schedule is injective, then 6542the number of elements in this list should be as large as the dimension 6543of the schedule space, but no direct correspondence should be assumed 6544between dimensions and elements. 6545If the input schedule is not injective, then an additional number 6546of C<isl_id>s equal to the largest dimension of the input domains 6547may be required. 6548If the number of provided C<isl_id>s is insufficient, then additional 6549names are automatically generated. 6550 6551 #include <isl/ast_build.h> 6552 __isl_give isl_ast_build * 6553 isl_ast_build_set_create_leaf( 6554 __isl_take isl_ast_build *control, 6555 __isl_give isl_ast_node *(*fn)( 6556 __isl_take isl_ast_build *build, 6557 void *user), void *user); 6558 6559The 6560C<isl_ast_build_set_create_leaf> function allows for the 6561specification of a callback that should be called whenever the AST 6562generator arrives at an element of the schedule domain. 6563The callback should return an AST node that should be inserted 6564at the corresponding position of the AST. The default action (when 6565the callback is not set) is to continue generating parts of the AST to scan 6566all the domain elements associated to the schedule domain element 6567and to insert user nodes, ``calling'' the domain element, for each of them. 6568The C<build> argument contains the current state of the C<isl_ast_build>. 6569To ease nested AST generation (see L</"Nested AST Generation">), 6570all control information that is 6571specific to the current AST generation such as the options and 6572the callbacks has been removed from this C<isl_ast_build>. 6573The callback would typically return the result of a nested 6574AST generation or a 6575user defined node created using the following function. 6576 6577 #include <isl/ast.h> 6578 __isl_give isl_ast_node *isl_ast_node_alloc_user( 6579 __isl_take isl_ast_expr *expr); 6580 6581 #include <isl/ast_build.h> 6582 __isl_give isl_ast_build * 6583 isl_ast_build_set_at_each_domain( 6584 __isl_take isl_ast_build *build, 6585 __isl_give isl_ast_node *(*fn)( 6586 __isl_take isl_ast_node *node, 6587 __isl_keep isl_ast_build *build, 6588 void *user), void *user); 6589 __isl_give isl_ast_build * 6590 isl_ast_build_set_before_each_for( 6591 __isl_take isl_ast_build *build, 6592 __isl_give isl_id *(*fn)( 6593 __isl_keep isl_ast_build *build, 6594 void *user), void *user); 6595 __isl_give isl_ast_build * 6596 isl_ast_build_set_after_each_for( 6597 __isl_take isl_ast_build *build, 6598 __isl_give isl_ast_node *(*fn)( 6599 __isl_take isl_ast_node *node, 6600 __isl_keep isl_ast_build *build, 6601 void *user), void *user); 6602 6603The callback set by C<isl_ast_build_set_at_each_domain> will 6604be called for each domain AST node. 6605The callbacks set by C<isl_ast_build_set_before_each_for> 6606and C<isl_ast_build_set_after_each_for> will be called 6607for each for AST node. The first will be called in depth-first 6608pre-order, while the second will be called in depth-first post-order. 6609Since C<isl_ast_build_set_before_each_for> is called before the for 6610node is actually constructed, it is only passed an C<isl_ast_build>. 6611The returned C<isl_id> will be added as an annotation (using 6612C<isl_ast_node_set_annotation>) to the constructed for node. 6613In particular, if the user has also specified an C<after_each_for> 6614callback, then the annotation can be retrieved from the node passed to 6615that callback using C<isl_ast_node_get_annotation>. 6616All callbacks should C<NULL> on failure. 6617The given C<isl_ast_build> can be used to create new 6618C<isl_ast_expr> objects using C<isl_ast_build_expr_from_pw_aff> 6619or C<isl_ast_build_call_from_pw_multi_aff>. 6620 6621=head3 Nested AST Generation 6622 6623C<isl> allows the user to create an AST within the context 6624of another AST. These nested ASTs are created using the 6625same C<isl_ast_build_ast_from_schedule> function that is used to create the 6626outer AST. The C<build> argument should be an C<isl_ast_build> 6627passed to a callback set by 6628C<isl_ast_build_set_create_leaf>. 6629The space of the range of the C<schedule> argument should refer 6630to this build. In particular, the space should be a wrapped 6631relation and the domain of this wrapped relation should be the 6632same as that of the range of the schedule returned by 6633C<isl_ast_build_get_schedule> below. 6634In practice, the new schedule is typically 6635created by calling C<isl_union_map_range_product> on the old schedule 6636and some extra piece of the schedule. 6637The space of the schedule domain is also available from 6638the C<isl_ast_build>. 6639 6640 #include <isl/ast_build.h> 6641 __isl_give isl_union_map *isl_ast_build_get_schedule( 6642 __isl_keep isl_ast_build *build); 6643 __isl_give isl_space *isl_ast_build_get_schedule_space( 6644 __isl_keep isl_ast_build *build); 6645 __isl_give isl_ast_build *isl_ast_build_restrict( 6646 __isl_take isl_ast_build *build, 6647 __isl_take isl_set *set); 6648 6649The C<isl_ast_build_get_schedule> function returns a (partial) 6650schedule for the domains elements for which part of the AST still needs to 6651be generated in the current build. 6652In particular, the domain elements are mapped to those iterations of the loops 6653enclosing the current point of the AST generation inside which 6654the domain elements are executed. 6655No direct correspondence between 6656the input schedule and this schedule should be assumed. 6657The space obtained from C<isl_ast_build_get_schedule_space> can be used 6658to create a set for C<isl_ast_build_restrict> to intersect 6659with the current build. In particular, the set passed to 6660C<isl_ast_build_restrict> can have additional parameters. 6661The ids of the set dimensions in the space returned by 6662C<isl_ast_build_get_schedule_space> correspond to the 6663iterators of the already generated loops. 6664The user should not rely on the ids of the output dimensions 6665of the relations in the union relation returned by 6666C<isl_ast_build_get_schedule> having any particular value. 6667 6668=head1 Applications 6669 6670Although C<isl> is mainly meant to be used as a library, 6671it also contains some basic applications that use some 6672of the functionality of C<isl>. 6673The input may be specified in either the L<isl format> 6674or the L<PolyLib format>. 6675 6676=head2 C<isl_polyhedron_sample> 6677 6678C<isl_polyhedron_sample> takes a polyhedron as input and prints 6679an integer element of the polyhedron, if there is any. 6680The first column in the output is the denominator and is always 6681equal to 1. If the polyhedron contains no integer points, 6682then a vector of length zero is printed. 6683 6684=head2 C<isl_pip> 6685 6686C<isl_pip> takes the same input as the C<example> program 6687from the C<piplib> distribution, i.e., a set of constraints 6688on the parameters, a line containing only -1 and finally a set 6689of constraints on a parametric polyhedron. 6690The coefficients of the parameters appear in the last columns 6691(but before the final constant column). 6692The output is the lexicographic minimum of the parametric polyhedron. 6693As C<isl> currently does not have its own output format, the output 6694is just a dump of the internal state. 6695 6696=head2 C<isl_polyhedron_minimize> 6697 6698C<isl_polyhedron_minimize> computes the minimum of some linear 6699or affine objective function over the integer points in a polyhedron. 6700If an affine objective function 6701is given, then the constant should appear in the last column. 6702 6703=head2 C<isl_polytope_scan> 6704 6705Given a polytope, C<isl_polytope_scan> prints 6706all integer points in the polytope. 6707 6708=head2 C<isl_codegen> 6709 6710Given a schedule, a context set and an options relation, 6711C<isl_codegen> prints out an AST that scans the domain elements 6712of the schedule in the order of their image(s) taking into account 6713the constraints in the context set. 6714