summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-09 04:16:27 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-09 04:16:27 +0000
commit995e42817c01111bc3dfeb092d3ed7e080edd8c2 (patch)
tree414972ec9c922d0bbb1bd4a9d813de7941a9ff17
parent122b6dbcb7c7c5e3c02277d75b5f38bc6d5c3103 (diff)
merge revision(s) 37567: [Backport #7315]
* bignum.c (bigmul0): enable big_mul_toom3. [ruby-core:48552] [Bug #7242] * bignum.c (bigmul1_toom3): fix incorrect calculation. the patch is made by Heesob Park. [ruby-core:48552] [Bug #7242] * bignum.c (bigmul0): disable big_mul_toom3 temporalily. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog13
-rw-r--r--bignum.c11
-rw-r--r--test/ruby/test_bignum.rb3
-rw-r--r--version.h2
4 files changed, 21 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index efe07b8501..6d388f0d7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,15 @@
-Thu Nov 9 05:33:99 2012 Kenta Murata <mrkn@mrkn.jp>
+Fri Nov 9 13:16:16 2012 Kenta Murata <mrkn@mrkn.jp>
- * bignum.c (bigmul0): disable big_mul_toom3_temporalily.
+ * bignum.c (bigmul0): enable big_mul_toom3.
+ [ruby-core:48552] [Bug #7242]
+
+ * bignum.c (bigmul1_toom3): fix incorrect calculation.
+ the patch is made by Heesob Park.
+ [ruby-core:48552] [Bug #7242]
+
+Fri Nov 9 13:16:16 2012 Kenta Murata <mrkn@mrkn.jp>
+
+ * bignum.c (bigmul0): disable big_mul_toom3 temporalily.
[ruby-core:48552] [Bug #7242]
* test/ruby/test_bignum.rb (test_mul_large_numbers):
diff --git a/bignum.c b/bignum.c
index ffc1105ccc..04df7ba4ea 100644
--- a/bignum.c
+++ b/bignum.c
@@ -2419,7 +2419,7 @@ bigmul1_toom3(VALUE x, VALUE y)
z2 = bigtrunc(bigadd(u2, u0, 0));
/* z3 <- (z2 - z3) / 2 + 2 * z(inf) == (z2 - z3) / 2 + 2 * u4 */
- z3 = bigadd(z2, z3, 0);
+ z3 = bigtrunc(bigadd(z2, z3, 0));
bigrsh_bang(BDIGITS(z3), RBIGNUM_LEN(z3), 1);
t = big_lshift(u4, 1); /* TODO: combining with next addition */
z3 = bigtrunc(bigadd(z3, t, 1));
@@ -2535,8 +2535,13 @@ bigmul0(VALUE x, VALUE y)
/* balance multiplication by slicing y when x is much smaller than y */
if (2 * xn <= yn) return bigmul1_balance(x, y);
- /* multiplication by karatsuba method */
- return bigmul1_karatsuba(x, y);
+ if (xn < TOOM3_MUL_DIGITS) {
+ /* multiplication by karatsuba method */
+ return bigmul1_karatsuba(x, y);
+ }
+ else if (3*xn <= 2*(yn + 2))
+ return bigmul1_balance(x, y);
+ return bigmul1_toom3(x, y);
}
/*
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index d4fdfe7a12..4343f3fdbf 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -274,7 +274,6 @@ class TestBignum < Test::Unit::TestCase
69131640408147806442422254638590386673344704147156793990832671592488742473
31524606724894164324227362735271650556732855509929890983919463699819116427
].join.to_i
-
b = %w[
31519454770031243652776765515030872050264386564379909299874378289835540661
99756262835346828114038365624177182230027040172583473561802565238817167503
@@ -354,7 +353,7 @@ class TestBignum < Test::Unit::TestCase
21851731257845562153822058534043916834839514338448582518847879059020959697
90538105704766415685100946308842788321400392381169436435078204622400475281
].join.to_i
- assert_equal(c, a*b)
+ assert_equal(c, a*b, '[ruby-core:48552]')
end
def test_divrem
diff --git a/version.h b/version.h
index 9a4a72f1e7..8132461c9f 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 319
+#define RUBY_PATCHLEVEL 320
#define RUBY_RELEASE_DATE "2012-11-09"
#define RUBY_RELEASE_YEAR 2012