mersenneforum.org GNU MP: Cannot reallocate memory - Why?
 Register FAQ Search Today's Posts Mark Forums Read

 2022-01-17, 21:16 #12 hunson   Feb 2020 Germany 2·52 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); in 'debug' but not in 'release', something was very strange. 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
 2022-01-17, 21:23 #13 bsquared     "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
 2022-01-18, 20:50 #14 hunson   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

 Similar Threads Thread Thread Starter Forum Replies Last Post ET_ Software 4 2018-05-14 13:55 cardmaker Msieve 10 2016-07-05 13:09 ixfd64 Hardware 4 2011-12-14 21:24 lycorn Software 23 2010-05-09 22:15 Unregistered Information & Answers 2 2008-04-11 07:40

All times are UTC. The time now is 06:34.

Tue May 24 06:34:48 UTC 2022 up 40 days, 4:36, 0 users, load averages: 1.39, 1.54, 1.69