* Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
*/
+#include <isl_ctx_private.h>
#include <isl_mat_private.h>
#include "isl_map_private.h"
#include "isl_tab.h"
#include <isl/seq.h>
+#include <isl_config.h>
/*
* The implementation of tableaus in this file was inspired by Section 8
return NULL;
}
+static void free_undo_record(struct isl_tab_undo *undo)
+{
+ switch (undo->type) {
+ case isl_tab_undo_saved_basis:
+ free(undo->u.col_var);
+ break;
+ default:;
+ }
+ free(undo);
+}
+
static void free_undo(struct isl_tab *tab)
{
struct isl_tab_undo *undo, *next;
for (undo = tab->top; undo && undo != &tab->bottom; undo = next) {
next = undo->next;
- free(undo);
+ free_undo_record(undo);
}
tab->top = undo;
}
struct isl_tab_var *var;
unsigned off = 2 + tab->M;
+ if (tab->mat->ctx->abort) {
+ isl_ctx_set_error(tab->mat->ctx, isl_error_abort);
+ return -1;
+ }
+
isl_int_swap(mat->row[row][0], mat->row[row][off + col]);
sgn = isl_int_sgn(mat->row[row][0]);
if (sgn < 0) {
return isl_tab_pivot(tab, r, var->index);
}
+/* Check whether all variables that are marked as non-negative
+ * also have a non-negative sample value. This function is not
+ * called from the current code but is useful during debugging.
+ */
+static void check_table(struct isl_tab *tab) __attribute__ ((unused));
static void check_table(struct isl_tab *tab)
{
int i;
static int may_be_equality(struct isl_tab *tab, int row)
{
- unsigned off = 2 + tab->M;
return tab->rational ? isl_int_is_zero(tab->mat->row[row][1])
: isl_int_lt(tab->mat->row[row][1],
tab->mat->row[row][0]);
static int perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo)
{
struct isl_tab_var *var = var_from_index(tab, undo->u.var_index);
- switch(undo->type) {
+ switch (undo->type) {
case isl_tab_undo_nonneg:
var->is_nonneg = 0;
break;
break;
case isl_tab_undo_relax:
return unrelax(tab, var);
+ default:
+ isl_die(tab->mat->ctx, isl_error_internal,
+ "perform_undo_var called on invalid undo record",
+ return -1);
}
return 0;
}
free(extra);
- free(col_var);
return 0;
error:
free(extra);
- free(col_var);
return -1;
}
tab->in_undo = 0;
return -1;
}
- free(undo);
+ free_undo_record(undo);
}
tab->in_undo = 0;
tab->top = undo;
return (isl_basic_set *)tab->bmap;
}
-void isl_tab_dump(struct isl_tab *tab, FILE *out, int indent)
+static void isl_tab_print_internal(__isl_keep struct isl_tab *tab,
+ FILE *out, int indent)
{
unsigned r, c;
int i;
tab->mat->n_row = tab->n_row;
c = tab->mat->n_col;
tab->mat->n_col = 2 + tab->M + tab->n_col;
- isl_mat_dump(tab->mat, out, indent);
+ isl_mat_print_internal(tab->mat, out, indent);
tab->mat->n_row = r;
tab->mat->n_col = c;
if (tab->bmap)
isl_basic_map_print_internal(tab->bmap, out, indent);
}
+
+void isl_tab_dump(__isl_keep struct isl_tab *tab)
+{
+ isl_tab_print_internal(tab, stderr, 0);
+}