summaryrefslogtreecommitdiff
path: root/isl_input.c
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2008-09-08 16:57:41 +0200
committerSven Verdoolaege <skimo@kotnet.org>2008-09-08 16:57:41 +0200
commit0c8b3535fe28f5ca90e0408ada81daf01cbb47e5 (patch)
tree8bf2ccb490cfc06ec450fe853b5c72b60b1d677c /isl_input.c
parent17151f04973ecdcfa99113e094369bbb852b20f7 (diff)
downloadisl-0c8b3535fe28f5ca90e0408ada81daf01cbb47e5.tar.gz
isl-0c8b3535fe28f5ca90e0408ada81daf01cbb47e5.tar.bz2
isl-0c8b3535fe28f5ca90e0408ada81daf01cbb47e5.zip
add isl_set_read_from_file for reading unions of polyhedra (in polylib format)
Diffstat (limited to 'isl_input.c')
-rw-r--r--isl_input.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/isl_input.c b/isl_input.c
index 6e5d9071..23b3c07d 100644
--- a/isl_input.c
+++ b/isl_input.c
@@ -75,6 +75,37 @@ error:
return NULL;
}
+static struct isl_set *isl_set_read_from_file_polylib(
+ struct isl_ctx *ctx, FILE *input)
+{
+ struct isl_set *set = NULL;
+ char line[1024];
+ int i;
+ unsigned n;
+
+ isl_assert(ctx, next_line(input, line, sizeof(line)), return NULL);
+ isl_assert(ctx, sscanf(line, "%u", &n) == 1, return NULL);
+
+ set = isl_set_alloc(ctx, 0, 0, n, 0);
+ if (!set)
+ return NULL;
+ if (n == 0)
+ return set;
+ for (i = 0; i < n; ++i) {
+ set->p[i] = isl_basic_set_read_from_file_polylib(ctx, input);
+ if (!set->p[i])
+ goto error;
+ }
+ set->n = n;
+ set->dim = set->p[0]->dim;
+ for (i = 1; i < n; ++i)
+ isl_assert(ctx, set->dim == set->p[i]->dim, goto error);
+ return set;
+error:
+ isl_set_free(ctx, set);
+ return NULL;
+}
+
struct isl_basic_set *isl_basic_set_read_from_file(struct isl_ctx *ctx,
FILE *input, unsigned input_format)
{
@@ -94,3 +125,12 @@ struct isl_basic_map *isl_basic_map_read_from_file(struct isl_ctx *ctx,
else
isl_assert(ctx, 0, return NULL);
}
+
+struct isl_set *isl_set_read_from_file(struct isl_ctx *ctx,
+ FILE *input, unsigned input_format)
+{
+ if (input_format == ISL_FORMAT_POLYLIB)
+ return isl_set_read_from_file_polylib(ctx, input);
+ else
+ isl_assert(ctx, 0, return NULL);
+}