summaryrefslogtreecommitdiff
path: root/isl_mat.c
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2008-08-22 16:31:44 +0200
committerSven Verdoolaege <skimo@kotnet.org>2008-08-25 10:24:29 +0200
commit14578ca228e38f9d45688cbf2c14bc855500f9a8 (patch)
treef024f854b8c3a06f27ce44202de304119fcf01d9 /isl_mat.c
parent07463aa4448ef62ce9994c36411d23dbfdca294d (diff)
downloadisl-14578ca228e38f9d45688cbf2c14bc855500f9a8.tar.gz
isl-14578ca228e38f9d45688cbf2c14bc855500f9a8.tar.bz2
isl-14578ca228e38f9d45688cbf2c14bc855500f9a8.zip
sample: remove lineality and skew into positive orthant
These changes are needed if we want isl_basic_set_sample to always return an actual point. Without them, the lexmin may be unbounded and we effectively get a ray.
Diffstat (limited to 'isl_mat.c')
-rw-r--r--isl_mat.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/isl_mat.c b/isl_mat.c
index 9b4558c5..4b3b20a7 100644
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -275,11 +275,13 @@ static void oppose(struct isl_ctx *ctx, struct isl_mat *M, struct isl_mat **U,
*
* with U and Q unimodular matrices and H a matrix in column echelon form
* such that on each echelon row the entries in the non-echelon column
- * are non-negative and stricly smaller than the entries in the echelon
- * column. If U or Q are NULL, then these matrices are not computed.
+ * are non-negative (if neg == 0) or non-positive (if neg == 1)
+ * and stricly smaller (in absolute value) than the entries in the echelon
+ * column.
+ * If U or Q are NULL, then these matrices are not computed.
*/
struct isl_mat *isl_mat_left_hermite(struct isl_ctx *ctx,
- struct isl_mat *M, struct isl_mat **U, struct isl_mat **Q)
+ struct isl_mat *M, int neg, struct isl_mat **U, struct isl_mat **Q)
{
isl_int c;
int row, col;
@@ -330,7 +332,10 @@ struct isl_mat *isl_mat_left_hermite(struct isl_ctx *ctx,
for (i = 0; i < col; ++i) {
if (isl_int_is_zero(M->row[row][i]))
continue;
- isl_int_fdiv_q(c, M->row[row][i], M->row[row][col]);
+ if (neg)
+ isl_int_cdiv_q(c, M->row[row][i], M->row[row][col]);
+ else
+ isl_int_fdiv_q(c, M->row[row][i], M->row[row][col]);
if (isl_int_is_zero(c))
continue;
subtract(ctx, M, U, Q, row, col, i, c);
@@ -780,20 +785,20 @@ void isl_mat_dump(struct isl_ctx *ctx, struct isl_mat *mat,
}
}
-struct isl_mat *isl_mat_drop_col(struct isl_ctx *ctx, struct isl_mat *mat,
- unsigned col)
+struct isl_mat *isl_mat_drop_cols(struct isl_ctx *ctx, struct isl_mat *mat,
+ unsigned col, unsigned n)
{
int r;
if (!mat)
return NULL;
- if (col != mat->n_col-1) {
+ if (col != mat->n_col-n) {
for (r = 0; r < mat->n_row; ++r)
- isl_seq_cpy(mat->row[r]+col, mat->row[r]+col+1,
- mat->n_col - col - 1);
+ isl_seq_cpy(mat->row[r]+col, mat->row[r]+col+n,
+ mat->n_col - col - n);
}
- mat->n_col--;
+ mat->n_col -= n;
return mat;
}