From: Sven Verdoolaege Date: Thu, 26 Feb 2009 10:59:03 +0000 (+0100) Subject: add isl_mat_swap_cols X-Git-Tag: isl-0.01~270 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19556df351532e510c9e7cf5ab7d35254338dc1e;p=platform%2Fupstream%2Fisl.git add isl_mat_swap_cols --- 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);