diff options
| author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-14 12:15:07 +0000 |
|---|---|---|
| committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-14 12:15:07 +0000 |
| commit | 57a0c4600eea2bda1a7f22d0b2e25bdb65287183 (patch) | |
| tree | d82d0fddfadfe41ae0b62ee16ad61e71b2bcf967 | |
| parent | 11438d8095feb8ce95b8036871188846af12aba8 (diff) | |
| download | ruby-57a0c4600eea2bda1a7f22d0b2e25bdb65287183.tar.gz ruby-57a0c4600eea2bda1a7f22d0b2e25bdb65287183.tar.xz ruby-57a0c4600eea2bda1a7f22d0b2e25bdb65287183.zip | |
* bignum.c (bigmul1_karatsuba): fix comment and refactoring.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | bignum.c | 8 |
2 files changed, 8 insertions, 4 deletions
@@ -1,3 +1,7 @@ +Sun Dec 14 21:13:02 2008 Yusuke Endoh <mame@tsg.ne.jp> + + * bignum.c (bigmul1_karatsuba): fix comment and refactoring. + Sun Dec 14 14:53:41 2008 Yusuke Endoh <mame@tsg.ne.jp> * bignum.c (bigmul1_balance, bigmul1_karatsuba): remove all @@ -1668,7 +1668,7 @@ bigmul1_karatsuba(VALUE x, VALUE y) * where * z2 = xh * yh * z0 = xl * yl - * z1 = (xh + xl) * (yh + yl) - x2 - x0 + * z1 = (xh + xl) * (yh + yl) - z2 - z0 * * ref: http://en.wikipedia.org/wiki/Karatsuba_algorithm */ @@ -1683,7 +1683,7 @@ bigmul1_karatsuba(VALUE x, VALUE y) /* copy t1 into high bytes of the result (z2) */ MEMCPY(zds + 2 * n, BDIGITS(t1), BDIGIT, t1n); - for (i = 2 * n + t1n; i < xn + yn; i++) BDIGITS(z)[i] = 0; + for (i = 2 * n + t1n; i < xn + yn; i++) zds[i] = 0; if (!BIGZEROP(xl) && !BIGZEROP(yl)) { /* t2 <- xl * yl */ @@ -1692,7 +1692,7 @@ bigmul1_karatsuba(VALUE x, VALUE y) /* copy t2 into low bytes of the result (z0) */ MEMCPY(zds, BDIGITS(t2), BDIGIT, t2n); - for (i = t2n; i < 2 * n; i++) BDIGITS(z)[i] = 0; + for (i = t2n; i < 2 * n; i++) zds[i] = 0; /* subtract t2 from middle bytes of the result (z1) */ i = xn + yn - n; @@ -1700,7 +1700,7 @@ bigmul1_karatsuba(VALUE x, VALUE y) } else { /* copy 0 into low bytes of the result (z0) */ - for (i = 0; i < 2 * n; i++) BDIGITS(z)[i] = 0; + for (i = 0; i < 2 * n; i++) zds[i] = 0; } /* subtract t1 from middle bytes of the result (z1) */ |
