[seed] [mpfr] Implement sinh, cosh, tanh



commit 0db0b75a50f935f3472890b59583bc93b4dafcef
Author: Matt ARSENAULT <arsenm2 rpi edu>
Date:   Sun Jul 5 02:34:07 2009 -0400

    [mpfr] Implement sinh, cosh, tanh

 modules/mpfr/seed-mpfr-trig.c |   92 +++++++++++++++++++++++++++++++++++++++++
 modules/mpfr/seed-mpfr.c      |    3 +
 modules/mpfr/seed-mpfr.h      |    4 ++
 3 files changed, 99 insertions(+), 0 deletions(-)
---
diff --git a/modules/mpfr/seed-mpfr-trig.c b/modules/mpfr/seed-mpfr-trig.c
index f392a20..1bc4425 100644
--- a/modules/mpfr/seed-mpfr-trig.c
+++ b/modules/mpfr/seed-mpfr-trig.c
@@ -367,3 +367,95 @@ SeedValue seed_mpfr_log10 (SeedContext ctx,
     return seed_value_from_int(ctx, ret, exception);
 }
 
+/* hyperbolic trig functions */
+
+SeedValue seed_mpfr_sinh (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.sinh", 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.sinh", "mpfr_t");
+    }
+
+    ret = mpfr_sinh(rop, op, rnd);
+
+    return seed_value_from_int(ctx, ret, exception);
+}
+
+SeedValue seed_mpfr_cosh (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.cosh", 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.cosh", "mpfr_t");
+    }
+
+    ret = mpfr_cosh(rop, op, rnd);
+
+    return seed_value_from_int(ctx, ret, exception);
+}
+
+SeedValue seed_mpfr_tanh (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.tanh", 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.tanh", "mpfr_t");
+    }
+
+    ret = mpfr_tanh(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 5763a73..c5cb8f2 100644
--- a/modules/mpfr/seed-mpfr.c
+++ b/modules/mpfr/seed-mpfr.c
@@ -343,6 +343,9 @@ seed_static_function mpfr_funcs[] =
     {"log", seed_mpfr_log, 0},
     {"log2", seed_mpfr_log2, 0},
     {"log10", seed_mpfr_log10, 0},
+    {"sinh", seed_mpfr_sinh, 0},
+    {"cosh", seed_mpfr_cosh, 0},
+    {"tanh", seed_mpfr_tanh, 0},
     {"set", seed_mpfr_set, 0},
     {"out_str", seed_mpfr_out_str, 0},
     {"pi", seed_mpfr_const_pi, 0},
diff --git a/modules/mpfr/seed-mpfr.h b/modules/mpfr/seed-mpfr.h
index 4cf4d97..e68b6e7 100644
--- a/modules/mpfr/seed-mpfr.h
+++ b/modules/mpfr/seed-mpfr.h
@@ -71,5 +71,9 @@ DEF_SEED_MPFR_FUNC(seed_mpfr_log);
 DEF_SEED_MPFR_FUNC(seed_mpfr_log2);
 DEF_SEED_MPFR_FUNC(seed_mpfr_log10);
 
+DEF_SEED_MPFR_FUNC(seed_mpfr_sinh);
+DEF_SEED_MPFR_FUNC(seed_mpfr_cosh);
+DEF_SEED_MPFR_FUNC(seed_mpfr_tanh);
+
 #endif      /* _SEED_MFPR_H_ */
 



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