mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
f858cd8a38
commit
f12ef626d1
2 changed files with 12 additions and 3 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Sat Aug 3 22:47:11 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* 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@fsij.org>
|
Sat Aug 3 22:23:31 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* bignum.c (big2str_orig): Receive the number to stringize as
|
* bignum.c (big2str_orig): Receive the number to stringize as
|
||||||
|
|
6
bignum.c
6
bignum.c
|
@ -2534,7 +2534,7 @@ bary_mul_karatsuba_start(BDIGIT *zds, size_t zl, const BDIGIT *xds, size_t xl, c
|
||||||
static void
|
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)
|
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);
|
bary_mul_karatsuba_branch(zds, zl, xds, xl, yds, yl, wds, wl);
|
||||||
return;
|
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)
|
bary_mul(BDIGIT *zds, size_t zl, const BDIGIT *xds, size_t xl, const BDIGIT *yds, size_t yl)
|
||||||
{
|
{
|
||||||
if (xl <= yl) {
|
if (xl <= yl) {
|
||||||
if (yl < KARATSUBA_MUL_DIGITS) {
|
if (xl < KARATSUBA_MUL_DIGITS) {
|
||||||
if (xds == yds && xl == yl)
|
if (xds == yds && xl == yl)
|
||||||
bary_sq_fast(zds, zl, xds, xl);
|
bary_sq_fast(zds, zl, xds, xl);
|
||||||
else
|
else
|
||||||
|
@ -2569,7 +2569,7 @@ bary_mul(BDIGIT *zds, size_t zl, const BDIGIT *xds, size_t xl, const BDIGIT *yds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (xl < KARATSUBA_MUL_DIGITS) {
|
if (yl < KARATSUBA_MUL_DIGITS) {
|
||||||
bary_mul1(zds, zl, yds, yl, xds, xl);
|
bary_mul1(zds, zl, yds, yl, xds, xl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue