aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
Commit message (Collapse)AuthorAgeFilesLines
...
* * bignum.c (MAX_BIG2STR_TABLE_ENTRIES): Use SIZEOF_SIZE_T.akr2013-07-311-11/+17
| | | | | | | | | (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
* * bignum.c (big2str_struct): New structure.akr2013-07-311-20/+26
| | | | | | | | | | (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
* * bignum.c (LOG2_KARATSUBA_BIG2STR_DIGITS): Renamed fromakr2013-07-291-9/+9
| | | | | | | | | 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
* * bignum.c (bigdivrem): Specialized implementation added forakr2013-07-281-0/+21
| | | | | | | | nx == 2 && ny == 2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (absint_numwords_generic): The char_bit variable changedakr2013-07-281-1/+1
| | | | | | | | to a static constant. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c: Constify bary_* functions.akr2013-07-281-41/+42
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_absint_size): Declaration moved fromakr2013-07-281-0/+28
| | | | | | | | | | | 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
* * bignum.c (rb_big_size): Return the bignum "bytewise" size.akr2013-07-271-1/+1
| | | | | | | | | [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
* * bignum.c: Move functions.akr2013-07-231-202/+203
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_divmod): Add special cases for x < y easily detectedakr2013-07-231-1/+18
| | | | | | | | and nx == 2 && ny == 2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_mulsub_1xN): New function.akr2013-07-221-31/+41
| | | | | | | | (bary_mul_toom3): Use bary_mulsub_1xN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (KARATSUBA_BALANCED): New macro.akr2013-07-221-9/+11
| | | | | | | | | | | | | | | (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
* * bignum.c (bigdivrem_mulsub): Extracted from bigdivrem1.akr2013-07-221-22/+37
| | | | | | | | (bigdivrem1): Use bary_add. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_sq_fast): Refine expressions.akr2013-07-211-4/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_mul): Use simple multiplication if yl is small.akr2013-07-211-8/+29
| | | | | | | | | | (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
* * bignum.c (bary_mul_toom3): New function based on bigmul1_toom3.akr2013-07-211-242/+406
| | | | | | | | | | | | | (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
* Update a comment for Toom3.akr2013-07-201-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_sq_fast): Specialize the last iteration of theakr2013-07-181-5/+20
| | | | | | | | | outer loop. (bigfixize): A condition simplified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (BDIGITS_ZERO): Defined.akr2013-07-181-24/+33
| | | | | | | | | | | | | | | | | | | (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
* * bignum.c: An static assertion for relation of SIZEOF_LONG andakr2013-07-171-37/+84
| | | | | | | | | | | | | 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
* * bignum.c (bigmul1_toom3): Use bigdivrem_single instead of bigdivrem.akr2013-07-161-6/+2
| | | | | | | | | (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
* * bignum.c (bigsq): Renamed from bigsqr.akr2013-07-161-5/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (USHORT): Unused macro removed.akr2013-07-161-4/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_shift3): Big shift width is not a problem for rightakr2013-07-161-8/+8
| | | | | | | | shift. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_mul_karatsuba): Avoid duplicate calculation whenakr2013-07-161-7/+21
| | | | | | | | | squaring. ((bary_mul_toom3_branch): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix spaces.akr2013-07-151-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_big2str0): Deprecated.akr2013-07-151-3/+10
| | | | | | | | | | * 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
* * bignum.c: Add static assertions.akr2013-07-151-0/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (maxpow_in_bdigit_dbl): Useless #if removed.akr2013-07-151-2/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_coerce): [DOC] Add docs for Bignum#coercezzak2013-07-151-1/+11
| | | | | | | | 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
* bignum.c: suppress warningsnobu2013-07-151-3/+6
| | | | | | | * 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
* * bignum.c (nlz16): Use __builtin_clz if possible.akr2013-07-151-0/+26
| | | | | | | | | | | | | (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
* * bignum.c (power_cache_get_power): Use bitsize insteadof ceil_log2.akr2013-07-151-65/+1
| | | | | | | | | | | | | (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
* * configure.in: Check __builtin_popcountl, __builtin_bswap32 andakr2013-07-141-4/+4
| | | | | | | | | | | | | | | | | __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
* * bignum.c (bary_subb): Support xn < yn.akr2013-07-141-38/+35
| | | | | | | | | | (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
* * bignum.c (DIGSPERLONG): Unused macro removed.akr2013-07-131-6/+0
| | | | | | | | (DIGSPERLL): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_aref): Less scan when the number is negative.akr2013-07-131-14/+12
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_shift): Avoid signed integer overflow.akr2013-07-131-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_mul_precheck): Use bary_small_lshift orakr2013-07-131-8/+17
| | | | | | | | bary_mul_normal if xl is 1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_shift3): New function.akr2013-07-131-93/+122
| | | | | | | | | | | | | | | | 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
* * bignum.c (bary_small_lshift): Use size_t instead of long.akr2013-07-131-3/+3
| | | | | | | | (bary_small_rshift): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_small_lshift): Functions moved to removeakr2013-07-131-32/+29
| | | | | | | | | declaration. (bary_small_rshift): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (biglsh_bang): Removed.akr2013-07-131-63/+4
| | | | | | | | | (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
* * bignum.c: Don't use toom3 after once karatsuba is choosen.akr2013-07-111-21/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | (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
* * bignum.c: Add a static assertion for RBIGNUM_EMBED_LEN_MAX.akr2013-07-101-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_2comp): Don't use bary_plus_one.akr2013-07-101-15/+22
| | | | | | | | (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
* bignum.c: sizeof_bdigit_dblnobu2013-07-101-0/+2
| | | | | | * 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
* * bignum.c (SIZEOF_BDIGIT_DBL): Add a ifdef guard for test.akr2013-07-101-6/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: select by preprocessor conditionsnobu2013-07-101-30/+24
| | | | | | | * 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
* * bignum.c (bary_mul): x*1 is x.akr2013-07-091-0/+11
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e