summaryrefslogtreecommitdiff
path: root/bignum.c
AgeCommit message (Collapse)Author
2013-07-18* bignum.c (bary_sq_fast): Specialize the last iteration of theakr
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* bignum.c (BDIGITS_ZERO): Defined.akr
(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-17* bignum.c: An static assertion for relation of SIZEOF_LONG andakr
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-16* bignum.c (bigmul1_toom3): Use bigdivrem_single instead of bigdivrem.akr
(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* bignum.c (bigsq): Renamed from bigsqr.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16* bignum.c (USHORT): Unused macro removed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16* bignum.c (big_shift3): Big shift width is not a problem for rightakr
shift. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16* bignum.c (bary_mul_karatsuba): Avoid duplicate calculation whenakr
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-15Fix spaces.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15* include/ruby/intern.h (rb_big2str0): Deprecated.akr
* 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* bignum.c: Add static assertions.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15* bignum.c (maxpow_in_bdigit_dbl): Useless #if removed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15* bignum.c (rb_big_coerce): [DOC] Add docs for Bignum#coercezzak
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-15bignum.c: suppress warningsnobu
* 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* bignum.c (nlz16): Use __builtin_clz if possible.akr
(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* bignum.c (power_cache_get_power): Use bitsize insteadof ceil_log2.akr
(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-14* configure.in: Check __builtin_popcountl, __builtin_bswap32 andakr
__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* bignum.c (bary_subb): Support xn < yn.akr
(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-13* bignum.c (DIGSPERLONG): Unused macro removed.akr
(DIGSPERLL): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13* bignum.c (rb_big_aref): Less scan when the number is negative.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13* bignum.c (big_shift): Avoid signed integer overflow.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13* bignum.c (bary_mul_precheck): Use bary_small_lshift orakr
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* bignum.c (big_shift3): New function.akr
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* bignum.c (bary_small_lshift): Use size_t instead of long.akr
(bary_small_rshift): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13* bignum.c (bary_small_lshift): Functions moved to removeakr
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* bignum.c (biglsh_bang): Removed.akr
(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-11* bignum.c: Don't use toom3 after once karatsuba is choosen.akr
(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-10* bignum.c: Add a static assertion for RBIGNUM_EMBED_LEN_MAX.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10* bignum.c (bary_2comp): Don't use bary_plus_one.akr
(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-10bignum.c: sizeof_bdigit_dblnobu
* 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* bignum.c (SIZEOF_BDIGIT_DBL): Add a ifdef guard for test.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10bignum.c: select by preprocessor conditionsnobu
* 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-09* bignum.c (bary_mul): x*1 is x.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09* bignum.c (bary_mul_single): Invoke MEMZERO here.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09* bignum.c (bary_mul1): No need to invoke MEMZERO at last.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (biglsh_bang): Don't shift a BDIGIT with BITSPERDIG bits.akr
(bigrsh_bang): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (bigrsh_bang): Fix bignum digits overrun.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (biglsh_bang): Fix bignum digits under-run.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (bary_mul): Arguments for work memory added.akr
(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* bignum.c (rb_big_sq_fast): New function for testing.akr
(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* bignum.c (bary_mul_balance): Initialize a local variable to suppressakr
a warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (bary_mul_balance): Reduce work memory.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* bignum.c (bary_mul): Add a RB_GC_GUARD.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* bignum.c (bary_mul_karatsuba): Unreachable code removed. Removeakr
several branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* internal.h (rb_big_mul_normal): Declared.akr
(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-07Useless comment removed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* bignum.c: Reorder functions to decrease forward reference.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* bignum.c: (bigsub_core): Use bary_sub.akr
(bary_sub): Returns a borrow flag. Use bary_subb. (bary_subb): New function for actually calculating subtraction with borrow. (bary_sub_one): New function. (bigadd_core): Use bary_add. (bary_add): Returns a carry flag. Use bary_addc. (bary_addc): New function for actually calculating addition with carry. (bary_add_one): New function. (bary_muladd_1xN): Extracted from bary_mul_normal. (bigmul1_normal): Removed. (bary_mul_karatsuba): New function. (bary_mul1): Invoke rb_thread_check_ints after bary_mul_normal. (bary_mul): Remove most and least significant zeros before actual multiplication. Use bary_sq_fast, bary_mul_balance, bary_mul_karatsuba and bigmul1_toom3 as bigmul0. (bigmul1_balance): Removed. (bigmul1_karatsuba): Removed. (bigsqr_fast): Removed. (bary_sparse_p): Extracted from big_sparse_p. (big_sparse_p): Removed. (bigmul0): Use bary_mul. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* bignum.c (bary_sq_fast): Extracted from bigsqr_fast andakr
ensure not to access zds[2*xn]. (bigsqr_fast): Allocate the result bignum with 2*xn words. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04* bignum.c (BARY_MUL1): Renamed from BARY_MUL.akr
(bary_mul1): Renamed from bary_mul. (bary_mul): Renamed from bary_mul2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e