-
-
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
faster gcd #8410
faster gcd #8410
Conversation
is this actually a faster method, or just a way to avoid rem |
If i'm reading this correctly, the binary algorithm should be about 1.8x faster for large N. |
This implementation requires I think that in the interest of generality it would be useful to keep the old version (for user-defined integers), while this more optimized one could be specialized on the concrete |
That's fair. I guess i'm a little squeamish about including code in Base which isn't used by any of the types in Base. |
Yes, I understand. It would also need to be tested explicitly via One more issue is that of extending the specialized version: using a On the other hand, Maybe having a concrete example in mind would be useful to further the discussion, e.g. ModInts. |
Ok, i've restricted this to |
Type-unstable? Couldn't that be fixed rather easily by promoting the arguments or converting the result of |
Sure, but i'm lazy. |
Should we have a comment in the source to inform source code readers why we have two implementations of |
2ef98c5
to
0388647
Compare
Ok, comment added. |
You have a strange definition of lazy. |
Average speedup for random inputs ranges from
20%8% (Int8) to 70% (Int64).