add isl_point_get_coordinate_val
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 5 Apr 2013 08:27:51 +0000 (10:27 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 28 May 2013 16:20:22 +0000 (18:20 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/point.h
isl_point.c

index 708e85a..5f8e980 100644 (file)
@@ -4392,6 +4392,9 @@ using
 
        int isl_point_get_coordinate(__isl_keep isl_point *pnt,
                enum isl_dim_type type, int pos, isl_int *v);
+       __isl_give isl_val *isl_point_get_coordinate_val(
+               __isl_keep isl_point *pnt,
+               enum isl_dim_type type, int pos);
        __isl_give isl_point *isl_point_set_coordinate(
                __isl_take isl_point *pnt,
                enum isl_dim_type type, int pos, isl_int v);
index d8bf1e4..7816ed3 100644 (file)
@@ -21,6 +21,8 @@ void isl_point_free(__isl_take isl_point *pnt);
 
 int isl_point_get_coordinate(__isl_keep isl_point *pnt,
        enum isl_dim_type type, int pos, isl_int *v);
+__isl_give isl_val *isl_point_get_coordinate_val(__isl_keep isl_point *pnt,
+       enum isl_dim_type type, int pos);
 __isl_give isl_point *isl_point_set_coordinate(__isl_take isl_point *pnt,
        enum isl_dim_type type, int pos, isl_int v);
 __isl_give isl_point *isl_point_set_coordinate_val(__isl_take isl_point *pnt,
index 874a22e..a86dd67 100644 (file)
@@ -143,6 +143,33 @@ int isl_point_get_coordinate(__isl_keep isl_point *pnt,
        return 0;
 }
 
+/* Return the value of coordinate "pos" of type "type" of "pnt".
+ */
+__isl_give isl_val *isl_point_get_coordinate_val(__isl_keep isl_point *pnt,
+       enum isl_dim_type type, int pos)
+{
+       isl_ctx *ctx;
+       isl_val *v;
+
+       if (!pnt)
+               return NULL;
+
+       ctx = isl_point_get_ctx(pnt);
+       if (isl_point_is_void(pnt))
+               isl_die(ctx, isl_error_invalid,
+                       "void point does not have coordinates", return NULL);
+       if (pos < 0 || pos >= isl_space_dim(pnt->dim, type))
+               isl_die(ctx, isl_error_invalid,
+                       "position out of bounds", return NULL);
+
+       if (type == isl_dim_set)
+               pos += isl_space_dim(pnt->dim, isl_dim_param);
+
+       v = isl_val_rat_from_isl_int(ctx, pnt->vec->el[1 + pos],
+                                               pnt->vec->el[0]);
+       return isl_val_normalize(v);
+}
+
 __isl_give isl_point *isl_point_set_coordinate(__isl_take isl_point *pnt,
        enum isl_dim_type type, int pos, isl_int v)
 {