[seed] [mpfr] Added mpfr.cbrt



commit 76def6eb1a80f10763bd43cf080144976bb6a4ee
Author: Matt ARSENAULT <arsenm2 rpi edu>
Date:   Sun Jul 5 11:51:07 2009 -0400

    [mpfr] Added mpfr.cbrt

 modules/mpfr/seed-mpfr-arithmetic.c |   30 ++++++++++++++++++++++++++++++
 modules/mpfr/seed-mpfr.c            |    1 +
 modules/mpfr/seed-mpfr.h            |    1 +
 3 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/modules/mpfr/seed-mpfr-arithmetic.c b/modules/mpfr/seed-mpfr-arithmetic.c
index 5b59902..af8f2b6 100644
--- a/modules/mpfr/seed-mpfr-arithmetic.c
+++ b/modules/mpfr/seed-mpfr-arithmetic.c
@@ -125,3 +125,33 @@ SeedValue seed_mpfr_rec_sqrt (SeedContext ctx,
     return seed_value_from_int(ctx, ret, exception);
 }
 
+SeedValue seed_mpfr_cbrt (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;
+
+    CHECK_ARG_COUNT("mpfr.cbrt", 2);
+
+    rop = seed_object_get_private(this_object);
+    rnd = seed_value_to_mpfr_rnd_t(ctx, args[1], exception);
+
+    if ( seed_value_is_object_of_class(ctx, args[0], mpfr_class) )
+    {
+        op = seed_object_get_private(args[0]);
+    }
+    else
+    {
+        TYPE_EXCEPTION("mpfr.cbrt", "mpfr_t");
+    }
+
+    ret = mpfr_cbrt(rop, op, rnd);
+
+    return seed_value_from_int(ctx, ret, exception);
+}
+
diff --git a/modules/mpfr/seed-mpfr.c b/modules/mpfr/seed-mpfr.c
index 3fab9d2..cbb0fda 100644
--- a/modules/mpfr/seed-mpfr.c
+++ b/modules/mpfr/seed-mpfr.c
@@ -604,6 +604,7 @@ seed_static_function mpfr_funcs[] =
     {"add", seed_mpfr_add, 0},
     {"sqrt", seed_mpfr_sqrt, 0},
     {"rec_sqrt", seed_mpfr_rec_sqrt, 0},
+    {"cbrt", seed_mpfr_cbrt, 0},
     {"sin", seed_mpfr_sin, 0},
     {"cos", seed_mpfr_cos, 0},
     {"tan", seed_mpfr_tan, 0},
diff --git a/modules/mpfr/seed-mpfr.h b/modules/mpfr/seed-mpfr.h
index 80db7cb..2fdb3cf 100644
--- a/modules/mpfr/seed-mpfr.h
+++ b/modules/mpfr/seed-mpfr.h
@@ -85,6 +85,7 @@ DEF_SEED_MPFR_FUNC(seed_mpfr_atanh);
 
 DEF_SEED_MPFR_FUNC(seed_mpfr_sqrt);
 DEF_SEED_MPFR_FUNC(seed_mpfr_rec_sqrt);
+DEF_SEED_MPFR_FUNC(seed_mpfr_cbrt);
 
 #endif      /* _SEED_MFPR_H_ */
 



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