-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Do not use widen
for 128-bit ints in MultiplicativeInverses
#47995
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
Conversation
This is a really nice improvement! I think we should consider making |
Also, do you happen to know if there's an efficient way to compute |
Nope :(
Sounds like a good idea. I would also use it somewhere in fast modular arithmetic |
ping ! |
Needs a rebase but other than that, I think it's ready. |
I just did the rebase and will merge when tests pass. |
…aLang#47995) * Do not use widen for UInt128 --------- Co-authored-by: Oscar Smith <oscardssmith@gmail.com>
Hello! This PR improves
MultiplicativeInverses
forInt128
andUInt128
. PR consists of 3 tiny points:widen
. It widened 128-bit ints toBigInt
, which hindered performance. The solution in this PR is to replacewiden
with higher half multiplication forInt128
andUInt128
.MultiplicativeInverses
for all bit integer types;MultiplicativeInverses
does not throw when the result overflows (see tests)As for the latter, it's alright with me, but I think it would be good to mention this fact somewhere
Also, I've coded the higher half mult. from scratch, so let me know if there were functions for this in Base already 😊