From 085b64113165bf00abae150f15a96431682dc522 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 29 Jul 2009 15:18:47 +0200 Subject: [PATCH] add isl_basic_set_positive_orthant --- include/isl_set.h | 1 + isl_map.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/isl_set.h b/include/isl_set.h index 7c467d2..40d24e3 100644 --- a/include/isl_set.h +++ b/include/isl_set.h @@ -96,6 +96,7 @@ struct isl_basic_set *isl_basic_set_universe(struct isl_dim *dim); struct isl_basic_set *isl_basic_set_universe_like(struct isl_basic_set *bset); struct isl_basic_set *isl_basic_set_interval(struct isl_ctx *ctx, isl_int min, isl_int max); +struct isl_basic_set *isl_basic_set_positive_orthant(struct isl_dim *dims); void isl_basic_set_dump(struct isl_basic_set *bset, FILE *out, int indent); struct isl_basic_set *isl_basic_set_swap_vars( diff --git a/isl_map.c b/isl_map.c index 868d9fb..ef64139 100644 --- a/isl_map.c +++ b/isl_map.c @@ -3420,6 +3420,36 @@ struct isl_map *isl_map_identity_like(struct isl_basic_map *model) return map_identity(isl_dim_copy(model->dim)); } +/* Construct a basic set with all set dimensions having only non-negative + * values. + */ +struct isl_basic_set *isl_basic_set_positive_orthant(struct isl_dim *dims) +{ + int i; + unsigned nparam; + unsigned dim; + struct isl_basic_set *bset; + + if (!dims) + return NULL; + nparam = dims->nparam; + dim = dims->n_out; + bset = isl_basic_set_alloc_dim(dims, 0, 0, dim); + if (!bset) + return NULL; + for (i = 0; i < dim; ++i) { + int k = isl_basic_set_alloc_inequality(bset); + if (k < 0) + goto error; + isl_seq_clr(bset->ineq[k], 1 + isl_basic_set_total_dim(bset)); + isl_int_set_si(bset->ineq[k][1 + nparam + i], 1); + } + return bset; +error: + isl_basic_set_free(bset); + return NULL; +} + int isl_set_is_equal(struct isl_set *set1, struct isl_set *set2) { return isl_map_is_equal((struct isl_map *)set1, (struct isl_map *)set2); -- 2.7.4