Polly 23.0.0git
isl_output.c
Go to the documentation of this file.
1/*
2 * Copyright 2008-2009 Katholieke Universiteit Leuven
3 * Copyright 2010 INRIA Saclay
4 * Copyright 2012-2013 Ecole Normale Superieure
5 * Copyright 2019 Cerebras Systems
6 *
7 * Use of this software is governed by the MIT license
8 *
9 * Written by Sven Verdoolaege, K.U.Leuven, Departement
10 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
11 * and INRIA Saclay - Ile-de-France, Parc Club Orsay Universite,
12 * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France
13 * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
14 * and Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
15 */
16
17#include <stdlib.h>
18#include <string.h>
19#include <isl_ctx_private.h>
20#include <isl_map_private.h>
21#include <isl/set.h>
22#include <isl_seq.h>
24#include <isl_printer_private.h>
25#include <isl_space_private.h>
26#include <isl_mat_private.h>
27#include <isl_vec_private.h>
28#include <isl/union_set.h>
29#include <isl/union_map.h>
30#include <isl/constraint.h>
31#include <isl_local.h>
33#include <isl_aff_private.h>
34#include <isl_id_private.h>
35#include <isl_val_private.h>
37#include <isl/ast_build.h>
38#include <isl_sort.h>
39#include <isl_output_private.h>
40
41#include <bset_to_bmap.c>
42#include <set_to_map.c>
43#include <uset_to_umap.c>
44
45static const char *s_to[2] = { " -> ", " \\to " };
46static const char *s_and[2] = { " and ", " \\wedge " };
47static const char *s_or[2] = { " or ", " \\vee " };
48static const char *s_le[2] = { "<=", "\\le" };
49static const char *s_ge[2] = { ">=", "\\ge" };
50static const char *s_open_set[2] = { "{ ", "\\{\\, " };
51static const char *s_close_set[2] = { " }", " \\,\\}" };
52static const char *s_open_list[2] = { "[", "(" };
53static const char *s_close_list[2] = { "]", ")" };
54static const char *s_such_that[2] = { " : ", " \\mid " };
55static const char *s_open_exists[2] = { "exists (", "\\exists \\, " };
56static const char *s_close_exists[2] = { ")", "" };
57static const char *s_div_prefix[2] = { "e", "\\alpha_" };
58static const char *s_mod[2] = { "mod", "\\bmod" };
59static const char *s_param_prefix[2] = { "p", "p_" };
60static const char *s_input_prefix[2] = { "i", "i_" };
61static const char *s_output_prefix[2] = { "o", "o_" };
62
64 struct isl_basic_map *bmap, int ineq, int n, __isl_take isl_printer *p)
65{
66 int i;
70 isl_int *c = ineq ? bmap->ineq[n] : bmap->eq[n];
71
72 if (n_in < 0 || n_out < 0 || nparam < 0)
73 return isl_printer_free(p);
74
76 p = isl_printer_print_int(p, ineq);
77 for (i = 0; i < n_out; ++i) {
79 p = isl_printer_print_isl_int(p, c[1+nparam+n_in+i]);
80 }
81 for (i = 0; i < n_in; ++i) {
83 p = isl_printer_print_isl_int(p, c[1+nparam+i]);
84 }
85 for (i = 0; i < bmap->n_div; ++i) {
87 p = isl_printer_print_isl_int(p, c[1+nparam+n_in+n_out+i]);
88 }
89 for (i = 0; i < nparam; ++i) {
91 p = isl_printer_print_isl_int(p, c[1+i]);
92 }
96 return p;
97}
98
100 struct isl_basic_map *bmap, __isl_take isl_printer *p)
101{
102 int i;
103
105
106 for (i = 0; i < bmap->n_eq; ++i)
107 p = print_constraint_polylib(bmap, 0, i, p);
108 for (i = 0; i < bmap->n_ineq; ++i)
109 p = print_constraint_polylib(bmap, 1, i, p);
110
111 return p;
112}
113
119
122{
124
126 if (total < 0)
127 return isl_printer_free(p);
129 p = isl_printer_print_int(p, bmap->n_eq + bmap->n_ineq);
130 p = isl_printer_print_str(p, " ");
131 p = isl_printer_print_int(p, 1 + total + 1);
132 if (ext) {
137
138 if (n_in < 0 || n_out < 0 || n_div < 0 || nparam < 0)
139 return isl_printer_free(p);
140
141 p = isl_printer_print_str(p, " ");
142 p = isl_printer_print_int(p, n_out);
143 p = isl_printer_print_str(p, " ");
144 p = isl_printer_print_int(p, n_in);
145 p = isl_printer_print_str(p, " ");
146 p = isl_printer_print_int(p, n_div);
147 p = isl_printer_print_str(p, " ");
148 p = isl_printer_print_int(p, nparam);
149 }
151 return print_constraints_polylib(bmap, p);
152}
153
159
161 __isl_take isl_printer *p, int ext)
162{
163 int i;
164
168 for (i = 0; i < map->n; ++i) {
171 p = isl_basic_map_print_polylib(map->p[i], p, ext);
172 }
173 return p;
174}
175
181
183 enum isl_dim_type type, unsigned pos, const char *name)
184{
185 enum isl_dim_type t;
186 int p;
187 isl_size s;
188 int count = 0;
189
190 for (t = isl_dim_param; t <= type && t <= isl_dim_out; ++t) {
191 s = t == type ? pos : isl_space_dim(space, t);
192 if (s < 0)
193 return isl_size_error;
194 for (p = 0; p < s; ++p) {
195 const char *n = isl_space_get_dim_name(space, t, p);
196 if (n && !strcmp(n, name))
197 count++;
198 }
199 }
200 return count;
201}
202
203/* Print the name of the variable of type "type" and position "pos"
204 * in "space" to "p".
205 */
207 __isl_take isl_printer *p, enum isl_dim_type type, unsigned pos,
208 int latex)
209{
210 const char *name;
211 char buffer[20];
212 isl_size primes;
213
214 name = type == isl_dim_div ? NULL
216
217 if (!name) {
218 const char *prefix;
219 if (type == isl_dim_param)
220 prefix = s_param_prefix[latex];
221 else if (type == isl_dim_div)
222 prefix = s_div_prefix[latex];
223 else if (isl_space_is_set(space) || type == isl_dim_in)
224 prefix = s_input_prefix[latex];
225 else
226 prefix = s_output_prefix[latex];
227 snprintf(buffer, sizeof(buffer), "%s%d", prefix, pos);
228 name = buffer;
229 }
230 primes = count_same_name(space, name == buffer ? isl_dim_div : type,
231 pos, name);
232 if (primes < 0)
233 return isl_printer_free(p);
235 while (primes-- > 0)
236 p = isl_printer_print_str(p, "'");
237 return p;
238}
239
241 enum isl_dim_type *type, unsigned *pos)
242{
243 isl_size n_in = isl_space_dim(space, isl_dim_in);
244 isl_size n_out = isl_space_dim(space, isl_dim_out);
245 isl_size nparam = isl_space_dim(space, isl_dim_param);
246
247 if (n_in < 0 || n_out < 0 || nparam < 0)
248 return isl_stat_error;
249
250 if (*pos < 1 + nparam) {
252 *pos -= 1;
253 } else if (*pos < 1 + nparam + n_in) {
254 *type = isl_dim_in;
255 *pos -= 1 + nparam;
256 } else if (*pos < 1 + nparam + n_in + n_out) {
257 *type = isl_dim_out;
258 *pos -= 1 + nparam + n_in;
259 } else {
260 *type = isl_dim_div;
261 *pos -= 1 + nparam + n_in + n_out;
262 }
263
264 return isl_stat_ok;
265}
266
267/* Can the div expression of the integer division at position "row" of "div"
268 * be printed?
269 * In particular, are the div expressions available and does the selected
270 * variable have a known explicit representation?
271 * Furthermore, the Omega format does not allow any div expressions
272 * to be printed.
273 */
275 __isl_keep isl_mat *div, int pos)
276{
277 if (p->output_format == ISL_FORMAT_OMEGA)
278 return isl_bool_false;
279 if (!div)
280 return isl_bool_false;
282}
283
286
288 __isl_keep isl_mat *div,
289 isl_int c, unsigned pos, __isl_take isl_printer *p, int latex)
290{
291 enum isl_dim_type type;
292 int print_div_def;
293
294 if (!p || !space)
295 return isl_printer_free(p);
296
297 if (pos == 0)
298 return isl_printer_print_isl_int(p, c);
299
300 if (pos2type(space, &type, &pos) < 0)
301 return isl_printer_free(p);
302 print_div_def = type == isl_dim_div && can_print_div_expr(p, div, pos);
303
304 if (isl_int_is_one(c))
305 ;
306 else if (isl_int_is_negone(c))
307 p = isl_printer_print_str(p, "-");
308 else {
310 if (p->output_format == ISL_FORMAT_C || print_div_def)
311 p = isl_printer_print_str(p, "*");
312 }
313 if (print_div_def)
314 p = print_div(space, div, pos, p);
315 else
316 p = print_name(space, p, type, pos, latex);
317 return p;
318}
319
321 __isl_keep isl_mat *div,
322 __isl_take isl_printer *p, isl_int *c, int len)
323{
324 int i;
325 int first;
326
327 for (i = 0, first = 1; i < len; ++i) {
328 int flip = 0;
329 if (isl_int_is_zero(c[i]))
330 continue;
331 if (!first) {
332 if (isl_int_is_neg(c[i])) {
333 flip = 1;
334 isl_int_neg(c[i], c[i]);
335 p = isl_printer_print_str(p, " - ");
336 } else
337 p = isl_printer_print_str(p, " + ");
338 }
339 first = 0;
340 p = print_term(space, div, c[i], i, p, 0);
341 if (flip)
342 isl_int_neg(c[i], c[i]);
343 }
344 if (first)
345 p = isl_printer_print_str(p, "0");
346 return p;
347}
348
349/* Print an affine expression "c"
350 * to "p", with the variable names taken from "space" and
351 * the integer division definitions taken from "div".
352 */
355{
356 isl_size n_div, total;
357 unsigned len;
358
360 n_div = isl_mat_rows(div);
361 if (total < 0 || n_div < 0)
362 return isl_printer_free(p);
363 len = 1 + total + n_div;
364 return print_affine_of_len(space, div, p, c, len);
365}
366
367/* offset is the offset of local_space inside data->type of data->space.
368 */
370 __isl_keep isl_space *local_space, enum isl_dim_type local_type,
371 struct isl_print_space_data *data, int offset)
372{
373 int i;
374 isl_size dim;
375
376 if (data->space != local_space && local_type == isl_dim_out)
377 offset += local_space->n_in;
378
379 dim = isl_space_dim(local_space, local_type);
380 if (dim < 0)
381 return isl_printer_free(p);
382 for (i = 0; i < dim; ++i) {
383 if (i)
384 p = isl_printer_print_str(p, ", ");
385 if (data->print_dim)
386 p = data->print_dim(p, data, offset + i);
387 else
388 p = print_name(data->space, p, data->type, offset + i,
389 data->latex);
390 }
391 return p;
392}
393
396{
397 struct isl_print_space_data data = { .space = space, .type = type };
398
399 return print_nested_var_list(p, space, type, &data, 0);
400}
401
403 __isl_keep isl_space *local_dim,
404 struct isl_print_space_data *data, int offset);
405
407 __isl_keep isl_space *local_space, enum isl_dim_type local_type,
408 struct isl_print_space_data *data, int offset)
409{
410 const char *name = NULL;
411 isl_size n = isl_space_dim(local_space, local_type);
412
413 if (n < 0)
414 return isl_printer_free(p);
415 if ((local_type == isl_dim_in || local_type == isl_dim_out)) {
416 name = isl_space_get_tuple_name(local_space, local_type);
417 if (name) {
418 if (data->latex)
419 p = isl_printer_print_str(p, "\\mathrm{");
421 if (data->latex)
422 p = isl_printer_print_str(p, "}");
423 }
424 }
425 if (!data->latex || n != 1 || name)
427 if ((local_type == isl_dim_in || local_type == isl_dim_out) &&
428 local_space->nested[local_type - isl_dim_in]) {
429 if (data->space != local_space && local_type == isl_dim_out)
430 offset += local_space->n_in;
432 local_space->nested[local_type - isl_dim_in],
433 data, offset);
434 } else
435 p = print_nested_var_list(p, local_space, local_type, data,
436 offset);
437 if (!data->latex || n != 1 || name)
439 return p;
440}
441
444 struct isl_print_space_data *data)
445{
446 data->space = space;
447 data->type = type;
448 return print_nested_tuple(p, space, type, data, 0);
449}
450
452 __isl_keep isl_space *local_dim,
453 struct isl_print_space_data *data, int offset)
454{
455 p = print_nested_tuple(p, local_dim, isl_dim_in, data, offset);
457 p = print_nested_tuple(p, local_dim, isl_dim_out, data, offset);
458
459 return p;
460}
461
463 __isl_take isl_printer *p, int rational,
464 struct isl_print_space_data *data)
465{
466 if (rational && !data->latex)
467 p = isl_printer_print_str(p, "rat: ");
469 ;
470 else if (isl_space_is_set(space))
471 p = print_tuple(space, p, isl_dim_set, data);
472 else {
473 p = print_tuple(space, p, isl_dim_in, data);
475 p = print_tuple(space, p, isl_dim_out, data);
476 }
477
478 return p;
479}
480
483{
485
486 if (nparam < 0)
487 return isl_printer_free(p);
488 if (nparam == 0)
489 return p;
490
492 p = isl_printer_print_str(p, "symbolic ");
494 p = isl_printer_print_str(p, ";");
496 return p;
497}
498
499/* Does the inequality constraint following "i" in "bmap"
500 * have an opposite value for the same last coefficient?
501 * "last" is the position of the last coefficient of inequality "i".
502 * If the next constraint is a div constraint, then it is ignored
503 * since div constraints are not printed.
504 */
506 int last)
507{
508 int r;
510 unsigned o_div = isl_basic_map_offset(bmap, isl_dim_div);
511
512 if (total < 0)
513 return isl_bool_error;
514 if (i + 1 >= bmap->n_ineq)
515 return isl_bool_false;
516 if (isl_seq_last_non_zero(bmap->ineq[i + 1], 1 + total) != last)
517 return isl_bool_false;
518 if (last >= o_div) {
519 isl_bool is_div;
521 bmap->ineq[i + 1], last - o_div);
522 if (is_div < 0)
523 return isl_bool_error;
524 if (is_div)
525 return isl_bool_false;
526 }
527 r = isl_int_abs_eq(bmap->ineq[i][last], bmap->ineq[i + 1][last]) &&
528 !isl_int_eq(bmap->ineq[i][last], bmap->ineq[i + 1][last]);
529 return isl_bool_ok(r);
530}
531
532/* Return a string representation of the operator used when
533 * printing a constraint where the LHS is greater than or equal to the LHS
534 * (sign > 0) or smaller than or equal to the LHS (sign < 0).
535 * If "strict" is set, then return the strict version of the comparison
536 * operator.
537 */
538static const char *constraint_op(int sign, int strict, int latex)
539{
540 if (strict)
541 return sign < 0 ? "<" : ">";
542 if (sign < 0)
543 return s_le[latex];
544 else
545 return s_ge[latex];
546}
547
548/* Print one side of a constraint "c" to "p", with
549 * the variable names taken from "space" and the integer division definitions
550 * taken from "div".
551 * "last" is the position of the last non-zero coefficient.
552 * Let c' be the result of zeroing out this coefficient, then
553 * the partial constraint
554 *
555 * c' op
556 *
557 * is printed.
558 */
561 isl_int *c, int last, const char *op, int latex)
562{
563 isl_int_set_si(c[last], 0);
564 p = print_affine(p, space, div, c);
565
566 p = isl_printer_print_str(p, " ");
568 p = isl_printer_print_str(p, " ");
569
570 return p;
571}
572
573/* Print a constraint "c" to "p", with the variable names
574 * taken from "space" and the integer division definitions taken from "div".
575 * "last" is the position of the last non-zero coefficient, which is
576 * moreover assumed to be negative.
577 * Let c' be the result of zeroing out this coefficient, then
578 * the constraint is printed in the form
579 *
580 * -c[last] op c'
581 */
584 isl_int *c, int last, const char *op, int latex)
585{
586 isl_int_abs(c[last], c[last]);
587
588 p = print_term(space, div, c[last], last, p, latex);
589
590 p = isl_printer_print_str(p, " ");
592 p = isl_printer_print_str(p, " ");
593
594 isl_int_set_si(c[last], 0);
595 p = print_affine(p, space, div, c);
596
597 return p;
598}
599
600/* Given an integer division
601 *
602 * floor(f/m)
603 *
604 * at position "pos" in "div", print the corresponding modulo expression
605 *
606 * (f) mod m
607 *
608 * to "p". The variable names are taken from "space", while any
609 * nested integer division definitions are taken from "div".
610 */
613 int latex)
614{
615 if (!p || !div)
616 return isl_printer_free(p);
617
618 p = isl_printer_print_str(p, "(");
620 div->row[pos] + 1, div->n_col - 1);
621 p = isl_printer_print_str(p, ") ");
623 p = isl_printer_print_str(p, " ");
624 p = isl_printer_print_isl_int(p, div->row[pos][0]);
625 return p;
626}
627
628/* Given an equality constraint with a non-zero coefficient "c"
629 * in position "pos", is this term of the form
630 *
631 * a m floor(g/m),
632 *
633 * with c = a m?
634 * Return the position of the corresponding integer division if so.
635 * Return the number of integer divisions if not.
636 * Return isl_size_error on error.
637 *
638 * Modulo constraints are currently not printed in C format.
639 * Other than that, "pos" needs to correspond to an integer division
640 * with explicit representation and "c" needs to be a multiple
641 * of the denominator of the integer division.
642 */
645 isl_int c)
646{
647 isl_bool can_print;
648 isl_size n_div;
649 enum isl_dim_type type;
650
651 n_div = isl_mat_rows(div);
652 if (!p || !space || n_div < 0)
653 return isl_size_error;
654 if (p->output_format == ISL_FORMAT_C)
655 return n_div;
656 if (pos2type(space, &type, &pos) < 0)
657 return isl_size_error;
658 if (type != isl_dim_div)
659 return n_div;
660 can_print = can_print_div_expr(p, div, pos);
661 if (can_print < 0)
662 return isl_size_error;
663 if (!can_print)
664 return n_div;
665 if (!isl_int_is_divisible_by(c, div->row[pos][0]))
666 return n_div;
667 return pos;
668}
669
670/* Print equality constraint "c" to "p" as a modulo constraint,
671 * with the variable names taken from "space" and
672 * the integer division definitions taken from "div".
673 * "last" is the position of the last non-zero coefficient, which is
674 * moreover assumed to be negative and a multiple of the denominator
675 * of the corresponding integer division. "div_pos" is the corresponding
676 * position in the sequence of integer divisions.
677 *
678 * The equality is of the form
679 *
680 * f - a m floor(g/m) = 0.
681 *
682 * Print it as
683 *
684 * a (g mod m) = -f + a g
685 */
688 __isl_keep isl_mat *div, unsigned div_pos,
689 isl_int *c, int last, int latex)
690{
691 isl_ctx *ctx;
692 int multiple;
693
694 ctx = isl_printer_get_ctx(p);
695 isl_int_divexact(c[last], c[last], div->row[div_pos][0]);
696 isl_int_abs(c[last], c[last]);
697 multiple = !isl_int_is_one(c[last]);
698 if (multiple) {
699 p = isl_printer_print_isl_int(p, c[last]);
700 p = isl_printer_print_str(p, "*(");
701 }
702 p = print_mod(p, space, div, div_pos, latex);
703 if (multiple)
704 p = isl_printer_print_str(p, ")");
705 p = isl_printer_print_str(p, " = ");
706 isl_seq_combine(c, ctx->negone, c,
707 c[last], div->row[div_pos] + 1, last);
708 isl_int_set_si(c[last], 0);
709 p = print_affine(p, space, div, c);
710 return p;
711}
712
713/* Print equality constraint "c" to "p", with the variable names
714 * taken from "space" and the integer division definitions taken from "div".
715 * "last" is the position of the last non-zero coefficient, which is
716 * moreover assumed to be negative.
717 *
718 * If possible, print the equality constraint as a modulo constraint.
719 */
722 int last, int latex)
723{
724 isl_size n_div;
725 isl_size div_pos;
726
727 n_div = isl_mat_rows(div);
728 div_pos = print_as_modulo_pos(p, space, div, last, c[last]);
729 if (n_div < 0 || div_pos < 0)
730 return isl_printer_free(p);
731 if (div_pos < n_div)
732 return print_eq_mod_constraint(p, space, div, div_pos,
733 c, last, latex);
734 return print_constraint(p, space, div, c, last, "=", latex);
735}
736
737/* Print the constraints of "bmap" to "p".
738 * The names of the variables are taken from "space" and
739 * the integer division definitions are taken from "div".
740 * Div constraints are only printed in "dump" mode.
741 * The constraints are sorted prior to printing (except in "dump" mode).
742 *
743 * If x is the last variable with a non-zero coefficient,
744 * then a lower bound
745 *
746 * f - a x >= 0
747 *
748 * is printed as
749 *
750 * a x <= f
751 *
752 * while an upper bound
753 *
754 * f + a x >= 0
755 *
756 * is printed as
757 *
758 * a x >= -f
759 *
760 * If the next constraint has an opposite sign for the same last coefficient,
761 * then it is printed as
762 *
763 * f >= a x
764 *
765 * or
766 *
767 * -f <= a x
768 *
769 * instead. In fact, the "a x" part is not printed explicitly, but
770 * reused from the next constraint, which is therefore treated as
771 * a first constraint in the conjunction.
772 *
773 * If the constant term of "f" is -1, then "f" is replaced by "f + 1" and
774 * the comparison operator is replaced by the strict variant.
775 * Essentially, ">= 1" is replaced by "> 0".
776 */
780{
781 int i;
782 isl_vec *c = NULL;
783 int rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
785 unsigned o_div = isl_basic_map_offset(bmap, isl_dim_div);
786 int first = 1;
787 int dump;
788
789 if (total < 0 || !p)
790 return isl_printer_free(p);
791 bmap = isl_basic_map_copy(bmap);
792 dump = p->dump;
793 if (!dump)
795 if (!bmap)
796 goto error;
797
798 c = isl_vec_alloc(bmap->ctx, 1 + total);
799 if (!c)
800 goto error;
801
802 for (i = bmap->n_eq - 1; i >= 0; --i) {
803 int l = isl_seq_last_non_zero(bmap->eq[i], 1 + total);
804 if (l < 0) {
805 if (i != bmap->n_eq - 1)
807 p = isl_printer_print_str(p, "0 = 0");
808 continue;
809 }
810 if (!first)
812 if (isl_int_is_neg(bmap->eq[i][l]))
813 isl_seq_cpy(c->el, bmap->eq[i], 1 + total);
814 else
815 isl_seq_neg(c->el, bmap->eq[i], 1 + total);
816 p = print_eq_constraint(p, space, div, c->el, l, latex);
817 first = 0;
818 }
819 for (i = 0; i < bmap->n_ineq; ++i) {
821 int l = isl_seq_last_non_zero(bmap->ineq[i], 1 + total);
822 int strict;
823 int s;
824 const char *op;
825 if (l < 0)
826 continue;
827 if (!dump && l >= o_div &&
828 can_print_div_expr(p, div, l - o_div)) {
829 isl_bool is_div;
831 bmap->ineq[i], l - o_div);
832 if (is_div < 0)
833 goto error;
834 if (is_div)
835 continue;
836 }
837 if (!first)
839 s = isl_int_sgn(bmap->ineq[i][l]);
840 strict = !rational && isl_int_is_negone(bmap->ineq[i][0]);
841 if (s < 0)
842 isl_seq_cpy(c->el, bmap->ineq[i], 1 + total);
843 else
844 isl_seq_neg(c->el, bmap->ineq[i], 1 + total);
845 if (strict)
846 isl_int_set_si(c->el[0], 0);
847 combine = dump ? isl_bool_false : next_is_opposite(bmap, i, l);
848 if (combine < 0)
849 goto error;
850 if (combine) {
851 op = constraint_op(-s, strict, latex);
852 p = print_half_constraint(p, space, div, c->el, l,
853 op, latex);
854 first = 1;
855 } else {
856 op = constraint_op(s, strict, latex);
857 p = print_constraint(p, space, div, c->el, l,
858 op, latex);
859 first = 0;
860 }
861 }
862
863 isl_basic_map_free(bmap);
864 isl_vec_free(c);
865
866 return p;
867error:
868 isl_basic_map_free(bmap);
869 isl_vec_free(c);
871 return NULL;
872}
873
876{
877 int c;
878
879 if (!p || !div)
880 return isl_printer_free(p);
881
882 c = p->output_format == ISL_FORMAT_C;
883 p = isl_printer_print_str(p, c ? "floord(" : "floor((");
885 div->row[pos] + 1, div->n_col - 1);
886 p = isl_printer_print_str(p, c ? ", " : ")/");
887 p = isl_printer_print_isl_int(p, div->row[pos][0]);
888 p = isl_printer_print_str(p, ")");
889 return p;
890}
891
892/* Print a comma separated list of div names, except those that have
893 * a definition that can be printed.
894 * If "print_defined_divs" is set, then those div names are printed
895 * as well, along with their definitions.
896 */
899 int print_defined_divs)
900{
901 int i;
902 int first = 1;
903 isl_size n_div;
904
905 n_div = isl_mat_rows(div);
906 if (!p || !space || n_div < 0)
907 return isl_printer_free(p);
908
909 for (i = 0; i < n_div; ++i) {
910 if (!print_defined_divs && can_print_div_expr(p, div, i))
911 continue;
912 if (!first)
913 p = isl_printer_print_str(p, ", ");
915 first = 0;
916 if (!can_print_div_expr(p, div, i))
917 continue;
918 p = isl_printer_print_str(p, " = ");
919 p = print_div(space, div, i, p);
920 }
921
922 return p;
923}
924
925/* Does printing an object with local variables described by "div"
926 * require an "exists" clause?
927 * That is, are there any local variables without an explicit representation?
928 * An exists clause is also needed in "dump" mode because
929 * explicit div representations are not printed inline in that case.
930 */
932{
933 int i;
934 isl_size n;
935
936 n = isl_mat_rows(div);
937 if (!p || n < 0)
938 return isl_bool_error;
939 if (n == 0)
940 return isl_bool_false;
941 if (p->dump)
942 return isl_bool_true;
943 for (i = 0; i < n; ++i)
944 if (!can_print_div_expr(p, div, i))
945 return isl_bool_true;
946 return isl_bool_false;
947}
948
949/* Print the start of an exists clause, i.e.,
950 *
951 * (exists variables:
952 *
953 * In dump mode, local variables with an explicit definition are printed
954 * as well because they will not be printed inline.
955 */
958{
959 int dump;
960
961 if (!p)
962 return NULL;
963
964 dump = p->dump;
966 p = print_div_list(p, space, div, latex, dump);
967 p = isl_printer_print_str(p, ": ");
968
969 return p;
970}
971
972/* Remove the explicit representations of all local variables in "div".
973 */
975{
976 int i;
977 isl_size n_div;
978
979 n_div = isl_mat_rows(div);
980 if (n_div < 0)
981 return isl_mat_free(div);
982
983 for (i = 0; i < n_div; ++i)
984 div = isl_mat_set_element_si(div, i, 0, 0);
985 return div;
986}
987
988/* Print the constraints of "bmap" to "p".
989 * The names of the variables are taken from "space".
990 * "latex" is set if the constraints should be printed in LaTeX format.
991 * Do not print inline explicit div representations in "dump" mode.
992 */
995{
996 int dump;
997 isl_mat *div;
998 isl_bool exists;
999
1000 if (!p)
1001 return NULL;
1002 dump = p->dump;
1003 div = isl_basic_map_get_divs(bmap);
1004 exists = need_exists(p, div);
1005 if (exists >= 0 && exists)
1006 p = open_exists(p, space, div, latex);
1007
1008 if (dump)
1009 div = mark_all_unknown(div);
1010 p = print_constraints(bmap, space, div, p, latex);
1011 isl_mat_free(div);
1012
1013 if (exists >= 0 && exists)
1015 return p;
1016}
1017
1018/* Print a colon followed by the constraints of "bmap"
1019 * to "p", provided there are any constraints.
1020 * The names of the variables are taken from "space".
1021 * "latex" is set if the constraints should be printed in LaTeX format.
1022 */
1026{
1028 return p;
1029
1030 p = isl_printer_print_str(p, ": ");
1031 p = print_disjunct(bmap, space, p, latex);
1032
1033 return p;
1034}
1035
1038{
1039 p = isl_printer_print_str(p, "{ [");
1040 p = print_var_list(p, bmap->dim, isl_dim_in);
1041 p = isl_printer_print_str(p, "] -> [");
1042 p = print_var_list(p, bmap->dim, isl_dim_out);
1043 p = isl_printer_print_str(p, "] ");
1044 p = print_optional_disjunct(bmap, bmap->dim, p, 0);
1045 p = isl_printer_print_str(p, " }");
1046 return p;
1047}
1048
1051{
1052 p = isl_printer_print_str(p, "{ [");
1053 p = print_var_list(p, bset->dim, isl_dim_set);
1054 p = isl_printer_print_str(p, "] ");
1055 p = print_optional_disjunct(bset, bset->dim, p, 0);
1056 p = isl_printer_print_str(p, " }");
1057 return p;
1058}
1059
1062{
1063 int i;
1064
1065 for (i = 0; i < map->n; ++i) {
1066 if (i)
1067 p = isl_printer_print_str(p, " union ");
1068 p = basic_map_print_omega(map->p[i], p);
1069 }
1070 return p;
1071}
1072
1075{
1076 int i;
1077
1078 for (i = 0; i < set->n; ++i) {
1079 if (i)
1080 p = isl_printer_print_str(p, " union ");
1081 p = basic_set_print_omega(set->p[i], p);
1082 }
1083 return p;
1084}
1085
1086/* Print the list of parameters in "space", followed by an arrow, to "p",
1087 * if there are any parameters.
1088 */
1091{
1092 isl_size nparam;
1093
1095 if (!p || nparam < 0)
1096 return isl_printer_free(p);
1097 if (nparam == 0)
1098 return p;
1099
1100 p = print_tuple(space, p, isl_dim_param, data);
1101 p = isl_printer_print_str(p, s_to[data->latex]);
1102
1103 return p;
1104}
1105
1108 int latex)
1109{
1110 struct isl_print_space_data data = { .latex = latex };
1111 int rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
1112
1113 p = print_param_tuple(p, bmap->dim, &data);
1114 p = isl_printer_print_str(p, "{ ");
1115 p = isl_print_space(bmap->dim, p, rational, &data);
1116 p = isl_printer_print_str(p, " : ");
1117 p = print_disjunct(bmap, bmap->dim, p, latex);
1118 p = isl_printer_print_str(p, " }");
1119 return p;
1120}
1121
1122/* Print the disjuncts of a map (or set) "map" to "p".
1123 * The names of the variables are taken from "space".
1124 * "latex" is set if the constraints should be printed in LaTeX format.
1125 */
1128{
1129 int i;
1130
1131 if (map->n == 0)
1132 p = isl_printer_print_str(p, "false");
1133 for (i = 0; i < map->n; ++i) {
1134 if (i)
1136 if (map->n > 1 && map->p[i]->n_eq + map->p[i]->n_ineq > 1)
1137 p = isl_printer_print_str(p, "(");
1138 p = print_disjunct(map->p[i], space, p, latex);
1139 if (map->n > 1 && map->p[i]->n_eq + map->p[i]->n_ineq > 1)
1140 p = isl_printer_print_str(p, ")");
1141 }
1142 return p;
1143}
1144
1145/* Print the disjuncts of a map (or set) "map" to "p".
1146 * The names of the variables are taken from "space".
1147 * "hull" describes constraints shared by all disjuncts of "map".
1148 * "latex" is set if the constraints should be printed in LaTeX format.
1149 *
1150 * Print the disjuncts as a conjunction of "hull" and
1151 * the result of removing the constraints of "hull" from "map".
1152 * If this result turns out to be the universe, then simply print "hull".
1153 */
1157{
1158 isl_bool is_universe;
1159
1162 is_universe = isl_map_plain_is_universe(map);
1163 if (is_universe < 0)
1164 goto error;
1165 if (!is_universe) {
1167 p = isl_printer_print_str(p, "(");
1169 p = isl_printer_print_str(p, ")");
1170 }
1172
1173 return p;
1174error:
1177 return NULL;
1178}
1179
1180/* Print the disjuncts of a map (or set) "map" to "p".
1181 * The names of the variables are taken from "space".
1182 * "latex" is set if the constraints should be printed in LaTeX format.
1183 *
1184 * If there are at least two disjuncts and "dump" mode is not turned out,
1185 * check for any shared constraints among all disjuncts.
1186 * If there are any, then print them separately in print_disjuncts_in_hull.
1187 */
1190{
1192 return p;
1193
1195 if (!p)
1196 return NULL;
1197
1198 if (!p->dump && map->n >= 2) {
1200 isl_bool is_universe;
1201
1204 if (is_universe < 0)
1205 p = isl_printer_free(p);
1206 else if (!is_universe)
1208 p, latex);
1210 }
1211
1213}
1214
1215/* Print the disjuncts of a map (or set).
1216 * The names of the variables are taken from "space".
1217 * "latex" is set if the constraints should be printed in LaTeX format.
1218 *
1219 * If the map turns out to be a universal parameter domain, then
1220 * we need to print the colon. Otherwise, the output looks identical
1221 * to the empty set.
1222 */
1231
1232/* Print the disjuncts of a set.
1233 * The names of the variables are taken from "space".
1234 * "latex" is set if the constraints should be printed in LaTeX format.
1235 */
1241
1246
1247static void free_split(__isl_take struct isl_aff_split *split, int n)
1248{
1249 int i;
1250
1251 if (!split)
1252 return;
1253
1254 for (i = 0; i < n; ++i) {
1257 }
1258
1259 free(split);
1260}
1261
1263{
1264 int i, j;
1265 isl_size nparam, n_in, n_out, total;
1266
1267 bmap = isl_basic_map_cow(bmap);
1268 if (!bmap)
1269 return NULL;
1270 bmap = isl_basic_map_free_inequality(bmap, bmap->n_ineq);
1271
1272 nparam = isl_basic_map_dim(bmap, isl_dim_param);
1273 n_in = isl_basic_map_dim(bmap, isl_dim_in);
1274 n_out = isl_basic_map_dim(bmap, isl_dim_out);
1276 if (n_in < 0 || n_out < 0 || nparam < 0 || total < 0)
1277 return isl_basic_map_free(bmap);
1278
1279 for (i = bmap->n_eq - 1; i >= 0; --i) {
1280 j = isl_seq_last_non_zero(bmap->eq[i] + 1, total);
1281 if (j >= nparam && j < nparam + n_in + n_out &&
1282 (isl_int_is_one(bmap->eq[i][1 + j]) ||
1283 isl_int_is_negone(bmap->eq[i][1 + j])))
1284 continue;
1285 if (isl_basic_map_drop_equality(bmap, i) < 0)
1286 goto error;
1287 }
1288
1289 bmap = isl_basic_map_finalize(bmap);
1290
1291 return bmap;
1292error:
1293 isl_basic_map_free(bmap);
1294 return NULL;
1295}
1296
1297static int aff_split_cmp(const void *p1, const void *p2, void *user)
1298{
1299 const struct isl_aff_split *s1, *s2;
1300 s1 = (const struct isl_aff_split *) p1;
1301 s2 = (const struct isl_aff_split *) p2;
1302
1303 return isl_basic_map_plain_cmp(s1->aff, s2->aff);
1304}
1305
1308{
1309 int i, j;
1310 isl_size v_div;
1311
1313 if (v_div < 0 || !aff)
1314 goto error;
1315
1316 for (i = bmap->n_eq - 1; i >= 0; --i) {
1317 if (isl_seq_any_non_zero(bmap->eq[i] + 1 + v_div, bmap->n_div))
1318 continue;
1319 for (j = 0; j < aff->n_eq; ++j) {
1320 if (!isl_seq_eq(bmap->eq[i], aff->eq[j], 1 + v_div) &&
1321 !isl_seq_is_neg(bmap->eq[i], aff->eq[j], 1 + v_div))
1322 continue;
1323 if (isl_basic_map_drop_equality(bmap, i) < 0)
1324 goto error;
1325 break;
1326 }
1327 }
1328
1329 return bmap;
1330error:
1331 isl_basic_map_free(bmap);
1332 return NULL;
1333}
1334
1336{
1337 int i, n;
1338 struct isl_aff_split *split;
1339 isl_ctx *ctx;
1340
1341 ctx = isl_map_get_ctx(map);
1342 split = isl_calloc_array(ctx, struct isl_aff_split, map->n);
1343 if (!split)
1344 return NULL;
1345
1346 for (i = 0; i < map->n; ++i) {
1347 isl_basic_map *bmap;
1348 split[i].aff = get_aff(isl_basic_map_copy(map->p[i]));
1349 bmap = isl_basic_map_copy(map->p[i]);
1350 bmap = isl_basic_map_cow(bmap);
1351 bmap = drop_aff(bmap, split[i].aff);
1352 split[i].map = isl_map_from_basic_map(bmap);
1353 if (!split[i].aff || !split[i].map)
1354 goto error;
1355 }
1356
1357 if (isl_sort(split, map->n, sizeof(struct isl_aff_split),
1358 &aff_split_cmp, NULL) < 0)
1359 goto error;
1360
1361 n = map->n;
1362 for (i = n - 1; i >= 1; --i) {
1364 split[i].aff))
1365 continue;
1367 split[i - 1].map = isl_map_union(split[i - 1].map,
1368 split[i].map);
1369 if (i != n - 1)
1370 split[i] = split[n - 1];
1371 split[n - 1].aff = NULL;
1372 split[n - 1].map = NULL;
1373 --n;
1374 }
1375
1376 return split;
1377error:
1378 free_split(split, map->n);
1379 return NULL;
1380}
1381
1382/* Given a set of equality constraints "eq" obtained from get_aff,
1383 * i.e., with a (positive or negative) unit coefficient in the last position,
1384 * look for an equality constraint in "eq" that defines
1385 * the "type" variable at position "pos" in "space",
1386 * i.e., where that last coefficient corresponds to the given variable.
1387 * If so, return the position of that equality constraint.
1388 * Return a value beyond the number of equality constraints
1389 * if no such constraint can be found.
1390 * Return isl_size_error in case of error.
1391 *
1392 * If a suitable constraint is found, then also make sure
1393 * it has a negative unit coefficient for the given variable.
1394 */
1396 __isl_keep isl_space *space, enum isl_dim_type type, int pos)
1397{
1398 int i;
1399 isl_size total, off;
1400 isl_size n_eq;
1401
1403 n_eq = isl_basic_map_n_equality(eq);
1404 off = isl_space_offset(space, type);
1405 if (total < 0 || n_eq < 0 || off < 0)
1406 return isl_size_error;
1407
1408 pos += off;
1409
1410 for (i = 0; i < n_eq; ++i) {
1411 if (isl_seq_last_non_zero(eq->eq[i] + 1, total) != pos)
1412 continue;
1413 if (isl_int_is_one(eq->eq[i][1 + pos]))
1414 isl_seq_neg(eq->eq[i], eq->eq[i], 1 + total);
1415 return i;
1416 }
1417
1418 return n_eq;
1419}
1420
1421/* Print dimension "pos" of data->space to "p".
1422 *
1423 * data->user is assumed to be an isl_basic_map keeping track of equalities.
1424 *
1425 * If the current dimension is defined by these equalities, then print
1426 * the corresponding expression, assigned to the name of the dimension
1427 * if there is any. Otherwise, print the name of the dimension.
1428 */
1430 struct isl_print_space_data *data, unsigned pos)
1431{
1432 isl_basic_map *eq = data->user;
1433 isl_size j, n_eq;
1434
1435 n_eq = isl_basic_map_n_equality(eq);
1436 j = defining_equality(eq, data->space, data->type, pos);
1437 if (j < 0 || n_eq < 0)
1438 return isl_printer_free(p);
1439 if (j < n_eq) {
1440 isl_size off;
1441
1442 if (isl_space_has_dim_name(data->space, data->type, pos)) {
1443 p = print_name(data->space, p, data->type, pos,
1444 data->latex);
1445 p = isl_printer_print_str(p, " = ");
1446 }
1447 off = isl_space_offset(data->space, data->type);
1448 if (off < 0)
1449 return isl_printer_free(p);
1450 pos += 1 + off;
1451 p = print_affine_of_len(data->space, NULL, p, eq->eq[j], pos);
1452 } else {
1453 p = print_name(data->space, p, data->type, pos, data->latex);
1454 }
1455
1456 return p;
1457}
1458
1460 struct isl_aff_split *split, int n, __isl_keep isl_space *space)
1461{
1462 struct isl_print_space_data data = { 0 };
1463 int i;
1464 int rational;
1465
1466 data.print_dim = &print_dim_eq;
1467 for (i = 0; i < n; ++i) {
1468 if (!split[i].map)
1469 break;
1470 rational = split[i].map->n > 0 &&
1472 if (i)
1473 p = isl_printer_print_str(p, "; ");
1474 data.user = split[i].aff;
1475 p = isl_print_space(space, p, rational, &data);
1476 p = print_disjuncts_map(split[i].map, space, p, 0);
1477 }
1478
1479 return p;
1480}
1481
1484{
1485 struct isl_print_space_data data = { 0 };
1486 struct isl_aff_split *split = NULL;
1487 int rational;
1488
1489 if (!p || !map)
1490 return isl_printer_free(p);
1491 if (!p->dump && map->n > 0)
1492 split = split_aff(map);
1493 if (split) {
1494 p = print_split_map(p, split, map->n, map->dim);
1495 } else {
1496 rational = map->n > 0 &&
1498 p = isl_print_space(map->dim, p, rational, &data);
1499 p = print_disjuncts_map(map, map->dim, p, 0);
1500 }
1501 free_split(split, map->n);
1502 return p;
1503}
1504
1507{
1508 struct isl_print_space_data data = { 0 };
1509
1510 p = print_param_tuple(p, map->dim, &data);
1512 p = print_body_map(p, map);
1514 return p;
1515}
1516
1519{
1520 struct isl_print_space_data data = { 0 };
1521
1522 data.latex = 1;
1523 p = print_param_tuple(p, map->dim, &data);
1525 data.print_dim = &print_dim_eq;
1526 data.user = aff;
1527 p = isl_print_space(map->dim, p, 0, &data);
1528 p = print_disjuncts_map(map, map->dim, p, 1);
1530
1531 return p;
1532}
1533
1536{
1537 int i;
1538 struct isl_aff_split *split = NULL;
1539
1540 if (map->n > 0)
1541 split = split_aff(map);
1542
1543 if (!split)
1544 return print_latex_map(map, p, NULL);
1545
1546 for (i = 0; i < map->n; ++i) {
1547 if (!split[i].map)
1548 break;
1549 if (i)
1550 p = isl_printer_print_str(p, " \\cup ");
1551 p = print_latex_map(split[i].map, p, split[i].aff);
1552 }
1553
1554 free_split(split, map->n);
1555 return p;
1556}
1557
1560{
1561 if (!p || !bmap)
1562 goto error;
1563 if (p->output_format == ISL_FORMAT_ISL)
1564 return isl_basic_map_print_isl(bmap, p, 0);
1565 else if (p->output_format == ISL_FORMAT_OMEGA)
1566 return basic_map_print_omega(bmap, p);
1567 isl_assert(bmap->ctx, 0, goto error);
1568error:
1570 return NULL;
1571}
1572
1575{
1576 if (!p || !bset)
1577 goto error;
1578
1579 if (p->output_format == ISL_FORMAT_ISL)
1580 return isl_basic_map_print_isl(bset, p, 0);
1581 else if (p->output_format == ISL_FORMAT_POLYLIB)
1582 return isl_basic_set_print_polylib(bset, p, 0);
1583 else if (p->output_format == ISL_FORMAT_EXT_POLYLIB)
1584 return isl_basic_set_print_polylib(bset, p, 1);
1585 else if (p->output_format == ISL_FORMAT_POLYLIB_CONSTRAINTS)
1586 return bset_print_constraints_polylib(bset, p);
1587 else if (p->output_format == ISL_FORMAT_OMEGA)
1588 return basic_set_print_omega(bset, p);
1589 isl_assert(p->ctx, 0, goto error);
1590error:
1592 return NULL;
1593}
1594
1597{
1598 if (!p || !set)
1599 goto error;
1600 if (p->output_format == ISL_FORMAT_ISL)
1602 else if (p->output_format == ISL_FORMAT_POLYLIB)
1603 return isl_set_print_polylib(set, p, 0);
1604 else if (p->output_format == ISL_FORMAT_EXT_POLYLIB)
1605 return isl_set_print_polylib(set, p, 1);
1606 else if (p->output_format == ISL_FORMAT_OMEGA)
1607 return isl_set_print_omega(set, p);
1608 else if (p->output_format == ISL_FORMAT_LATEX)
1610 isl_assert(set->ctx, 0, goto error);
1611error:
1613 return NULL;
1614}
1615
1618{
1619 if (!p || !map)
1620 goto error;
1621
1622 if (p->output_format == ISL_FORMAT_ISL)
1623 return isl_map_print_isl(map, p);
1624 else if (p->output_format == ISL_FORMAT_POLYLIB)
1625 return isl_map_print_polylib(map, p, 0);
1626 else if (p->output_format == ISL_FORMAT_EXT_POLYLIB)
1627 return isl_map_print_polylib(map, p, 1);
1628 else if (p->output_format == ISL_FORMAT_OMEGA)
1629 return isl_map_print_omega(map, p);
1630 else if (p->output_format == ISL_FORMAT_LATEX)
1631 return isl_map_print_latex(map, p);
1632 isl_assert(map->ctx, 0, goto error);
1633error:
1635 return NULL;
1636}
1637
1642
1643#undef BASE
1644#define BASE map
1645#include "isl_union_print_templ.c"
1646
1647/* Print the body of "uset" (everything except the parameter declarations)
1648 * to "p" in isl format.
1649 */
1652{
1653 return print_body_union_map(p, uset_to_umap(uset));
1654}
1655
1657{
1658 struct isl_union_print_data *data;
1659 data = (struct isl_union_print_data *)user;
1660
1661 if (!data->first)
1662 data->p = isl_printer_print_str(data->p, " \\cup ");
1663 data->first = 0;
1664
1665 data->p = isl_map_print_latex(map, data->p);
1667
1668 return isl_stat_ok;
1669}
1670
1673{
1674 struct isl_union_print_data data = { p, 1 };
1676 p = data.p;
1677 return p;
1678}
1679
1682{
1683 if (!p || !umap)
1684 goto error;
1685
1686 if (p->output_format == ISL_FORMAT_ISL)
1687 return print_union_map_isl(p, umap);
1688 if (p->output_format == ISL_FORMAT_LATEX)
1689 return isl_union_map_print_latex(umap, p);
1690
1692 "invalid output format for isl_union_map", goto error);
1693error:
1695 return NULL;
1696}
1697
1700{
1701 if (!p || !uset)
1702 goto error;
1703
1704 if (p->output_format == ISL_FORMAT_ISL)
1705 return print_union_map_isl(p, uset_to_umap(uset));
1706 if (p->output_format == ISL_FORMAT_LATEX)
1708
1710 "invalid output format for isl_union_set", goto error);
1711error:
1713 return NULL;
1714}
1715
1717{
1718 int i;
1719 int n;
1720
1721 if (!rec)
1722 return isl_size_error;
1723
1724 for (i = 0, n = 0; i < rec->n; ++i) {
1725 isl_bool is_zero = isl_poly_is_zero(rec->p[i]);
1726
1727 if (is_zero < 0)
1728 return isl_size_error;
1729 if (!is_zero)
1730 ++n;
1731 }
1732
1733 return n;
1734}
1735
1738{
1739 isl_poly_cst *cst;
1740 int neg;
1741
1742 cst = isl_poly_as_cst(poly);
1743 if (!cst)
1744 goto error;
1745 neg = !first && isl_int_is_neg(cst->n);
1746 if (!first)
1747 p = isl_printer_print_str(p, neg ? " - " : " + ");
1748 if (neg)
1749 isl_int_neg(cst->n, cst->n);
1750 if (isl_int_is_zero(cst->d)) {
1751 int sgn = isl_int_sgn(cst->n);
1752 p = isl_printer_print_str(p, sgn < 0 ? "-infty" :
1753 sgn == 0 ? "NaN" : "infty");
1754 } else
1755 p = isl_printer_print_isl_int(p, cst->n);
1756 if (neg)
1757 isl_int_neg(cst->n, cst->n);
1758 if (!isl_int_is_zero(cst->d) && !isl_int_is_one(cst->d)) {
1759 p = isl_printer_print_str(p, "/");
1760 p = isl_printer_print_isl_int(p, cst->d);
1761 }
1762 return p;
1763error:
1765 return NULL;
1766}
1767
1769 __isl_keep isl_space *space, __isl_keep isl_mat *div, int var)
1770{
1772
1774 if (total < 0)
1775 return isl_printer_free(p);
1776 if (var < total)
1777 p = print_term(space, NULL, space->ctx->one, 1 + var, p, 0);
1778 else
1779 p = print_div(space, div, var - total, p);
1780 return p;
1781}
1782
1784 __isl_keep isl_space *space, __isl_keep isl_mat *div, int var, int exp)
1785{
1786 p = print_base(p, space, div, var);
1787 if (exp == 1)
1788 return p;
1789 if (p->output_format == ISL_FORMAT_C) {
1790 int i;
1791 for (i = 1; i < exp; ++i) {
1792 p = isl_printer_print_str(p, "*");
1793 p = print_base(p, space, div, var);
1794 }
1795 } else {
1796 p = isl_printer_print_str(p, "^");
1797 p = isl_printer_print_int(p, exp);
1798 }
1799 return p;
1800}
1801
1802/* Print the polynomial "poly" defined over the domain space "space" and
1803 * local variables defined by "div" to "p".
1804 */
1808{
1809 int i, first, print_parens;
1810 isl_size n;
1811 isl_bool is_cst;
1812 isl_poly_rec *rec;
1813
1814 is_cst = isl_poly_is_cst(poly);
1815 if (!p || is_cst < 0 || !space || !div)
1816 goto error;
1817
1818 if (is_cst)
1819 return poly_print_cst(poly, p, 1);
1820
1821 rec = isl_poly_as_rec(poly);
1822 n = poly_rec_n_non_zero(rec);
1823 if (n < 0)
1824 return isl_printer_free(p);
1825 print_parens = n > 1;
1826 if (print_parens)
1827 p = isl_printer_print_str(p, "(");
1828 for (i = 0, first = 1; i < rec->n; ++i) {
1829 isl_bool is_zero = isl_poly_is_zero(rec->p[i]);
1830 isl_bool is_one = isl_poly_is_one(rec->p[i]);
1831 isl_bool is_negone = isl_poly_is_negone(rec->p[i]);
1832 isl_bool is_cst = isl_poly_is_cst(rec->p[i]);
1833
1834 if (is_zero < 0 || is_one < 0 || is_negone < 0)
1835 return isl_printer_free(p);
1836 if (is_zero)
1837 continue;
1838 if (is_negone) {
1839 if (!i)
1840 p = isl_printer_print_str(p, "-1");
1841 else if (first)
1842 p = isl_printer_print_str(p, "-");
1843 else
1844 p = isl_printer_print_str(p, " - ");
1845 } else if (is_cst && !is_one)
1846 p = poly_print_cst(rec->p[i], p, first);
1847 else {
1848 if (!first)
1849 p = isl_printer_print_str(p, " + ");
1850 if (i == 0 || !is_one)
1851 p = poly_print(rec->p[i], space, div, p);
1852 }
1853 first = 0;
1854 if (i == 0)
1855 continue;
1856 if (!is_one && !is_negone)
1857 p = isl_printer_print_str(p, " * ");
1858 p = print_pow(p, space, div, rec->poly.var, i);
1859 }
1860 if (print_parens)
1861 p = isl_printer_print_str(p, ")");
1862 return p;
1863error:
1865 return NULL;
1866}
1867
1870{
1871 if (!p || !qp)
1872 goto error;
1873 p = poly_print(qp->poly, qp->dim, qp->div, p);
1874 return p;
1875error:
1877 return NULL;
1878}
1879
1882{
1883 struct isl_print_space_data data = { 0 };
1884
1885 if (!p || !qp)
1886 goto error;
1887
1888 p = print_param_tuple(p, qp->dim, &data);
1889 p = isl_printer_print_str(p, "{ ");
1890 if (!isl_space_is_params(qp->dim)) {
1891 p = isl_print_space(qp->dim, p, 0, &data);
1892 p = isl_printer_print_str(p, " -> ");
1893 }
1894 p = print_qpolynomial(p, qp);
1895 p = isl_printer_print_str(p, " }");
1896 return p;
1897error:
1899 return NULL;
1900}
1901
1902/* Print the quasi-polynomial "qp" to "p" in C format, with the variable names
1903 * taken from the domain space "space".
1904 */
1907{
1908 isl_bool is_one;
1909 isl_val *den;
1910
1911 den = isl_qpolynomial_get_den(qp);
1912 qp = isl_qpolynomial_copy(qp);
1914 is_one = isl_val_is_one(den);
1915 if (is_one < 0)
1916 p = isl_printer_free(p);
1917 if (!is_one)
1918 p = isl_printer_print_str(p, "(");
1919 if (qp)
1920 p = poly_print(qp->poly, space, qp->div, p);
1921 else
1922 p = isl_printer_free(p);
1923 if (!is_one) {
1924 p = isl_printer_print_str(p, ")/");
1925 p = isl_printer_print_val(p, den);
1926 }
1928 isl_val_free(den);
1929 return p;
1930}
1931
1934{
1935 if (!p || !qp)
1936 goto error;
1937
1938 if (p->output_format == ISL_FORMAT_ISL)
1939 return print_qpolynomial_isl(p, qp);
1940 else if (p->output_format == ISL_FORMAT_C)
1941 return print_qpolynomial_c(p, qp->dim, qp);
1942 else
1943 isl_die(qp->dim->ctx, isl_error_unsupported,
1944 "output format not supported for isl_qpolynomials",
1945 goto error);
1946error:
1948 return NULL;
1949}
1950
1952 unsigned output_format)
1953{
1954 isl_printer *p;
1955
1956 if (!qp)
1957 return;
1958
1959 isl_assert(qp->dim->ctx, output_format == ISL_FORMAT_ISL, return);
1960 p = isl_printer_to_file(qp->dim->ctx, out);
1963}
1964
1967{
1968 int i;
1969 isl_qpolynomial_list *list;
1970 isl_size n;
1971
1972 list = isl_qpolynomial_fold_peek_list(fold);
1973 n = isl_qpolynomial_list_size(list);
1974 if (n < 0)
1975 return isl_printer_free(p);
1976 if (fold->type == isl_fold_min)
1977 p = isl_printer_print_str(p, "min");
1978 else if (fold->type == isl_fold_max)
1979 p = isl_printer_print_str(p, "max");
1980 p = isl_printer_print_str(p, "(");
1981 for (i = 0; i < n; ++i) {
1982 isl_qpolynomial *qp;
1983
1984 if (i)
1985 p = isl_printer_print_str(p, ", ");
1986 qp = isl_qpolynomial_list_peek(list, i);
1987 p = print_qpolynomial(p, qp);
1988 }
1989 p = isl_printer_print_str(p, ")");
1990 return p;
1991}
1992
1994 FILE *out, unsigned output_format)
1995{
1996 isl_printer *p;
1997
1998 if (!fold)
1999 return;
2000
2001 isl_assert(fold->dim->ctx, output_format == ISL_FORMAT_ISL, return);
2002
2003 p = isl_printer_to_file(fold->dim->ctx, out);
2005
2007}
2008
2011{
2012 struct isl_print_space_data data = { 0 };
2013 int i = 0;
2014
2015 for (i = 0; i < pwqp->n; ++i) {
2017
2018 if (i)
2019 p = isl_printer_print_str(p, "; ");
2021 if (!isl_space_is_params(space)) {
2022 p = isl_print_space(space, p, 0, &data);
2023 p = isl_printer_print_str(p, " -> ");
2024 }
2025 p = print_qpolynomial(p, pwqp->p[i].qp);
2026 p = print_disjuncts(set_to_map(pwqp->p[i].set), space, p, 0);
2028 }
2029
2030 return p;
2031}
2032
2035{
2036 struct isl_print_space_data data = { 0 };
2037
2038 if (!p || !pwqp)
2039 goto error;
2040
2041 p = print_param_tuple(p, pwqp->dim, &data);
2042 p = isl_printer_print_str(p, "{ ");
2043 if (pwqp->n == 0) {
2044 if (!isl_space_is_set(pwqp->dim)) {
2045 p = print_tuple(pwqp->dim, p, isl_dim_in, &data);
2046 p = isl_printer_print_str(p, " -> ");
2047 }
2048 p = isl_printer_print_str(p, "0");
2049 }
2051 p = isl_printer_print_str(p, " }");
2052 return p;
2053error:
2055 return NULL;
2056}
2057
2059 unsigned output_format)
2060{
2061 isl_printer *p;
2062
2063 if (!pwqp)
2064 return;
2065
2066 p = isl_printer_to_file(pwqp->dim->ctx, out);
2067 p = isl_printer_set_output_format(p, output_format);
2069
2071}
2072
2075{
2076 struct isl_print_space_data data = { 0 };
2077 int i = 0;
2078
2079 for (i = 0; i < pwf->n; ++i) {
2081
2082 if (i)
2083 p = isl_printer_print_str(p, "; ");
2085 if (!isl_space_is_params(space)) {
2086 p = isl_print_space(space, p, 0, &data);
2087 p = isl_printer_print_str(p, " -> ");
2088 }
2089 p = qpolynomial_fold_print(pwf->p[i].fold, p);
2090 p = print_disjuncts(set_to_map(pwf->p[i].set), space, p, 0);
2092 }
2093
2094 return p;
2095}
2096
2099{
2100 struct isl_print_space_data data = { 0 };
2101
2102 p = print_param_tuple(p, pwf->dim, &data);
2103 p = isl_printer_print_str(p, "{ ");
2104 if (pwf->n == 0) {
2105 if (!isl_space_is_set(pwf->dim)) {
2106 p = print_tuple(pwf->dim, p, isl_dim_in, &data);
2107 p = isl_printer_print_str(p, " -> ");
2108 }
2109 p = isl_printer_print_str(p, "0");
2110 }
2112 p = isl_printer_print_str(p, " }");
2113 return p;
2114}
2115
2118
2119/* We skip the constraint if it is implied by the div expression.
2120 *
2121 * *first indicates whether this is the first constraint in the conjunction and
2122 * is updated if the constraint is actually printed.
2123 */
2125 __isl_keep isl_local_space *ls, isl_int *c, const char *op, int *first)
2126{
2127 unsigned o_div;
2128 isl_size n_div;
2129 int div;
2130
2132 n_div = isl_local_space_dim(ls, isl_dim_div);
2133 if (n_div < 0)
2134 return isl_printer_free(p);
2135 div = isl_seq_last_non_zero(c + o_div, n_div);
2136 if (div >= 0) {
2137 isl_bool is_div = isl_local_space_is_div_constraint(ls, c, div);
2138 if (is_div < 0)
2139 return isl_printer_free(p);
2140 if (is_div)
2141 return p;
2142 }
2143
2144 if (!*first)
2145 p = isl_printer_print_str(p, " && ");
2146
2147 p = print_ls_affine_c(p, ls, c);
2148 p = isl_printer_print_str(p, " ");
2150 p = isl_printer_print_str(p, " 0");
2151
2152 *first = 0;
2153
2154 return p;
2155}
2156
2159 isl_int *c, unsigned len);
2160
2163{
2164 int i, j;
2165 int first = 1;
2166 isl_size n_div = isl_basic_set_dim(bset, isl_dim_div);
2168 isl_mat *div;
2169 isl_local_space *ls;
2170
2171 if (n_div < 0 || total < 0)
2172 return isl_printer_free(p);
2173
2174 total -= n_div;
2175 div = isl_basic_set_get_divs(bset);
2177 for (i = 0; i < bset->n_eq; ++i) {
2178 j = isl_seq_last_non_zero(bset->eq[i] + 1 + total, n_div);
2179 if (j < 0)
2180 p = print_constraint_c(p, ls,
2181 bset->eq[i], "==", &first);
2182 else {
2183 if (i)
2184 p = isl_printer_print_str(p, " && ");
2185 p = isl_printer_print_str(p, "(");
2186 p = print_ls_partial_affine_c(p, ls, bset->eq[i],
2187 1 + total + j);
2188 p = isl_printer_print_str(p, ") % ");
2190 bset->eq[i][1 + total + j]);
2191 p = isl_printer_print_str(p, " == 0");
2192 first = 0;
2193 }
2194 }
2195 for (i = 0; i < bset->n_ineq; ++i)
2196 p = print_constraint_c(p, ls, bset->ineq[i], ">=", &first);
2198 return p;
2199}
2200
2203{
2204 int i;
2205
2206 if (!set)
2207 return isl_printer_free(p);
2208
2209 if (set->n == 0)
2210 p = isl_printer_print_str(p, "0");
2211
2212 for (i = 0; i < set->n; ++i) {
2213 if (i)
2214 p = isl_printer_print_str(p, " || ");
2215 if (set->n > 1)
2216 p = isl_printer_print_str(p, "(");
2217 p = print_basic_set_c(p, space, set->p[i]);
2218 if (set->n > 1)
2219 p = isl_printer_print_str(p, ")");
2220 }
2221 return p;
2222}
2223
2224/* Print the piecewise quasi-polynomial "pwqp" to "p" in C format.
2225 */
2228{
2229 int i;
2231
2233 if (pwqp->n == 1 && isl_set_plain_is_universe(pwqp->p[0].set)) {
2234 p = print_qpolynomial_c(p, space, pwqp->p[0].qp);
2236 return p;
2237 }
2238
2239 for (i = 0; i < pwqp->n; ++i) {
2240 p = isl_printer_print_str(p, "(");
2241 p = print_set_c(p, space, pwqp->p[i].set);
2242 p = isl_printer_print_str(p, ") ? (");
2243 p = print_qpolynomial_c(p, space, pwqp->p[i].qp);
2244 p = isl_printer_print_str(p, ") : ");
2245 }
2246
2248 p = isl_printer_print_str(p, "0");
2249 return p;
2250}
2251
2254{
2255 if (!p || !pwqp)
2256 goto error;
2257
2258 if (p->output_format == ISL_FORMAT_ISL)
2260 else if (p->output_format == ISL_FORMAT_C)
2261 return print_pw_qpolynomial_c(p, pwqp);
2262 isl_assert(p->ctx, 0, goto error);
2263error:
2265 return NULL;
2266}
2267
2268#undef BASE
2269#define BASE pw_qpolynomial
2270#include "isl_union_print_templ.c"
2271
2274{
2275 if (!p || !upwqp)
2276 goto error;
2277
2278 if (p->output_format == ISL_FORMAT_ISL)
2279 return print_union_pw_qpolynomial_isl(p, upwqp);
2281 "invalid output format for isl_union_pw_qpolynomial",
2282 goto error);
2283error:
2285 return NULL;
2286}
2287
2288/* Print the quasi-polynomial reduction "fold" to "p" in C format,
2289 * with the variable names taken from the domain space "space".
2290 */
2294{
2295 int i;
2296 isl_qpolynomial_list *list;
2297 isl_size n;
2298
2299 list = isl_qpolynomial_fold_peek_list(fold);
2300 n = isl_qpolynomial_list_size(list);
2301 if (n < 0)
2302 return isl_printer_free(p);
2303 for (i = 0; i < n - 1; ++i)
2304 if (fold->type == isl_fold_min)
2305 p = isl_printer_print_str(p, "min(");
2306 else if (fold->type == isl_fold_max)
2307 p = isl_printer_print_str(p, "max(");
2308
2309 for (i = 0; i < n; ++i) {
2310 isl_qpolynomial *qp;
2311
2312 if (i)
2313 p = isl_printer_print_str(p, ", ");
2314 qp = isl_qpolynomial_list_peek(list, i);
2315 p = print_qpolynomial_c(p, space, qp);
2316 if (i)
2317 p = isl_printer_print_str(p, ")");
2318 }
2319 return p;
2320}
2321
2324{
2325 if (!p || !fold)
2326 goto error;
2327 if (p->output_format == ISL_FORMAT_ISL)
2328 return qpolynomial_fold_print(fold, p);
2329 else if (p->output_format == ISL_FORMAT_C)
2330 return print_qpolynomial_fold_c(p, fold->dim, fold);
2331 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
2332 goto error);
2333error:
2335 return NULL;
2336}
2337
2338/* Print the piecewise quasi-polynomial reduction "pwf" to "p" in C format.
2339 */
2342{
2343 int i;
2345
2347 if (pwf->n == 1 && isl_set_plain_is_universe(pwf->p[0].set)) {
2348 p = print_qpolynomial_fold_c(p, space, pwf->p[0].fold);
2350 return p;
2351 }
2352
2353 for (i = 0; i < pwf->n; ++i) {
2354 p = isl_printer_print_str(p, "(");
2355 p = print_set_c(p, space, pwf->p[i].set);
2356 p = isl_printer_print_str(p, ") ? (");
2357 p = print_qpolynomial_fold_c(p, space, pwf->p[i].fold);
2358 p = isl_printer_print_str(p, ") : ");
2359 }
2360
2362 p = isl_printer_print_str(p, "0");
2363 return p;
2364}
2365
2368{
2369 if (!p || !pwf)
2370 goto error;
2371
2372 if (p->output_format == ISL_FORMAT_ISL)
2373 return print_pw_qpolynomial_fold_isl(p, pwf);
2374 else if (p->output_format == ISL_FORMAT_C)
2375 return print_pw_qpolynomial_fold_c(p, pwf);
2376 isl_assert(p->ctx, 0, goto error);
2377error:
2379 return NULL;
2380}
2381
2383 FILE *out, unsigned output_format)
2384{
2385 isl_printer *p;
2386
2387 if (!pwf)
2388 return;
2389
2390 p = isl_printer_to_file(pwf->dim->ctx, out);
2391 p = isl_printer_set_output_format(p, output_format);
2393
2395}
2396
2397#undef BASE
2398#define BASE pw_qpolynomial_fold
2399#include "isl_union_print_templ.c"
2400
2404{
2405 if (!p || !upwf)
2406 goto error;
2407
2408 if (p->output_format == ISL_FORMAT_ISL)
2409 return print_union_pw_qpolynomial_fold_isl(p, upwf);
2411 "invalid output format for isl_union_pw_qpolynomial_fold",
2412 goto error);
2413error:
2415 return NULL;
2416}
2417
2418/* Print the isl_constraint "c" to "p".
2419 */
2422{
2423 struct isl_print_space_data data = { 0 };
2424 isl_local_space *ls;
2426 isl_bool exists;
2427
2428 if (!p || !c)
2429 goto error;
2430
2432 if (!ls)
2433 return isl_printer_free(p);
2435 p = print_param_tuple(p, space, &data);
2436 p = isl_printer_print_str(p, "{ ");
2437 p = isl_print_space(space, p, 0, &data);
2438 p = isl_printer_print_str(p, " : ");
2439 exists = need_exists(p, ls->div);
2440 if (exists < 0)
2441 p = isl_printer_free(p);
2442 if (exists >= 0 && exists)
2443 p = open_exists(p, space, ls->div, 0);
2444 p = print_affine_of_len(space, ls->div, p, c->v->el, c->v->size);
2446 p = isl_printer_print_str(p, " = 0");
2447 else
2448 p = isl_printer_print_str(p, " >= 0");
2449 if (exists >= 0 && exists)
2451 p = isl_printer_print_str(p, " }");
2454
2455 return p;
2456error:
2458 return NULL;
2459}
2460
2463{
2464 struct isl_print_space_data data = { 0 };
2465
2466 if (!space)
2467 goto error;
2468
2469 p = print_param_tuple(p, space, &data);
2470
2471 p = isl_printer_print_str(p, "{ ");
2474 else
2475 p = isl_print_space(space, p, 0, &data);
2476 p = isl_printer_print_str(p, " }");
2477
2478 return p;
2479error:
2481 return NULL;
2482}
2483
2486{
2487 if (!p || !space)
2488 return isl_printer_free(p);
2489 if (p->output_format == ISL_FORMAT_ISL)
2491 else if (p->output_format == ISL_FORMAT_OMEGA)
2493
2495 "output format not supported for space",
2496 return isl_printer_free(p));
2497}
2498
2501{
2502 struct isl_print_space_data data = { 0 };
2503 isl_size n_div;
2504
2505 n_div = isl_local_space_dim(ls, isl_dim_div);
2506 if (n_div < 0)
2507 goto error;
2508
2509 p = print_param_tuple(p, ls->dim, &data);
2510 p = isl_printer_print_str(p, "{ ");
2511 p = isl_print_space(ls->dim, p, 0, &data);
2512 if (n_div > 0) {
2513 p = isl_printer_print_str(p, " : ");
2515 p = print_div_list(p, ls->dim, ls->div, 0, 1);
2517 } else if (isl_space_is_params(ls->dim))
2519 p = isl_printer_print_str(p, " }");
2520 return p;
2521error:
2523 return NULL;
2524}
2525
2526/* Look for the last of the "n" integer divisions that is used in "aff" and
2527 * that can be printed as a modulo and
2528 * return the position of this integer division.
2529 * Return "n" if no such integer division can be found.
2530 * Return isl_size_error on error.
2531 *
2532 * In particular, look for an integer division that appears in "aff"
2533 * with a coefficient that is a multiple of the denominator
2534 * of the integer division.
2535 * That is, check if the numerator of "aff" is of the form
2536 *
2537 * f(...) + a m floor(g/m)
2538 *
2539 * and return the position of "floor(g/m)".
2540 *
2541 * Note that, unlike print_as_modulo_pos, no check needs to be made
2542 * for whether the integer division can be printed, since it will
2543 * need to be printed as an integer division anyway if it is not printed
2544 * as a modulo.
2545 */
2547 unsigned n)
2548{
2549 isl_size o_div;
2550 int i;
2551
2552 if (n == 0)
2553 return n;
2555 if (o_div < 0)
2556 return isl_size_error;
2557 for (i = n - 1; i >= 0; --i) {
2558 if (isl_int_is_zero(aff->v->el[1 + o_div + i]))
2559 continue;
2560 if (isl_int_is_divisible_by(aff->v->el[1 + o_div + i],
2561 aff->ls->div->row[i][0]))
2562 return i;
2563 }
2564
2565 return n;
2566}
2567
2568/* Print the numerator of the affine expression "aff" to "p",
2569 * with the variable names taken from "space".
2570 */
2573{
2575
2577 if (total < 0)
2578 return isl_printer_free(p);
2579 p = print_affine_of_len(space, aff->ls->div, p,
2580 aff->v->el + 1, 1 + total);
2581
2582 return p;
2583}
2584
2587
2588/* Print the modulo term "c" * ("aff" mod "mod") to "p",
2589 * with the variable names taken from "space".
2590 * If "first" is set, then this is the first term of an expression.
2591 */
2595{
2596 isl_bool is_one, is_neg;
2597
2598 is_neg = isl_val_is_neg(c);
2599 if (is_neg < 0)
2600 p = isl_printer_free(p);
2601 if (!first) {
2602 if (is_neg)
2603 c = isl_val_neg(c);
2604 p = isl_printer_print_str(p, is_neg ? " - " : " + ");
2605 }
2606 is_one = isl_val_is_one(c);
2607 if (is_one < 0)
2608 p = isl_printer_free(p);
2609 if (!is_one) {
2611 p = isl_printer_print_str(p, "*(");
2612 }
2613 p = isl_printer_print_str(p, "(");
2614 p = print_aff_num(p, space, aff);
2615 p = isl_printer_print_str(p, ")");
2616 p = isl_printer_print_str(p, " mod ");
2617 p = isl_printer_print_val(p, mod);
2618 if (!is_one)
2619 p = isl_printer_print_str(p, ")");
2620
2621 isl_val_free(c);
2622
2623 return p;
2624}
2625
2626/* Print the numerator of the affine expression "aff" to "p",
2627 * with the variable names taken from "space",
2628 * given that the numerator of "aff" is of the form
2629 *
2630 * f(...) + a m floor(g/m)
2631 *
2632 * with "floor(g/m)" the integer division at position "last".
2633 *
2634 * First replace "aff" by its numerator and rewrite it as
2635 *
2636 * f(...) + a g - a (g mod m)
2637 *
2638 * Recursively write out (the numerator of) "f(...) + a g"
2639 * (which may involve other modulo expressions) and
2640 * then write out "- a (g mod m)".
2641 */
2643 __isl_keep isl_space *space, __isl_keep isl_aff *aff, unsigned last)
2644{
2645 isl_bool is_zero;
2646 isl_val *a, *m;
2647 isl_aff *div, *term;
2648
2649 aff = isl_aff_copy(aff);
2653 div = isl_aff_get_div(aff, last);
2656 div = isl_aff_scale_val(div, isl_val_copy(m));
2658 aff = isl_aff_add(aff, term);
2659
2660 is_zero = isl_aff_plain_is_zero(aff);
2661 if (is_zero < 0) {
2662 p = isl_printer_free(p);
2663 } else {
2664 if (!is_zero)
2665 p = print_aff_num(p, space, aff);
2666 a = isl_val_neg(a);
2667 p = print_mod_term(p, space, div, is_zero, isl_val_copy(a), m);
2668 }
2669
2670 isl_val_free(a);
2671 isl_val_free(m);
2673 isl_aff_free(div);
2674
2675 return p;
2676}
2677
2678/* Print the numerator of the affine expression "aff" to "p",
2679 * with the variable names taken from "space",
2680 * separating out any (obvious) modulo expressions.
2681 *
2682 * In particular, look for modulo expressions in "aff",
2683 * separating them out if found and simply printing out "aff" otherwise.
2684 */
2687{
2688 isl_size n_div, mod;
2689
2690 n_div = isl_aff_dim(aff, isl_dim_div);
2691 if (n_div < 0)
2692 return isl_printer_free(p);
2693 mod = last_modulo(p, aff, n_div);
2694 if (mod < 0)
2695 return isl_printer_free(p);
2696 if (mod < n_div)
2697 return print_aff_num_mod(p, space, aff, mod);
2698 else
2699 return print_aff_num_base(p, space, aff);
2700}
2701
2702/* Print the (potentially rational) affine expression "aff" to "p",
2703 * with the variable names taken from "space".
2704 */
2707{
2708 if (isl_aff_is_nan(aff))
2709 return isl_printer_print_str(p, "NaN");
2710
2711 p = isl_printer_print_str(p, "(");
2712 p = print_aff_num(p, space, aff);
2713 if (isl_int_is_one(aff->v->el[0]))
2714 p = isl_printer_print_str(p, ")");
2715 else {
2716 p = isl_printer_print_str(p, ")/");
2717 p = isl_printer_print_isl_int(p, aff->v->el[0]);
2718 }
2719
2720 return p;
2721}
2722
2725{
2726 struct isl_print_space_data data = { 0 };
2727
2728 if (isl_space_is_params(aff->ls->dim))
2729 ;
2730 else {
2731 p = print_tuple(aff->ls->dim, p, isl_dim_set, &data);
2732 p = isl_printer_print_str(p, " -> ");
2733 }
2734 p = isl_printer_print_str(p, "[");
2735 p = print_aff_body(p, aff->ls->dim, aff);
2736 p = isl_printer_print_str(p, "]");
2737
2738 return p;
2739}
2740
2743{
2744 struct isl_print_space_data data = { 0 };
2745
2746 if (!aff)
2747 goto error;
2748
2749 p = print_param_tuple(p, aff->ls->dim, &data);
2750 p = isl_printer_print_str(p, "{ ");
2751 p = print_body_aff(p, aff);
2752 p = isl_printer_print_str(p, " }");
2753 return p;
2754error:
2756 return NULL;
2757}
2758
2759/* Print dimension "pos" of data->space to "p" as a zero.
2760 */
2762 struct isl_print_space_data *data, unsigned pos)
2763{
2764 return isl_printer_print_str(p, "0");
2765}
2766
2767#undef BASE
2768#define BASE aff
2769#include "isl_pw_print_templ.c"
2770
2772 __isl_keep isl_local_space *ls, enum isl_dim_type type, unsigned pos)
2773{
2774 if (type == isl_dim_div) {
2775 p = isl_printer_print_str(p, "floord(");
2776 p = print_ls_affine_c(p, ls, ls->div->row[pos] + 1);
2777 p = isl_printer_print_str(p, ", ");
2778 p = isl_printer_print_isl_int(p, ls->div->row[pos][0]);
2779 p = isl_printer_print_str(p, ")");
2780 } else {
2781 const char *name;
2782
2783 name = isl_space_get_dim_name(ls->dim, type, pos);
2784 if (!name)
2785 name = "UNNAMED";
2787 }
2788 return p;
2789}
2790
2792 __isl_keep isl_local_space *ls, isl_int c, unsigned pos)
2793{
2794 enum isl_dim_type type;
2795
2796 if (!p || !ls)
2797 return isl_printer_free(p);
2798
2799 if (pos == 0)
2800 return isl_printer_print_isl_int(p, c);
2801
2802 if (isl_int_is_one(c))
2803 ;
2804 else if (isl_int_is_negone(c))
2805 p = isl_printer_print_str(p, "-");
2806 else {
2808 p = isl_printer_print_str(p, "*");
2809 }
2810 if (pos2type(ls->dim, &type, &pos) < 0)
2811 return isl_printer_free(p);
2812 p = print_ls_name_c(p, ls, type, pos);
2813 return p;
2814}
2815
2818 isl_int *c, unsigned len)
2819{
2820 int i;
2821 int first;
2822
2823 for (i = 0, first = 1; i < len; ++i) {
2824 int flip = 0;
2825 if (isl_int_is_zero(c[i]))
2826 continue;
2827 if (!first) {
2828 if (isl_int_is_neg(c[i])) {
2829 flip = 1;
2830 isl_int_neg(c[i], c[i]);
2831 p = isl_printer_print_str(p, " - ");
2832 } else
2833 p = isl_printer_print_str(p, " + ");
2834 }
2835 first = 0;
2836 p = print_ls_term_c(p, ls, c[i], i);
2837 if (flip)
2838 isl_int_neg(c[i], c[i]);
2839 }
2840 if (first)
2841 p = isl_printer_print_str(p, "0");
2842 return p;
2843}
2844
2854
2857{
2859
2861 if (total < 0)
2862 return isl_printer_free(p);
2863 if (!isl_int_is_one(aff->v->el[0]))
2864 p = isl_printer_print_str(p, "(");
2865 p = print_ls_partial_affine_c(p, aff->ls, aff->v->el + 1, 1 + total);
2866 if (!isl_int_is_one(aff->v->el[0])) {
2867 p = isl_printer_print_str(p, ")/");
2868 p = isl_printer_print_isl_int(p, aff->v->el[0]);
2869 }
2870 return p;
2871}
2872
2873/* In the C format, we cannot express that "pwaff" may be undefined
2874 * on parts of the domain space. We therefore assume that the expression
2875 * will only be evaluated on its definition domain and compute the gist
2876 * of each cell with respect to this domain.
2877 */
2879 __isl_keep isl_pw_aff *pwaff)
2880{
2881 isl_set *domain;
2882 isl_ast_build *build;
2883 isl_ast_expr *expr;
2884
2885 if (pwaff->n < 1)
2887 "cannot print empty isl_pw_aff in C format",
2888 return isl_printer_free(p));
2889
2892 expr = isl_ast_build_expr_from_pw_aff(build, isl_pw_aff_copy(pwaff));
2894 isl_ast_expr_free(expr);
2895 isl_ast_build_free(build);
2896
2897 return p;
2898}
2899
2902{
2903 if (!p || !aff)
2904 goto error;
2905
2906 if (p->output_format == ISL_FORMAT_ISL)
2907 return print_aff_isl(p, aff);
2908 else if (p->output_format == ISL_FORMAT_C)
2909 return print_aff_c(p, aff);
2910 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
2911 goto error);
2912error:
2914 return NULL;
2915}
2916
2918 __isl_keep isl_pw_aff *pwaff)
2919{
2920 if (!p || !pwaff)
2921 goto error;
2922
2923 if (p->output_format == ISL_FORMAT_ISL)
2924 return print_pw_aff_isl(p, pwaff);
2925 else if (p->output_format == ISL_FORMAT_C)
2926 return print_pw_aff_c(p, pwaff);
2927 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
2928 goto error);
2929error:
2931 return NULL;
2932}
2933
2934#undef BASE
2935#define BASE pw_aff
2936#include "isl_union_print_templ.c"
2937
2938/* Print the isl_union_pw_aff "upa" to "p".
2939 *
2940 * We currently only support an isl format.
2941 */
2944{
2945 if (!p || !upa)
2946 return isl_printer_free(p);
2947
2948 if (p->output_format == ISL_FORMAT_ISL)
2949 return print_union_pw_aff_isl(p, upa);
2951 "unsupported output format", return isl_printer_free(p));
2952}
2953
2954/* Print dimension "pos" of data->space to "p".
2955 *
2956 * data->user is assumed to be an isl_multi_aff.
2957 *
2958 * If the current dimension is an output dimension, then print
2959 * the corresponding expression. Otherwise, print the name of the dimension.
2960 * Make sure to use the domain space for printing names as
2961 * that is the space that will be used for printing constraints (if any).
2962 */
2964 struct isl_print_space_data *data, unsigned pos)
2965{
2966 isl_multi_aff *ma = data->user;
2968
2969 space = isl_multi_aff_get_domain_space(ma);
2970 if (data->type == isl_dim_out) {
2971 p = print_aff_body(p, space, ma->u.p[pos]);
2972 } else {
2973 enum isl_dim_type type = data->type;
2974
2975 if (type == isl_dim_in)
2976 type = isl_dim_set;
2977 p = print_name(space, p, type, pos, data->latex);
2978 }
2980
2981 return p;
2982}
2983
2986{
2987 struct isl_print_space_data data = { 0 };
2988
2989 data.print_dim = &print_dim_ma;
2990 data.user = maff;
2991 return isl_print_space(maff->space, p, 0, &data);
2992}
2993
2996{
2997 struct isl_print_space_data data = { 0 };
2998
2999 if (!maff)
3000 goto error;
3001
3002 p = print_param_tuple(p, maff->space, &data);
3003 p = isl_printer_print_str(p, "{ ");
3004 p = print_body_multi_aff(p, maff);
3005 p = isl_printer_print_str(p, " }");
3006 return p;
3007error:
3009 return NULL;
3010}
3011
3014{
3015 if (!p || !maff)
3016 goto error;
3017
3018 if (p->output_format == ISL_FORMAT_ISL)
3019 return print_multi_aff_isl(p, maff);
3020 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
3021 goto error);
3022error:
3024 return NULL;
3025}
3026
3027#undef BASE
3028#define BASE multi_aff
3029#include "isl_pw_print_templ.c"
3030
3031/* Print the unnamed, single-dimensional piecewise multi affine expression "pma"
3032 * to "p".
3033 */
3036{
3037 int i;
3039
3041 for (i = 0; i < pma->n - 1; ++i) {
3042 p = isl_printer_print_str(p, "(");
3043 p = print_set_c(p, space, pma->p[i].set);
3044 p = isl_printer_print_str(p, ") ? (");
3045 p = print_aff_c(p, pma->p[i].maff->u.p[0]);
3046 p = isl_printer_print_str(p, ") : ");
3047 }
3049
3050 return print_aff_c(p, pma->p[pma->n - 1].maff->u.p[0]);
3051}
3052
3055{
3056 isl_size n;
3057 const char *name;
3058
3059 if (!pma)
3060 goto error;
3061 if (pma->n < 1)
3063 "cannot print empty isl_pw_multi_aff in C format",
3064 goto error);
3066 if (n < 0)
3067 return isl_printer_free(p);
3069 if (!name && n == 1)
3071 if (!name)
3073 "cannot print unnamed isl_pw_multi_aff in C format",
3074 goto error);
3075
3077 if (n != 0)
3079 "not supported yet", goto error);
3080
3081 return p;
3082error:
3084 return NULL;
3085}
3086
3089{
3090 if (!p || !pma)
3091 goto error;
3092
3093 if (p->output_format == ISL_FORMAT_ISL)
3094 return print_pw_multi_aff_isl(p, pma);
3095 if (p->output_format == ISL_FORMAT_C)
3096 return print_pw_multi_aff_c(p, pma);
3097 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
3098 goto error);
3099error:
3101 return NULL;
3102}
3103
3104#undef BASE
3105#define BASE pw_multi_aff
3106#include "isl_union_print_templ.c"
3107
3110{
3111 if (!p || !upma)
3112 goto error;
3113
3114 if (p->output_format == ISL_FORMAT_ISL)
3115 return print_union_pw_multi_aff_isl(p, upma);
3116 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
3117 goto error);
3118error:
3120 return NULL;
3121}
3122
3123/* Print dimension "pos" of data->space to "p".
3124 *
3125 * data->user is assumed to be an isl_multi_pw_aff.
3126 *
3127 * If the current dimension is an output dimension, then print
3128 * the corresponding piecewise affine expression.
3129 * Otherwise, print the name of the dimension.
3130 * Make sure to use the same space in both cases.
3131 * In particular, use the domain space for printing names as
3132 * that is the space that is used for printing constraints.
3133 */
3135 struct isl_print_space_data *data, unsigned pos)
3136{
3137 int i;
3138 int need_parens;
3140 isl_multi_pw_aff *mpa = data->user;
3141 isl_pw_aff *pa;
3142
3143 if (data->type != isl_dim_out) {
3144 enum isl_dim_type type = data->type;
3145
3146 if (type == isl_dim_in)
3147 type = isl_dim_set;
3148 space = isl_multi_pw_aff_get_domain_space(mpa);
3149 p = print_name(space, p, type, pos, data->latex);
3151 return p;
3152 }
3153
3154 pa = mpa->u.p[pos];
3155 if (pa->n == 0)
3156 return isl_printer_print_str(p, "(0 : false)");
3157
3158 need_parens = pa->n != 1 || !isl_set_plain_is_universe(pa->p[0].set);
3159 if (need_parens)
3160 p = isl_printer_print_str(p, "(");
3161 space = isl_multi_pw_aff_get_domain_space(mpa);
3162 for (i = 0; i < pa->n; ++i) {
3163
3164 if (i)
3165 p = isl_printer_print_str(p, "; ");
3166 p = print_aff_body(p, space, pa->p[i].aff);
3167 p = print_disjuncts(pa->p[i].set, space, p, 0);
3168 }
3170 if (need_parens)
3171 p = isl_printer_print_str(p, ")");
3172
3173 return p;
3174}
3175
3176/* Print "mpa" to "p" in isl format.
3177 *
3178 * If "mpa" is zero-dimensional and has a non-trivial explicit domain,
3179 * then it is printed after the tuple of affine expressions.
3180 */
3183{
3184 struct isl_print_space_data data = { 0 };
3185 isl_bool has_domain;
3186
3187 if (!mpa)
3188 return isl_printer_free(p);
3189
3190 p = print_param_tuple(p, mpa->space, &data);
3191 p = isl_printer_print_str(p, "{ ");
3192 data.print_dim = &print_dim_mpa;
3193 data.user = mpa;
3194 p = isl_print_space(mpa->space, p, 0, &data);
3196 if (has_domain < 0)
3197 return isl_printer_free(p);
3198 if (has_domain) {
3200
3201 space = isl_space_domain(isl_space_copy(mpa->space));
3202 p = print_disjuncts_set(mpa->u.dom, space, p, 0);
3204 }
3205 p = isl_printer_print_str(p, " }");
3206 return p;
3207}
3208
3211{
3212 if (!p || !mpa)
3213 return isl_printer_free(p);
3214
3215 if (p->output_format == ISL_FORMAT_ISL)
3216 return print_multi_pw_aff_isl(p, mpa);
3217 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
3218 return isl_printer_free(p));
3219}
3220
3221/* Print dimension "pos" of data->space to "p".
3222 *
3223 * data->user is assumed to be an isl_multi_val.
3224 *
3225 * If the current dimension is an output dimension, then print
3226 * the corresponding value. Otherwise, print the name of the dimension.
3227 */
3229 struct isl_print_space_data *data, unsigned pos)
3230{
3231 isl_multi_val *mv = data->user;
3232
3233 if (data->type == isl_dim_out)
3234 return isl_printer_print_val(p, mv->u.p[pos]);
3235 else
3236 return print_name(data->space, p, data->type, pos, data->latex);
3237}
3238
3239/* Print the isl_multi_val "mv" to "p" in isl format.
3240 */
3243{
3244 struct isl_print_space_data data = { 0 };
3245
3246 if (!mv)
3247 return isl_printer_free(p);
3248
3249 p = print_param_tuple(p, mv->space, &data);
3250 p = isl_printer_print_str(p, "{ ");
3251 data.print_dim = &print_dim_mv;
3252 data.user = mv;
3253 p = isl_print_space(mv->space, p, 0, &data);
3254 p = isl_printer_print_str(p, " }");
3255 return p;
3256}
3257
3258/* Print the isl_multi_val "mv" to "p".
3259 *
3260 * Currently only supported in isl format.
3261 */
3264{
3265 if (!p || !mv)
3266 return isl_printer_free(p);
3267
3268 if (p->output_format == ISL_FORMAT_ISL)
3269 return print_multi_val_isl(p, mv);
3270 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
3271 return isl_printer_free(p));
3272}
3273
3274/* Print dimension "pos" of data->space to "p".
3275 *
3276 * data->user is assumed to be an isl_multi_id.
3277 *
3278 * If the current dimension is an output dimension, then print
3279 * the corresponding identifier. Otherwise, print the name of the dimension.
3280 */
3282 struct isl_print_space_data *data, unsigned pos)
3283{
3284 isl_multi_id *mi = data->user;
3285
3286 if (data->type == isl_dim_out)
3287 return isl_printer_print_id(p, mi->u.p[pos]);
3288 else
3289 return print_name(data->space, p, data->type, pos, data->latex);
3290}
3291
3292/* Print the isl_multi_id "mi" to "p" in isl format.
3293 */
3296{
3298 struct isl_print_space_data data = { 0 };
3299
3300 space = isl_multi_id_peek_space(mi);
3301 p = print_param_tuple(p, space, &data);
3302 p = isl_printer_print_str(p, "{ ");
3303 data.print_dim = &print_dim_mi;
3304 data.user = mi;
3305 p = isl_print_space(space, p, 0, &data);
3306 p = isl_printer_print_str(p, " }");
3307 return p;
3308}
3309
3310/* Print the isl_multi_id "mi" to "p".
3311 *
3312 * Currently only supported in isl format.
3313 */
3316{
3317 if (!p || !mi)
3318 return isl_printer_free(p);
3319
3320 if (p->output_format == ISL_FORMAT_ISL)
3321 return print_multi_id_isl(p, mi);
3323 "unsupported output format", return isl_printer_free(p));
3324}
3325
3326/* Print dimension "pos" of data->space to "p".
3327 *
3328 * data->user is assumed to be an isl_multi_union_pw_aff.
3329 *
3330 * The current dimension is necessarily a set dimension, so
3331 * we print the corresponding isl_union_pw_aff, including
3332 * the braces.
3333 */
3335 struct isl_print_space_data *data, unsigned pos)
3336{
3338 isl_union_pw_aff *upa;
3339
3340 upa = isl_multi_union_pw_aff_get_union_pw_aff(mupa, pos);
3341 p = print_body_union_pw_aff(p, upa);
3343
3344 return p;
3345}
3346
3347/* Print the isl_multi_union_pw_aff "mupa" to "p" in isl format.
3348 *
3349 * If "mupa" is zero-dimensional and has a non-trivial explicit domain,
3350 * then it is printed after the tuple of affine expressions.
3351 * In order to clarify that this domain belongs to the expression,
3352 * the tuple along with the domain are placed inside parentheses.
3353 * If "mupa" has any parameters, then the opening parenthesis
3354 * appears after the parameter declarations.
3355 */
3358{
3359 struct isl_print_space_data data = { 0 };
3360 isl_bool has_domain;
3362
3363 if (!mupa)
3364 return isl_printer_free(p);
3366 if (has_domain < 0)
3367 return isl_printer_free(p);
3368
3369 space = isl_multi_union_pw_aff_get_space(mupa);
3370 p = print_param_tuple(p, space, &data);
3371
3372 if (has_domain)
3373 p = isl_printer_print_str(p, "(");
3374
3376 data.user = mupa;
3377
3378 p = isl_print_space(space, p, 0, &data);
3380
3381 if (has_domain) {
3382 p = isl_printer_print_str(p, " : ");
3384 p = isl_printer_print_str(p, ")");
3385 }
3386
3387 return p;
3388}
3389
3390/* Print the isl_multi_union_pw_aff "mupa" to "p" in isl format.
3391 *
3392 * We currently only support an isl format.
3393 */
3396{
3397 if (!p || !mupa)
3398 return isl_printer_free(p);
3399
3400 if (p->output_format == ISL_FORMAT_ISL)
3403 "unsupported output format", return isl_printer_free(p));
3404}
__isl_null isl_aff * isl_aff_free(__isl_take isl_aff *aff)
Definition isl_aff.c:449
__isl_null isl_union_pw_aff * isl_union_pw_aff_free(__isl_take isl_union_pw_aff *upa)
__isl_give isl_val * isl_aff_get_coefficient_val(__isl_keep isl_aff *aff, enum isl_dim_type type, int pos)
Definition isl_aff.c:852
__isl_overload __isl_give isl_aff * isl_aff_scale_val(__isl_take isl_aff *aff, __isl_take isl_val *v)
Definition isl_aff.c:2075
__isl_give isl_val * isl_aff_get_denominator_val(__isl_keep isl_aff *aff)
Definition isl_aff.c:819
isl_bool isl_aff_plain_is_zero(__isl_keep isl_aff *aff)
Definition isl_aff.c:757
__isl_give isl_aff * isl_aff_set_coefficient_si(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, int v)
Definition isl_aff.c:1221
__isl_give isl_aff * isl_aff_copy(__isl_keep isl_aff *aff)
Definition isl_aff.c:145
isl_size isl_pw_multi_aff_dim(__isl_keep isl_pw_multi_aff *pma, enum isl_dim_type type)
__isl_give isl_space * isl_pw_multi_aff_get_domain_space(__isl_keep isl_pw_multi_aff *pma)
isl_size isl_aff_dim(__isl_keep isl_aff *aff, enum isl_dim_type type)
Definition isl_aff.c:509
const char * isl_pw_multi_aff_get_tuple_name(__isl_keep isl_pw_multi_aff *pma, enum isl_dim_type type)
__isl_export __isl_give isl_aff * isl_aff_add(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:1976
__isl_give isl_aff * isl_aff_get_div(__isl_keep isl_aff *aff, int pos)
Definition isl_aff.c:1439
__isl_export __isl_give isl_set * isl_pw_aff_domain(__isl_take isl_pw_aff *pwaff)
__isl_give isl_pw_aff * isl_pw_aff_copy(__isl_keep isl_pw_aff *pwaff)
isl_bool isl_aff_is_nan(__isl_keep isl_aff *aff)
Definition isl_aff.c:772
struct isl_union_pw_multi_aff isl_union_pw_multi_aff
Definition aff_type.h:38
struct isl_union_pw_aff isl_union_pw_aff
Definition aff_type.h:23
struct isl_multi_aff isl_multi_aff
Definition aff_type.h:29
struct isl_multi_pw_aff isl_multi_pw_aff
Definition aff_type.h:43
struct isl_multi_union_pw_aff isl_multi_union_pw_aff
Definition aff_type.h:46
__isl_null isl_ast_expr * isl_ast_expr_free(__isl_take isl_ast_expr *expr)
Definition isl_ast.c:243
__isl_give isl_printer * isl_printer_print_ast_expr(__isl_take isl_printer *p, __isl_keep isl_ast_expr *expr)
Definition isl_ast.c:2600
__isl_export __isl_give isl_ast_build * isl_ast_build_from_context(__isl_take isl_set *set)
__isl_overload __isl_give isl_ast_expr * isl_ast_build_expr_from_pw_aff(__isl_keep isl_ast_build *build, __isl_take isl_pw_aff *pa)
__isl_null isl_ast_build * isl_ast_build_free(__isl_take isl_ast_build *build)
static __isl_give isl_basic_map * bset_to_bmap(__isl_take isl_basic_set *bset)
Definition bset_to_bmap.c:7
__isl_give isl_local_space * isl_constraint_get_local_space(__isl_keep isl_constraint *constraint)
isl_bool isl_constraint_is_equality(__isl_keep isl_constraint *constraint)
#define __isl_take
Definition ctx.h:22
isl_stat
Definition ctx.h:84
@ isl_stat_error
Definition ctx.h:85
@ isl_stat_ok
Definition ctx.h:86
#define __isl_give
Definition ctx.h:19
#define isl_size_error
Definition ctx.h:98
#define isl_die(ctx, errno, msg, code)
Definition ctx.h:138
#define isl_assert(ctx, test, code)
Definition ctx.h:153
isl_bool isl_bool_ok(int b)
Definition isl_ctx.c:58
@ isl_error_unsupported
Definition ctx.h:82
@ isl_error_invalid
Definition ctx.h:80
#define isl_calloc_array(ctx, type, n)
Definition ctx.h:133
#define ISL_F_ISSET(p, f)
Definition ctx.h:118
#define __isl_keep
Definition ctx.h:25
int isl_size
Definition ctx.h:97
isl_bool isl_bool_not(isl_bool b)
Definition isl_ctx.c:44
isl_bool
Definition ctx.h:89
@ isl_bool_false
Definition ctx.h:91
@ isl_bool_true
Definition ctx.h:92
@ isl_bool_error
Definition ctx.h:90
m
Definition guard1-0.c:2
isl_stat isl_stat void * user
Definition hmap.h:39
__isl_give isl_printer * isl_printer_print_id(__isl_take isl_printer *p, __isl_keep isl_id *id)
Definition isl_id.c:240
struct isl_multi_id isl_multi_id
Definition id_type.h:16
int GMPQAPI sgn(mp_rat op)
void GMPZAPI neg(mp_int rop, mp_int op)
isl_size isl_aff_domain_dim(__isl_keep isl_aff *aff, enum isl_dim_type type)
Definition isl_aff.c:498
isl_bool isl_multi_pw_aff_has_non_trivial_domain(__isl_keep isl_multi_pw_aff *mpa)
Definition isl_aff.c:6796
isl_bool isl_multi_union_pw_aff_has_non_trivial_domain(__isl_keep isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:8681
isl_size isl_aff_domain_offset(__isl_keep isl_aff *aff, enum isl_dim_type type)
Definition isl_aff.c:535
static __isl_give isl_ast_expr * var(struct isl_ast_add_term_data *data, enum isl_dim_type type, int pos)
static int count(int *con, unsigned len, int status)
__isl_keep isl_qpolynomial_list * isl_qpolynomial_fold_peek_list(__isl_keep isl_qpolynomial_fold *fold)
Definition isl_fold.c:161
#define isl_int_is_zero(i)
Definition isl_int.h:31
#define isl_int_is_one(i)
Definition isl_int.h:32
#define isl_int_is_negone(i)
Definition isl_int.h:33
__isl_give isl_printer * isl_printer_print_isl_int(__isl_take isl_printer *p, isl_int i)
#define isl_int_is_neg(i)
Definition isl_int.h:35
#define isl_int_neg(r, i)
Definition isl_int_gmp.h:24
#define isl_int_abs_eq(i, j)
Definition isl_int_gmp.h:64
#define isl_int_is_divisible_by(i, j)
Definition isl_int_gmp.h:69
#define isl_int_eq(i, j)
Definition isl_int_gmp.h:57
#define isl_int_divexact(r, i, j)
Definition isl_int_gmp.h:44
#define isl_int_sgn(i)
Definition isl_int_gmp.h:54
#define isl_int_set_si(r, i)
Definition isl_int_gmp.h:15
mpz_t isl_int
Definition isl_int_gmp.h:9
#define isl_int_abs(r, i)
Definition isl_int_gmp.h:23
isl_bool isl_local_div_is_marked_unknown(__isl_keep isl_local *local, int pos)
Definition isl_local.c:110
isl_bool isl_local_space_is_div_constraint(__isl_keep isl_local_space *ls, isl_int *constraint, unsigned div)
unsigned isl_local_space_offset(__isl_keep isl_local_space *ls, enum isl_dim_type type)
__isl_give isl_local_space * isl_local_space_alloc_div(__isl_take isl_space *space, __isl_take isl_mat *div)
isl_size isl_basic_map_var_offset(__isl_keep isl_basic_map *bmap, enum isl_dim_type type)
Definition isl_map.c:147
__isl_give isl_basic_map * isl_basic_map_free_inequality(__isl_take isl_basic_map *bmap, unsigned n)
Definition isl_map.c:1767
isl_bool isl_basic_map_plain_is_equal(__isl_keep isl_basic_map *bmap1, __isl_keep isl_basic_map *bmap2)
Definition isl_map.c:11086
isl_size isl_basic_map_n_equality(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:248
int isl_basic_map_drop_equality(__isl_keep isl_basic_map *bmap, unsigned pos)
Definition isl_map.c:1694
unsigned isl_basic_map_offset(__isl_keep isl_basic_map *bmap, enum isl_dim_type type)
Definition isl_map.c:178
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
Definition isl_map.c:73
__isl_give isl_basic_map * isl_basic_map_cow(__isl_take isl_basic_map *bmap)
Definition isl_map.c:2064
__isl_give isl_mat * isl_basic_map_get_divs(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:481
__isl_give isl_basic_map * isl_basic_map_sort_constraints(__isl_take isl_basic_map *bmap)
Definition isl_map.c:10959
__isl_give isl_mat * isl_basic_set_get_divs(__isl_keep isl_basic_set *bset)
Definition isl_map.c:507
int isl_basic_map_plain_cmp(__isl_keep isl_basic_map *bmap1, __isl_keep isl_basic_map *bmap2)
Definition isl_map.c:10996
__isl_give isl_basic_map * isl_basic_map_finalize(__isl_take isl_basic_map *bmap)
isl_bool isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap, isl_int *constraint, unsigned div)
__isl_give isl_map * isl_map_plain_gist_basic_map(__isl_take isl_map *map, __isl_take isl_basic_map *context)
#define ISL_BASIC_MAP_RATIONAL
#define isl_set
#define isl_basic_set
static __isl_give isl_printer * print_pw_multi_aff_c(__isl_take isl_printer *p, __isl_keep isl_pw_multi_aff *pma)
static __isl_give isl_printer * isl_basic_map_print_isl(__isl_keep isl_basic_map *bmap, __isl_take isl_printer *p, int latex)
__isl_give isl_printer * isl_printer_print_basic_map(__isl_take isl_printer *p, __isl_keep isl_basic_map *bmap)
static __isl_give isl_printer * print_nested_tuple(__isl_take isl_printer *p, __isl_keep isl_space *local_space, enum isl_dim_type local_type, struct isl_print_space_data *data, int offset)
Definition isl_output.c:406
static const char * s_param_prefix[2]
Definition isl_output.c:59
__isl_give isl_printer * isl_printer_print_union_pw_multi_aff(__isl_take isl_printer *p, __isl_keep isl_union_pw_multi_aff *upma)
static __isl_give isl_printer * print_term(__isl_keep isl_space *space, __isl_keep isl_mat *div, isl_int c, unsigned pos, __isl_take isl_printer *p, int latex)
Definition isl_output.c:287
__isl_give isl_printer * isl_printer_print_basic_set(__isl_take isl_printer *p, __isl_keep isl_basic_set *bset)
static __isl_give isl_printer * print_dim_ma(__isl_take isl_printer *p, struct isl_print_space_data *data, unsigned pos)
void isl_pw_qpolynomial_print(__isl_keep isl_pw_qpolynomial *pwqp, FILE *out, unsigned output_format)
static __isl_give isl_printer * qpolynomial_fold_print(__isl_keep isl_qpolynomial_fold *fold, __isl_take isl_printer *p)
static __isl_give isl_printer * print_pw_aff_c(__isl_take isl_printer *p, __isl_keep isl_pw_aff *pwaff)
static const char * s_ge[2]
Definition isl_output.c:49
static __isl_give isl_printer * print_mod_term(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_aff *aff, int first, __isl_take isl_val *c, __isl_keep isl_val *mod)
static __isl_give isl_printer * print_ls_affine_c(__isl_take isl_printer *p, __isl_keep isl_local_space *ls, isl_int *c)
static __isl_give isl_printer * print_body_pw_qpolynomial_fold(__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf)
static const char * s_input_prefix[2]
Definition isl_output.c:60
static const char * s_open_set[2]
Definition isl_output.c:50
__isl_give isl_printer * isl_printer_print_multi_val(__isl_take isl_printer *p, __isl_keep isl_multi_val *mv)
static __isl_give isl_mat * mark_all_unknown(__isl_take isl_mat *div)
Definition isl_output.c:974
static __isl_give isl_printer * isl_map_print_polylib(__isl_keep isl_map *map, __isl_take isl_printer *p, int ext)
Definition isl_output.c:160
static __isl_give isl_printer * print_constraint_c(__isl_take isl_printer *p, __isl_keep isl_local_space *ls, isl_int *c, const char *op, int *first)
static __isl_give isl_printer * print_multi_union_pw_aff_isl(__isl_take isl_printer *p, __isl_keep isl_multi_union_pw_aff *mupa)
static __isl_give isl_printer * print_qpolynomial_fold_c(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_qpolynomial_fold *fold)
static isl_size poly_rec_n_non_zero(__isl_keep isl_poly_rec *rec)
static const char * s_le[2]
Definition isl_output.c:48
static const char * s_open_list[2]
Definition isl_output.c:52
static __isl_give isl_printer * print_aff_num(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_aff *aff)
static __isl_give isl_printer * isl_map_print_omega(__isl_keep isl_map *map, __isl_take isl_printer *p)
static __isl_give isl_printer * print_multi_pw_aff_isl(__isl_take isl_printer *p, __isl_keep isl_multi_pw_aff *mpa)
static isl_size count_same_name(__isl_keep isl_space *space, enum isl_dim_type type, unsigned pos, const char *name)
Definition isl_output.c:182
static __isl_give isl_printer * print_body_map(__isl_take isl_printer *p, __isl_keep isl_map *map)
static isl_stat print_latex_map_body(__isl_take isl_map *map, void *user)
__isl_give isl_printer * isl_printer_print_map(__isl_take isl_printer *p, __isl_keep isl_map *map)
__isl_give isl_printer * isl_printer_print_union_set(__isl_take isl_printer *p, __isl_keep isl_union_set *uset)
__isl_give isl_printer * isl_printer_print_local_space(__isl_take isl_printer *p, __isl_keep isl_local_space *ls)
static __isl_give isl_printer * print_split_map(__isl_take isl_printer *p, struct isl_aff_split *split, int n, __isl_keep isl_space *space)
static __isl_give isl_printer * print_param_tuple(__isl_take isl_printer *p, __isl_keep isl_space *space, struct isl_print_space_data *data)
static __isl_give isl_printer * basic_set_print_omega(__isl_keep isl_basic_set *bset, __isl_take isl_printer *p)
static __isl_give isl_printer * print_qpolynomial_c(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_qpolynomial *qp)
__isl_give isl_printer * isl_printer_print_multi_union_pw_aff(__isl_take isl_printer *p, __isl_keep isl_multi_union_pw_aff *mupa)
static __isl_give isl_printer * print_multi_aff_isl(__isl_take isl_printer *p, __isl_keep isl_multi_aff *maff)
static __isl_give isl_printer * print_body_aff(__isl_take isl_printer *p, __isl_keep isl_aff *aff)
static __isl_give isl_printer * poly_print(__isl_keep isl_poly *poly, __isl_keep isl_space *space, __isl_keep isl_mat *div, __isl_take isl_printer *p)
static __isl_give isl_printer * print_constraints(__isl_keep isl_basic_map *bmap, __isl_keep isl_space *space, __isl_keep isl_mat *div, __isl_take isl_printer *p, int latex)
Definition isl_output.c:777
static __isl_give isl_printer * print_constraints_polylib(struct isl_basic_map *bmap, __isl_take isl_printer *p)
Definition isl_output.c:99
__isl_give isl_printer * isl_printer_print_union_pw_aff(__isl_take isl_printer *p, __isl_keep isl_union_pw_aff *upa)
static isl_bool next_is_opposite(__isl_keep isl_basic_map *bmap, int i, int last)
Definition isl_output.c:505
static __isl_give isl_printer * print_div_list(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, int latex, int print_defined_divs)
Definition isl_output.c:897
__isl_give isl_printer * isl_printer_print_constraint(__isl_take isl_printer *p, __isl_keep isl_constraint *c)
static __isl_give isl_printer * print_disjunct(__isl_keep isl_basic_map *bmap, __isl_keep isl_space *space, __isl_take isl_printer *p, int latex)
Definition isl_output.c:993
static __isl_give isl_printer * print_body_multi_aff(__isl_take isl_printer *p, __isl_keep isl_multi_aff *maff)
static __isl_give isl_printer * isl_map_print_isl(__isl_keep isl_map *map, __isl_take isl_printer *p)
__isl_give isl_printer * isl_printer_print_set(__isl_take isl_printer *p, __isl_keep isl_set *set)
__isl_give isl_printer * isl_printer_print_space(__isl_take isl_printer *p, __isl_keep isl_space *space)
__isl_give isl_printer * isl_printer_print_qpolynomial(__isl_take isl_printer *p, __isl_keep isl_qpolynomial *qp)
static __isl_give isl_printer * print_affine_of_len(__isl_keep isl_space *space, __isl_keep isl_mat *div, __isl_take isl_printer *p, isl_int *c, int len)
Definition isl_output.c:320
static isl_size print_as_modulo_pos(__isl_keep isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, unsigned pos, isl_int c)
Definition isl_output.c:643
static const char * s_close_set[2]
Definition isl_output.c:51
__isl_give isl_printer * isl_printer_print_pw_qpolynomial(__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp)
static __isl_give isl_printer * print_qpolynomial(__isl_take isl_printer *p, __isl_keep isl_qpolynomial *qp)
static __isl_give isl_printer * isl_basic_map_print_polylib(__isl_keep isl_basic_map *bmap, __isl_take isl_printer *p, int ext)
Definition isl_output.c:120
static __isl_give isl_printer * poly_print_cst(__isl_keep isl_poly *poly, __isl_take isl_printer *p, int first)
static __isl_give struct isl_aff_split * split_aff(__isl_keep isl_map *map)
static __isl_give isl_printer * print_mod(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, int pos, int latex)
Definition isl_output.c:611
static __isl_give isl_printer * print_pw_qpolynomial_fold_c(__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf)
static __isl_give isl_printer * print_disjuncts_set(__isl_keep isl_set *set, __isl_keep isl_space *space, __isl_take isl_printer *p, int latex)
static __isl_give isl_printer * print_constraint_polylib(struct isl_basic_map *bmap, int ineq, int n, __isl_take isl_printer *p)
Definition isl_output.c:63
void isl_qpolynomial_fold_print(__isl_keep isl_qpolynomial_fold *fold, FILE *out, unsigned output_format)
__isl_give isl_printer * isl_printer_print_qpolynomial_fold(__isl_take isl_printer *p, __isl_keep isl_qpolynomial_fold *fold)
static __isl_give isl_printer * print_nested_var_list(__isl_take isl_printer *p, __isl_keep isl_space *local_space, enum isl_dim_type local_type, struct isl_print_space_data *data, int offset)
Definition isl_output.c:369
static __isl_give isl_printer * isl_printer_print_union_set_isl_body(__isl_take isl_printer *p, __isl_keep isl_union_set *uset)
__isl_give isl_printer * isl_printer_print_aff(__isl_take isl_printer *p, __isl_keep isl_aff *aff)
static __isl_give isl_printer * isl_basic_set_print_polylib(__isl_keep isl_basic_set *bset, __isl_take isl_printer *p, int ext)
Definition isl_output.c:154
__isl_give isl_printer * isl_printer_print_multi_id(__isl_take isl_printer *p, __isl_keep isl_multi_id *mi)
static __isl_give isl_printer * print_ls_name_c(__isl_take isl_printer *p, __isl_keep isl_local_space *ls, enum isl_dim_type type, unsigned pos)
static const char * s_mod[2]
Definition isl_output.c:58
static __isl_give isl_printer * print_dim_zero(__isl_take isl_printer *p, struct isl_print_space_data *data, unsigned pos)
static __isl_give isl_printer * print_nested_map_dim(__isl_take isl_printer *p, __isl_keep isl_space *local_dim, struct isl_print_space_data *data, int offset)
Definition isl_output.c:451
static __isl_give isl_printer * open_exists(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, int latex)
Definition isl_output.c:956
static __isl_give isl_printer * print_disjuncts_map(__isl_keep isl_map *map, __isl_keep isl_space *space, __isl_take isl_printer *p, int latex)
static __isl_give isl_printer * print_tuple(__isl_keep isl_space *space, __isl_take isl_printer *p, enum isl_dim_type type, struct isl_print_space_data *data)
Definition isl_output.c:442
static __isl_give isl_basic_map * drop_aff(__isl_take isl_basic_map *bmap, __isl_keep isl_basic_map *aff)
static __isl_give isl_printer * print_disjuncts_core(__isl_keep isl_map *map, __isl_keep isl_space *space, __isl_take isl_printer *p, int latex)
__isl_give isl_printer * isl_printer_print_multi_pw_aff(__isl_take isl_printer *p, __isl_keep isl_multi_pw_aff *mpa)
static __isl_give isl_printer * print_var_list(__isl_take isl_printer *p, __isl_keep isl_space *space, enum isl_dim_type type)
Definition isl_output.c:394
__isl_give isl_printer * isl_printer_print_multi_aff(__isl_take isl_printer *p, __isl_keep isl_multi_aff *maff)
static __isl_give isl_basic_map * get_aff(__isl_take isl_basic_map *bmap)
static __isl_give isl_printer * isl_map_print_latex(__isl_keep isl_map *map, __isl_take isl_printer *p)
static __isl_give isl_printer * print_name(__isl_keep isl_space *space, __isl_take isl_printer *p, enum isl_dim_type type, unsigned pos, int latex)
Definition isl_output.c:206
static __isl_give isl_printer * print_pow(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, int var, int exp)
static __isl_give isl_printer * isl_printer_print_space_isl(__isl_take isl_printer *p, __isl_keep isl_space *space)
static __isl_give isl_printer * print_pw_qpolynomial_fold_isl(__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf)
static __isl_give isl_printer * print_aff_num_mod(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_aff *aff, unsigned last)
static __isl_give isl_printer * print_base(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, int var)
static const char * s_open_exists[2]
Definition isl_output.c:55
static __isl_give isl_printer * print_dim_mi(__isl_take isl_printer *p, struct isl_print_space_data *data, unsigned pos)
static __isl_give isl_printer * print_latex_map(__isl_keep isl_map *map, __isl_take isl_printer *p, __isl_keep isl_basic_map *aff)
static __isl_give isl_printer * isl_set_print_polylib(__isl_keep isl_set *set, __isl_take isl_printer *p, int ext)
Definition isl_output.c:176
static __isl_give isl_printer * print_unnamed_pw_multi_aff_c(__isl_take isl_printer *p, __isl_keep isl_pw_multi_aff *pma)
static const char * s_close_exists[2]
Definition isl_output.c:56
void isl_pw_qpolynomial_fold_print(__isl_keep isl_pw_qpolynomial_fold *pwf, FILE *out, unsigned output_format)
static __isl_give isl_printer * print_aff_isl(__isl_take isl_printer *p, __isl_keep isl_aff *aff)
static __isl_give isl_printer * print_dim_mv(__isl_take isl_printer *p, struct isl_print_space_data *data, unsigned pos)
static __isl_give isl_printer * print_set_c(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_set *set)
static isl_bool can_print_div_expr(__isl_keep isl_printer *p, __isl_keep isl_mat *div, int pos)
Definition isl_output.c:274
static __isl_give isl_printer * print_pw_qpolynomial_c(__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp)
static const char * constraint_op(int sign, int strict, int latex)
Definition isl_output.c:538
static const char * s_output_prefix[2]
Definition isl_output.c:61
static __isl_give isl_printer * print_aff_body(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_aff *aff)
static const char * s_and[2]
Definition isl_output.c:46
static __isl_give isl_printer * print_ls_term_c(__isl_take isl_printer *p, __isl_keep isl_local_space *ls, isl_int c, unsigned pos)
static __isl_give isl_printer * print_union_pw_aff_dim(__isl_take isl_printer *p, struct isl_print_space_data *data, unsigned pos)
__isl_give isl_printer * isl_print_space(__isl_keep isl_space *space, __isl_take isl_printer *p, int rational, struct isl_print_space_data *data)
Definition isl_output.c:462
void isl_qpolynomial_print(__isl_keep isl_qpolynomial *qp, FILE *out, unsigned output_format)
static __isl_give isl_printer * print_disjuncts_in_hull(__isl_keep isl_map *map, __isl_keep isl_space *space, __isl_take isl_basic_map *hull, __isl_take isl_printer *p, int latex)
static __isl_give isl_printer * print_affine(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, isl_int *c)
Definition isl_output.c:353
__isl_give isl_printer * isl_printer_print_pw_qpolynomial_fold(__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf)
static __isl_give isl_printer * print_aff_num_base(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_aff *aff)
__isl_give isl_printer * isl_printer_print_pw_aff(__isl_take isl_printer *p, __isl_keep isl_pw_aff *pwaff)
static isl_stat pos2type(__isl_keep isl_space *space, enum isl_dim_type *type, unsigned *pos)
Definition isl_output.c:240
static int aff_split_cmp(const void *p1, const void *p2, void *user)
static const char * s_or[2]
Definition isl_output.c:47
static __isl_give isl_printer * print_multi_val_isl(__isl_take isl_printer *p, __isl_keep isl_multi_val *mv)
static __isl_give isl_printer * print_optional_disjunct(__isl_keep isl_basic_map *bmap, __isl_keep isl_space *space, __isl_take isl_printer *p, int latex)
__isl_give isl_printer * isl_printer_print_union_pw_qpolynomial(__isl_take isl_printer *p, __isl_keep isl_union_pw_qpolynomial *upwqp)
static __isl_give isl_printer * print_eq_mod_constraint(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, unsigned div_pos, isl_int *c, int last, int latex)
Definition isl_output.c:686
static __isl_give isl_printer * print_div(__isl_keep isl_space *space, __isl_keep isl_mat *div, int pos, __isl_take isl_printer *p)
Definition isl_output.c:874
static isl_bool need_exists(__isl_keep isl_printer *p, __isl_keep isl_mat *div)
Definition isl_output.c:931
static __isl_give isl_printer * print_basic_set_c(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_basic_set *bset)
static __isl_give isl_printer * bset_print_constraints_polylib(struct isl_basic_set *bset, __isl_take isl_printer *p)
Definition isl_output.c:114
static __isl_give isl_printer * print_dim_mpa(__isl_take isl_printer *p, struct isl_print_space_data *data, unsigned pos)
static __isl_give isl_printer * print_ls_partial_affine_c(__isl_take isl_printer *p, __isl_keep isl_local_space *ls, isl_int *c, unsigned len)
static __isl_give isl_printer * print_multi_id_isl(__isl_take isl_printer *p, __isl_keep isl_multi_id *mi)
static __isl_give isl_printer * print_dim_eq(__isl_take isl_printer *p, struct isl_print_space_data *data, unsigned pos)
static __isl_give isl_printer * print_omega_parameters(__isl_keep isl_space *space, __isl_take isl_printer *p)
Definition isl_output.c:481
static const char * s_such_that[2]
Definition isl_output.c:54
static __isl_give isl_printer * print_constraint(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, isl_int *c, int last, const char *op, int latex)
Definition isl_output.c:582
static isl_size last_modulo(__isl_keep isl_printer *p, __isl_keep isl_aff *aff, unsigned n)
static __isl_give isl_printer * basic_map_print_omega(__isl_keep isl_basic_map *bmap, __isl_take isl_printer *p)
static const char * s_to[2]
Definition isl_output.c:45
static __isl_give isl_printer * print_eq_constraint(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, isl_int *c, int last, int latex)
Definition isl_output.c:720
static const char * s_div_prefix[2]
Definition isl_output.c:57
static __isl_give isl_printer * isl_set_print_omega(__isl_keep isl_set *set, __isl_take isl_printer *p)
static __isl_give isl_printer * isl_union_map_print_latex(__isl_keep isl_union_map *umap, __isl_take isl_printer *p)
__isl_give isl_printer * isl_printer_print_union_map(__isl_take isl_printer *p, __isl_keep isl_union_map *umap)
static __isl_give isl_printer * print_half_constraint(__isl_take isl_printer *p, __isl_keep isl_space *space, __isl_keep isl_mat *div, isl_int *c, int last, const char *op, int latex)
Definition isl_output.c:559
static isl_size defining_equality(__isl_keep isl_basic_map *eq, __isl_keep isl_space *space, enum isl_dim_type type, int pos)
static __isl_give isl_printer * print_qpolynomial_isl(__isl_take isl_printer *p, __isl_keep isl_qpolynomial *qp)
static __isl_give isl_printer * print_body_pw_qpolynomial(__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp)
static __isl_give isl_printer * print_aff_c(__isl_take isl_printer *p, __isl_keep isl_aff *aff)
static const char * s_close_list[2]
Definition isl_output.c:53
__isl_give isl_printer * isl_printer_print_union_pw_qpolynomial_fold(__isl_take isl_printer *p, __isl_keep isl_union_pw_qpolynomial_fold *upwf)
__isl_give isl_printer * isl_printer_print_pw_multi_aff(__isl_take isl_printer *p, __isl_keep isl_pw_multi_aff *pma)
static __isl_give isl_printer * print_pw_qpolynomial_isl(__isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp)
static void free_split(__isl_take struct isl_aff_split *split, int n)
static __isl_give isl_printer * print_disjuncts(__isl_keep isl_map *map, __isl_keep isl_space *space, __isl_take isl_printer *p, int latex)
__isl_keep isl_poly_cst * isl_poly_as_cst(__isl_keep isl_poly *poly)
__isl_keep isl_poly_rec * isl_poly_as_rec(__isl_keep isl_poly *poly)
isl_bool isl_poly_is_cst(__isl_keep isl_poly *poly)
__isl_give isl_val * isl_qpolynomial_get_den(__isl_keep isl_qpolynomial *qp)
isl_bool isl_poly_is_zero(__isl_keep isl_poly *poly)
isl_bool isl_poly_is_one(__isl_keep isl_poly *poly)
isl_bool isl_poly_is_negone(__isl_keep isl_poly *poly)
void isl_seq_combine(isl_int *dst, isl_int m1, isl_int *src1, isl_int m2, isl_int *src2, unsigned len)
Definition isl_seq.c:116
int isl_seq_last_non_zero(isl_int *p, unsigned len)
Definition isl_seq.c:217
int isl_seq_is_neg(isl_int *p1, isl_int *p2, unsigned len)
Definition isl_seq.c:192
void isl_seq_cpy(isl_int *dst, isl_int *src, unsigned len)
Definition isl_seq.c:42
int isl_seq_eq(isl_int *p1, isl_int *p2, unsigned len)
Definition isl_seq.c:173
int isl_seq_any_non_zero(isl_int *p, unsigned len)
Definition isl_seq.c:230
void isl_seq_neg(isl_int *dst, isl_int *src, unsigned len)
Definition isl_seq.c:35
int isl_sort(void *const pbase, size_t total_elems, size_t size, int(*cmp)(const void *, const void *, void *arg), void *arg)
Definition isl_sort.c:153
isl_size isl_space_offset(__isl_keep isl_space *space, enum isl_dim_type type)
Definition isl_space.c:397
static __isl_give isl_set * split(__isl_take isl_set *empty, __isl_take isl_set *min_expr, __isl_take isl_mat *cst)
const char * pwqp
Definition isl_test.c:3636
const char * poly
Definition isl_test.c:3868
enum isl_fold type
Definition isl_test.c:3867
const char * pa
Definition isl_test.c:7173
const char * set
Definition isl_test.c:1364
const char * hull
Definition isl_test.c:1493
const char * ma
Definition isl_test.c:7387
const char * map
Definition isl_test.c:1791
const char * pma
Definition isl_test.c:3019
const char * p
Definition isl_test.c:8454
const char * offset
Definition isl_test.c:1577
const char * name
Definition isl_test.c:10749
__isl_give isl_val *(* op)(__isl_take isl_val *v)
Definition isl_test.c:781
const char * aff
Definition isl_test.c:7130
const char * mupa
Definition isl_test.c:7217
static __isl_give isl_union_map * total(__isl_take isl_union_map *umap, __isl_give isl_map *(*fn)(__isl_take isl_map *))
#define isl_union_set
t0 *a *b *t *a *b * t
isl_size isl_local_space_dim(__isl_keep isl_local_space *ls, enum isl_dim_type type)
__isl_null isl_local_space * isl_local_space_free(__isl_take isl_local_space *ls)
__isl_give isl_space * isl_local_space_get_space(__isl_keep isl_local_space *ls)
__isl_give isl_basic_map * isl_map_plain_unshifted_simple_hull(__isl_take isl_map *map)
__isl_export __isl_give isl_map * isl_map_union(__isl_take isl_map *map1, __isl_take isl_map *map2)
Definition isl_map.c:8894
isl_bool isl_basic_map_plain_is_universe(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:9950
__isl_give isl_map * isl_map_copy(__isl_keep isl_map *map)
Definition isl_map.c:1494
__isl_null isl_basic_map * isl_basic_map_free(__isl_take isl_basic_map *bmap)
Definition isl_map.c:1503
isl_size isl_basic_map_dim(__isl_keep isl_basic_map *bmap, enum isl_dim_type type)
Definition isl_map.c:83
isl_bool isl_map_plain_is_universe(__isl_keep isl_map *map)
Definition isl_map.c:10023
isl_ctx * isl_map_get_ctx(__isl_keep isl_map *map)
Definition isl_map.c:392
__isl_null isl_map * isl_map_free(__isl_take isl_map *map)
Definition isl_map.c:7040
__isl_constructor __isl_give isl_map * isl_map_from_basic_map(__isl_take isl_basic_map *bmap)
Definition isl_map.c:4037
__isl_give isl_basic_map * isl_basic_map_copy(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:1479
isl_size isl_mat_rows(__isl_keep isl_mat *mat)
Definition isl_mat.c:257
__isl_null isl_mat * isl_mat_free(__isl_take isl_mat *mat)
Definition isl_mat.c:240
__isl_give isl_mat * isl_mat_set_element_si(__isl_take isl_mat *mat, int row, int col, int v)
Definition isl_mat.c:356
__isl_give isl_space * isl_pw_qpolynomial_fold_get_domain_space(__isl_keep isl_pw_qpolynomial_fold *pwf)
__isl_give isl_space * isl_pw_qpolynomial_get_domain_space(__isl_keep isl_pw_qpolynomial *pwqp)
__isl_give isl_qpolynomial * isl_qpolynomial_copy(__isl_keep isl_qpolynomial *qp)
__isl_give isl_space * isl_qpolynomial_get_domain_space(__isl_keep isl_qpolynomial *qp)
__isl_null isl_qpolynomial * isl_qpolynomial_free(__isl_take isl_qpolynomial *qp)
__isl_give isl_qpolynomial * isl_qpolynomial_scale_val(__isl_take isl_qpolynomial *qp, __isl_take isl_val *v)
__isl_give isl_space * isl_qpolynomial_fold_get_domain_space(__isl_keep isl_qpolynomial_fold *fold)
Definition isl_fold.c:87
struct isl_union_pw_qpolynomial_fold isl_union_pw_qpolynomial_fold
struct isl_union_pw_qpolynomial isl_union_pw_qpolynomial
@ isl_fold_min
@ isl_fold_max
#define ISL_FORMAT_POLYLIB
Definition printer.h:28
__isl_give isl_printer * isl_printer_print_int(__isl_take isl_printer *p, int i)
__isl_null isl_printer * isl_printer_free(__isl_take isl_printer *printer)
#define ISL_FORMAT_C
Definition printer.h:31
#define ISL_FORMAT_LATEX
Definition printer.h:32
__isl_give isl_printer * isl_printer_set_isl_int_width(__isl_take isl_printer *p, int width)
__isl_give isl_printer * isl_printer_to_file(isl_ctx *ctx, FILE *file)
#define ISL_FORMAT_ISL
Definition printer.h:27
__isl_give isl_printer * isl_printer_print_str(__isl_take isl_printer *p, const char *s)
__isl_give isl_printer * isl_printer_start_line(__isl_take isl_printer *p)
isl_ctx * isl_printer_get_ctx(__isl_keep isl_printer *printer)
__isl_give isl_printer * isl_printer_end_line(__isl_take isl_printer *p)
__isl_give isl_printer * isl_printer_set_output_format(__isl_take isl_printer *p, int output_format)
#define ISL_FORMAT_POLYLIB_CONSTRAINTS
Definition printer.h:29
#define ISL_FORMAT_OMEGA
Definition printer.h:30
#define ISL_FORMAT_EXT_POLYLIB
Definition printer.h:33
a(0)
isl_size isl_basic_set_dim(__isl_keep isl_basic_set *bset, enum isl_dim_type type)
Definition isl_map.c:202
isl_bool isl_set_plain_is_universe(__isl_keep isl_set *set)
Definition isl_map.c:10039
__isl_null isl_space * isl_space_free(__isl_take isl_space *space)
Definition isl_space.c:478
isl_ctx * isl_space_get_ctx(__isl_keep isl_space *space)
Definition isl_space.c:23
__isl_give isl_space * isl_space_copy(__isl_keep isl_space *space)
Definition isl_space.c:469
isl_bool isl_space_has_dim_name(__isl_keep isl_space *space, enum isl_dim_type type, unsigned pos)
Definition isl_space.c:885
__isl_keep const char * isl_space_get_dim_name(__isl_keep isl_space *space, enum isl_dim_type type, unsigned pos)
Definition isl_space.c:896
isl_bool isl_space_is_params(__isl_keep isl_space *space)
Definition isl_space.c:211
__isl_keep const char * isl_space_get_tuple_name(__isl_keep isl_space *space, enum isl_dim_type type)
Definition isl_space.c:852
isl_size isl_space_dim(__isl_keep isl_space *space, enum isl_dim_type type)
Definition isl_space.c:372
isl_bool isl_space_is_set(__isl_keep isl_space *space)
Definition isl_space.c:70
__isl_export __isl_give isl_space * isl_space_domain(__isl_take isl_space *space)
Definition isl_space.c:2232
isl_dim_type
Definition space_type.h:13
@ isl_dim_param
Definition space_type.h:15
@ isl_dim_in
Definition space_type.h:16
@ isl_dim_set
Definition space_type.h:18
@ isl_dim_all
Definition space_type.h:20
@ isl_dim_div
Definition space_type.h:19
@ isl_dim_out
Definition space_type.h:17
isl_map * map
isl_basic_map * aff
isl_int ** ineq
isl_int negone
struct isl_poly poly
enum isl_dim_type type
__isl_give isl_printer *(* print_dim)(__isl_take isl_printer *p, struct isl_print_space_data *data, unsigned pos)
isl_int * el
static void combine(std::vector< std::string > &vec1, const std::vector< std::string > &vec2)
static Signature set_to_map
static Signature domain
__isl_export isl_stat isl_union_map_foreach_map(__isl_keep isl_union_map *umap, isl_stat(*fn)(__isl_take isl_map *map, void *user), void *user)
static __isl_give isl_union_map * uset_to_umap(__isl_take isl_union_set *uset)
Definition uset_to_umap.c:7
__isl_give isl_val * isl_val_copy(__isl_keep isl_val *v)
Definition isl_val.c:219
__isl_give isl_printer * isl_printer_print_val(__isl_take isl_printer *p, __isl_keep isl_val *v)
Definition isl_val.c:1471
__isl_export __isl_give isl_val * isl_val_div(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition isl_val.c:875
__isl_export isl_bool isl_val_is_neg(__isl_keep isl_val *v)
Definition isl_val.c:1234
__isl_null isl_val * isl_val_free(__isl_take isl_val *v)
Definition isl_val.c:263
__isl_export isl_bool isl_val_is_one(__isl_keep isl_val *v)
Definition isl_val.c:1201
__isl_export __isl_give isl_val * isl_val_neg(__isl_take isl_val *v)
Definition isl_val.c:410
struct isl_multi_val isl_multi_val
Definition val_type.h:16
__isl_null isl_vec * isl_vec_free(__isl_take isl_vec *vec)
Definition isl_vec.c:234
__isl_give isl_vec * isl_vec_alloc(isl_ctx *ctx, unsigned size)
Definition isl_vec.c:33
n
Definition youcefn.c:8