![]() |
![]() |
#12 |
Feb 2020
Germany
1100102 Posts |
![]()
Thanks for looking into my code.
I was already writing a reply where I explained that I do not understand the problem and I could not figure it out when I decided to have a look if someone else answered after henryzz :) I even had it running with the Code:
primes = malloc(sizeof(int) * sieve_depth); I corrected the corresponding lines and the code works! Thanks. I tried to save some memory, so I used a char variable to store the information from the sieve. Worked out great for me... Now I can try out my 'efficient' program to generate prime candidates ![]() |
![]() |
![]() |
![]() |
#13 |
"Ben"
Feb 2007
3,617 Posts |
![]()
Speaking of efficiency, it is much better to flip the order of the loops. Exponentiation and the other operations on big numbers are a lot more expensive than division by a single limb, so do the loop over 'e' first. Then after you've computed each candidate 'n', loop over the primes and trial divide, breaking out if mod==0.
Last fiddled with by bsquared on 2022-01-17 at 21:24 |
![]() |
![]() |
![]() |
#14 |
Feb 2020
Germany
2·52 Posts |
![]()
Thanks for the bug finding! The program works as expected now.
@bsquared: I wrote the program with flipped for-loops in the beginning. Then I switched to see what the performance might be, encountered the bug and forgot to change it back :/ *now* I can use my efficient program (I actually find it quite alright for a novice) regards |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
P-1 memory | ET_ | Software | 4 | 2018-05-14 13:55 |
error failled to reallocate | cardmaker | Msieve | 10 | 2016-07-05 13:09 |
"Hybrid Memory Cube" offers 1 Tb/s memory bandwith at just 1.4 mW/Gb/s | ixfd64 | Hardware | 4 | 2011-12-14 21:24 |
Memory available to P-1 | lycorn | Software | 23 | 2010-05-09 22:15 |
available memory | Unregistered | Information & Answers | 2 | 2008-04-11 07:40 |