isl_convex_hull.c: initial_facet_constraint: drop all redundant bounds on face
[platform/upstream/isl.git] / isl_output.c
1 /*
2  * Copyright 2008-2009 Katholieke Universiteit Leuven
3  *
4  * Use of this software is governed by the GNU LGPLv2.1 license
5  *
6  * Written by Sven Verdoolaege, K.U.Leuven, Departement
7  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8  */
9
10 #include <isl_set.h>
11
12 static void print_constraint_polylib(struct isl_basic_set *bset,
13         int ineq, int n,
14         FILE *out, int indent, const char *prefix, const char *suffix)
15 {
16         int i;
17         unsigned dim = isl_basic_set_n_dim(bset);
18         unsigned nparam = isl_basic_set_n_param(bset);
19         isl_int *c = ineq ? bset->ineq[n] : bset->eq[n];
20
21         fprintf(out, "%*s%s", indent, "", prefix ? prefix : "");
22         fprintf(out, "%d", ineq);
23         for (i = 0; i < dim; ++i) {
24                 fprintf(out, " ");
25                 isl_int_print(out, c[1+nparam+i], 5);
26         }
27         for (i = 0; i < bset->n_div; ++i) {
28                 fprintf(out, " ");
29                 isl_int_print(out, c[1+nparam+dim+i], 5);
30         }
31         for (i = 0; i < nparam; ++i) {
32                 fprintf(out, " ");
33                 isl_int_print(out, c[1+i], 5);
34         }
35         fprintf(out, " ");
36         isl_int_print(out, c[0], 5);
37         fprintf(out, "%s\n", suffix ? suffix : "");
38 }
39
40 static void print_constraints_polylib(struct isl_basic_set *bset,
41         FILE *out, int indent, const char *prefix, const char *suffix)
42 {
43         int i;
44
45         for (i = 0; i < bset->n_eq; ++i)
46                 print_constraint_polylib(bset, 0, i, out,
47                                         indent, prefix, suffix);
48         for (i = 0; i < bset->n_ineq; ++i)
49                 print_constraint_polylib(bset, 1, i, out,
50                                         indent, prefix, suffix);
51 }
52
53 static void isl_basic_set_print_polylib(struct isl_basic_set *bset, FILE *out,
54         int indent, const char *prefix, const char *suffix)
55 {
56         unsigned total = isl_basic_set_total_dim(bset);
57         fprintf(out, "%*s%s", indent, "", prefix ? prefix : "");
58         fprintf(out, "%d %d", bset->n_eq + bset->n_ineq, 1 + total + 1);
59         fprintf(out, "%s\n", suffix ? suffix : "");
60         print_constraints_polylib(bset, out, indent, prefix, suffix);
61 }
62
63 static void isl_set_print_polylib(struct isl_set *set, FILE *out, int indent)
64 {
65         int i;
66
67         fprintf(out, "%*s", indent, "");
68         fprintf(out, "%d\n", set->n);
69         for (i = 0; i < set->n; ++i) {
70                 fprintf(out, "\n");
71                 isl_basic_set_print_polylib(set->p[i], out, indent, NULL, NULL);
72         }
73 }
74
75 void isl_basic_set_print(struct isl_basic_set *bset, FILE *out, int indent,
76         const char *prefix, const char *suffix, unsigned output_format)
77 {
78         if (!bset)
79                 return;
80         if (output_format == ISL_FORMAT_POLYLIB)
81                 isl_basic_set_print_polylib(bset, out, indent, prefix, suffix);
82         else if (output_format == ISL_FORMAT_POLYLIB_CONSTRAINTS)
83                 print_constraints_polylib(bset, out, indent, prefix, suffix);
84         else
85                 isl_assert(bset->ctx, 0, return);
86 }
87
88 void isl_set_print(struct isl_set *set, FILE *out, int indent,
89         unsigned output_format)
90 {
91         if (!set)
92                 return;
93         if (output_format == ISL_FORMAT_POLYLIB)
94                 isl_set_print_polylib(set, out, indent);
95         else
96                 isl_assert(set->ctx, 0, return);
97 }