Sieve of Eratosthenes: Difference between revisions
→With Wheel: A. comment is not code. B. Rosetta Code is for simple and illuminating codes first. we _add_ the better performant (and very long) ones, not replace.
GordonBGood (talk | contribs) m (→With Wheel: Haskell - correctly accidentally merging two sections, corrected comments...) |
(→With Wheel: A. comment is not code. B. Rosetta Code is for simple and illuminating codes first. we _add_ the better performant (and very long) ones, not replace.) |
||
Line 5,623:
Used [[Emirp_primes#List-based|here]] and [[Extensible_prime_generator#List_based|here]].
The above
1. The
2.
<lang haskell>-- autogenerates wheel primes, first sieve prime, and gaps
Line 5,670:
When compiled with -O2 optimization and -fllvm (the LLVM back end), the above code is over twice as fast as the Odds-Only version as it should be as that is about the ratio of reduced operations minus some slightly increased operation complexity, sieving the primes to a hundred million in about seven seconds on a modern middle range desktop computer. It is almost twice as fast as the "primesW" version due to the increased algorithmic efficiency!
Note that the "wheelGen" code could be used to not need to do further culling at all by continuously generating wheels until the square of the "firstSievePrime
===Priority Queue based incremental sieve===
|