diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-03 14:20:31 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-03 14:20:31 +0000 |
commit | f12ef626d161021a1318e8848fef8ca5b0cb65e5 (patch) | |
tree | 1539ece6c5e6082d93c1e87b856d3a74f0623fdb /bignum.c | |
parent | f858cd8a382169c40656b7511dd4b657f57f3bdc (diff) | |
download | ruby-f12ef626d161021a1318e8848fef8ca5b0cb65e5.tar.gz |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -2534,7 +2534,7 @@ bary_mul_karatsuba_start(BDIGIT *zds, size_t zl, const BDIGIT *xds, size_t xl, c 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 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 BDIGIT *xds, size_t xl, const BDIGIT *yds } } else { - if (xl < KARATSUBA_MUL_DIGITS) { + if (yl < KARATSUBA_MUL_DIGITS) { bary_mul1(zds, zl, yds, yl, xds, xl); return; } |