2 * Copyright 2008-2009 Katholieke Universiteit Leuven
3 * Copyright 2010 INRIA Saclay
5 * Use of this software is governed by the GNU LGPLv2.1 license
7 * Written by Sven Verdoolaege, K.U.Leuven, Departement
8 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
9 * and INRIA Saclay - Ile-de-France, Parc Club Orsay Universite,
10 * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France
15 #include <isl_ctx_private.h>
16 #include <isl_map_private.h>
19 #include <isl_polynomial_private.h>
20 #include <isl_printer_private.h>
21 #include <isl_space_private.h>
22 #include <isl_mat_private.h>
23 #include <isl/union_map.h>
24 #include <isl/constraint.h>
25 #include <isl_local_space_private.h>
26 #include <isl_aff_private.h>
28 static const char *s_to[2] = { " -> ", " \\to " };
29 static const char *s_and[2] = { " and ", " \\wedge " };
30 static const char *s_or[2] = { " or ", " \\vee " };
31 static const char *s_le[2] = { "<=", "\\le" };
32 static const char *s_ge[2] = { ">=", "\\ge" };
33 static const char *s_open_set[2] = { "{ ", "\\{\\, " };
34 static const char *s_close_set[2] = { " }", " \\,\\}" };
35 static const char *s_open_list[2] = { "[", "(" };
36 static const char *s_close_list[2] = { "]", ")" };
37 static const char *s_such_that[2] = { " : ", " \\mid " };
38 static const char *s_open_exists[2] = { "exists (", "\\exists \\, " };
39 static const char *s_close_exists[2] = { ")", "" };
40 static const char *s_div_prefix[2] = { "e", "\\alpha_" };
41 static const char *s_param_prefix[2] = { "p", "p_" };
42 static const char *s_input_prefix[2] = { "i", "i_" };
43 static const char *s_output_prefix[2] = { "o", "o_" };
45 static __isl_give isl_printer *print_constraint_polylib(
46 struct isl_basic_map *bmap, int ineq, int n, __isl_take isl_printer *p)
49 unsigned n_in = isl_basic_map_dim(bmap, isl_dim_in);
50 unsigned n_out = isl_basic_map_dim(bmap, isl_dim_out);
51 unsigned nparam = isl_basic_map_dim(bmap, isl_dim_param);
52 isl_int *c = ineq ? bmap->ineq[n] : bmap->eq[n];
54 p = isl_printer_start_line(p);
55 p = isl_printer_print_int(p, ineq);
56 for (i = 0; i < n_out; ++i) {
57 p = isl_printer_print_str(p, " ");
58 p = isl_printer_print_isl_int(p, c[1+nparam+n_in+i]);
60 for (i = 0; i < n_in; ++i) {
61 p = isl_printer_print_str(p, " ");
62 p = isl_printer_print_isl_int(p, c[1+nparam+i]);
64 for (i = 0; i < bmap->n_div; ++i) {
65 p = isl_printer_print_str(p, " ");
66 p = isl_printer_print_isl_int(p, c[1+nparam+n_in+n_out+i]);
68 for (i = 0; i < nparam; ++i) {
69 p = isl_printer_print_str(p, " ");
70 p = isl_printer_print_isl_int(p, c[1+i]);
72 p = isl_printer_print_str(p, " ");
73 p = isl_printer_print_isl_int(p, c[0]);
74 p = isl_printer_end_line(p);
78 static __isl_give isl_printer *print_constraints_polylib(
79 struct isl_basic_map *bmap, __isl_take isl_printer *p)
83 p = isl_printer_set_isl_int_width(p, 5);
85 for (i = 0; i < bmap->n_eq; ++i)
86 p = print_constraint_polylib(bmap, 0, i, p);
87 for (i = 0; i < bmap->n_ineq; ++i)
88 p = print_constraint_polylib(bmap, 1, i, p);
93 static __isl_give isl_printer *bset_print_constraints_polylib(
94 struct isl_basic_set *bset, __isl_take isl_printer *p)
96 return print_constraints_polylib((struct isl_basic_map *)bset, p);
99 static __isl_give isl_printer *isl_basic_map_print_polylib(
100 __isl_keep isl_basic_map *bmap, __isl_take isl_printer *p, int ext)
102 unsigned total = isl_basic_map_total_dim(bmap);
103 p = isl_printer_start_line(p);
104 p = isl_printer_print_int(p, bmap->n_eq + bmap->n_ineq);
105 p = isl_printer_print_str(p, " ");
106 p = isl_printer_print_int(p, 1 + total + 1);
108 p = isl_printer_print_str(p, " ");
109 p = isl_printer_print_int(p,
110 isl_basic_map_dim(bmap, isl_dim_out));
111 p = isl_printer_print_str(p, " ");
112 p = isl_printer_print_int(p,
113 isl_basic_map_dim(bmap, isl_dim_in));
114 p = isl_printer_print_str(p, " ");
115 p = isl_printer_print_int(p,
116 isl_basic_map_dim(bmap, isl_dim_div));
117 p = isl_printer_print_str(p, " ");
118 p = isl_printer_print_int(p,
119 isl_basic_map_dim(bmap, isl_dim_param));
121 p = isl_printer_end_line(p);
122 return print_constraints_polylib(bmap, p);
125 static __isl_give isl_printer *isl_basic_set_print_polylib(
126 __isl_keep isl_basic_set *bset, __isl_take isl_printer *p, int ext)
128 return isl_basic_map_print_polylib((struct isl_basic_map *)bset, p, ext);
131 static __isl_give isl_printer *isl_map_print_polylib(__isl_keep isl_map *map,
132 __isl_take isl_printer *p, int ext)
136 p = isl_printer_start_line(p);
137 p = isl_printer_print_int(p, map->n);
138 p = isl_printer_end_line(p);
139 for (i = 0; i < map->n; ++i) {
140 p = isl_printer_start_line(p);
141 p = isl_printer_end_line(p);
142 p = isl_basic_map_print_polylib(map->p[i], p, ext);
147 static __isl_give isl_printer *isl_set_print_polylib(__isl_keep isl_set *set,
148 __isl_take isl_printer *p, int ext)
150 return isl_map_print_polylib((struct isl_map *)set, p, ext);
153 static int count_same_name(__isl_keep isl_space *dim,
154 enum isl_dim_type type, unsigned pos, const char *name)
160 for (t = isl_dim_param; t <= type && t <= isl_dim_out; ++t) {
161 s = t == type ? pos : isl_space_dim(dim, t);
162 for (p = 0; p < s; ++p) {
163 const char *n = isl_space_get_dim_name(dim, t, p);
164 if (n && !strcmp(n, name))
171 static __isl_give isl_printer *print_name(__isl_keep isl_space *dim,
172 __isl_take isl_printer *p, enum isl_dim_type type, unsigned pos,
179 name = type == isl_dim_div ? NULL : isl_space_get_dim_name(dim, type, pos);
183 if (type == isl_dim_param)
184 prefix = s_param_prefix[latex];
185 else if (type == isl_dim_div)
186 prefix = s_div_prefix[latex];
187 else if (isl_space_is_set(dim) || type == isl_dim_in)
188 prefix = s_input_prefix[latex];
190 prefix = s_output_prefix[latex];
191 snprintf(buffer, sizeof(buffer), "%s%d", prefix, pos);
194 primes = count_same_name(dim, name == buffer ? isl_dim_div : type,
196 p = isl_printer_print_str(p, name);
198 p = isl_printer_print_str(p, "'");
202 static enum isl_dim_type pos2type(__isl_keep isl_space *dim, unsigned *pos)
204 enum isl_dim_type type;
205 unsigned n_in = isl_space_dim(dim, isl_dim_in);
206 unsigned n_out = isl_space_dim(dim, isl_dim_out);
207 unsigned nparam = isl_space_dim(dim, isl_dim_param);
209 if (*pos < 1 + nparam) {
210 type = isl_dim_param;
212 } else if (*pos < 1 + nparam + n_in) {
215 } else if (*pos < 1 + nparam + n_in + n_out) {
217 *pos -= 1 + nparam + n_in;
220 *pos -= 1 + nparam + n_in + n_out;
226 static __isl_give isl_printer *print_div(__isl_keep isl_space *dim,
227 __isl_keep isl_mat *div, int pos, __isl_take isl_printer *p);
229 static __isl_give isl_printer *print_term(__isl_keep isl_space *dim,
230 __isl_keep isl_mat *div,
231 isl_int c, unsigned pos, __isl_take isl_printer *p, int latex)
233 enum isl_dim_type type;
237 return isl_printer_print_isl_int(p, c);
239 type = pos2type(dim, &pos);
240 print_div_def = type == isl_dim_div && div &&
241 !isl_int_is_zero(div->row[pos][0]);
243 if (isl_int_is_one(c))
245 else if (isl_int_is_negone(c))
246 p = isl_printer_print_str(p, "-");
248 p = isl_printer_print_isl_int(p, c);
249 if (p->output_format == ISL_FORMAT_C || print_div_def)
250 p = isl_printer_print_str(p, "*");
253 p = print_div(dim, div, pos, p);
255 p = print_name(dim, p, type, pos, latex);
259 static __isl_give isl_printer *print_affine_of_len(__isl_keep isl_space *dim,
260 __isl_keep isl_mat *div,
261 __isl_take isl_printer *p, isl_int *c, int len)
266 for (i = 0, first = 1; i < len; ++i) {
268 if (isl_int_is_zero(c[i]))
271 if (isl_int_is_neg(c[i])) {
273 isl_int_neg(c[i], c[i]);
274 p = isl_printer_print_str(p, " - ");
276 p = isl_printer_print_str(p, " + ");
279 p = print_term(dim, div, c[i], i, p, 0);
281 isl_int_neg(c[i], c[i]);
284 p = isl_printer_print_str(p, "0");
288 static __isl_give isl_printer *print_affine(__isl_keep isl_basic_map *bmap,
289 __isl_keep isl_space *dim, __isl_take isl_printer *p, isl_int *c)
291 unsigned len = 1 + isl_basic_map_total_dim(bmap);
292 return print_affine_of_len(dim, NULL, p, c, len);
295 static int defining_equality(__isl_keep isl_basic_map *eq,
296 __isl_keep isl_space *dim, enum isl_dim_type type, int pos)
304 pos += isl_space_offset(dim, type);
305 total = isl_basic_map_total_dim(eq);
307 for (i = 0; i < eq->n_eq; ++i) {
308 if (isl_seq_last_non_zero(eq->eq[i] + 1, total) != pos)
310 if (isl_int_is_one(eq->eq[i][1 + pos]))
311 isl_seq_neg(eq->eq[i], eq->eq[i], 1 + total);
318 static __isl_give isl_printer *print_aff_body(__isl_take isl_printer *p,
319 __isl_keep isl_aff *aff);
321 /* offset is the offset of local_dim inside global_type of global_dim.
323 static __isl_give isl_printer *print_nested_var_list(__isl_take isl_printer *p,
324 __isl_keep isl_space *global_dim, enum isl_dim_type global_type,
325 __isl_keep isl_space *local_dim, enum isl_dim_type local_type,
326 int latex, __isl_keep isl_basic_map *eq,
327 __isl_keep isl_multi_aff *maff, int offset)
331 if (global_dim != local_dim && local_type == isl_dim_out)
332 offset += local_dim->n_in;
334 for (i = 0; i < isl_space_dim(local_dim, local_type); ++i) {
336 p = isl_printer_print_str(p, ", ");
337 if (maff && global_type == isl_dim_out) {
338 p = print_aff_body(p, maff->p[offset + i]);
341 j = defining_equality(eq, global_dim, global_type, offset + i);
343 int pos = 1 + isl_space_offset(global_dim, global_type)
345 p = print_affine_of_len(eq->dim, NULL,
348 p = print_name(global_dim, p, global_type, offset + i,
355 static __isl_give isl_printer *print_var_list(__isl_keep isl_space *dim,
356 __isl_take isl_printer *p, enum isl_dim_type type,
357 int latex, __isl_keep isl_basic_map *eq, __isl_keep isl_multi_aff *maff)
359 return print_nested_var_list(p, dim, type, dim, type, latex,
363 static __isl_give isl_printer *print_nested_map_dim(__isl_take isl_printer *p,
364 __isl_keep isl_space *global_dim, enum isl_dim_type global_type,
365 __isl_keep isl_space *local_dim,
366 int latex, __isl_keep isl_basic_map *eq,
367 __isl_keep isl_multi_aff *maff, int offset);
369 static __isl_give isl_printer *print_nested_tuple(__isl_take isl_printer *p,
370 __isl_keep isl_space *global_dim, enum isl_dim_type global_type,
371 __isl_keep isl_space *local_dim, enum isl_dim_type local_type,
372 int latex, __isl_keep isl_basic_map *eq,
373 __isl_keep isl_multi_aff *maff, int offset)
375 const char *name = NULL;
376 unsigned n = isl_space_dim(local_dim, local_type);
377 if ((local_type == isl_dim_in || local_type == isl_dim_out)) {
378 name = isl_space_get_tuple_name(local_dim, local_type);
381 p = isl_printer_print_str(p, "\\mathrm{");
382 p = isl_printer_print_str(p, name);
384 p = isl_printer_print_str(p, "}");
387 if (!latex || n != 1 || name)
388 p = isl_printer_print_str(p, s_open_list[latex]);
389 if ((local_type == isl_dim_in || local_type == isl_dim_out) &&
390 local_dim->nested[local_type - isl_dim_in]) {
391 if (global_dim != local_dim && local_type == isl_dim_out)
392 offset += local_dim->n_in;
393 p = print_nested_map_dim(p, global_dim, global_type,
394 local_dim->nested[local_type - isl_dim_in],
395 latex, eq, maff, offset);
397 p = print_nested_var_list(p, global_dim, global_type,
398 local_dim, local_type, latex,
400 if (!latex || n != 1 || name)
401 p = isl_printer_print_str(p, s_close_list[latex]);
405 static __isl_give isl_printer *print_tuple(__isl_keep isl_space *dim,
406 __isl_take isl_printer *p, enum isl_dim_type type,
407 int latex, __isl_keep isl_basic_map *eq, __isl_keep isl_multi_aff *maff)
409 return print_nested_tuple(p, dim, type, dim, type, latex, eq, maff, 0);
412 static __isl_give isl_printer *print_nested_map_dim(__isl_take isl_printer *p,
413 __isl_keep isl_space *global_dim, enum isl_dim_type global_type,
414 __isl_keep isl_space *local_dim,
415 int latex, __isl_keep isl_basic_map *eq,
416 __isl_keep isl_multi_aff *maff, int offset)
418 p = print_nested_tuple(p, global_dim, global_type,
419 local_dim, isl_dim_in, latex, eq, maff, offset);
420 p = isl_printer_print_str(p, s_to[latex]);
421 p = print_nested_tuple(p, global_dim, global_type,
422 local_dim, isl_dim_out, latex, eq, maff, offset);
427 static __isl_give isl_printer *print_space(__isl_keep isl_space *dim,
428 __isl_take isl_printer *p, int latex, int rational,
429 __isl_keep isl_basic_map *eq, __isl_keep isl_multi_aff *maff)
431 if (rational && !latex)
432 p = isl_printer_print_str(p, "rat: ");
433 if (isl_space_is_params(dim))
435 else if (isl_space_is_set(dim))
436 p = print_tuple(dim, p, isl_dim_set, latex, eq, maff);
438 p = print_tuple(dim, p, isl_dim_in, latex, eq, maff);
439 p = isl_printer_print_str(p, s_to[latex]);
440 p = print_tuple(dim, p, isl_dim_out, latex, eq, maff);
446 static __isl_give isl_printer *print_omega_parameters(__isl_keep isl_space *dim,
447 __isl_take isl_printer *p)
449 if (isl_space_dim(dim, isl_dim_param) == 0)
452 p = isl_printer_start_line(p);
453 p = isl_printer_print_str(p, "symbolic ");
454 p = print_var_list(dim, p, isl_dim_param, 0, NULL, NULL);
455 p = isl_printer_print_str(p, ";");
456 p = isl_printer_end_line(p);
460 static __isl_give isl_printer *print_constraint(struct isl_basic_map *bmap,
461 __isl_keep isl_space *dim, __isl_take isl_printer *p,
462 isl_int *c, int last, const char *op, int first_constraint, int latex)
464 if (!first_constraint)
465 p = isl_printer_print_str(p, s_and[latex]);
467 isl_int_abs(c[last], c[last]);
469 p = print_term(dim, NULL, c[last], last, p, latex);
471 p = isl_printer_print_str(p, " ");
472 p = isl_printer_print_str(p, op);
473 p = isl_printer_print_str(p, " ");
475 isl_int_set_si(c[last], 0);
476 p = print_affine(bmap, dim, p, c);
481 static __isl_give isl_printer *print_constraints(__isl_keep isl_basic_map *bmap,
482 __isl_keep isl_space *dim, __isl_take isl_printer *p, int latex)
486 unsigned total = isl_basic_map_total_dim(bmap);
488 c = isl_vec_alloc(bmap->ctx, 1 + total);
492 for (i = bmap->n_eq - 1; i >= 0; --i) {
493 int l = isl_seq_last_non_zero(bmap->eq[i], 1 + total);
495 if (i != bmap->n_eq - 1)
496 p = isl_printer_print_str(p, s_and[latex]);
497 p = isl_printer_print_str(p, "0 = 0");
500 if (isl_int_is_neg(bmap->eq[i][l]))
501 isl_seq_cpy(c->el, bmap->eq[i], 1 + total);
503 isl_seq_neg(c->el, bmap->eq[i], 1 + total);
504 p = print_constraint(bmap, dim, p, c->el, l,
505 "=", i == bmap->n_eq - 1, latex);
507 for (i = 0; i < bmap->n_ineq; ++i) {
508 int l = isl_seq_last_non_zero(bmap->ineq[i], 1 + total);
513 s = isl_int_sgn(bmap->ineq[i][l]);
515 isl_seq_cpy(c->el, bmap->ineq[i], 1 + total);
517 isl_seq_neg(c->el, bmap->ineq[i], 1 + total);
518 op = s < 0 ? s_le[latex] : s_ge[latex];
519 p = print_constraint(bmap, dim, p, c->el, l,
520 op, !bmap->n_eq && !i, latex);
532 static __isl_give isl_printer *print_omega_constraints(
533 __isl_keep isl_basic_map *bmap, __isl_take isl_printer *p)
535 if (bmap->n_eq + bmap->n_ineq == 0)
538 p = isl_printer_print_str(p, ": ");
539 if (bmap->n_div > 0) {
541 p = isl_printer_print_str(p, "exists (");
542 for (i = 0; i < bmap->n_div; ++i) {
544 p = isl_printer_print_str(p, ", ");
545 p = print_name(bmap->dim, p, isl_dim_div, i, 0);
547 p = isl_printer_print_str(p, ": ");
549 p = print_constraints(bmap, bmap->dim, p, 0);
551 p = isl_printer_print_str(p, ")");
555 static __isl_give isl_printer *basic_map_print_omega(
556 __isl_keep isl_basic_map *bmap, __isl_take isl_printer *p)
558 p = isl_printer_print_str(p, "{ [");
559 p = print_var_list(bmap->dim, p, isl_dim_in, 0, NULL, NULL);
560 p = isl_printer_print_str(p, "] -> [");
561 p = print_var_list(bmap->dim, p, isl_dim_out, 0, NULL, NULL);
562 p = isl_printer_print_str(p, "] ");
563 p = print_omega_constraints(bmap, p);
564 p = isl_printer_print_str(p, " }");
568 static __isl_give isl_printer *isl_basic_map_print_omega(
569 __isl_keep isl_basic_map *bmap, __isl_take isl_printer *p)
571 p = print_omega_parameters(bmap->dim, p);
573 p = isl_printer_start_line(p);
574 p = basic_map_print_omega(bmap, p);
575 p = isl_printer_end_line(p);
579 static __isl_give isl_printer *basic_set_print_omega(
580 __isl_keep isl_basic_set *bset, __isl_take isl_printer *p)
582 p = isl_printer_print_str(p, "{ [");
583 p = print_var_list(bset->dim, p, isl_dim_set, 0, NULL, NULL);
584 p = isl_printer_print_str(p, "] ");
585 p = print_omega_constraints((isl_basic_map *)bset, p);
586 p = isl_printer_print_str(p, " }");
590 static __isl_give isl_printer *isl_basic_set_print_omega(
591 __isl_keep isl_basic_set *bset, __isl_take isl_printer *p)
593 p = print_omega_parameters(bset->dim, p);
595 p = isl_printer_start_line(p);
596 p = basic_set_print_omega(bset, p);
597 p = isl_printer_end_line(p);
601 static __isl_give isl_printer *isl_map_print_omega(__isl_keep isl_map *map,
602 __isl_take isl_printer *p)
606 p = print_omega_parameters(map->dim, p);
608 p = isl_printer_start_line(p);
609 for (i = 0; i < map->n; ++i) {
611 p = isl_printer_print_str(p, " union ");
612 p = basic_map_print_omega(map->p[i], p);
614 p = isl_printer_end_line(p);
618 static __isl_give isl_printer *isl_set_print_omega(__isl_keep isl_set *set,
619 __isl_take isl_printer *p)
623 p = print_omega_parameters(set->dim, p);
625 p = isl_printer_start_line(p);
626 for (i = 0; i < set->n; ++i) {
628 p = isl_printer_print_str(p, " union ");
629 p = basic_set_print_omega(set->p[i], p);
631 p = isl_printer_end_line(p);
635 static __isl_give isl_printer *print_disjunct(__isl_keep isl_basic_map *bmap,
636 __isl_keep isl_space *dim, __isl_take isl_printer *p, int latex)
638 if (bmap->n_div > 0) {
640 p = isl_printer_print_str(p, s_open_exists[latex]);
641 for (i = 0; i < bmap->n_div; ++i) {
643 p = isl_printer_print_str(p, ", ");
644 p = print_name(dim, p, isl_dim_div, i, latex);
645 if (latex || isl_int_is_zero(bmap->div[i][0]))
647 p = isl_printer_print_str(p, " = [(");
648 p = print_affine(bmap, dim, p, bmap->div[i] + 1);
649 p = isl_printer_print_str(p, ")/");
650 p = isl_printer_print_isl_int(p, bmap->div[i][0]);
651 p = isl_printer_print_str(p, "]");
653 p = isl_printer_print_str(p, ": ");
656 p = print_constraints(bmap, dim, p, latex);
659 p = isl_printer_print_str(p, s_close_exists[latex]);
663 static __isl_give isl_printer *isl_basic_map_print_isl(
664 __isl_keep isl_basic_map *bmap, __isl_take isl_printer *p,
667 int rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
668 if (isl_basic_map_dim(bmap, isl_dim_param) > 0) {
669 p = print_tuple(bmap->dim, p, isl_dim_param, latex, NULL, NULL);
670 p = isl_printer_print_str(p, " -> ");
672 p = isl_printer_print_str(p, "{ ");
673 p = print_space(bmap->dim, p, latex, rational, NULL, NULL);
674 p = isl_printer_print_str(p, " : ");
675 p = print_disjunct(bmap, bmap->dim, p, latex);
676 p = isl_printer_print_str(p, " }");
680 static __isl_give isl_printer *print_disjuncts(__isl_keep isl_map *map,
681 __isl_take isl_printer *p, int latex)
685 if (isl_map_plain_is_universe(map))
688 p = isl_printer_print_str(p, s_such_that[latex]);
690 p = isl_printer_print_str(p, "1 = 0");
691 for (i = 0; i < map->n; ++i) {
693 p = isl_printer_print_str(p, s_or[latex]);
694 if (map->n > 1 && map->p[i]->n_eq + map->p[i]->n_ineq > 1)
695 p = isl_printer_print_str(p, "(");
696 p = print_disjunct(map->p[i], map->dim, p, latex);
697 if (map->n > 1 && map->p[i]->n_eq + map->p[i]->n_ineq > 1)
698 p = isl_printer_print_str(p, ")");
703 /* Print the disjuncts of a map (or set).
704 * If the map turns out to be a universal parameter domain, then
705 * we need to print the colon. Otherwise, the output looks identical
708 static __isl_give isl_printer *print_disjuncts_map(__isl_keep isl_map *map,
709 __isl_take isl_printer *p, int latex)
711 if (isl_map_plain_is_universe(map) && isl_space_is_params(map->dim))
712 return isl_printer_print_str(p, s_such_that[latex]);
714 return print_disjuncts(map, p, latex);
717 struct isl_aff_split {
722 static void free_split(__isl_take struct isl_aff_split *split, int n)
729 for (i = 0; i < n; ++i) {
730 isl_basic_map_free(split[i].aff);
731 isl_map_free(split[i].map);
737 static __isl_give isl_basic_map *get_aff(__isl_take isl_basic_map *bmap)
740 unsigned nparam, n_in, n_out, total;
742 bmap = isl_basic_map_cow(bmap);
745 if (isl_basic_map_free_inequality(bmap, bmap->n_ineq) < 0)
748 nparam = isl_basic_map_dim(bmap, isl_dim_param);
749 n_in = isl_basic_map_dim(bmap, isl_dim_in);
750 n_out = isl_basic_map_dim(bmap, isl_dim_out);
751 total = isl_basic_map_dim(bmap, isl_dim_all);
752 for (i = bmap->n_eq - 1; i >= 0; --i) {
753 j = isl_seq_last_non_zero(bmap->eq[i] + 1, total);
754 if (j >= nparam && j < nparam + n_in + n_out &&
755 (isl_int_is_one(bmap->eq[i][1 + j]) ||
756 isl_int_is_negone(bmap->eq[i][1 + j])))
758 if (isl_basic_map_drop_equality(bmap, i) < 0)
762 bmap = isl_basic_map_finalize(bmap);
766 isl_basic_map_free(bmap);
770 static int aff_split_cmp(const void *p1, const void *p2)
772 const struct isl_aff_split *s1, *s2;
773 s1 = (const struct isl_aff_split *) p1;
774 s2 = (const struct isl_aff_split *) p2;
776 return isl_basic_map_plain_cmp(s1->aff, s2->aff);
779 static __isl_give isl_basic_map *drop_aff(__isl_take isl_basic_map *bmap,
780 __isl_keep isl_basic_map *aff)
788 total = isl_space_dim(bmap->dim, isl_dim_all);
790 for (i = bmap->n_eq - 1; i >= 0; --i) {
791 if (isl_seq_first_non_zero(bmap->eq[i] + 1 + total,
794 for (j = 0; j < aff->n_eq; ++j) {
795 if (!isl_seq_eq(bmap->eq[i], aff->eq[j], 1 + total) &&
796 !isl_seq_is_neg(bmap->eq[i], aff->eq[j], 1 + total))
798 if (isl_basic_map_drop_equality(bmap, i) < 0)
806 isl_basic_map_free(bmap);
810 static __isl_give struct isl_aff_split *split_aff(__isl_keep isl_map *map)
813 struct isl_aff_split *split;
816 ctx = isl_map_get_ctx(map);
817 split = isl_calloc_array(ctx, struct isl_aff_split, map->n);
821 for (i = 0; i < map->n; ++i) {
823 split[i].aff = get_aff(isl_basic_map_copy(map->p[i]));
824 bmap = isl_basic_map_copy(map->p[i]);
825 bmap = isl_basic_map_cow(bmap);
826 bmap = drop_aff(bmap, split[i].aff);
827 split[i].map = isl_map_from_basic_map(bmap);
828 if (!split[i].aff || !split[i].map)
832 qsort(split, map->n, sizeof(struct isl_aff_split), &aff_split_cmp);
835 for (i = n - 1; i >= 1; --i) {
836 if (!isl_basic_map_plain_is_equal(split[i - 1].aff,
839 isl_basic_map_free(split[i].aff);
840 split[i - 1].map = isl_map_union(split[i - 1].map,
843 split[i] = split[n - 1];
844 split[n - 1].aff = NULL;
845 split[n - 1].map = NULL;
851 free_split(split, map->n);
855 static __isl_give isl_printer *print_split_map(__isl_take isl_printer *p,
856 struct isl_aff_split *split, int n)
861 for (i = 0; i < n; ++i) {
866 dim = split[i].map->dim;
867 rational = split[i].map->n > 0 &&
868 ISL_F_ISSET(split[i].map->p[0], ISL_BASIC_MAP_RATIONAL);
870 p = isl_printer_print_str(p, "; ");
871 p = print_space(dim, p, 0, rational, split[i].aff, NULL);
872 p = print_disjuncts_map(split[i].map, p, 0);
878 static __isl_give isl_printer *isl_map_print_isl_body(__isl_keep isl_map *map,
879 __isl_take isl_printer *p)
881 struct isl_aff_split *split = NULL;
885 split = split_aff(map);
887 p = print_split_map(p, split, map->n);
889 rational = map->n > 0 &&
890 ISL_F_ISSET(map->p[0], ISL_BASIC_MAP_RATIONAL);
891 p = print_space(map->dim, p, 0, rational, NULL, NULL);
892 p = print_disjuncts_map(map, p, 0);
894 free_split(split, map->n);
898 static __isl_give isl_printer *isl_map_print_isl(__isl_keep isl_map *map,
899 __isl_take isl_printer *p)
901 if (isl_map_dim(map, isl_dim_param) > 0) {
902 p = print_tuple(map->dim, p, isl_dim_param, 0, NULL, NULL);
903 p = isl_printer_print_str(p, s_to[0]);
905 p = isl_printer_print_str(p, s_open_set[0]);
906 p = isl_map_print_isl_body(map, p);
907 p = isl_printer_print_str(p, s_close_set[0]);
911 static __isl_give isl_printer *print_latex_map(__isl_keep isl_map *map,
912 __isl_take isl_printer *p, __isl_keep isl_basic_map *aff)
914 if (isl_map_dim(map, isl_dim_param) > 0) {
915 p = print_tuple(map->dim, p, isl_dim_param, 1, NULL, NULL);
916 p = isl_printer_print_str(p, s_to[1]);
918 p = isl_printer_print_str(p, s_open_set[1]);
919 p = print_space(map->dim, p, 1, 0, aff, NULL);
920 p = print_disjuncts_map(map, p, 1);
921 p = isl_printer_print_str(p, s_close_set[1]);
926 static __isl_give isl_printer *isl_map_print_latex(__isl_keep isl_map *map,
927 __isl_take isl_printer *p)
930 struct isl_aff_split *split = NULL;
933 split = split_aff(map);
936 return print_latex_map(map, p, NULL);
938 for (i = 0; i < map->n; ++i) {
942 p = isl_printer_print_str(p, " \\cup ");
943 p = print_latex_map(split[i].map, p, split[i].aff);
946 free_split(split, map->n);
950 __isl_give isl_printer *isl_printer_print_basic_map(__isl_take isl_printer *p,
951 __isl_keep isl_basic_map *bmap)
955 if (p->output_format == ISL_FORMAT_ISL)
956 return isl_basic_map_print_isl(bmap, p, 0);
957 else if (p->output_format == ISL_FORMAT_OMEGA)
958 return isl_basic_map_print_omega(bmap, p);
959 isl_assert(bmap->ctx, 0, goto error);
965 void isl_basic_map_print(__isl_keep isl_basic_map *bmap, FILE *out, int indent,
966 const char *prefix, const char *suffix, unsigned output_format)
968 isl_printer *printer;
973 printer = isl_printer_to_file(bmap->ctx, out);
974 printer = isl_printer_set_indent(printer, indent);
975 printer = isl_printer_set_prefix(printer, prefix);
976 printer = isl_printer_set_suffix(printer, suffix);
977 printer = isl_printer_set_output_format(printer, output_format);
978 isl_printer_print_basic_map(printer, bmap);
980 isl_printer_free(printer);
983 __isl_give isl_printer *isl_printer_print_basic_set(__isl_take isl_printer *p,
984 __isl_keep isl_basic_set *bset)
989 if (p->output_format == ISL_FORMAT_ISL)
990 return isl_basic_map_print_isl(bset, p, 0);
991 else if (p->output_format == ISL_FORMAT_POLYLIB)
992 return isl_basic_set_print_polylib(bset, p, 0);
993 else if (p->output_format == ISL_FORMAT_EXT_POLYLIB)
994 return isl_basic_set_print_polylib(bset, p, 1);
995 else if (p->output_format == ISL_FORMAT_POLYLIB_CONSTRAINTS)
996 return bset_print_constraints_polylib(bset, p);
997 else if (p->output_format == ISL_FORMAT_OMEGA)
998 return isl_basic_set_print_omega(bset, p);
999 isl_assert(p->ctx, 0, goto error);
1001 isl_printer_free(p);
1005 void isl_basic_set_print(struct isl_basic_set *bset, FILE *out, int indent,
1006 const char *prefix, const char *suffix, unsigned output_format)
1008 isl_printer *printer;
1013 printer = isl_printer_to_file(bset->ctx, out);
1014 printer = isl_printer_set_indent(printer, indent);
1015 printer = isl_printer_set_prefix(printer, prefix);
1016 printer = isl_printer_set_suffix(printer, suffix);
1017 printer = isl_printer_set_output_format(printer, output_format);
1018 isl_printer_print_basic_set(printer, bset);
1020 isl_printer_free(printer);
1023 __isl_give isl_printer *isl_printer_print_set(__isl_take isl_printer *p,
1024 __isl_keep isl_set *set)
1028 if (p->output_format == ISL_FORMAT_ISL)
1029 return isl_map_print_isl((isl_map *)set, p);
1030 else if (p->output_format == ISL_FORMAT_POLYLIB)
1031 return isl_set_print_polylib(set, p, 0);
1032 else if (p->output_format == ISL_FORMAT_EXT_POLYLIB)
1033 return isl_set_print_polylib(set, p, 1);
1034 else if (p->output_format == ISL_FORMAT_OMEGA)
1035 return isl_set_print_omega(set, p);
1036 else if (p->output_format == ISL_FORMAT_LATEX)
1037 return isl_map_print_latex((isl_map *)set, p);
1038 isl_assert(set->ctx, 0, goto error);
1040 isl_printer_free(p);
1044 void isl_set_print(struct isl_set *set, FILE *out, int indent,
1045 unsigned output_format)
1047 isl_printer *printer;
1052 printer = isl_printer_to_file(set->ctx, out);
1053 printer = isl_printer_set_indent(printer, indent);
1054 printer = isl_printer_set_output_format(printer, output_format);
1055 printer = isl_printer_print_set(printer, set);
1057 isl_printer_free(printer);
1060 __isl_give isl_printer *isl_printer_print_map(__isl_take isl_printer *p,
1061 __isl_keep isl_map *map)
1066 if (p->output_format == ISL_FORMAT_ISL)
1067 return isl_map_print_isl(map, p);
1068 else if (p->output_format == ISL_FORMAT_POLYLIB)
1069 return isl_map_print_polylib(map, p, 0);
1070 else if (p->output_format == ISL_FORMAT_EXT_POLYLIB)
1071 return isl_map_print_polylib(map, p, 1);
1072 else if (p->output_format == ISL_FORMAT_OMEGA)
1073 return isl_map_print_omega(map, p);
1074 else if (p->output_format == ISL_FORMAT_LATEX)
1075 return isl_map_print_latex(map, p);
1076 isl_assert(map->ctx, 0, goto error);
1078 isl_printer_free(p);
1082 struct isl_union_print_data {
1087 static int print_map_body(__isl_take isl_map *map, void *user)
1089 struct isl_union_print_data *data;
1090 data = (struct isl_union_print_data *)user;
1093 data->p = isl_printer_print_str(data->p, "; ");
1096 data->p = isl_map_print_isl_body(map, data->p);
1102 static __isl_give isl_printer *isl_union_map_print_isl(
1103 __isl_keep isl_union_map *umap, __isl_take isl_printer *p)
1105 struct isl_union_print_data data = { p, 1 };
1107 dim = isl_union_map_get_space(umap);
1108 if (isl_space_dim(dim, isl_dim_param) > 0) {
1109 p = print_tuple(dim, p, isl_dim_param, 0, NULL, NULL);
1110 p = isl_printer_print_str(p, s_to[0]);
1112 isl_space_free(dim);
1113 p = isl_printer_print_str(p, s_open_set[0]);
1114 isl_union_map_foreach_map(umap, &print_map_body, &data);
1116 p = isl_printer_print_str(p, s_close_set[0]);
1120 static int print_latex_map_body(__isl_take isl_map *map, void *user)
1122 struct isl_union_print_data *data;
1123 data = (struct isl_union_print_data *)user;
1126 data->p = isl_printer_print_str(data->p, " \\cup ");
1129 data->p = isl_map_print_latex(map, data->p);
1135 static __isl_give isl_printer *isl_union_map_print_latex(
1136 __isl_keep isl_union_map *umap, __isl_take isl_printer *p)
1138 struct isl_union_print_data data = { p, 1 };
1139 isl_union_map_foreach_map(umap, &print_latex_map_body, &data);
1144 __isl_give isl_printer *isl_printer_print_union_map(__isl_take isl_printer *p,
1145 __isl_keep isl_union_map *umap)
1150 if (p->output_format == ISL_FORMAT_ISL)
1151 return isl_union_map_print_isl(umap, p);
1152 if (p->output_format == ISL_FORMAT_LATEX)
1153 return isl_union_map_print_latex(umap, p);
1155 isl_die(p->ctx, isl_error_invalid,
1156 "invalid output format for isl_union_map", goto error);
1158 isl_printer_free(p);
1162 __isl_give isl_printer *isl_printer_print_union_set(__isl_take isl_printer *p,
1163 __isl_keep isl_union_set *uset)
1168 if (p->output_format == ISL_FORMAT_ISL)
1169 return isl_union_map_print_isl((isl_union_map *)uset, p);
1170 if (p->output_format == ISL_FORMAT_LATEX)
1171 return isl_union_map_print_latex((isl_union_map *)uset, p);
1173 isl_die(p->ctx, isl_error_invalid,
1174 "invalid output format for isl_union_set", goto error);
1176 isl_printer_free(p);
1180 void isl_map_print(__isl_keep isl_map *map, FILE *out, int indent,
1181 unsigned output_format)
1183 isl_printer *printer;
1188 printer = isl_printer_to_file(map->ctx, out);
1189 printer = isl_printer_set_indent(printer, indent);
1190 printer = isl_printer_set_output_format(printer, output_format);
1191 printer = isl_printer_print_map(printer, map);
1193 isl_printer_free(printer);
1196 static int upoly_rec_n_non_zero(__isl_keep struct isl_upoly_rec *rec)
1201 for (i = 0, n = 0; i < rec->n; ++i)
1202 if (!isl_upoly_is_zero(rec->p[i]))
1208 static __isl_give isl_printer *print_div(__isl_keep isl_space *dim,
1209 __isl_keep isl_mat *div, int pos, __isl_take isl_printer *p)
1211 int c = p->output_format == ISL_FORMAT_C;
1212 p = isl_printer_print_str(p, c ? "floord(" : "[(");
1213 p = print_affine_of_len(dim, div, p,
1214 div->row[pos] + 1, div->n_col - 1);
1215 p = isl_printer_print_str(p, c ? ", " : ")/");
1216 p = isl_printer_print_isl_int(p, div->row[pos][0]);
1217 p = isl_printer_print_str(p, c ? ")" : "]");
1221 static __isl_give isl_printer *upoly_print_cst(__isl_keep struct isl_upoly *up,
1222 __isl_take isl_printer *p, int first)
1224 struct isl_upoly_cst *cst;
1227 cst = isl_upoly_as_cst(up);
1230 neg = !first && isl_int_is_neg(cst->n);
1232 p = isl_printer_print_str(p, neg ? " - " : " + ");
1234 isl_int_neg(cst->n, cst->n);
1235 if (isl_int_is_zero(cst->d)) {
1236 int sgn = isl_int_sgn(cst->n);
1237 p = isl_printer_print_str(p, sgn < 0 ? "-infty" :
1238 sgn == 0 ? "NaN" : "infty");
1240 p = isl_printer_print_isl_int(p, cst->n);
1242 isl_int_neg(cst->n, cst->n);
1243 if (!isl_int_is_zero(cst->d) && !isl_int_is_one(cst->d)) {
1244 p = isl_printer_print_str(p, "/");
1245 p = isl_printer_print_isl_int(p, cst->d);
1249 isl_printer_free(p);
1253 static __isl_give isl_printer *print_base(__isl_take isl_printer *p,
1254 __isl_keep isl_space *dim, __isl_keep isl_mat *div, int var)
1258 total = isl_space_dim(dim, isl_dim_all);
1260 p = print_term(dim, NULL, dim->ctx->one, 1 + var, p, 0);
1262 p = print_div(dim, div, var - total, p);
1266 static __isl_give isl_printer *print_pow(__isl_take isl_printer *p,
1267 __isl_keep isl_space *dim, __isl_keep isl_mat *div, int var, int exp)
1269 p = print_base(p, dim, div, var);
1272 if (p->output_format == ISL_FORMAT_C) {
1274 for (i = 1; i < exp; ++i) {
1275 p = isl_printer_print_str(p, "*");
1276 p = print_base(p, dim, div, var);
1279 p = isl_printer_print_str(p, "^");
1280 p = isl_printer_print_int(p, exp);
1285 static __isl_give isl_printer *upoly_print(__isl_keep struct isl_upoly *up,
1286 __isl_keep isl_space *dim, __isl_keep isl_mat *div,
1287 __isl_take isl_printer *p, int outer)
1289 int i, n, first, print_parens;
1290 struct isl_upoly_rec *rec;
1292 if (!p || !up || !dim || !div)
1295 if (isl_upoly_is_cst(up))
1296 return upoly_print_cst(up, p, 1);
1298 rec = isl_upoly_as_rec(up);
1301 n = upoly_rec_n_non_zero(rec);
1302 print_parens = n > 1 ||
1303 (outer && rec->up.var >= isl_space_dim(dim, isl_dim_all));
1305 p = isl_printer_print_str(p, "(");
1306 for (i = 0, first = 1; i < rec->n; ++i) {
1307 if (isl_upoly_is_zero(rec->p[i]))
1309 if (isl_upoly_is_negone(rec->p[i])) {
1311 p = isl_printer_print_str(p, "-1");
1313 p = isl_printer_print_str(p, "-");
1315 p = isl_printer_print_str(p, " - ");
1316 } else if (isl_upoly_is_cst(rec->p[i]) &&
1317 !isl_upoly_is_one(rec->p[i]))
1318 p = upoly_print_cst(rec->p[i], p, first);
1321 p = isl_printer_print_str(p, " + ");
1322 if (i == 0 || !isl_upoly_is_one(rec->p[i]))
1323 p = upoly_print(rec->p[i], dim, div, p, 0);
1328 if (!isl_upoly_is_one(rec->p[i]) &&
1329 !isl_upoly_is_negone(rec->p[i]))
1330 p = isl_printer_print_str(p, " * ");
1331 p = print_pow(p, dim, div, rec->up.var, i);
1334 p = isl_printer_print_str(p, ")");
1337 isl_printer_free(p);
1341 static __isl_give isl_printer *print_qpolynomial(__isl_take isl_printer *p,
1342 __isl_keep isl_qpolynomial *qp)
1346 p = upoly_print(qp->upoly, qp->dim, qp->div, p, 1);
1349 isl_printer_free(p);
1353 static __isl_give isl_printer *print_qpolynomial_isl(__isl_take isl_printer *p,
1354 __isl_keep isl_qpolynomial *qp)
1359 if (isl_space_dim(qp->dim, isl_dim_param) > 0) {
1360 p = print_tuple(qp->dim, p, isl_dim_param, 0, NULL, NULL);
1361 p = isl_printer_print_str(p, " -> ");
1363 p = isl_printer_print_str(p, "{ ");
1364 if (!isl_space_is_params(qp->dim)) {
1365 p = print_space(qp->dim, p, 0, 0, NULL, NULL);
1366 p = isl_printer_print_str(p, " -> ");
1368 p = print_qpolynomial(p, qp);
1369 p = isl_printer_print_str(p, " }");
1372 isl_printer_free(p);
1376 static __isl_give isl_printer *print_qpolynomial_c(__isl_take isl_printer *p,
1377 __isl_keep isl_space *dim, __isl_keep isl_qpolynomial *qp)
1382 isl_qpolynomial_get_den(qp, &den);
1383 if (!isl_int_is_one(den)) {
1385 p = isl_printer_print_str(p, "(");
1386 qp = isl_qpolynomial_copy(qp);
1387 f = isl_qpolynomial_rat_cst_on_domain(isl_space_copy(qp->dim),
1388 den, qp->dim->ctx->one);
1389 qp = isl_qpolynomial_mul(qp, f);
1392 p = upoly_print(qp->upoly, dim, qp->div, p, 0);
1393 if (!isl_int_is_one(den)) {
1394 p = isl_printer_print_str(p, ")/");
1395 p = isl_printer_print_isl_int(p, den);
1396 isl_qpolynomial_free(qp);
1402 __isl_give isl_printer *isl_printer_print_qpolynomial(
1403 __isl_take isl_printer *p, __isl_keep isl_qpolynomial *qp)
1408 if (p->output_format == ISL_FORMAT_ISL)
1409 return print_qpolynomial_isl(p, qp);
1410 else if (p->output_format == ISL_FORMAT_C)
1411 return print_qpolynomial_c(p, qp->dim, qp);
1413 isl_die(qp->dim->ctx, isl_error_unsupported,
1414 "output format not supported for isl_qpolynomials",
1417 isl_printer_free(p);
1421 void isl_qpolynomial_print(__isl_keep isl_qpolynomial *qp, FILE *out,
1422 unsigned output_format)
1429 isl_assert(qp->dim->ctx, output_format == ISL_FORMAT_ISL, return);
1430 p = isl_printer_to_file(qp->dim->ctx, out);
1431 p = isl_printer_print_qpolynomial(p, qp);
1432 isl_printer_free(p);
1435 static __isl_give isl_printer *qpolynomial_fold_print(
1436 __isl_keep isl_qpolynomial_fold *fold, __isl_take isl_printer *p)
1440 if (fold->type == isl_fold_min)
1441 p = isl_printer_print_str(p, "min");
1442 else if (fold->type == isl_fold_max)
1443 p = isl_printer_print_str(p, "max");
1444 p = isl_printer_print_str(p, "(");
1445 for (i = 0; i < fold->n; ++i) {
1447 p = isl_printer_print_str(p, ", ");
1448 p = print_qpolynomial(p, fold->qp[i]);
1450 p = isl_printer_print_str(p, ")");
1454 void isl_qpolynomial_fold_print(__isl_keep isl_qpolynomial_fold *fold,
1455 FILE *out, unsigned output_format)
1462 isl_assert(fold->dim->ctx, output_format == ISL_FORMAT_ISL, return);
1464 p = isl_printer_to_file(fold->dim->ctx, out);
1465 p = isl_printer_print_qpolynomial_fold(p, fold);
1467 isl_printer_free(p);
1470 static __isl_give isl_printer *isl_pwqp_print_isl_body(
1471 __isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp)
1475 for (i = 0; i < pwqp->n; ++i) {
1477 p = isl_printer_print_str(p, "; ");
1478 if (!isl_space_is_params(pwqp->p[i].set->dim)) {
1479 p = print_space(pwqp->p[i].set->dim, p, 0, 0, NULL, NULL);
1480 p = isl_printer_print_str(p, " -> ");
1482 p = print_qpolynomial(p, pwqp->p[i].qp);
1483 p = print_disjuncts((isl_map *)pwqp->p[i].set, p, 0);
1489 static __isl_give isl_printer *print_pw_qpolynomial_isl(
1490 __isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp)
1495 if (isl_space_dim(pwqp->dim, isl_dim_param) > 0) {
1496 p = print_tuple(pwqp->dim, p, isl_dim_param, 0, NULL, NULL);
1497 p = isl_printer_print_str(p, " -> ");
1499 p = isl_printer_print_str(p, "{ ");
1501 if (!isl_space_is_set(pwqp->dim)) {
1502 p = print_tuple(pwqp->dim, p, isl_dim_in, 0, NULL, NULL);
1503 p = isl_printer_print_str(p, " -> ");
1505 p = isl_printer_print_str(p, "0");
1507 p = isl_pwqp_print_isl_body(p, pwqp);
1508 p = isl_printer_print_str(p, " }");
1511 isl_printer_free(p);
1515 void isl_pw_qpolynomial_print(__isl_keep isl_pw_qpolynomial *pwqp, FILE *out,
1516 unsigned output_format)
1523 p = isl_printer_to_file(pwqp->dim->ctx, out);
1524 p = isl_printer_set_output_format(p, output_format);
1525 p = isl_printer_print_pw_qpolynomial(p, pwqp);
1527 isl_printer_free(p);
1530 static __isl_give isl_printer *isl_pwf_print_isl_body(
1531 __isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf)
1535 for (i = 0; i < pwf->n; ++i) {
1537 p = isl_printer_print_str(p, "; ");
1538 if (!isl_space_is_params(pwf->p[i].set->dim)) {
1539 p = print_space(pwf->p[i].set->dim, p, 0, 0, NULL, NULL);
1540 p = isl_printer_print_str(p, " -> ");
1542 p = qpolynomial_fold_print(pwf->p[i].fold, p);
1543 p = print_disjuncts((isl_map *)pwf->p[i].set, p, 0);
1549 static __isl_give isl_printer *print_pw_qpolynomial_fold_isl(
1550 __isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf)
1552 if (isl_space_dim(pwf->dim, isl_dim_param) > 0) {
1553 p = print_tuple(pwf->dim, p, isl_dim_param, 0, NULL, NULL);
1554 p = isl_printer_print_str(p, " -> ");
1556 p = isl_printer_print_str(p, "{ ");
1558 if (!isl_space_is_set(pwf->dim)) {
1559 p = print_tuple(pwf->dim, p, isl_dim_in, 0, NULL, NULL);
1560 p = isl_printer_print_str(p, " -> ");
1562 p = isl_printer_print_str(p, "0");
1564 p = isl_pwf_print_isl_body(p, pwf);
1565 p = isl_printer_print_str(p, " }");
1569 static __isl_give isl_printer *print_affine_c(__isl_take isl_printer *p,
1570 __isl_keep isl_space *dim, __isl_keep isl_basic_set *bset, isl_int *c);
1572 static __isl_give isl_printer *print_name_c(__isl_take isl_printer *p,
1573 __isl_keep isl_space *dim,
1574 __isl_keep isl_basic_set *bset, enum isl_dim_type type, unsigned pos)
1576 if (type == isl_dim_div) {
1577 p = isl_printer_print_str(p, "floord(");
1578 p = print_affine_c(p, dim, bset, bset->div[pos] + 1);
1579 p = isl_printer_print_str(p, ", ");
1580 p = isl_printer_print_isl_int(p, bset->div[pos][0]);
1581 p = isl_printer_print_str(p, ")");
1585 name = isl_space_get_dim_name(dim, type, pos);
1588 p = isl_printer_print_str(p, name);
1593 static __isl_give isl_printer *print_term_c(__isl_take isl_printer *p,
1594 __isl_keep isl_space *dim,
1595 __isl_keep isl_basic_set *bset, isl_int c, unsigned pos)
1597 enum isl_dim_type type;
1600 return isl_printer_print_isl_int(p, c);
1602 if (isl_int_is_one(c))
1604 else if (isl_int_is_negone(c))
1605 p = isl_printer_print_str(p, "-");
1607 p = isl_printer_print_isl_int(p, c);
1608 p = isl_printer_print_str(p, "*");
1610 type = pos2type(dim, &pos);
1611 p = print_name_c(p, dim, bset, type, pos);
1615 static __isl_give isl_printer *print_partial_affine_c(__isl_take isl_printer *p,
1616 __isl_keep isl_space *dim,
1617 __isl_keep isl_basic_set *bset, isl_int *c, unsigned len)
1622 for (i = 0, first = 1; i < len; ++i) {
1624 if (isl_int_is_zero(c[i]))
1627 if (isl_int_is_neg(c[i])) {
1629 isl_int_neg(c[i], c[i]);
1630 p = isl_printer_print_str(p, " - ");
1632 p = isl_printer_print_str(p, " + ");
1635 p = print_term_c(p, dim, bset, c[i], i);
1637 isl_int_neg(c[i], c[i]);
1640 p = isl_printer_print_str(p, "0");
1644 static __isl_give isl_printer *print_affine_c(__isl_take isl_printer *p,
1645 __isl_keep isl_space *dim, __isl_keep isl_basic_set *bset, isl_int *c)
1647 unsigned len = 1 + isl_basic_set_total_dim(bset);
1648 return print_partial_affine_c(p, dim, bset, c, len);
1651 static __isl_give isl_printer *print_constraint_c(__isl_take isl_printer *p,
1652 __isl_keep isl_space *dim,
1653 __isl_keep isl_basic_set *bset, isl_int *c, const char *op, int first)
1656 p = isl_printer_print_str(p, " && ");
1658 p = print_affine_c(p, dim, bset, c);
1659 p = isl_printer_print_str(p, " ");
1660 p = isl_printer_print_str(p, op);
1661 p = isl_printer_print_str(p, " 0");
1665 static __isl_give isl_printer *print_basic_set_c(__isl_take isl_printer *p,
1666 __isl_keep isl_space *dim, __isl_keep isl_basic_set *bset)
1669 unsigned n_div = isl_basic_set_dim(bset, isl_dim_div);
1670 unsigned total = isl_basic_set_total_dim(bset) - n_div;
1672 for (i = 0; i < bset->n_eq; ++i) {
1673 j = isl_seq_last_non_zero(bset->eq[i] + 1 + total, n_div);
1675 p = print_constraint_c(p, dim, bset,
1676 bset->eq[i], "==", !i);
1679 p = isl_printer_print_str(p, " && ");
1680 p = isl_printer_print_str(p, "(");
1681 p = print_partial_affine_c(p, dim, bset, bset->eq[i],
1683 p = isl_printer_print_str(p, ") % ");
1684 p = isl_printer_print_isl_int(p,
1685 bset->eq[i][1 + total + j]);
1686 p = isl_printer_print_str(p, " == 0");
1689 for (i = 0; i < bset->n_ineq; ++i)
1690 p = print_constraint_c(p, dim, bset, bset->ineq[i], ">=",
1695 static __isl_give isl_printer *print_set_c(__isl_take isl_printer *p,
1696 __isl_keep isl_space *dim, __isl_keep isl_set *set)
1701 p = isl_printer_print_str(p, "0");
1703 for (i = 0; i < set->n; ++i) {
1705 p = isl_printer_print_str(p, " || ");
1707 p = isl_printer_print_str(p, "(");
1708 p = print_basic_set_c(p, dim, set->p[i]);
1710 p = isl_printer_print_str(p, ")");
1715 static __isl_give isl_printer *print_pw_qpolynomial_c(
1716 __isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp)
1720 if (pwqp->n == 1 && isl_set_plain_is_universe(pwqp->p[0].set))
1721 return print_qpolynomial_c(p, pwqp->dim, pwqp->p[0].qp);
1723 for (i = 0; i < pwqp->n; ++i) {
1724 p = isl_printer_print_str(p, "(");
1725 p = print_set_c(p, pwqp->dim, pwqp->p[i].set);
1726 p = isl_printer_print_str(p, ") ? (");
1727 p = print_qpolynomial_c(p, pwqp->dim, pwqp->p[i].qp);
1728 p = isl_printer_print_str(p, ") : ");
1731 p = isl_printer_print_str(p, "0");
1735 __isl_give isl_printer *isl_printer_print_pw_qpolynomial(
1736 __isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial *pwqp)
1741 if (p->output_format == ISL_FORMAT_ISL)
1742 return print_pw_qpolynomial_isl(p, pwqp);
1743 else if (p->output_format == ISL_FORMAT_C)
1744 return print_pw_qpolynomial_c(p, pwqp);
1745 isl_assert(p->ctx, 0, goto error);
1747 isl_printer_free(p);
1751 static int print_pwqp_body(__isl_take isl_pw_qpolynomial *pwqp, void *user)
1753 struct isl_union_print_data *data;
1754 data = (struct isl_union_print_data *)user;
1757 data->p = isl_printer_print_str(data->p, "; ");
1760 data->p = isl_pwqp_print_isl_body(data->p, pwqp);
1761 isl_pw_qpolynomial_free(pwqp);
1766 static __isl_give isl_printer *print_union_pw_qpolynomial_isl(
1767 __isl_take isl_printer *p, __isl_keep isl_union_pw_qpolynomial *upwqp)
1769 struct isl_union_print_data data = { p, 1 };
1771 dim = isl_union_pw_qpolynomial_get_space(upwqp);
1772 if (isl_space_dim(dim, isl_dim_param) > 0) {
1773 p = print_tuple(dim, p, isl_dim_param, 0, NULL, NULL);
1774 p = isl_printer_print_str(p, " -> ");
1776 isl_space_free(dim);
1777 p = isl_printer_print_str(p, "{ ");
1778 isl_union_pw_qpolynomial_foreach_pw_qpolynomial(upwqp, &print_pwqp_body,
1781 p = isl_printer_print_str(p, " }");
1785 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial(
1786 __isl_take isl_printer *p, __isl_keep isl_union_pw_qpolynomial *upwqp)
1791 if (p->output_format == ISL_FORMAT_ISL)
1792 return print_union_pw_qpolynomial_isl(p, upwqp);
1793 isl_die(p->ctx, isl_error_invalid,
1794 "invalid output format for isl_union_pw_qpolynomial",
1797 isl_printer_free(p);
1801 static __isl_give isl_printer *print_qpolynomial_fold_c(
1802 __isl_take isl_printer *p, __isl_keep isl_space *dim,
1803 __isl_keep isl_qpolynomial_fold *fold)
1807 for (i = 0; i < fold->n - 1; ++i)
1808 if (fold->type == isl_fold_min)
1809 p = isl_printer_print_str(p, "min(");
1810 else if (fold->type == isl_fold_max)
1811 p = isl_printer_print_str(p, "max(");
1813 for (i = 0; i < fold->n; ++i) {
1815 p = isl_printer_print_str(p, ", ");
1816 p = print_qpolynomial_c(p, dim, fold->qp[i]);
1818 p = isl_printer_print_str(p, ")");
1823 __isl_give isl_printer *isl_printer_print_qpolynomial_fold(
1824 __isl_take isl_printer *p, __isl_keep isl_qpolynomial_fold *fold)
1828 if (p->output_format == ISL_FORMAT_ISL)
1829 return qpolynomial_fold_print(fold, p);
1830 else if (p->output_format == ISL_FORMAT_C)
1831 return print_qpolynomial_fold_c(p, fold->dim, fold);
1832 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
1835 isl_printer_free(p);
1839 static __isl_give isl_printer *print_pw_qpolynomial_fold_c(
1840 __isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf)
1844 if (pwf->n == 1 && isl_set_plain_is_universe(pwf->p[0].set))
1845 return print_qpolynomial_fold_c(p, pwf->dim, pwf->p[0].fold);
1847 for (i = 0; i < pwf->n; ++i) {
1848 p = isl_printer_print_str(p, "(");
1849 p = print_set_c(p, pwf->dim, pwf->p[i].set);
1850 p = isl_printer_print_str(p, ") ? (");
1851 p = print_qpolynomial_fold_c(p, pwf->dim, pwf->p[i].fold);
1852 p = isl_printer_print_str(p, ") : ");
1855 p = isl_printer_print_str(p, "0");
1859 __isl_give isl_printer *isl_printer_print_pw_qpolynomial_fold(
1860 __isl_take isl_printer *p, __isl_keep isl_pw_qpolynomial_fold *pwf)
1865 if (p->output_format == ISL_FORMAT_ISL)
1866 return print_pw_qpolynomial_fold_isl(p, pwf);
1867 else if (p->output_format == ISL_FORMAT_C)
1868 return print_pw_qpolynomial_fold_c(p, pwf);
1869 isl_assert(p->ctx, 0, goto error);
1871 isl_printer_free(p);
1875 void isl_pw_qpolynomial_fold_print(__isl_keep isl_pw_qpolynomial_fold *pwf,
1876 FILE *out, unsigned output_format)
1883 p = isl_printer_to_file(pwf->dim->ctx, out);
1884 p = isl_printer_set_output_format(p, output_format);
1885 p = isl_printer_print_pw_qpolynomial_fold(p, pwf);
1887 isl_printer_free(p);
1890 static int print_pwf_body(__isl_take isl_pw_qpolynomial_fold *pwf, void *user)
1892 struct isl_union_print_data *data;
1893 data = (struct isl_union_print_data *)user;
1896 data->p = isl_printer_print_str(data->p, "; ");
1899 data->p = isl_pwf_print_isl_body(data->p, pwf);
1900 isl_pw_qpolynomial_fold_free(pwf);
1905 static __isl_give isl_printer *print_union_pw_qpolynomial_fold_isl(
1906 __isl_take isl_printer *p,
1907 __isl_keep isl_union_pw_qpolynomial_fold *upwf)
1909 struct isl_union_print_data data = { p, 1 };
1911 dim = isl_union_pw_qpolynomial_fold_get_space(upwf);
1912 if (isl_space_dim(dim, isl_dim_param) > 0) {
1913 p = print_tuple(dim, p, isl_dim_param, 0, NULL, NULL);
1914 p = isl_printer_print_str(p, " -> ");
1916 isl_space_free(dim);
1917 p = isl_printer_print_str(p, "{ ");
1918 isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold(upwf,
1919 &print_pwf_body, &data);
1921 p = isl_printer_print_str(p, " }");
1925 __isl_give isl_printer *isl_printer_print_union_pw_qpolynomial_fold(
1926 __isl_take isl_printer *p,
1927 __isl_keep isl_union_pw_qpolynomial_fold *upwf)
1932 if (p->output_format == ISL_FORMAT_ISL)
1933 return print_union_pw_qpolynomial_fold_isl(p, upwf);
1934 isl_die(p->ctx, isl_error_invalid,
1935 "invalid output format for isl_union_pw_qpolynomial_fold",
1938 isl_printer_free(p);
1942 __isl_give isl_printer *isl_printer_print_constraint(__isl_take isl_printer *p,
1943 __isl_keep isl_constraint *c)
1945 isl_basic_map *bmap;
1950 bmap = isl_basic_map_from_constraint(isl_constraint_copy(c));
1951 p = isl_printer_print_basic_map(p, bmap);
1952 isl_basic_map_free(bmap);
1955 isl_printer_free(p);
1959 __isl_give isl_printer *isl_printer_print_space(__isl_take isl_printer *p,
1960 __isl_keep isl_space *dim)
1965 if (isl_space_dim(dim, isl_dim_param) > 0) {
1966 p = print_tuple(dim, p, isl_dim_param, 0, NULL, NULL);
1967 p = isl_printer_print_str(p, " -> ");
1970 p = isl_printer_print_str(p, "{ ");
1971 if (isl_space_is_params(dim))
1972 p = isl_printer_print_str(p, s_such_that[0]);
1974 p = print_space(dim, p, 0, 0, NULL, NULL);
1975 p = isl_printer_print_str(p, " }");
1979 isl_printer_free(p);
1983 __isl_give isl_printer *isl_printer_print_local_space(__isl_take isl_printer *p,
1984 __isl_keep isl_local_space *ls)
1992 total = isl_local_space_dim(ls, isl_dim_all);
1993 if (isl_local_space_dim(ls, isl_dim_param) > 0) {
1994 p = print_tuple(ls->dim, p, isl_dim_param, 0, NULL, NULL);
1995 p = isl_printer_print_str(p, " -> ");
1997 p = isl_printer_print_str(p, "{ ");
1998 p = print_space(ls->dim, p, 0, 0, NULL, NULL);
1999 n_div = isl_local_space_dim(ls, isl_dim_div);
2002 p = isl_printer_print_str(p, " : ");
2003 p = isl_printer_print_str(p, s_open_exists[0]);
2004 for (i = 0; i < n_div; ++i) {
2006 p = isl_printer_print_str(p, ", ");
2007 p = print_name(ls->dim, p, isl_dim_div, i, 0);
2008 if (isl_int_is_zero(ls->div->row[i][0]))
2010 p = isl_printer_print_str(p, " = [(");
2011 p = print_affine_of_len(ls->dim, ls->div, p,
2012 ls->div->row[i] + 1, 1 + total);
2013 p = isl_printer_print_str(p, ")/");
2014 p = isl_printer_print_isl_int(p, ls->div->row[i][0]);
2015 p = isl_printer_print_str(p, "]");
2017 } else if (isl_space_is_params(ls->dim))
2018 p = isl_printer_print_str(p, s_such_that[0]);
2019 p = isl_printer_print_str(p, " }");
2022 isl_printer_free(p);
2026 static __isl_give isl_printer *print_aff_body(__isl_take isl_printer *p,
2027 __isl_keep isl_aff *aff)
2031 total = isl_local_space_dim(aff->ls, isl_dim_all);
2032 p = isl_printer_print_str(p, "(");
2033 p = print_affine_of_len(aff->ls->dim, aff->ls->div, p,
2034 aff->v->el + 1, 1 + total);
2035 if (isl_int_is_one(aff->v->el[0]))
2036 p = isl_printer_print_str(p, ")");
2038 p = isl_printer_print_str(p, ")/");
2039 p = isl_printer_print_isl_int(p, aff->v->el[0]);
2045 static __isl_give isl_printer *print_aff(__isl_take isl_printer *p,
2046 __isl_keep isl_aff *aff)
2048 if (isl_space_is_params(aff->ls->dim))
2051 p = print_tuple(aff->ls->dim, p, isl_dim_set, 0, NULL, NULL);
2052 p = isl_printer_print_str(p, " -> ");
2054 p = isl_printer_print_str(p, "[");
2055 p = print_aff_body(p, aff);
2056 p = isl_printer_print_str(p, "]");
2061 static __isl_give isl_printer *print_aff_isl(__isl_take isl_printer *p,
2062 __isl_keep isl_aff *aff)
2067 if (isl_local_space_dim(aff->ls, isl_dim_param) > 0) {
2068 p = print_tuple(aff->ls->dim, p, isl_dim_param, 0, NULL, NULL);
2069 p = isl_printer_print_str(p, " -> ");
2071 p = isl_printer_print_str(p, "{ ");
2072 p = print_aff(p, aff);
2073 p = isl_printer_print_str(p, " }");
2076 isl_printer_free(p);
2080 static __isl_give isl_printer *print_pw_aff_isl(__isl_take isl_printer *p,
2081 __isl_keep isl_pw_aff *pwaff)
2088 if (isl_space_dim(pwaff->dim, isl_dim_param) > 0) {
2089 p = print_tuple(pwaff->dim, p, isl_dim_param, 0, NULL, NULL);
2090 p = isl_printer_print_str(p, " -> ");
2092 p = isl_printer_print_str(p, "{ ");
2093 for (i = 0; i < pwaff->n; ++i) {
2095 p = isl_printer_print_str(p, "; ");
2096 p = print_aff(p, pwaff->p[i].aff);
2097 p = print_disjuncts((isl_map *)pwaff->p[i].set, p, 0);
2099 p = isl_printer_print_str(p, " }");
2102 isl_printer_free(p);
2106 static __isl_give isl_printer *print_ls_affine_c(__isl_take isl_printer *p,
2107 __isl_keep isl_local_space *ls, isl_int *c);
2109 static __isl_give isl_printer *print_ls_name_c(__isl_take isl_printer *p,
2110 __isl_keep isl_local_space *ls, enum isl_dim_type type, unsigned pos)
2112 if (type == isl_dim_div) {
2113 p = isl_printer_print_str(p, "floord(");
2114 p = print_ls_affine_c(p, ls, ls->div->row[pos] + 1);
2115 p = isl_printer_print_str(p, ", ");
2116 p = isl_printer_print_isl_int(p, ls->div->row[pos][0]);
2117 p = isl_printer_print_str(p, ")");
2121 name = isl_space_get_dim_name(ls->dim, type, pos);
2124 p = isl_printer_print_str(p, name);
2129 static __isl_give isl_printer *print_ls_term_c(__isl_take isl_printer *p,
2130 __isl_keep isl_local_space *ls, isl_int c, unsigned pos)
2132 enum isl_dim_type type;
2135 return isl_printer_print_isl_int(p, c);
2137 if (isl_int_is_one(c))
2139 else if (isl_int_is_negone(c))
2140 p = isl_printer_print_str(p, "-");
2142 p = isl_printer_print_isl_int(p, c);
2143 p = isl_printer_print_str(p, "*");
2145 type = pos2type(ls->dim, &pos);
2146 p = print_ls_name_c(p, ls, type, pos);
2150 static __isl_give isl_printer *print_ls_partial_affine_c(
2151 __isl_take isl_printer *p, __isl_keep isl_local_space *ls,
2152 isl_int *c, unsigned len)
2157 for (i = 0, first = 1; i < len; ++i) {
2159 if (isl_int_is_zero(c[i]))
2162 if (isl_int_is_neg(c[i])) {
2164 isl_int_neg(c[i], c[i]);
2165 p = isl_printer_print_str(p, " - ");
2167 p = isl_printer_print_str(p, " + ");
2170 p = print_ls_term_c(p, ls, c[i], i);
2172 isl_int_neg(c[i], c[i]);
2175 p = isl_printer_print_str(p, "0");
2179 static __isl_give isl_printer *print_ls_affine_c(__isl_take isl_printer *p,
2180 __isl_keep isl_local_space *ls, isl_int *c)
2182 unsigned len = 1 + isl_local_space_dim(ls, isl_dim_all);
2183 return print_ls_partial_affine_c(p, ls, c, len);
2186 static __isl_give isl_printer *print_aff_c(__isl_take isl_printer *p,
2187 __isl_keep isl_aff *aff)
2191 total = isl_local_space_dim(aff->ls, isl_dim_all);
2192 p = isl_printer_print_str(p, "(");
2193 p = print_ls_partial_affine_c(p, aff->ls, aff->v->el + 1, 1 + total);
2194 if (isl_int_is_one(aff->v->el[0]))
2195 p = isl_printer_print_str(p, ")");
2197 p = isl_printer_print_str(p, ")/");
2198 p = isl_printer_print_isl_int(p, aff->v->el[0]);
2203 static __isl_give isl_printer *print_pw_aff_c(__isl_take isl_printer *p,
2204 __isl_keep isl_pw_aff *pwaff)
2209 isl_die(p->ctx, isl_error_unsupported,
2210 "cannot print empty isl_pw_aff in C format", goto error);
2212 for (i = 0; i < pwaff->n - 1; ++i) {
2213 p = isl_printer_print_str(p, "(");
2214 p = print_set_c(p, pwaff->dim, pwaff->p[i].set);
2215 p = isl_printer_print_str(p, ") ? (");
2216 p = print_aff_c(p, pwaff->p[i].aff);
2217 p = isl_printer_print_str(p, ") : ");
2220 return print_aff_c(p, pwaff->p[pwaff->n - 1].aff);
2222 isl_printer_free(p);
2226 __isl_give isl_printer *isl_printer_print_aff(__isl_take isl_printer *p,
2227 __isl_keep isl_aff *aff)
2232 if (p->output_format == ISL_FORMAT_ISL)
2233 return print_aff_isl(p, aff);
2234 else if (p->output_format == ISL_FORMAT_C)
2235 return print_aff_c(p, aff);
2236 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
2239 isl_printer_free(p);
2243 __isl_give isl_printer *isl_printer_print_pw_aff(__isl_take isl_printer *p,
2244 __isl_keep isl_pw_aff *pwaff)
2249 if (p->output_format == ISL_FORMAT_ISL)
2250 return print_pw_aff_isl(p, pwaff);
2251 else if (p->output_format == ISL_FORMAT_C)
2252 return print_pw_aff_c(p, pwaff);
2253 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
2256 isl_printer_free(p);
2260 static __isl_give isl_printer *print_multi_aff(__isl_take isl_printer *p,
2261 __isl_keep isl_multi_aff *maff)
2263 return print_space(maff->space, p, 0, 0, NULL, maff);
2266 static __isl_give isl_printer *print_multi_aff_isl(__isl_take isl_printer *p,
2267 __isl_keep isl_multi_aff *maff)
2272 if (isl_space_dim(maff->space, isl_dim_param) > 0) {
2273 p = print_tuple(maff->space, p, isl_dim_param, 0, NULL, NULL);
2274 p = isl_printer_print_str(p, " -> ");
2276 p = isl_printer_print_str(p, "{ ");
2277 p = print_multi_aff(p, maff);
2278 p = isl_printer_print_str(p, " }");
2281 isl_printer_free(p);
2285 __isl_give isl_printer *isl_printer_print_multi_aff(__isl_take isl_printer *p,
2286 __isl_keep isl_multi_aff *maff)
2291 if (p->output_format == ISL_FORMAT_ISL)
2292 return print_multi_aff_isl(p, maff);
2293 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
2296 isl_printer_free(p);
2300 static __isl_give isl_printer *print_pw_multi_aff_isl(__isl_take isl_printer *p,
2301 __isl_keep isl_pw_multi_aff *pma)
2308 if (isl_space_dim(pma->dim, isl_dim_param) > 0) {
2309 p = print_tuple(pma->dim, p, isl_dim_param, 0, NULL, NULL);
2310 p = isl_printer_print_str(p, " -> ");
2312 p = isl_printer_print_str(p, "{ ");
2313 for (i = 0; i < pma->n; ++i) {
2315 p = isl_printer_print_str(p, "; ");
2316 p = print_multi_aff(p, pma->p[i].maff);
2317 p = print_disjuncts((isl_map *)pma->p[i].set, p, 0);
2319 p = isl_printer_print_str(p, " }");
2322 isl_printer_free(p);
2326 __isl_give isl_printer *isl_printer_print_pw_multi_aff(
2327 __isl_take isl_printer *p, __isl_keep isl_pw_multi_aff *pma)
2332 if (p->output_format == ISL_FORMAT_ISL)
2333 return print_pw_multi_aff_isl(p, pma);
2334 isl_die(p->ctx, isl_error_unsupported, "unsupported output format",
2337 isl_printer_free(p);