summaryrefslogtreecommitdiff
path: root/test/-ext-/bignum/test_mul.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-08 13:05:57 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-08 13:05:57 +0000
commit6fdad008a2bf2e28db5029104b51373b767021fd (patch)
tree068375d8277b90188bfbc623e62c2c3639b1d6f7 /test/-ext-/bignum/test_mul.rb
parent85855a22420bb6e2fd244f294c844106c992141a (diff)
* bignum.c (rb_big_sq_fast): New function for testing.
(rb_big_mul_toom3): Ditto. * internal.h (rb_big_sq_fast): Declared. (rb_big_mul_toom3): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/bignum/test_mul.rb')
-rw-r--r--test/-ext-/bignum/test_mul.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/-ext-/bignum/test_mul.rb b/test/-ext-/bignum/test_mul.rb
index e125401664..e462506e9f 100644
--- a/test/-ext-/bignum/test_mul.rb
+++ b/test/-ext-/bignum/test_mul.rb
@@ -36,6 +36,22 @@ class TestBignum < Test::Unit::TestCase
assert_equal(z, x.big_mul_normal(y))
end
+ def test_sq_fast
+ x = (1 << BITSPERDIG) | 1
+ z = (1 << 2*BITSPERDIG) | (2 << BITSPERDIG) | 1
+ assert_equal(z, x.big_sq_fast)
+ end
+
+ def test_sq_fast_max2
+ x = (BDIGMAX << BITSPERDIG) | BDIGMAX
+ assert_equal(x.big_mul_normal(x), x.big_sq_fast)
+ end
+
+ def test_sq_fast_zero_in_middle
+ x = (BDIGMAX << 2*BITSPERDIG) | BDIGMAX
+ assert_equal(x.big_mul_normal(x), x.big_sq_fast)
+ end
+
def test_mul_balance
x = (1 << BITSPERDIG) | 1
y = (1 << BITSPERDIG) | 1
@@ -104,5 +120,11 @@ class TestBignum < Test::Unit::TestCase
assert_equal(x.big_mul_normal(y), x.big_mul_karatsuba(y))
end
+ def test_mul_toom3
+ x = (1 << 2*BITSPERDIG) | (1 << BITSPERDIG) | 1
+ y = (1 << 2*BITSPERDIG) | (1 << BITSPERDIG) | 1
+ assert_equal(x.big_mul_normal(y), x.big_mul_toom3(y))
+ end
+
end
end