Граф коммитов

552 Коммитов

Автор SHA1 Сообщение Дата
akr d3845ef8db * bignum.c (bary_sq_fast): Refine expressions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-21 15:17:09 +00:00
akr 5cf931d65e * bignum.c (bary_mul): Use simple multiplication if yl is small.
(rb_cstr_to_inum): Invoke bigsq instead of bigmul0.
  (bigsq): Re-implemented.
  (bigmul0): Invoke bigsq if two arguments are identical.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-21 12:13:47 +00:00
akr a2116ef2cd * bignum.c (bary_mul_toom3): New function based on bigmul1_toom3.
(bary_mul_toom3_branch): Call bary_mul_toom3.
  (rb_big_mul_toom3): Ditto.
  (bigmul1_toom3): Removed.
  (big_real_len): Ditto.
  (big_split): Ditto.
  (big_split3): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-21 01:01:26 +00:00
akr abfb7b35a2 Update a comment for Toom3.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-20 13:32:11 +00:00
akr 2314c1bf47 * bignum.c (bary_sq_fast): Specialize the last iteration of the
outer loop.
  (bigfixize): A condition simplified.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 12:58:46 +00:00
akr 80afc9b2f3 * bignum.c (BDIGITS_ZERO): Defined.
(bary_pack): Use BDIGITS_ZERO.
  (bary_unpack): Ditto.
  (bary_mul_single): Ditto.
  (bary_mul_normal): Ditto.
  (bary_sq_fast): Ditto.
  (bary_mul_balance_with_mulfunc): Ditto.
  (bary_mul_precheck): Ditto.
  (bary_mul_toom3_branch): Ditto.
  (rb_cstr_to_inum): Ditto.
  (big_shift3): Ditto.
  (bigmul1_toom3): Ditto.
  (bary_divmod): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 04:00:49 +00:00
akr 15f7c7f9d4 * bignum.c: An static assertion for relation of SIZEOF_LONG and
SIZEOF_BDIGITS is added.
  (bary_mul_precheck): Reduce comparisons.
  (bary_mul): Invoke bary_sq_fast or bary_mul1 if the bignum size is
  small.
  (bigfixize): Resize the argument bignum here.
  (bignorm): Don't call bigtrunc after bigfixize.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 13:53:24 +00:00
akr deaec24790 * bignum.c (bigmul1_toom3): Use bigdivrem_single instead of bigdivrem.
(big_three): Removed.
  (Init_Bignum): Don't initialize big_three.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 15:17:21 +00:00
akr 6be7c95734 * bignum.c (bigsq): Renamed from bigsqr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 11:23:03 +00:00
akr a08c5527ea * bignum.c (USHORT): Unused macro removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 10:44:27 +00:00
akr 4106413465 * bignum.c (big_shift3): Big shift width is not a problem for right
shift.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 10:08:25 +00:00
akr c0cce2938c * bignum.c (bary_mul_karatsuba): Avoid duplicate calculation when
squaring.
  ((bary_mul_toom3_branch): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 09:37:42 +00:00
akr a38f209a39 Fix spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 12:56:29 +00:00
akr 46360975a4 * include/ruby/intern.h (rb_big2str0): Deprecated.
* bignum.c (rb_big2str1): Renamed from rb_big2str0.
  (rb_big2str0): Deprecated wrapper for rb_big2str1.
  (rb_big2str): Invoke rb_big2str1 instead of rb_big2str0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 05:42:22 +00:00
akr 1a42f3683f * bignum.c: Add static assertions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 04:50:49 +00:00
akr a5da8319b6 * bignum.c (maxpow_in_bdigit_dbl): Useless #if removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 02:26:24 +00:00
zzak b39b66f4aa * bignum.c (rb_big_coerce): [DOC] Add docs for Bignum#coerce
Based on patch by Juanito Fatas [Fixes GH-360]
  https://github.com/ruby/ruby/pull/360


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 02:13:13 +00:00
nobu e068834b5c bignum.c: suppress warnings
* bignum.c (big_shift2, rb_big_lshift, rb_big_rshift): cast explicitly
  to suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 02:11:15 +00:00
akr 150b265502 * bignum.c (nlz16): Use __builtin_clz if possible.
(nlz32): Use __builtin_clz or __builtin_clzl if possible.
  (nlz64): Use __builtin_clzl or __builtin_clzll if possible.
  (nlz128): Use __builtin_clzll if possible.

* configure.in: Check __builtin_clz, __builtin_clzl and
  __builtin_clzll.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 01:49:32 +00:00
akr 508669b6da * bignum.c (power_cache_get_power): Use bitsize insteadof ceil_log2.
(ones): Removed.
  (next_pow2): Removed.
  (floor_log2): Removed.
  (ceil_log2): Removed.

* configure.in (__builtin_popcountl): Don't check.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 00:46:00 +00:00
akr 240f3056aa * configure.in: Check __builtin_popcountl, __builtin_bswap32 and
__builtin_bswap64.

* internal.h (swap32): Use the configure result for the condition to
  use __builtin_bswap32.
  (swap64): Use the configure result for the condition to use
  __builtin_bswap64.

* bignum.c (ones): Use the configure result for the condition to use
  __builtin_popcountl.
  (bary_unpack_internal): Use appropriate types for swap argument.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-14 14:28:33 +00:00
akr b0eacd027a * bignum.c (bary_subb): Support xn < yn.
(bigsub_core): Removed.
  (bigsub): Don't compare before subtraction.  Just subtract and
  get the two's complement if the subtraction causes a borrow.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-14 13:24:44 +00:00
akr 651f762c17 * bignum.c (DIGSPERLONG): Unused macro removed.
(DIGSPERLL): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:38:52 +00:00
akr 75a86e4733 * bignum.c (rb_big_aref): Less scan when the number is negative.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:36:18 +00:00
akr b9eeeac5c8 * bignum.c (big_shift): Avoid signed integer overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:19:48 +00:00
akr f9029004ee * bignum.c (bary_mul_precheck): Use bary_small_lshift or
bary_mul_normal if xl is 1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:16:23 +00:00
akr de79b66f46 * bignum.c (big_shift3): New function.
big_lshift and big_rshift are merged.
  (big_shift2): New function.
  (big_lshift): Use big_shift3.
  (big_rshift): Ditto.
  (check_shiftdown): Removed.
  (rb_big_lshift): Use big_shift2 and big_shift3.
  (rb_big_rshift): Ditto.
  (big_lshift): Removed.
  (big_rshift): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 14:03:13 +00:00
akr 0001cf6bdc * bignum.c (bary_small_lshift): Use size_t instead of long.
(bary_small_rshift): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 06:53:12 +00:00
akr e31c9896d6 * bignum.c (bary_small_lshift): Functions moved to remove
declaration.
  (bary_small_rshift): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 06:36:40 +00:00
akr 725bc0c870 * bignum.c (biglsh_bang): Removed.
(bigrsh_bang): Ditto.
  (bigmul1_toom3): Use bary_small_lshift and bary_small_rshift.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 00:28:10 +00:00
akr 973d855391 * bignum.c: Don't use toom3 after once karatsuba is choosen.
(mulfunc_t): New type.
  (bary_mul_toom3_start): Renamed from bary_mul.
  (bary_mul_karatsuba_start): Renamed from bary_mul.
  (bary_mul_balance_with_mulfunc): Renamed from bary_mul_balance and
  new argument, mulfunc, is added.
  (rb_big_mul_balance): Invoke bary_mul_balance_with_mulfunc with
  bary_mul_toom3_start.
  (bary_mul_karatsuba): Invoke bary_mul_karatsuba_start instead of
  bary_mul.
  (bary_mul_precheck): Extracted from bary_mul.
  (bary_mul_karatsuba_branch): Extracted from bary_mul.
  (bary_mul_karatsuba_start): New function to call bary_mul_precheck
  and bary_mul_karatsuba_branch.
  (bary_mul_toom3_branch): Extracted from bary_mul.
  (bary_mul_toom3_start): New function to call bary_mul_precheck and
  bary_mul_toom3_branch.
  (bary_mul): Just call bary_mul_toom3_start.
  Arguments for work memory are removed.
  (rb_cstr_to_inum): Follow the bary_mul change.
  (bigmul0): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11 03:06:02 +00:00
akr c0796c36b5 * bignum.c: Add a static assertion for RBIGNUM_EMBED_LEN_MAX.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 13:46:38 +00:00
akr 55e60d05dc * bignum.c (bary_2comp): Don't use bary_plus_one.
(bary_add_one): Replaced by the implementation of bary_plus_one.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 13:06:33 +00:00
nobu c37e6ab28d bignum.c: sizeof_bdigit_dbl
* bignum.c (sizeof_bdigit_dbl): check sizeof(BDIGIT_DBL).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 11:48:24 +00:00
akr 716c93bed1 * bignum.c (SIZEOF_BDIGIT_DBL): Add a ifdef guard for test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 11:10:05 +00:00
nobu cc47b02969 bignum.c: select by preprocessor conditions
* bignum.c (maxpow_in_bdigit_dbl, maxpow_in_bdigit): select by
  preprocessor conditions to reduce dead code and suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 05:58:45 +00:00
akr 5ec8b6e78e * bignum.c (bary_mul): x*1 is x.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 15:43:48 +00:00
akr 55cbeefb2d * bignum.c (bary_mul_single): Invoke MEMZERO here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 13:44:49 +00:00
akr 0c620c2ec3 * bignum.c (bary_mul1): No need to invoke MEMZERO at last.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 13:19:59 +00:00
akr fa343a796f * bignum.c (biglsh_bang): Don't shift a BDIGIT with BITSPERDIG bits.
(bigrsh_bang): Ditto.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 16:50:04 +00:00
akr fa1e85c933 * bignum.c (bigrsh_bang): Fix bignum digits overrun.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 16:19:18 +00:00
akr be2a1ad45b * bignum.c (biglsh_bang): Fix bignum digits under-run.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 15:48:09 +00:00
akr 1ffdd828b3 * bignum.c (bary_mul): Arguments for work memory added.
(bary_mul_balance): Ditto.
  (bary_mul_karatsuba): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 13:44:34 +00:00
akr 6fdad008a2 * 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
2013-07-08 13:05:57 +00:00
akr 85855a2242 * bignum.c (bary_mul_balance): Initialize a local variable to suppress
a warning.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 13:00:11 +00:00
akr ffe55cdc1e * bignum.c (bary_mul_balance): Reduce work memory.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 11:56:55 +00:00
akr a25f95f8b7 * bignum.c (bary_mul): Add a RB_GC_GUARD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 23:04:25 +00:00
akr 1210743cad * bignum.c (bary_mul_karatsuba): Unreachable code removed. Remove
several branches.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 15:21:26 +00:00
akr 29634bca31 * internal.h (rb_big_mul_normal): Declared.
(rb_big_mul_balance): Ditto.
  (rb_big_mul_karatsuba): Ditto.

* bignum.c (rb_big_mul_normal): New function for tests.
  (rb_big_mul_balance): Ditto.
  (rb_big_mul_karatsuba): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 14:01:40 +00:00
akr d7c2f3f8a4 Useless comment removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 11:04:07 +00:00