add isl_pw_multi_aff_get_pw_aff
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 11 Dec 2011 12:12:29 +0000 (13:12 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 11 Dec 2011 15:53:05 +0000 (16:53 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/aff.h
isl_aff.c

index 6c40d9e..3a9afa7 100644 (file)
@@ -3137,6 +3137,8 @@ The expression can be inspected using
                enum isl_dim_type type);
        __isl_give isl_aff *isl_multi_aff_get_aff(
                __isl_keep isl_multi_aff *multi, int pos);
+       __isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff(
+               __isl_keep isl_pw_multi_aff *pma, int pos);
        const char *isl_pw_multi_aff_get_dim_name(
                __isl_keep isl_pw_multi_aff *pma,
                enum isl_dim_type type, unsigned pos);
index 32c0d03..0ee2120 100644 (file)
@@ -278,6 +278,8 @@ void *isl_pw_multi_aff_free(__isl_take isl_pw_multi_aff *pma);
 
 unsigned isl_pw_multi_aff_dim(__isl_keep isl_pw_multi_aff *pma,
        enum isl_dim_type type);
+__isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff(
+       __isl_keep isl_pw_multi_aff *pma, int pos);
 
 isl_ctx *isl_pw_multi_aff_get_ctx(__isl_keep isl_pw_multi_aff *pma);
 __isl_give isl_space *isl_pw_multi_aff_get_domain_space(
index 722da3b..d0e1010 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -2516,3 +2516,37 @@ error:
                isl_local_space_free(*ls);
        return isl_multi_aff_free(maff);
 }
+
+
+/* Extract an isl_pw_aff corresponding to output dimension "pos" of "pma".
+ */
+__isl_give isl_pw_aff *isl_pw_multi_aff_get_pw_aff(
+       __isl_keep isl_pw_multi_aff *pma, int pos)
+{
+       int i;
+       int n_out;
+       isl_space *space;
+       isl_pw_aff *pa;
+
+       if (!pma)
+               return NULL;
+
+       n_out = isl_pw_multi_aff_dim(pma, isl_dim_out);
+       if (pos < 0 || pos >= n_out)
+               isl_die(isl_pw_multi_aff_get_ctx(pma), isl_error_invalid,
+                       "index out of bounds", return NULL);
+
+       space = isl_pw_multi_aff_get_space(pma);
+       space = isl_space_drop_dims(space, isl_dim_out,
+                                   pos + 1, n_out - pos - 1);
+       space = isl_space_drop_dims(space, isl_dim_out, 0, pos);
+
+       pa = isl_pw_aff_alloc_size(space, pma->n);
+       for (i = 0; i < pma->n; ++i) {
+               isl_aff *aff;
+               aff = isl_multi_aff_get_aff(pma->p[i].maff, pos);
+               pa = isl_pw_aff_add_piece(pa, isl_set_copy(pma->p[i].set), aff);
+       }
+
+       return pa;
+}