Click here to Skip to main content
15,902,634 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
PIEBALDconsult15-Jan-09 6:12
mvePIEBALDconsult15-Jan-09 6:12 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Luc Pattyn15-Jan-09 6:28
sitebuilderLuc Pattyn15-Jan-09 6:28 
AnswerRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Member 419459328-Nov-08 9:03
Member 419459328-Nov-08 9:03 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
PIEBALDconsult28-Nov-08 10:46
mvePIEBALDconsult28-Nov-08 10:46 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Luc Pattyn28-Nov-08 11:01
sitebuilderLuc Pattyn28-Nov-08 11:01 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes [modified] Pin
PIEBALDconsult29-Nov-08 4:13
mvePIEBALDconsult29-Nov-08 4:13 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Member 41945934-Jan-09 16:56
Member 41945934-Jan-09 16:56 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Member 41945935-Jan-09 11:06
Member 41945935-Jan-09 11:06 
I have just thought of a way to self check my calculations for determining the
correct bit to use as a start for a Sieve Block that is not Sieve Block 0. The
first Sieve Block, Sieve Block 0, is a lead pipe cinch. It IS correct. The
problem is whether or not the subsequent blocks are correct - whether or not all
bits have been examined to remove from the subsequent blocks, or whether or not
the correct starting bit was calculated for any Prime Number that is not in that
Sieve Block. My thought was to increase the size of the Sieve Block being
processed to twice the size of the original. Essentially, calculate the Sieve
for two blocks as if they were one. There would be no calculations to make for
switching from one Sieve Block to the next, any more than would need to be made
in passing from one half of a single Sieve Block to the second half of the
block, the data bits are contiguous. The original Sieve Block 0 would be copied
to a .SAV file. Once the new pair of Sieve Blocks has been calculated, compare
the new Sieve Block 0 to the saved copy, if they are the same, then continue
(they WILL be the same for Sieve Block 0), then save the new Sieve Block 0 as a
.SIV file, and save the second Sieve Block as a .SAV file (it is a valid Sieve
Block 1 since it was masked contiguously with Sieve Block 0). Now calculate the
start of Sieve Block 1, and create a new pair of Sieve Block 1 and Sieve Block 2
as was done for Sieve Block 0 and Sieve Block 1. Again compare Sieve Block 1
with the prior saved .SAV file, and if they match, save the new Sieve Block 1 as
a .SIV file, and Sieve Block 2 as a .SAV file. Each Sieve Block build builds a
correct block to validate the next block when it is created. Twice the work, but
you have validation. Actually, the actual masking of the bits is quite fast, the
reading and writing and calculations for the starting bit are the time killers.

One question. Would it be sufficient to take an MD5 checksum of the second
block, then an MD5 checksum of the next newly created block and compare the MD5
checksum to determine if valid? I think it wise to save a file of the MD5
checksums anyway to be able to validate the correctness of the blocks when read
back in. I would actually save them in a file instead of attaching them to the
end of the file data. The file data is sector and cluster bounded, to add an
extra DWORD would take extra sectors, whereas a file with MD5 checksums would
only appear once. I had planned to use 2 750 GB external hard drives to save the
files giving 1500 GB storage, and 6000 Sieve Blocks (1/4 GB per Sieve Block).
This would be all primes below 2^188000.

Does anyone see any problems with this approach?

Dave.
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Luc Pattyn28-Nov-08 11:33
sitebuilderLuc Pattyn28-Nov-08 11:33 
AnswerRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
PIEBALDconsult2-Dec-08 3:45
mvePIEBALDconsult2-Dec-08 3:45 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Luc Pattyn2-Dec-08 22:14
sitebuilderLuc Pattyn2-Dec-08 22:14 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
73Zeppelin2-Dec-08 22:28
73Zeppelin2-Dec-08 22:28 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Luc Pattyn2-Dec-08 23:15
sitebuilderLuc Pattyn2-Dec-08 23:15 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
73Zeppelin3-Dec-08 0:14
73Zeppelin3-Dec-08 0:14 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
PIEBALDconsult3-Dec-08 4:11
mvePIEBALDconsult3-Dec-08 4:11 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Luc Pattyn3-Dec-08 5:45
sitebuilderLuc Pattyn3-Dec-08 5:45 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
PIEBALDconsult3-Dec-08 16:16
mvePIEBALDconsult3-Dec-08 16:16 
GeneralA la recherche des nombres premiers Pin
Luc Pattyn3-Dec-08 16:37
sitebuilderLuc Pattyn3-Dec-08 16:37 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
PIEBALDconsult3-Dec-08 5:06
mvePIEBALDconsult3-Dec-08 5:06 
GeneralRe: Wheel Factorization to simplify a Sieve of Eratosthenes Pin
Luc Pattyn3-Dec-08 5:53
sitebuilderLuc Pattyn3-Dec-08 5:53 
AnswerRe: Wheel Factorization to simplify a Sieve of Eratosthenes [modified] Pin
PIEBALDconsult9-Jan-09 11:53
mvePIEBALDconsult9-Jan-09 11:53 
QuestionEfficient Search/Comparison Algorithm Pin
SanchitK20-Nov-08 3:29
SanchitK20-Nov-08 3:29 
AnswerRe: Efficient Search/Comparison Algorithm Pin
Member 419459320-Nov-08 6:17
Member 419459320-Nov-08 6:17 
AnswerRe: Efficient Search/Comparison Algorithm Pin
Alan Balkany20-Nov-08 10:20
Alan Balkany20-Nov-08 10:20 
AnswerRe: Efficient Search/Comparison Algorithm Pin
cmk20-Nov-08 12:59
cmk20-Nov-08 12:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.