[seed] More rounding functions
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] More rounding functions
- Date: Sun, 5 Jul 2009 22:26:19 +0000 (UTC)
commit d31406898690806d151375ab0fffdabb05acdaa9
Author: Matt ARSENAULT <arsenm2 rpi edu>
Date: Sun Jul 5 18:15:57 2009 -0400
More rounding functions
modules/mpfr/seed-mpfr-arithmetic.c | 120 +++++++++++++++++++++++++++++++++++
modules/mpfr/seed-mpfr.c | 4 +
modules/mpfr/seed-mpfr.h | 5 ++
3 files changed, 129 insertions(+), 0 deletions(-)
---
diff --git a/modules/mpfr/seed-mpfr-arithmetic.c b/modules/mpfr/seed-mpfr-arithmetic.c
index 9486d15..a6caae9 100644
--- a/modules/mpfr/seed-mpfr-arithmetic.c
+++ b/modules/mpfr/seed-mpfr-arithmetic.c
@@ -391,3 +391,123 @@ SeedValue seed_mpfr_trunc (SeedContext ctx,
return seed_value_from_int(ctx, ret, exception);
}
+SeedValue seed_mpfr_rint_ceil (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.rint_ceil", 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.rint_ceil", "mpfr_t");
+ }
+
+ ret = mpfr_rint_ceil(rop, op, rnd);
+
+ return seed_value_from_int(ctx, ret, exception);
+}
+
+SeedValue seed_mpfr_rint_floor (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.rint_floor", 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.rint_floor", "mpfr_t");
+ }
+
+ ret = mpfr_rint_floor(rop, op, rnd);
+
+ return seed_value_from_int(ctx, ret, exception);
+}
+
+SeedValue seed_mpfr_rint_round (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.rint_round", 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.rint_round", "mpfr_t");
+ }
+
+ ret = mpfr_rint_round(rop, op, rnd);
+
+ return seed_value_from_int(ctx, ret, exception);
+}
+
+SeedValue seed_mpfr_rint_trunc (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.rint_trunc", 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.rint_trunc", "mpfr_t");
+ }
+
+ ret = mpfr_rint_trunc(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 194ecd0..44794f2 100644
--- a/modules/mpfr/seed-mpfr.c
+++ b/modules/mpfr/seed-mpfr.c
@@ -636,6 +636,10 @@ seed_static_function mpfr_funcs[] =
{"floor", seed_mpfr_floor, 0},
{"round", seed_mpfr_round, 0},
{"trunc", seed_mpfr_trunc, 0},
+ {"rint_ceil", seed_mpfr_rint_ceil, 0},
+ {"rint_floor", seed_mpfr_rint_floor, 0},
+ {"rint_round", seed_mpfr_rint_round, 0},
+ {"rint_trunc", seed_mpfr_rint_trunc, 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 e96aa6d..d7a7790 100644
--- a/modules/mpfr/seed-mpfr.h
+++ b/modules/mpfr/seed-mpfr.h
@@ -64,6 +64,11 @@ 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_rint_ceil);
+DEF_SEED_MPFR_FUNC(seed_mpfr_rint_floor);
+DEF_SEED_MPFR_FUNC(seed_mpfr_rint_round);
+DEF_SEED_MPFR_FUNC(seed_mpfr_rint_trunc);
+
DEF_SEED_MPFR_FUNC(seed_mpfr_add);
DEF_SEED_MPFR_FUNC(seed_mpfr_sin);
DEF_SEED_MPFR_FUNC(seed_mpfr_cos);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]