From 19556df351532e510c9e7cf5ab7d35254338dc1e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 26 Feb 2009 11:59:03 +0100 Subject: [PATCH] add isl_mat_swap_cols --- isl_mat.c | 19 +++++++++++++++++++ isl_mat.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/isl_mat.c b/isl_mat.c index 306f236..e2566d5 100644 --- a/isl_mat.c +++ b/isl_mat.c @@ -670,6 +670,25 @@ error: return NULL; } +struct isl_mat *isl_mat_swap_cols(struct isl_ctx *ctx, + struct isl_mat *mat, unsigned i, unsigned j) +{ + int r; + + mat = isl_mat_cow(ctx, mat); + if (!mat) + return NULL; + isl_assert(ctx, i < mat->n_col, goto error); + isl_assert(ctx, j < mat->n_col, goto error); + + for (r = 0; r < mat->n_row; ++r) + isl_int_swap(mat->row[r][i], mat->row[r][j]); + return mat; +error: + isl_mat_free(ctx, mat); + return NULL; +} + struct isl_mat *isl_mat_swap_rows(struct isl_ctx *ctx, struct isl_mat *mat, unsigned i, unsigned j) { diff --git a/isl_mat.h b/isl_mat.h index 503b6f4..ea38739 100644 --- a/isl_mat.h +++ b/isl_mat.h @@ -41,6 +41,8 @@ void isl_mat_sub_copy(struct isl_ctx *ctx, isl_int **dst, isl_int **src, void isl_mat_sub_neg(struct isl_ctx *ctx, isl_int **dst, isl_int **src, unsigned n_row, unsigned dst_col, unsigned src_col, unsigned n_col); +struct isl_mat *isl_mat_swap_cols(struct isl_ctx *ctx, + struct isl_mat *mat, unsigned i, unsigned j); struct isl_mat *isl_mat_swap_rows(struct isl_ctx *ctx, struct isl_mat *mat, unsigned i, unsigned j); -- 2.7.4