-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Make gcdx(0, 0) return (0, 0, 0) #40989
Conversation
Is there a justification for why one is better than the other? This is a silent breaking change, so we cannot do this lightly. |
Sure, I understand. Basically it is because of (1) standards, (2) expectation and (3) bad practice (IMO). As mentioned it is the standard for GMP, but also for other programmes like Wolfram: https://www.wolframalpha.com/input/?i=extendedgcd%280%2C0%29. When I write Continuing on this, I find it bad practice to not return the "smallest" values. If we can return a small number, why don't we? Obviously this need to be documented, but the general behavior of |
This makes sense to me. Adding triage to confirm. @Keno why is this a breaking change? I think as long as the result conforms with the definition, it's OK. |
Well, it is a breaking change as people may rely on specific return values. However, I still think it is good to proceed. |
@nanosoldier |
Triage approves on the argument that this is a pretty minor change, arguably more mathematically consistent, and agrees with GMP and Mathematica. |
Looks like an unrelated compilation failure (SuiteSparse checksum failure); let's try again: @nanosoldier |
... wait, the head of this PR is ancient. Let's rebase first. |
3e568ae
to
fcdc925
Compare
@nanosoldier |
The package evaluation job you requested has completed - possible new issues were detected. |
lol. the one failure is Nemo which 5 years ago discovered that Nemo disagreed with julia and therefore in Nemocas/Nemo.jl#730 switched how their gcdx works. Specifically, see https://github.com/Nemocas/Nemo.jl/blob/a5a9c5c2d565a94ad8d75ed484848d2d60d19cb2/src/flint/fmpz.jl#L1282. |
Is this related to / close #39638? |
no |
Can I bump this? |
Thanks for the bump. This should get an entry in NEWS.md (follow the style of the other entries in that file) Aside from that LGTM. It would be nice to test |
This removes the somewhat inconsistent behaviour of returning (0, 1, 0). Also update NEWS.md accordingly.
fcdc925
to
ac15de8
Compare
Haven't checked that it passes the tests. I also added some extra tests for |
ac15de8
to
ad6d8d6
Compare
Also test gcd, gcdx and lcm for BigInt, and add some additional canonical tests for gcdx.
Elegant approach to testing. I like it! |
Thank you for your contribution! |
As the title suggests. This should conform to GMP's definition: https://gmplib.org/manual/Number-Theoretic-Functions#index-Extended-GCD.