add isl_tab_set_initial_basis_with_cone
[platform/upstream/isl.git] / isl_output.c
1 #include <isl_set.h>
2
3 static void print_constraint_polylib(struct isl_basic_set *bset,
4         int ineq, int n,
5         FILE *out, int indent, const char *prefix, const char *suffix)
6 {
7         int i;
8         unsigned dim = isl_basic_set_n_dim(bset);
9         unsigned nparam = isl_basic_set_n_param(bset);
10         isl_int *c = ineq ? bset->ineq[n] : bset->eq[n];
11
12         fprintf(out, "%*s%s", indent, "", prefix ? prefix : "");
13         fprintf(out, "%d", ineq);
14         for (i = 0; i < dim; ++i) {
15                 fprintf(out, " ");
16                 isl_int_print(out, c[1+nparam+i], 5);
17         }
18         for (i = 0; i < bset->n_div; ++i) {
19                 fprintf(out, " ");
20                 isl_int_print(out, c[1+nparam+dim+i], 5);
21         }
22         for (i = 0; i < nparam; ++i) {
23                 fprintf(out, " ");
24                 isl_int_print(out, c[1+i], 5);
25         }
26         fprintf(out, " ");
27         isl_int_print(out, c[0], 5);
28         fprintf(out, "%s\n", suffix ? suffix : "");
29 }
30
31 static void print_constraints_polylib(struct isl_basic_set *bset,
32         FILE *out, int indent, const char *prefix, const char *suffix)
33 {
34         int i;
35
36         for (i = 0; i < bset->n_eq; ++i)
37                 print_constraint_polylib(bset, 0, i, out,
38                                         indent, prefix, suffix);
39         for (i = 0; i < bset->n_ineq; ++i)
40                 print_constraint_polylib(bset, 1, i, out,
41                                         indent, prefix, suffix);
42 }
43
44 static void isl_basic_set_print_polylib(struct isl_basic_set *bset, FILE *out,
45         int indent, const char *prefix, const char *suffix)
46 {
47         unsigned total = isl_basic_set_total_dim(bset);
48         fprintf(out, "%*s%s", indent, "", prefix ? prefix : "");
49         fprintf(out, "%d %d", bset->n_eq + bset->n_ineq, 1 + total + 1);
50         fprintf(out, "%s\n", suffix ? suffix : "");
51         print_constraints_polylib(bset, out, indent, prefix, suffix);
52 }
53
54 static void isl_set_print_polylib(struct isl_set *set, FILE *out, int indent)
55 {
56         int i;
57
58         fprintf(out, "%*s", indent, "");
59         fprintf(out, "%d\n", set->n);
60         for (i = 0; i < set->n; ++i) {
61                 fprintf(out, "\n");
62                 isl_basic_set_print_polylib(set->p[i], out, indent, NULL, NULL);
63         }
64 }
65
66 void isl_basic_set_print(struct isl_basic_set *bset, FILE *out, int indent,
67         const char *prefix, const char *suffix, unsigned output_format)
68 {
69         if (!bset)
70                 return;
71         if (output_format == ISL_FORMAT_POLYLIB)
72                 isl_basic_set_print_polylib(bset, out, indent, prefix, suffix);
73         else if (output_format == ISL_FORMAT_POLYLIB_CONSTRAINTS)
74                 print_constraints_polylib(bset, out, indent, prefix, suffix);
75         else
76                 isl_assert(bset->ctx, 0, return);
77 }
78
79 void isl_set_print(struct isl_set *set, FILE *out, int indent,
80         unsigned output_format)
81 {
82         if (!set)
83                 return;
84         if (output_format == ISL_FORMAT_POLYLIB)
85                 isl_set_print_polylib(set, out, indent);
86         else
87                 isl_assert(set->ctx, 0, return);
88 }