[seed] [mpfr] Added mpfr.div_2si



commit 43110b2c79de98c3db06c6c0482aed9d096689b1
Author: Matt ARSENAULT <arsenm2 rpi edu>
Date:   Wed Jul 8 19:01:22 2009 -0400

    [mpfr] Added mpfr.div_2si

 modules/mpfr/seed-mpfr-arithmetic.c |   40 +++++++++++++++++++++++++++++++++++
 modules/mpfr/seed-mpfr.c            |    1 +
 modules/mpfr/seed-mpfr.h            |    1 +
 3 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/modules/mpfr/seed-mpfr-arithmetic.c b/modules/mpfr/seed-mpfr-arithmetic.c
index f874bd7..166c428 100644
--- a/modules/mpfr/seed-mpfr-arithmetic.c
+++ b/modules/mpfr/seed-mpfr-arithmetic.c
@@ -1210,3 +1210,43 @@ SeedValue seed_mpfr_mul_2si (SeedContext ctx,
     return seed_value_from_int(ctx, ret, exception);
 }
 
+SeedValue seed_mpfr_div_2si (SeedContext ctx,
+                             SeedObject function,
+                             SeedObject this_object,
+                             gsize argument_count,
+                             const SeedValue args[],
+                             SeedException * exception)
+{
+    mpfr_rnd_t rnd;
+    mpfr_ptr rop, op;
+    gint ret;
+    gulong k;
+
+    CHECK_ARG_COUNT("mpfr.div_2si", 3);
+
+    rop = seed_object_get_private(this_object);
+    rnd = seed_value_to_mpfr_rnd_t(ctx, args[2], exception);
+
+    if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
+    {
+        op = seed_object_get_private(args[0]);
+    }
+    else
+    {
+        TYPE_EXCEPTION("mpfr.div_2si", "mpfr_t");
+    }
+
+    if ( seed_value_is_number(ctx, args[1]) )
+    {
+        k = seed_value_to_ulong(ctx, args[1], exception);
+    }
+    else
+    {
+        TYPE_EXCEPTION("mpfr.div_2si", "long int");
+    }
+
+    ret = mpfr_div_2si(rop, op, k, rnd);
+
+    return seed_value_from_int(ctx, ret, exception);
+}
+
diff --git a/modules/mpfr/seed-mpfr.c b/modules/mpfr/seed-mpfr.c
index e092a60..6445cd4 100644
--- a/modules/mpfr/seed-mpfr.c
+++ b/modules/mpfr/seed-mpfr.c
@@ -994,6 +994,7 @@ seed_static_function mpfr_funcs[] =
     {"sqr", seed_mpfr_sqr, 0},
     {"pow", seed_mpfr_pow, 0},
     {"mul_2si", seed_mpfr_mul_2si, 0},
+    {"div_2si", seed_mpfr_div_2si, 0},
     {"root", seed_mpfr_root, 0},
     {"rec_sqrt", seed_mpfr_rec_sqrt, 0},
     {"cbrt", seed_mpfr_cbrt, 0},
diff --git a/modules/mpfr/seed-mpfr.h b/modules/mpfr/seed-mpfr.h
index 33e1ffc..c94b2d5 100644
--- a/modules/mpfr/seed-mpfr.h
+++ b/modules/mpfr/seed-mpfr.h
@@ -126,6 +126,7 @@ DEF_SEED_MPFR_FUNC(seed_mpfr_root);
 DEF_SEED_MPFR_FUNC(seed_mpfr_rec_sqrt);
 DEF_SEED_MPFR_FUNC(seed_mpfr_cbrt);
 DEF_SEED_MPFR_FUNC(seed_mpfr_mul_2si);
+DEF_SEED_MPFR_FUNC(seed_mpfr_div_2si);
 
 DEF_SEED_MPFR_FUNC(seed_mpfr_cmp);
 DEF_SEED_MPFR_FUNC(seed_mpfr_cmpabs);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]