From b3acbdec6ee87a2c00278f47556b7de0653a7687 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 15 Apr 2009 20:43:08 +0200 Subject: [PATCH] privately export isl_mat_unimodular_complete --- isl_equalities.c | 30 ++---------------------------- isl_mat.c | 26 ++++++++++++++++++++++++++ isl_mat.h | 3 +++ 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/isl_equalities.c b/isl_equalities.c index 67fe05f..0632ddd 100644 --- a/isl_equalities.c +++ b/isl_equalities.c @@ -104,32 +104,6 @@ error: return NULL; } -static struct isl_mat *unimodular_complete(struct isl_ctx *ctx, - struct isl_mat *M, int row) -{ - int r; - struct isl_mat *H = NULL, *Q = NULL; - - isl_assert(ctx, M->n_row == M->n_col, goto error); - M->n_row = row; - H = isl_mat_left_hermite(ctx, isl_mat_copy(ctx, M), 0, NULL, &Q); - M->n_row = M->n_col; - if (!H) - goto error; - for (r = 0; r < row; ++r) - isl_assert(ctx, isl_int_is_one(H->row[r][r]), goto error); - for (r = row; r < M->n_row; ++r) - isl_seq_cpy(M->row[r], Q->row[r], M->n_col); - isl_mat_free(ctx, H); - isl_mat_free(ctx, Q); - return M; -error: - isl_mat_free(ctx, H); - isl_mat_free(ctx, Q); - isl_mat_free(ctx, M); - return NULL; -} - /* Compute and return the matrix * * U_1^{-1} diag(d_1, 1, ..., 1) @@ -147,7 +121,7 @@ static struct isl_mat *parameter_compression_1(struct isl_ctx *ctx, if (!U) return NULL; isl_seq_cpy(U->row[0], B->row[0] + 1, B->n_col - 1); - U = unimodular_complete(ctx, U, 1); + U = isl_mat_unimodular_complete(ctx, U, 1); U = isl_mat_right_inverse(ctx, U); if (!U) return NULL; @@ -193,7 +167,7 @@ static struct isl_mat *parameter_compression_multi(struct isl_ctx *ctx, goto error; for (i = 0; i < B->n_row; ++i) { isl_seq_cpy(U->row[0], B->row[i] + 1, size); - U = unimodular_complete(ctx, U, 1); + U = isl_mat_unimodular_complete(ctx, U, 1); if (!U) goto error; isl_int_divexact(D, D, d->block.data[i]); diff --git a/isl_mat.c b/isl_mat.c index 10b81e3..4947c3d 100644 --- a/isl_mat.c +++ b/isl_mat.c @@ -987,3 +987,29 @@ void isl_mat_col_mul(struct isl_mat *mat, int dst_col, isl_int f, int src_col) for (i = 0; i < mat->n_row; ++i) isl_int_mul(mat->row[i][dst_col], f, mat->row[i][src_col]); } + +struct isl_mat *isl_mat_unimodular_complete(struct isl_ctx *ctx, + struct isl_mat *M, int row) +{ + int r; + struct isl_mat *H = NULL, *Q = NULL; + + isl_assert(ctx, M->n_row == M->n_col, goto error); + M->n_row = row; + H = isl_mat_left_hermite(ctx, isl_mat_copy(ctx, M), 0, NULL, &Q); + M->n_row = M->n_col; + if (!H) + goto error; + for (r = 0; r < row; ++r) + isl_assert(ctx, isl_int_is_one(H->row[r][r]), goto error); + for (r = row; r < M->n_row; ++r) + isl_seq_cpy(M->row[r], Q->row[r], M->n_col); + isl_mat_free(ctx, H); + isl_mat_free(ctx, Q); + return M; +error: + isl_mat_free(ctx, H); + isl_mat_free(ctx, Q); + isl_mat_free(ctx, M); + return NULL; +} diff --git a/isl_mat.h b/isl_mat.h index 72aa593..97cc107 100644 --- a/isl_mat.h +++ b/isl_mat.h @@ -77,6 +77,9 @@ struct isl_basic_set *isl_basic_set_preimage(struct isl_basic_set *bset, struct isl_mat *mat); struct isl_set *isl_set_preimage(struct isl_set *set, struct isl_mat *mat); +struct isl_mat *isl_mat_unimodular_complete(struct isl_ctx *ctx, + struct isl_mat *M, int row); + void isl_mat_dump(struct isl_ctx *ctx, struct isl_mat *mat, FILE *out, int indent); -- 2.7.4