-
Notifications
You must be signed in to change notification settings - Fork 160
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
kernel: fix wrong result bugs in partial perms code #3220
Conversation
Various computations involving T_PERM2 objects of degree 65536 returned incorrect results. The reason was that the degree, which is always an UInt, was stored in an UInt2. But for degree 65536, this overflows to zero, hence the code effectively treated the permutation as the identity. The fix is to always store the degree as UInt, not as UInt2 or UInt4 (the latter case actually is probably fine, but let's do it right anyway). The fix in PowPPerm2Perm2 is a bit nasty and constitutes a deoptimization; a proper fix at this stage would involve duplicating and tweaking a bunch of code; but I plan to rewrite this file to use C++ templates anyway, at which point the proper fix will come almost for free. So instead of wasting time on a "proper" fix now, let's live with this workaround for now.
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.
Looks good to me, good job and thanks!
Codecov Report
@@ Coverage Diff @@
## master #3220 +/- ##
==========================================
+ Coverage 84.77% 84.81% +0.03%
==========================================
Files 688 687 -1
Lines 335887 330815 -5072
==========================================
- Hits 284737 280568 -4169
+ Misses 51150 50247 -903
|
I suggest we backport this to 4.10, chance for regression should be negligible. @james-d-mitchell ping (just want to make sure you are aware of this PR) |
Thanks for the ping @fingolfin I'm also happy with this change. |
Backported to stable-4.10 via ab4dc53 |
Various computations involving T_PERM2 objects of degree 65536 returned
incorrect results. The reason was that the degree, which is always an UInt,
was stored in an UInt2. But for degree 65536, this overflows to zero, hence
the code effectively treated the permutation as the identity.
The fix is to always store the degree as UInt, not as UInt2 or UInt4 (the
latter case actually is probably fine, but let's do it right anyway).
The fix in PowPPerm2Perm2 is a bit nasty and constitutes a deoptimization; a
proper fix at this stage would involve duplicating and tweaking a bunch of
code; but I plan to rewrite this file to use C++ templates anyway, at which
point the proper fix will come almost for free. So instead of wasting time on
a "proper" fix now, let's live with this workaround for now.