[seed] [mpfr] Added mpfr.pi



commit 5efda6a612269a871c0db17974e3fc8da03ccc11
Author: Matt ARSENAULT <arsenm2 rpi edu>
Date:   Sat Jul 4 02:11:51 2009 -0400

    [mpfr] Added mpfr.pi

 modules/mpfr/mpfr.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/modules/mpfr/mpfr.c b/modules/mpfr/mpfr.c
index 62970b2..b6ae40c 100644
--- a/modules/mpfr/mpfr.c
+++ b/modules/mpfr/mpfr.c
@@ -132,6 +132,30 @@ seed_mpfr_sin (SeedContext ctx,
     return seed_value_from_int(ctx, ret, except);
 }
 
+static SeedValue
+seed_mpfr_const_pi (SeedContext ctx,
+                    SeedObject function,
+                    SeedObject this_object,
+                    gsize arg_count,
+                    const SeedValue args[],
+                    SeedException * except)
+{
+    mpfr_rnd_t rnd;
+    mpfr_ptr rop;
+    gint ret;
+
+    if ( arg_count != 1 )
+    {
+        EXPECTED_EXCEPTION("mpfr.pi", "1");
+    }
+
+    rop = seed_object_get_private(this_object);
+    rnd = seed_value_to_mpfr_rnd_t(ctx, args[0], except);
+
+    ret = mpfr_const_pi(rop, rnd);
+
+    return seed_value_from_int(ctx, ret, except);
+}
 
 /* This is a bit disgusting. Oh well. */
 static SeedValue
@@ -395,6 +419,7 @@ seed_static_function mpfr_funcs[] =
     {"sin", seed_mpfr_sin, 0},
     {"set", seed_mpfr_set, 0},
     {"out_str", seed_mpfr_out_str, 0},
+    {"pi", seed_mpfr_const_pi, 0},
     {NULL, NULL, 0}
 };
 



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