[seed] [mpfr] More rounding related functions
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] [mpfr] More rounding related functions
- Date: Mon, 6 Jul 2009 03:10:59 +0000 (UTC)
commit b38405d41a87e45e9eebab79e4b701362ef5289a
Author: Matt ARSENAULT <arsenm2 rpi edu>
Date: Sun Jul 5 19:06:28 2009 -0400
[mpfr] More rounding related functions
modules/mpfr/seed-mpfr-arithmetic.c | 112 +++++++++++++++++++++++++++++++++++
modules/mpfr/seed-mpfr.c | 4 +
modules/mpfr/seed-mpfr.h | 5 ++
3 files changed, 121 insertions(+), 0 deletions(-)
---
diff --git a/modules/mpfr/seed-mpfr-arithmetic.c b/modules/mpfr/seed-mpfr-arithmetic.c
index a6caae9..38b1bc7 100644
--- a/modules/mpfr/seed-mpfr-arithmetic.c
+++ b/modules/mpfr/seed-mpfr-arithmetic.c
@@ -511,3 +511,115 @@ SeedValue seed_mpfr_rint_trunc (SeedContext ctx,
return seed_value_from_int(ctx, ret, exception);
}
+SeedValue seed_mpfr_frac (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.frac", 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.frac", "mpfr_t");
+ }
+
+ ret = mpfr_frac(rop, op, rnd);
+
+ return seed_value_from_int(ctx, ret, exception);
+}
+
+
+SeedValue seed_mpfr_integer_p (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue args[],
+ SeedException * exception)
+{
+ mpfr_ptr rop;
+ gboolean ret;
+
+ CHECK_ARG_COUNT("mpfr.integer", 0);
+ rop = seed_object_get_private(this_object);
+ ret = mpfr_integer_p(rop);
+
+ return seed_value_from_boolean(ctx, ret, exception);
+}
+
+SeedValue seed_mpfr_fmod (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue args[],
+ SeedException * exception)
+{
+ mpfr_rnd_t rnd;
+ mpfr_ptr rop, op1, op2;
+ gint ret;
+
+ CHECK_ARG_COUNT("mpfr.fmod", 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) &&
+ seed_value_is_object_of_class(ctx, args[1], mpfr_class))
+ {
+ op1 = seed_object_get_private(args[0]);
+ op2 = seed_object_get_private(args[1]);
+ }
+ else
+ {
+ TYPE_EXCEPTION("mpfr.fmod", "mpfr_t");
+ }
+
+ ret = mpfr_fmod(rop, op1, op2, rnd);
+
+ return seed_value_from_int(ctx, ret, exception);
+}
+
+SeedValue seed_mpfr_remainder (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue args[],
+ SeedException * exception)
+{
+ mpfr_rnd_t rnd;
+ mpfr_ptr rop, op1, op2;
+ gint ret;
+
+ CHECK_ARG_COUNT("mpfr.remainder", 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) &&
+ seed_value_is_object_of_class(ctx, args[1], mpfr_class))
+ {
+ op1 = seed_object_get_private(args[0]);
+ op2 = seed_object_get_private(args[1]);
+ }
+ else
+ {
+ TYPE_EXCEPTION("mpfr.remainder", "mpfr_t");
+ }
+
+ ret = mpfr_remainder(rop, op1, op2, rnd);
+
+ return seed_value_from_int(ctx, ret, exception);
+}
+
diff --git a/modules/mpfr/seed-mpfr.c b/modules/mpfr/seed-mpfr.c
index 44794f2..b2ecec1 100644
--- a/modules/mpfr/seed-mpfr.c
+++ b/modules/mpfr/seed-mpfr.c
@@ -640,6 +640,10 @@ seed_static_function mpfr_funcs[] =
{"rint_floor", seed_mpfr_rint_floor, 0},
{"rint_round", seed_mpfr_rint_round, 0},
{"rint_trunc", seed_mpfr_rint_trunc, 0},
+ {"frac", seed_mpfr_frac, 0},
+ {"fmod", seed_mpfr_fmod, 0},
+ {"remainder", seed_mpfr_remainder, 0},
+ {"integer_p", seed_mpfr_integer_p, 0},
{"dim", seed_mpfr_dim, 0},
{"sin", seed_mpfr_sin, 0},
{"cos", seed_mpfr_cos, 0},
diff --git a/modules/mpfr/seed-mpfr.h b/modules/mpfr/seed-mpfr.h
index d7a7790..3f40ad1 100644
--- a/modules/mpfr/seed-mpfr.h
+++ b/modules/mpfr/seed-mpfr.h
@@ -63,6 +63,11 @@ DEF_SEED_MPFR_FUNC(seed_mpfr_ceil);
DEF_SEED_MPFR_FUNC(seed_mpfr_floor);
DEF_SEED_MPFR_FUNC(seed_mpfr_round);
DEF_SEED_MPFR_FUNC(seed_mpfr_trunc);
+DEF_SEED_MPFR_FUNC(seed_mpfr_frac);
+
+DEF_SEED_MPFR_FUNC(seed_mpfr_fmod);
+DEF_SEED_MPFR_FUNC(seed_mpfr_remainder);
+DEF_SEED_MPFR_FUNC(seed_mpfr_integer_p);
DEF_SEED_MPFR_FUNC(seed_mpfr_rint_ceil);
DEF_SEED_MPFR_FUNC(seed_mpfr_rint_floor);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]