add isl_mat_set_element_val
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 9 Apr 2013 14:23:48 +0000 (16:23 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 28 May 2013 16:17:45 +0000 (18:17 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/mat.h
isl_mat.c

index bd26ecf..3fec840 100644 (file)
@@ -3491,6 +3491,9 @@ The elements can be changed and inspected using the following functions.
                int row, int col, isl_int v);
        __isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat,
                int row, int col, int v);
+       __isl_give isl_mat *isl_mat_set_element_val(
+               __isl_take isl_mat *mat, int row, int col,
+               __isl_take isl_val *v);
 
 C<isl_mat_get_element> will return a negative value if anything went wrong.
 In that case, the value of C<*v> is undefined.
index 13db7e2..f5205f9 100644 (file)
@@ -16,6 +16,7 @@
 #include <isl/ctx.h>
 #include <isl/blk.h>
 #include <isl/vec.h>
+#include <isl/val.h>
 
 #if defined(__cplusplus)
 extern "C" {
@@ -43,6 +44,8 @@ __isl_give isl_mat *isl_mat_set_element(__isl_take isl_mat *mat,
        int row, int col, isl_int v);
 __isl_give isl_mat *isl_mat_set_element_si(__isl_take isl_mat *mat,
        int row, int col, int v);
+__isl_give isl_mat *isl_mat_set_element_val(__isl_take isl_mat *mat,
+       int row, int col, __isl_take isl_val *v);
 
 struct isl_mat *isl_mat_swap_cols(struct isl_mat *mat, unsigned i, unsigned j);
 struct isl_mat *isl_mat_swap_rows(struct isl_mat *mat, unsigned i, unsigned j);
index 6b54849..dc256ce 100644 (file)
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -13,6 +13,7 @@
 #include <isl/seq.h>
 #include <isl_mat_private.h>
 #include <isl_space_private.h>
+#include <isl_val_private.h>
 
 isl_ctx *isl_mat_get_ctx(__isl_keep isl_mat *mat)
 {
@@ -283,6 +284,24 @@ error:
        return NULL;
 }
 
+/* Replace the element at row "row", column "col" of "mat" by "v".
+ */
+__isl_give isl_mat *isl_mat_set_element_val(__isl_take isl_mat *mat,
+       int row, int col, __isl_take isl_val *v)
+{
+       if (!v)
+               return isl_mat_free(mat);
+       if (!isl_val_is_int(v))
+               isl_die(isl_val_get_ctx(v), isl_error_invalid,
+                       "expecting integer value", goto error);
+       mat = isl_mat_set_element(mat, row, col, v->n);
+       isl_val_free(v);
+       return mat;
+error:
+       isl_val_free(v);
+       return isl_mat_free(mat);
+}
+
 __isl_give isl_mat *isl_mat_diag(isl_ctx *ctx, unsigned n_row, isl_int d)
 {
        int i;