[前][次][番号順一覧][スレッド一覧]

ruby-changes:30308

From: akr <ko1@a...>
Date: Sat, 3 Aug 2013 23:21:34 +0900 (JST)
Subject: [ruby-changes:30308] akr:r42360 (trunk): * bignum.c: The branch condition of selecting multiplication

akr	2013-08-03 23:20:31 +0900 (Sat, 03 Aug 2013)

  New Revision: 42360

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42360

  Log:
    * bignum.c: The branch condition of selecting multiplication
      algorighms should check smaller argument because Karatsuba and Toom3
      is effective only if both arguments are big.
      (bary_mul_toom3_branch): Compare the smaller argument to
      TOOM3_MUL_DIGITS.
      (bary_mul): Compare the smaller argument to KARATSUBA_MUL_DIGITS.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42359)
+++ ChangeLog	(revision 42360)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Aug  3 22:47:11 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c: The branch condition of selecting multiplication
+	  algorighms should check smaller argument because Karatsuba and Toom3
+	  is effective only if both arguments are big.
+	  (bary_mul_toom3_branch): Compare the smaller argument to
+	  TOOM3_MUL_DIGITS.
+	  (bary_mul): Compare the smaller argument to KARATSUBA_MUL_DIGITS.
+
 Sat Aug  3 22:23:31 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (big2str_orig): Receive the number to stringize as
Index: bignum.c
===================================================================
--- bignum.c	(revision 42359)
+++ bignum.c	(revision 42360)
@@ -2534,7 +2534,7 @@ bary_mul_karatsuba_start(BDIGIT *zds, si https://github.com/ruby/ruby/blob/trunk/bignum.c#L2534
 static void
 bary_mul_toom3_branch(BDIGIT *zds, size_t zl, const BDIGIT *xds, size_t xl, const BDIGIT *yds, size_t yl, BDIGIT *wds, size_t wl)
 {
-    if (yl < TOOM3_MUL_DIGITS) {
+    if (xl < TOOM3_MUL_DIGITS) {
         bary_mul_karatsuba_branch(zds, zl, xds, xl, yds, yl, wds, wl);
         return;
     }
@@ -2560,7 +2560,7 @@ static void https://github.com/ruby/ruby/blob/trunk/bignum.c#L2560
 bary_mul(BDIGIT *zds, size_t zl, const BDIGIT *xds, size_t xl, const BDIGIT *yds, size_t yl)
 {
     if (xl <= yl) {
-        if (yl < KARATSUBA_MUL_DIGITS) {
+        if (xl < KARATSUBA_MUL_DIGITS) {
             if (xds == yds && xl == yl)
                 bary_sq_fast(zds, zl, xds, xl);
             else
@@ -2569,7 +2569,7 @@ bary_mul(BDIGIT *zds, size_t zl, const B https://github.com/ruby/ruby/blob/trunk/bignum.c#L2569
         }
     }
     else {
-        if (xl < KARATSUBA_MUL_DIGITS) {
+        if (yl < KARATSUBA_MUL_DIGITS) {
             bary_mul1(zds, zl, yds, yl, xds, xl);
             return;
         }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]