[seed] [mpfr] Added mpfr.min, mpfr.max
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] [mpfr] Added mpfr.min, mpfr.max
- Date: Mon, 6 Jul 2009 03:11:14 +0000 (UTC)
commit 8de7ca10090920cd681563b89ad52c9753a11395
Author: Matt ARSENAULT <arsenm2 rpi edu>
Date: Sun Jul 5 19:40:02 2009 -0400
[mpfr] Added mpfr.min, mpfr.max
modules/mpfr/seed-mpfr-arithmetic.c | 64 +++++++++++++++++++++++++++++++++++
modules/mpfr/seed-mpfr.c | 2 +
modules/mpfr/seed-mpfr.h | 3 ++
3 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/modules/mpfr/seed-mpfr-arithmetic.c b/modules/mpfr/seed-mpfr-arithmetic.c
index 7428805..db9690b 100644
--- a/modules/mpfr/seed-mpfr-arithmetic.c
+++ b/modules/mpfr/seed-mpfr-arithmetic.c
@@ -684,3 +684,67 @@ SeedValue seed_mpfr_nextbelow (SeedContext ctx,
return seed_make_null(ctx);
}
+SeedValue seed_mpfr_min (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.min", 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.min", "mpfr_t");
+ }
+
+ ret = mpfr_min(rop, op1, op2, rnd);
+
+ return seed_value_from_int(ctx, ret, exception);
+}
+
+SeedValue seed_mpfr_max (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.max", 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.max", "mpfr_t");
+ }
+
+ ret = mpfr_max(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 10e9f8c..a273862 100644
--- a/modules/mpfr/seed-mpfr.c
+++ b/modules/mpfr/seed-mpfr.c
@@ -643,6 +643,8 @@ 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},
+ {"min", seed_mpfr_min, 0},
+ {"max", seed_mpfr_max, 0},
{"frac", seed_mpfr_frac, 0},
{"fmod", seed_mpfr_fmod, 0},
{"remainder", seed_mpfr_remainder, 0},
diff --git a/modules/mpfr/seed-mpfr.h b/modules/mpfr/seed-mpfr.h
index 7affb7c..a42ea36 100644
--- a/modules/mpfr/seed-mpfr.h
+++ b/modules/mpfr/seed-mpfr.h
@@ -69,6 +69,9 @@ DEF_SEED_MPFR_FUNC(seed_mpfr_nexttoward);
DEF_SEED_MPFR_FUNC(seed_mpfr_nextabove);
DEF_SEED_MPFR_FUNC(seed_mpfr_nextbelow);
+DEF_SEED_MPFR_FUNC(seed_mpfr_min);
+DEF_SEED_MPFR_FUNC(seed_mpfr_max);
+
DEF_SEED_MPFR_FUNC(seed_mpfr_fmod);
DEF_SEED_MPFR_FUNC(seed_mpfr_remainder);
DEF_SEED_MPFR_FUNC(seed_mpfr_integer_p);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]