summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2013-05-28 14:12:55 +0200
committerSven Verdoolaege <skimo@kotnet.org>2013-05-28 20:42:49 +0200
commitd93eecde09989748350cc1a7f92bea4c6c4e14c3 (patch)
tree633173f1404c20f14605cfdc36f4e2af7fe2b3fe
parent7bc3560a92635b5dcf7eb9e7329992fc935a1ce2 (diff)
downloadisl-d93eecde09989748350cc1a7f92bea4c6c4e14c3.tar.gz
isl-d93eecde09989748350cc1a7f92bea4c6c4e14c3.tar.bz2
isl-d93eecde09989748350cc1a7f92bea4c6c4e14c3.zip
temporarily add isl_val_get_num_isl_int
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
-rw-r--r--doc/user.pod6
-rw-r--r--include/isl/val_int.h1
-rw-r--r--isl_val.c15
3 files changed, 20 insertions, 2 deletions
diff --git a/doc/user.pod b/doc/user.pod
index ee8ce0c9..1e46faf8 100644
--- a/doc/user.pod
+++ b/doc/user.pod
@@ -522,13 +522,15 @@ C<GMP> values using the following functions.
=head3 Conversion from C<isl_int>
-The following function is only temporarily available to ease
-the transition from C<isl_int> to C<isl_val>. It will be removed
+The following functions are only temporarily available to ease
+the transition from C<isl_int> to C<isl_val>. They will be removed
in the next release.
#include <isl/val_int.h>
__isl_give isl_val *isl_val_int_from_isl_int(isl_ctx *ctx,
isl_int n);
+ int isl_val_get_num_isl_int(__isl_keep isl_val *v,
+ isl_int *n);
=head2 Integers (obsolescent)
diff --git a/include/isl/val_int.h b/include/isl/val_int.h
index 3f8bc202..521d5a6f 100644
--- a/include/isl/val_int.h
+++ b/include/isl/val_int.h
@@ -5,5 +5,6 @@
#include <isl/val.h>
__isl_give isl_val *isl_val_int_from_isl_int(isl_ctx *ctx, isl_int n);
+int isl_val_get_num_isl_int(__isl_keep isl_val *v, isl_int *n);
#endif
diff --git a/isl_val.c b/isl_val.c
index c61b4adb..dca32289 100644
--- a/isl_val.c
+++ b/isl_val.c
@@ -284,6 +284,21 @@ long isl_val_get_num_si(__isl_keep isl_val *v)
return isl_int_get_si(v->n);
}
+/* Extract the numerator of a rational value "v" as an isl_int.
+ *
+ * If "v" is not a rational value, then the result is undefined.
+ */
+int isl_val_get_num_isl_int(__isl_keep isl_val *v, isl_int *n)
+{
+ if (!v)
+ return -1;
+ if (!isl_val_is_rat(v))
+ isl_die(isl_val_get_ctx(v), isl_error_invalid,
+ "expecting rational value", return -1);
+ isl_int_set(*n, v->n);
+ return 0;
+}
+
/* Extract the denominator of a rational value "v" as an integer.
*
* If "v" is not a rational value, then the result is undefined.