Modified 64-bit primality test#2564
Conversation
src/ulong_extras.h
Outdated
|
|
||
| ulong n_nextprime(ulong n, int FLINT_UNUSED(proved)); | ||
|
|
||
| int n_is_semiprime_k(ulong n); |
There was a problem hiding this comment.
You can make this a static function; it doesn't need to be declared in the header file.
src/ulong_extras/is_prime.c
Outdated
| #define WITNESS_BASE_HASH_SIZE 32768 | ||
| /* To keep this file readable, the lookup tables have been | ||
| placed in a seprate header file. */ | ||
| placed in a seperate header file. */ |
src/ulong_extras/is_prime.c
Outdated
| { | ||
| // Precomputed multiplicative inverses of the sqrt of k | ||
| const double SQRTINV[11] = { | ||
| 0.7071067811865475,0.5773502691896258,0.5, |
There was a problem hiding this comment.
Could you change these to hexadecimal float literals? Just to guard against the possibility that a compiler misrounds and that this creates an off-by-one error for one of the numbers we need to detect.
src/ulong_extras/is_prime.c
Outdated
| placed in a seperate header file. */ | ||
| #include "is_prime_tables.h" | ||
|
|
||
| int n_is_semiprime_k(ulong n) |
There was a problem hiding this comment.
Suggest making this function static.
|
Can you please update the documentation for Also feel free to add yourself to the copyright notices for |
|
Should be good now. I reran Feitsma's set to make sure that the hex literals are sufficient as well. |
|
Thanks! |
This adds a floating-point semiprime check to the primality test, and substantially reduces the size of the witness table to 64Kib which should produce roughly equivalent or superior performance in many applications.