Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpz_prevprime #10

Closed
wants to merge 4 commits into from
Closed

mpz_prevprime #10

wants to merge 4 commits into from

Conversation

sethtroisi
Copy link
Owner

mpz_prevprime

for (i = 0; i < prime_limit; i++)
{
unsigned r;
/* FIXME: Reduce moduli + incr and store back, to allow for
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested several versions of this and none of them were faster.

@@ -82,47 +122,54 @@ mpz_nextprime (mpz_ptr p, mpz_srcptr n)
/* Compute residues modulo small odd primes */
moduli = TMP_SALLOC_TYPE (prime_limit * sizeof moduli[0], unsigned short);

for (;;)
{
/* FIXME: Compute lazily? */
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this too and it's not useful, because to exit the lower loop you have to check each of these is non-zero, so there all need to be calculated, and reordering doesn't seem to help (as there is overhead in tracking if they are calculated)

@sethtroisi
Copy link
Owner Author

A different version (much better) is close to being merged upstream.

@sethtroisi sethtroisi closed this Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant