method
extend_table

v1_9_2_180 -
Show latest stable
-
0 notes -
Class: EratosthenesSieve
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
extend_table()
private
Hide source
# File lib/prime.rb, line 457 def extend_table lbound = NUMS_PER_TABLE * @tables.length ubound = lbound + NUMS_PER_TABLE new_table = [FILLED_ENTRY] * ENTRIES_PER_TABLE # which represents primarity in lbound...ubound (3..Integer(Math.sqrt(ubound))).step(2) do |p| i, j, k = indices(p) next if @tables[i][j][k].zero? start = (lbound.div(p)+1)*p # least multiple of p which is >= lbound start += p if start.even? (start...ubound).step(2*p) do |n| _, j, k = indices(n) new_table[j] &= FILLED_ENTRY^(1<<k) end end @tables << new_table.freeze end