Sujet : Re: Sieve of Erastosthenes optimized to the max
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.c++Date : 02. Jul 2024, 08:20:27
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86zfr0b9hw.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Vir Campestris <
vir.campestris@invalid.invalid> writes:
On 19/06/2024 01:34, Tim Rentsch wrote:
>
Would you mind if I asked you to post the code so I can
take a look at it? Or if you would rather email it to
me that also works.
>
I've hacked out all my include files, added a GPL licence, and
included build instructions. It follows in the signature block.
600 lines :(
>
I bet the line wrapping breaks it too.
I got the code. There were some line wrappings but I just went
through and fixed those by hand. After fixing the problem line
wraps I was able to compile and run the code (I used std=c++17,
which apparently works okay). I did a simple check to make sure
the primes being found are right, which they do indeed seem to
be. I haven't really experimented with changing the code; I
only just ran it with various bounds on what primes to find,
mostly to get a sense of the performance.
I admit I don't understand the scheme the code is using. It
looks to me like the code is doing divisions and remainders a
lot, which my code basically doesn't do at all (it does do one
division for each prime up to the square root of the limit of
primes being sought, but that's all). I know the big template
near the beginning is crucial to understanding what the code is
doing, but I haven't been able to figure out what abstraction
that template is supposed to represent. The core of my program
is between 50 and 60 lines, and all pretty straightforward.
Is there some suggestion you could make or a question you would
like to ask? What can I do that might be helpful?