summaryrefslogtreecommitdiff
path: root/isl_tab.c
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2009-10-05 11:41:37 +0200
committerSven Verdoolaege <skimo@kotnet.org>2009-10-09 19:56:02 +0200
commitd13fd7f0fc432a2175eee6d5c8e35e43661e6a36 (patch)
tree72bd05888425d6dfc144122f743af4648a89638d /isl_tab.c
parent6470e1b83f923566155a45a9389bf50d792e3abb (diff)
downloadisl-d13fd7f0fc432a2175eee6d5c8e35e43661e6a36.tar.gz
isl-d13fd7f0fc432a2175eee6d5c8e35e43661e6a36.tar.bz2
isl-d13fd7f0fc432a2175eee6d5c8e35e43661e6a36.zip
isl_tab.c: extract out samples handling from isl_tab_pip.c
Diffstat (limited to 'isl_tab.c')
-rw-r--r--isl_tab.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/isl_tab.c b/isl_tab.c
index 7a1fd19f..94d3eb0a 100644
--- a/isl_tab.c
+++ b/isl_tab.c
@@ -791,6 +791,54 @@ void isl_tab_push_basis(struct isl_tab *tab)
push_union(tab, isl_tab_undo_saved_basis, u);
}
+struct isl_tab *isl_tab_init_samples(struct isl_tab *tab)
+{
+ if (!tab)
+ return NULL;
+
+ tab->n_sample = 0;
+ tab->n_outside = 0;
+ tab->samples = isl_mat_alloc(tab->mat->ctx, 1, 1 + tab->n_var);
+ if (!tab->samples)
+ goto error;
+ return tab;
+error:
+ isl_tab_free(tab);
+ return NULL;
+}
+
+struct isl_tab *isl_tab_add_sample(struct isl_tab *tab,
+ __isl_take isl_vec *sample)
+{
+ if (!tab || !sample)
+ goto error;
+
+ tab->samples = isl_mat_extend(tab->samples,
+ tab->n_sample + 1, tab->samples->n_col);
+ if (!tab->samples)
+ goto error;
+
+ isl_seq_cpy(tab->samples->row[tab->n_sample], sample->el, sample->size);
+ isl_vec_free(sample);
+ tab->n_sample++;
+
+ return tab;
+error:
+ isl_vec_free(sample);
+ isl_tab_free(tab);
+ return NULL;
+}
+
+struct isl_tab *isl_tab_drop_sample(struct isl_tab *tab, int s)
+{
+ if (s != tab->n_outside)
+ isl_mat_swap_rows(tab->samples, tab->n_outside, s);
+ tab->n_outside++;
+ isl_tab_push(tab, isl_tab_undo_drop_sample);
+
+ return tab;
+}
+
/* Mark row with index "row" as being redundant.
* If we may need to undo the operation or if the row represents
* a variable of the original problem, the row is kept,