privately add isl_mat_col_addmul
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 22 Nov 2016 15:21:08 +0000 (22 16:21 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 23 Nov 2016 10:49:40 +0000 (23 11:49 +0100)
This will be used in a fix of reduce_divs in isl_polynomial.c.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_mat.c
isl_mat_private.h

index 2eb399e..d878427 100644 (file)
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -1530,6 +1530,29 @@ void isl_mat_col_mul(struct isl_mat *mat, int dst_col, isl_int f, int src_col)
                isl_int_mul(mat->row[i][dst_col], f, mat->row[i][src_col]);
 }
 
+/* Add "f" times column "src_col" to column "dst_col" of "mat" and
+ * return the result.
+ */
+__isl_give isl_mat *isl_mat_col_addmul(__isl_take isl_mat *mat, int dst_col,
+       isl_int f, int src_col)
+{
+       int i;
+
+       if (check_col(mat, dst_col) < 0 || check_col(mat, src_col) < 0)
+               return isl_mat_free(mat);
+
+       for (i = 0; i < mat->n_row; ++i) {
+               if (isl_int_is_zero(mat->row[i][src_col]))
+                       continue;
+               mat = isl_mat_cow(mat);
+               if (!mat)
+                       return NULL;
+               isl_int_addmul(mat->row[i][dst_col], f, mat->row[i][src_col]);
+       }
+
+       return mat;
+}
+
 struct isl_mat *isl_mat_unimodular_complete(struct isl_mat *M, int row)
 {
        int r;
index fd808ed..a97169f 100644 (file)
@@ -44,6 +44,8 @@ isl_stat isl_mat_row_gcd(__isl_keep isl_mat *mat, int row, isl_int *gcd);
 void isl_mat_col_mul(struct isl_mat *mat, int dst_col, isl_int f, int src_col);
 void isl_mat_col_submul(struct isl_mat *mat,
                        int dst_col, isl_int f, int src_col);
+__isl_give isl_mat *isl_mat_col_addmul(__isl_take isl_mat *mat, int dst_col,
+       isl_int f, int src_col);
 
 int isl_mat_get_element(__isl_keep isl_mat *mat, int row, int col, isl_int *v);
 __isl_give isl_mat *isl_mat_set_element(__isl_take isl_mat *mat,