#define isl_int_fdiv_r(r,i,j) mpz_fdiv_r(r,i,j)
#define isl_int_read(r,s) mpz_set_str(r,s,10)
-#define isl_int_print(out,i) \
+#define isl_int_print(out,i,width) \
do { \
char *s; \
void (*gmp_free) (void *, size_t); \
s = mpz_get_str(0, 10, i); \
- fprintf(out, "%s", s); \
+ fprintf(out, "%*s", width, s); \
mp_get_memory_functions(NULL, NULL, &gmp_free); \
(*gmp_free)(s, strlen(s)+1); \
} while (0)
struct isl_basic_map *bmap);
struct isl_basic_set *isl_basic_set_affine_hull(struct isl_basic_set *bset);
struct isl_basic_set *isl_basic_set_simplify(struct isl_basic_set *bset);
-#define ISL_FORMAT_POLYLIB 1
-#define ISL_FORMAT_OMEGA 2
+#define ISL_FORMAT_POLYLIB 1
+#define ISL_FORMAT_OMEGA 2
struct isl_basic_set *isl_basic_set_read_from_file(struct isl_ctx *ctx,
FILE *input, unsigned nparam, unsigned input_format);
struct isl_set *isl_set_read_from_file(struct isl_ctx *ctx,
FILE *input, unsigned nparam, unsigned input_format);
+#define ISL_FORMAT_POLYLIB_CONSTRAINTS 3
+void isl_basic_set_print(struct isl_basic_set *bset, FILE *out, int indent,
+ const char *prefix, const char *suffix, unsigned output_format);
+void isl_set_print(struct isl_set *set, FILE *out, int indent,
+ unsigned output_format);
+
struct isl_basic_set *isl_basic_set_from_underlying_set(
struct isl_basic_set *bset, struct isl_basic_set *like);
struct isl_set *isl_set_from_underlying_set(
unsigned in = bmap->n_in;
unsigned dim = bmap->n_in + bmap->n_out;
if (!pos)
- isl_int_print(out, c);
+ isl_int_print(out, c, 0);
else {
if (!isl_int_is_one(c))
- isl_int_print(out, c);
+ isl_int_print(out, c, 0);
if (pos < 1 + bmap->nparam)
fprintf(out, "p%d", pos - 1);
else if (pos < 1 + bmap->nparam + in)
fprintf(out, "e%d = [(", i);
dump_affine(bmap, bmap->div[i]+1, out);
fprintf(out, ")/");
- isl_int_print(out, bmap->div[i][0]);
+ isl_int_print(out, bmap->div[i][0], 0);
fprintf(out, "]\n");
}
}
--- /dev/null
+#include <isl_set.h>
+
+static void print_constraint_polylib(struct isl_basic_set *bset,
+ int ineq, int n,
+ FILE *out, int indent, const char *prefix, const char *suffix)
+{
+ int i;
+ isl_int *c = ineq ? bset->ineq[n] : bset->eq[n];
+
+ fprintf(out, "%*s%s", indent, "", prefix ? prefix : "");
+ fprintf(out, "%d", ineq);
+ for (i = 0; i < bset->dim; ++i) {
+ fprintf(out, " ");
+ isl_int_print(out, c[1+bset->nparam+i], 5);
+ }
+ for (i = 0; i < bset->n_div; ++i) {
+ fprintf(out, " ");
+ isl_int_print(out, c[1+bset->nparam+bset->dim+i], 5);
+ }
+ for (i = 0; i < bset->nparam; ++i) {
+ fprintf(out, " ");
+ isl_int_print(out, c[1+i], 5);
+ }
+ fprintf(out, " ");
+ isl_int_print(out, c[0], 5);
+ fprintf(out, "%s\n", suffix ? suffix : "");
+}
+
+static void print_constraints_polylib(struct isl_basic_set *bset,
+ FILE *out, int indent, const char *prefix, const char *suffix)
+{
+ int i;
+
+ for (i = 0; i < bset->n_eq; ++i)
+ print_constraint_polylib(bset, 0, i, out,
+ indent, prefix, suffix);
+ for (i = 0; i < bset->n_ineq; ++i)
+ print_constraint_polylib(bset, 1, i, out,
+ indent, prefix, suffix);
+}
+
+static void isl_basic_set_print_polylib(struct isl_basic_set *bset, FILE *out,
+ int indent, const char *prefix, const char *suffix)
+{
+ unsigned total = bset->nparam + bset->dim + bset->n_div;
+ fprintf(out, "%*s%s", indent, "", prefix ? prefix : "");
+ fprintf(out, "%d %d", bset->n_eq + bset->n_ineq, 1 + total + 1);
+ fprintf(out, "%s\n", suffix ? suffix : "");
+ print_constraints_polylib(bset, out, indent, prefix, suffix);
+}
+
+static void isl_set_print_polylib(struct isl_set *set, FILE *out, int indent)
+{
+ int i;
+
+ fprintf(out, "%*s", indent, "");
+ fprintf(out, "%d\n", set->n);
+ for (i = 0; i < set->n; ++i) {
+ fprintf(out, "\n");
+ isl_basic_set_print_polylib(set->p[i], out, indent, NULL, NULL);
+ }
+}
+
+void isl_basic_set_print(struct isl_basic_set *bset, FILE *out, int indent,
+ const char *prefix, const char *suffix, unsigned output_format)
+{
+ if (!bset)
+ return;
+ if (output_format == ISL_FORMAT_POLYLIB)
+ isl_basic_set_print_polylib(bset, out, indent, prefix, suffix);
+ else if (output_format == ISL_FORMAT_POLYLIB_CONSTRAINTS)
+ print_constraints_polylib(bset, out, indent, prefix, suffix);
+ else
+ isl_assert(bset->ctx, 0, return);
+}
+
+void isl_set_print(struct isl_set *set, FILE *out, int indent,
+ unsigned output_format)
+{
+ if (!set)
+ return;
+ if (output_format == ISL_FORMAT_POLYLIB)
+ isl_set_print_polylib(set, out, indent);
+ else
+ isl_assert(set->ctx, 0, return);
+}