-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
Fix the calculation of "is prime" for numbers after 1321. #3799
Conversation
Should this have regression tests? One possibility to cover a wide range of values is to test for class MersennePrimeTest is UnitTest
fun name(): String => "math/MersennePrimeTest"
fun apply(h: TestHelper) =>
let mersenne_prime_exponents: Array[U8] = [
2; 3; 5; 7
13; 17; 19; 31
61; 89; 107; 127
]
var p: U8 = 128
var x = U128.max_value() // (2 ^ p) - 1
while p >= 2 do
if mersenne_prime_exponents.contains(p) then
h.assert_true(IsPrime[U128](x))
else
h.assert_false(IsPrime[U128](x))
end
p = p - 1
x = x >> 1
end |
Eric, I am always for more tests covering a wider range. I am not familiar with Mersenne primes though. I am going to adding tests to this PR before it is merged and reduce the redundancy in the implementation. |
I am working on my additions here. I am currently looking at generalizing Mersenne prime production. |
@rhagenson if the additional tests aren't ready in the next couple days, let's merge this so it goes out in the release and go from there. |
Sounds good. I will push what I have done today (short of any WIP stuff) so we can get it ready. The issue right now is that Mersenne primes are computationally intensive so I am trying to find a way to pare that down slightly to test a large portion of the range, but not all. |
The only problematic type is |
The force push is me using git fixup for the first time (I just learned about it last week thanks to Sean) so if it broke something I will need help fixing it. I had neglected to remove some debugging stuff, including the |
I have going to remove myself as a reviewer since obviously at this time I have made additions so there is a general implicit approval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not quickly determine how to unassign myself so going to stamp it with my approval anyhow as I have to switch what I am focusing on right now.
No description provided.