add isl_mat_get_col
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 28 Dec 2016 17:02:05 +0000 (28 18:02 +0100)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Fri, 14 May 2021 22:16:01 +0000 (15 00:16 +0200)
This function will be used in the support for
inter-statement consecutivity constraints.

Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
isl_mat.c
isl_mat_private.h

index d32ad8c..54c52d3 100644 (file)
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -2,7 +2,7 @@
  * Copyright 2008-2009 Katholieke Universiteit Leuven
  * Copyright 2010      INRIA Saclay
  * Copyright 2014      Ecole Normale Superieure
- * Copyright 2017      Sven Verdoolaege
+ * Copyright 2016-2017 Sven Verdoolaege
  *
  * Use of this software is governed by the MIT license
  *
@@ -1867,6 +1867,25 @@ __isl_give isl_vec *isl_mat_get_row(__isl_keep isl_mat *mat, unsigned row)
        return v;
 }
 
+/* Return a copy of column "col" of "mat" as an isl_vec.
+ */
+__isl_give isl_vec *isl_mat_get_col(__isl_keep isl_mat *mat, unsigned col)
+{
+       int i;
+       isl_vec *v;
+
+       if (check_col_range(mat, col, 1) < 0)
+               return NULL;
+
+       v = isl_vec_alloc(isl_mat_get_ctx(mat), mat->n_row);
+       if (!v)
+               return NULL;
+       for (i = 0; i < mat->n_row; ++i)
+               isl_int_set(v->el[i], mat->row[i][col]);
+
+       return v;
+}
+
 __isl_give isl_mat *isl_mat_vec_concat(__isl_take isl_mat *top,
        __isl_take isl_vec *bot)
 {
index 9d880b5..9b4a62e 100644 (file)
@@ -47,6 +47,7 @@ __isl_give isl_mat *isl_mat_scale_down_row(__isl_take isl_mat *mat, int row,
        isl_int m);
 
 __isl_give isl_vec *isl_mat_get_row(__isl_keep isl_mat *mat, unsigned row);
+__isl_give isl_vec *isl_mat_get_col(__isl_keep isl_mat *mat, unsigned col);
 
 __isl_give isl_mat *isl_mat_lexnonneg_rows(__isl_take isl_mat *mat);