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

602 Коммитов

Автор SHA1 Сообщение Дата
akr 180d461a22 * bignum.c (big_div_struct): Use size_t.
(bigdivrem1): Ditto.
  (bigdivrem_num_extra_words): Ditto.
  (bigdivrem_single): Ditto.
  (bigdivrem_normal): Ditto.
  (bary_divmod): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-09 19:55:24 +00:00
nobu ca3b9bbfe0 bignum.c: suppress warning
* bignum.c (rb_big_mul_karatsuba): suppress logical-op-parentheses
  warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-09 13:41:23 +00:00
akr fe6273975e * bignum.c (rb_big_odd_p): Check the bignum length.
(rb_big_even_p): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-07 11:08:03 +00:00
akr ff84827eb6 * bignum.c (dbl2big): A condition simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-07 10:31:35 +00:00
akr d35596c61d * bignum.c (nlz16): Removed.
(nlz32): Ditto.
  (nlz64): Ditto.
  (nlz128): Ditto.
  (nlz_int): New function.
  (nlz_long): New function.
  (nlz_long_long): New function.
  (nlz_int128): New function.
  (nlz): Follow above changes.
  (bitsize): Follow above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06 22:43:01 +00:00
akr 25336fa7c1 * bignum.c (rb_big_realloc): Use VALGRIND_MAKE_MEM_UNDEFINED to
declare undefined memory area.
  (bignew_1): Ditto.

* internal.h (VALGRIND_MAKE_MEM_DEFINED): Moved from gc.c
  (VALGRIND_MAKE_MEM_UNDEFINED): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06 03:26:34 +00:00
akr 2ae634f2f4 * bignum.c: Rename local variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-05 14:50:07 +00:00
akr 5a13ad0386 * bignum.c (BARY_TRUNC): New macro.
(bary_cmp): Use BARY_TRUNC.
  (bary_mul_toom3): Ditto.
  (bary_divmod): Ditto.
  (abs2twocomp): Ditto.
  (bigfixize): Ditto.
  (rb_cstr_to_inum): Ditto.
  (big2str_karatsuba): Ditto.
  (bigdivrem): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 16:58:30 +00:00
akr 092511bac7 * bignum.c (big2str_karatsuba): Don't allocate new temporary buffer
if the buffer is enough for current invocation.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 16:01:14 +00:00
nobu b3be3c29c4 bignum.c: suppress warnings
* bignum.c (power_cache_get_power): declare as inline before call to
  suppress warnings from gcc 4.2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 15:41:31 +00:00
akr 606a03dc59 * bignum.c (bary2bdigitdbl): New function.
(bdigitdbl2bary): Ditto.
  (bary_mul_single): Use bdigitdbl2bary.
  (power_cache_get_power): Ditto.
  (bary_divmod): Use bary2bdigitdbl.
  (big2str_orig): Ditto.
  (bigdivrem): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 15:26:04 +00:00
akr f12ef626d1 * 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
2013-08-03 14:20:31 +00:00
akr f858cd8a38 * bignum.c (big2str_orig): Receive the number to stringize as
BDIGIT array and size.
  (big2str_karatsuba): Receive the number to stringize as BDIGIT array
  and size.  Use an temporary array of BDIGIT.
  (rb_big2str1): Follow the above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 13:27:25 +00:00
akr 36c89c484b * bignum.c (MAX_BASE36_POWER_TABLE_ENTRIES): Renamed from
MAX_BIG2STR_TABLE_ENTRIES.
  (base36_power_cache): Renamed from big2str_power_cache.
  (base36_numdigits_cache): Renamed from big2str_numdigits_cache.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 04:32:33 +00:00
akr 04cf3fa346 * bignum.c (big2str_orig): Refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 17:24:19 +00:00
akr 81f42c7576 * bignum.c (big2str_orig): Rename a local variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 16:42:40 +00:00
akr d0741fdf1c * bignum.c (bigadd_core): Removed.
(bigadd): Use bary_add instead of bigadd_core.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 16:22:47 +00:00
akr ebbaec9696 * bignum.c (rb_big2str1): Simplify power_level calculation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 15:55:07 +00:00
akr 54c3b1ba19 * bignum.c (power_cache_get_power): Appry bigtrunc to the result of
bigsq.
  (big2str_karatsuba): Fix number of leading zero characters.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 14:53:22 +00:00
nobu ba95b9787d bignum.c: suppress a warning
* bignum.c (rb_cstr_to_inum): remove set but unused variable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 14:10:51 +00:00
akr bc7c0a63fd * bignum.c (big2str_karatsuba): Reduce power_level more than one at
recursion, if possible.
  (rb_big2str1): Follow the above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 09:36:23 +00:00
akr 9e8f82e087 * bignum.c (bary_mul): Swap x and y for bary_mul1 if x is longer than y.
[ruby-dev:47565] [Bug #8719] Reported by Narihiro Nakamura.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 03:28:33 +00:00
akr 474dc1e816 * bignum.c (big2str_orig): Remove len argument.
(big2str_karatsuba): Ditto.
  (rb_big2str1): Follow above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 22:49:12 +00:00
akr 9ebd675c47 * bignum.c (rb_big2str1): Remove a local variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 14:57:21 +00:00
akr 69263bb755 * bignum.c (rb_cstr_to_inum): Use power_cache_get_power.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 14:34:59 +00:00
akr d620b0b9cd * bignum.c (rb_big2str1): Raise an error for too big number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 12:05:04 +00:00
akr 780a125faf * bignum.c (power_cache_get_power): Hide cached Bignum objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 11:48:42 +00:00
akr 0ade4f39fd * bignum.c (rb_big2str1): Remove non-trim mode.
(rb_big2str0): Non-trim mode implemented here.
  (big2str_find_n1): Change the result type to long again.
  (big2str_base_powerof2): Don't take arguments: len and trim.
  (rb_big2str): Follow above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 10:19:23 +00:00
akr 93055423bd * bignum.c (big2str_alloc): New function to allocate the result string.
It is called after actual length is calculated.
  (big2str_struct): Add fields: negative, result and ptr.
  (big2str_orig): Write out the result via b2s->ptr.
  (big2str_orig): Ditto.
  (rb_big2str1): Don't allocate the result string at beginning.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 03:43:14 +00:00
akr 478bd3128c * bignum.c (big2str_orig): Use temporary buffer when trim mode.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 22:38:53 +00:00
akr 39a00c6710 * bignum.c (big2str_orig): Simplified because RBIGNUM_LEN(x) <= 2 now.
(big2str_struct): Two fields added: hbase2, hbase2_numdigits.
  (rb_big2str1): Initialize above fields.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 21:33:14 +00:00
akr eed6c15a21 * bignum.c (big2str_karatsuba): Fix a condition of power_level.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 16:48:08 +00:00
nobu 278b494ba7 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 16:21:11 +00:00
akr 4f1b07e9eb * bignum.c (LOG2_KARATSUBA_BIG2STR_DIGITS): Removed.
(KARATSUBA_BIG2STR_DIGITS): Removed.
  (big2str_numdigits_cache): New variable.
  (power_cache_get_power): Merged with power_cache_get_power0.
  This function returns maxpow_in_bdigit_dbl(base)**(2**power_level).
  (rb_big2str1): use power_cache_get_power.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 16:20:26 +00:00
akr d28913b4b9 * bignum.c (big2str_find_n1): Change the return type to size_t.
(big2str_orig): Ditto.
  (big2str_karatsuba): Ditto.
  (rb_big2str1): Follow the above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 15:01:55 +00:00
akr 9e84b33564 * bignum.c (power_cache_get_power): Change numdigits_ret to size_t *.
(big2str_orig): Change len argument to size_t.
  (big2str_karatsuba): Ditto.
  (rb_big2str1): Follow the above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 14:21:54 +00:00
akr 621d2b3d6c * bignum.c (bary_cmp): Extracted from rb_big_cmp.
(power_cache_get_power): Change n1 argument (number of digits) to
  power_level which is just passed to power_cache_get_power0.
  (big2str_karatsuba): Ditto.
  (rb_big2str1): Calculate the initial power_level.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 13:42:22 +00:00
akr aba8c29a8b * bignum.c (MAX_BIG2STR_TABLE_ENTRIES): Use SIZEOF_SIZE_T.
(power_cache_get_power0): Add rb_bug call for too bit i argument.
  (power_cache_get_power): Simplified.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 10:58:58 +00:00
akr 6189859101 * bignum.c (big2str_struct): New structure.
(big2str_orig): Use big2str_struct.
  (big2str_karatsuba): Ditto.
  (rb_big2str1): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 03:20:35 +00:00
akr 16bf45bf38 * bignum.c (LOG2_KARATSUBA_BIG2STR_DIGITS): Renamed from
LOG2_KARATSUBA_DIGITS.
  (KARATSUBA_BIG2STR_DIGITS): Renamed from KARATSUBA_DIGITS.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 13:18:46 +00:00
akr 7a9aeb33db * bignum.c (bigdivrem): Specialized implementation added for
nx == 2 && ny == 2



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 15:14:20 +00:00
akr 37377b24d1 * bignum.c (absint_numwords_generic): The char_bit variable changed
to a static constant.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 03:51:13 +00:00
akr aecf007782 * bignum.c: Constify bary_* functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 03:12:36 +00:00
akr e5ff9d58ef * include/ruby/intern.h (rb_absint_size): Declaration moved from
internal.h to calculate required buffer size to pack integers.
  (rb_absint_numwords): Ditto.
  (rb_absint_singlebit_p): Ditto.
  [ruby-core:42813] [Feature #6065]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 02:14:58 +00:00
akr 5b89a56b4f * bignum.c (rb_big_size): Return the bignum "bytewise" size.
[ruby-core:55578] [Feature #8553]
  This is accepted by matz on DevelopersMeeting20130727Japan.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-27 15:39:01 +00:00
akr a84ea11986 * bignum.c: Move functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 11:49:25 +00:00
akr ca3f5b533d * bignum.c (bary_divmod): Add special cases for x < y easily detected
and nx == 2 && ny == 2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 11:16:39 +00:00
akr 66cc0fa4ab * bignum.c (bary_mulsub_1xN): New function.
(bary_mul_toom3): Use bary_mulsub_1xN.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 22:16:45 +00:00
akr fdb991b9a0 * bignum.c (KARATSUBA_BALANCED): New macro.
(TOOM3_BALANCED): Ditto.
  (bary_mul_balance_with_mulfunc): Use KARATSUBA_BALANCED and
  TOOM3_BALANCED.
  (rb_big_mul_balance): Relax a condition.
  (rb_big_mul_karatsuba): Use KARATSUBA_BALANCED.
  (rb_big_mul_toom3): Use TOOM3_BALANCED.
  (bary_mul_karatsuba_branch): Use KARATSUBA_BALANCED.
  (bary_mul_toom3_branch): Use TOOM3_BALANCED.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 18:35:27 +00:00
akr 685e4c67bf * bignum.c (bigdivrem_mulsub): Extracted from bigdivrem1.
(bigdivrem1): Use bary_add.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 16:36:36 +00:00