summaryrefslogtreecommitdiff
path: root/ext/-test-
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-31 12:17:18 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-31 12:17:18 +0000
commit83a0709174f9f99038b45914ee54acd7c126f11b (patch)
tree43ff78bd13a795e4df422caa2bcd3b8232100e7b /ext/-test-
parentd0d63cff8ac29b294d6751c61528bb01c4d30d64 (diff)
* bignum.c: Use GMP to accelerate big Bignum multiplication.
(bary_mul_gmp): New function. (bary_mul): Use bary_mul_gmp. (bigsq): Use different threshold with GMP. * configure.in: Detect GMP. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-')
-rw-r--r--ext/-test-/bignum/mul.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/-test-/bignum/mul.c b/ext/-test-/bignum/mul.c
index ad416a9..758465b 100644
--- a/ext/-test-/bignum/mul.c
+++ b/ext/-test-/bignum/mul.c
@@ -42,6 +42,16 @@ mul_toom3(VALUE x, VALUE y)
return rb_big_norm(rb_big_mul_toom3(big(x), big(y)));
}
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+mul_gmp(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_gmp(big(x), big(y)));
+}
+#else
+#define mul_gmp rb_f_notimplement
+#endif
+
void
Init_mul(VALUE klass)
{
@@ -52,4 +62,5 @@ Init_mul(VALUE klass)
rb_define_method(rb_cInteger, "big_mul_balance", mul_balance, 1);
rb_define_method(rb_cInteger, "big_mul_karatsuba", mul_karatsuba, 1);
rb_define_method(rb_cInteger, "big_mul_toom3", mul_toom3, 1);
+ rb_define_method(rb_cInteger, "big_mul_gmp", mul_gmp, 1);
}