summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2009-04-13 21:19:41 +0200
committerSven Verdoolaege <skimo@kotnet.org>2009-05-06 11:23:45 +0200
commit5148fa1588494226bfb7b1c5278dea3e316e6372 (patch)
tree9fcd4a658f4ee7bd85ea573df5422a02863bdf71
parentca3cb6d13589c3447578448f6d05403e289bea28 (diff)
downloadisl-5148fa1588494226bfb7b1c5278dea3e316e6372.tar.gz
isl-5148fa1588494226bfb7b1c5278dea3e316e6372.tar.bz2
isl-5148fa1588494226bfb7b1c5278dea3e316e6372.zip
isl_tab.c: add isl_tab_get_sample_value
-rw-r--r--isl_tab.c36
-rw-r--r--isl_tab.h3
2 files changed, 39 insertions, 0 deletions
diff --git a/isl_tab.c b/isl_tab.c
index 5ae619e4..6397e2f7 100644
--- a/isl_tab.c
+++ b/isl_tab.c
@@ -1100,6 +1100,42 @@ static struct isl_vec *extract_integer_sample(struct isl_ctx *ctx,
return vec;
}
+struct isl_vec *isl_tab_get_sample_value(struct isl_ctx *ctx,
+ struct isl_tab *tab)
+{
+ int i;
+ struct isl_vec *vec;
+ isl_int m;
+
+ if (!tab)
+ return NULL;
+
+ vec = isl_vec_alloc(ctx, 1 + tab->n_var);
+ if (!vec)
+ return NULL;
+
+ isl_int_init(m);
+
+ isl_int_set_si(vec->block.data[0], 1);
+ for (i = 0; i < tab->n_var; ++i) {
+ int row;
+ if (!tab->var[i].is_row) {
+ isl_int_set_si(vec->block.data[1 + i], 0);
+ continue;
+ }
+ row = tab->var[i].index;
+ isl_int_gcd(m, vec->block.data[0], tab->mat->row[row][0]);
+ isl_int_divexact(m, tab->mat->row[row][0], m);
+ isl_seq_scale(vec->block.data, vec->block.data, m, 1 + i);
+ isl_int_divexact(m, vec->block.data[0], tab->mat->row[row][0]);
+ isl_int_mul(vec->block.data[1 + i], m, tab->mat->row[row][1]);
+ }
+ isl_seq_normalize(vec->block.data, vec->size);
+
+ isl_int_clear(m);
+ return vec;
+}
+
/* Update "bmap" based on the results of the tableau "tab".
* In particular, implicit equalities are made explicit, redundant constraints
* are removed and if the sample value happens to be integer, it is stored
diff --git a/isl_tab.h b/isl_tab.h
index e3535f7e..e6231aac 100644
--- a/isl_tab.h
+++ b/isl_tab.h
@@ -118,6 +118,9 @@ struct isl_tab *isl_tab_add_ineq(struct isl_ctx *ctx,
int isl_tab_is_equality(struct isl_ctx *ctx, struct isl_tab *tab, int con);
int isl_tab_is_redundant(struct isl_ctx *ctx, struct isl_tab *tab, int con);
+struct isl_vec *isl_tab_get_sample_value(struct isl_ctx *ctx,
+ struct isl_tab *tab);
+
enum isl_ineq_type {
isl_ineq_error = -1,
isl_ineq_redundant,