Skip to content
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

Merged
merged 1 commit into from
Jan 23, 2019

Conversation

fingolfin
Copy link
Member

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.

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.
@fingolfin fingolfin added kind: bug Issues describing general bugs, and PRs fixing them kind: bug: wrong result Issues describing bugs that result in mathematically or otherwise wrong results, and PRs fixing them topic: kernel labels Jan 23, 2019
Copy link
Member

@wilfwilson wilfwilson left a 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!

@coveralls
Copy link

coveralls commented Jan 23, 2019

Coverage Status

Coverage increased (+0.0009%) to 84.644% when pulling d9f7321 on fingolfin:mh/fix-pperm into e868e29 on gap-system:master.

@codecov
Copy link

codecov bot commented Jan 23, 2019

Codecov Report

Merging #3220 into master will increase coverage by 0.03%.
The diff coverage is n/a.

@@            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
Impacted Files Coverage Δ
src/modules.h 33.33% <0%> (-66.67%) ⬇️
src/macfloat.h 40% <0%> (-60%) ⬇️
src/records.h 50% <0%> (-50%) ⬇️
src/gapstate.h 28.57% <0%> (-42.86%) ⬇️
src/gvars.h 66.66% <0%> (-33.34%) ⬇️
src/hookintrprtr.h 66.66% <0%> (-33.34%) ⬇️
src/fibhash.h 66.66% <0%> (-33.34%) ⬇️
src/intobj.h 65.71% <0%> (-31.73%) ⬇️
src/calls.h 68.04% <0%> (-29.9%) ⬇️
src/objects.h 60.31% <0%> (-29.24%) ⬇️
... and 77 more

@fingolfin
Copy link
Member Author

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)

@james-d-mitchell
Copy link
Contributor

Thanks for the ping @fingolfin I'm also happy with this change.

@fingolfin fingolfin merged commit f27cff4 into gap-system:master Jan 23, 2019
@fingolfin fingolfin deleted the mh/fix-pperm branch January 23, 2019 13:19
@fingolfin
Copy link
Member Author

Backported to stable-4.10 via ab4dc53

@olexandr-konovalov olexandr-konovalov added this to the GAP 4.10.1 milestone Jan 26, 2019
@olexandr-konovalov olexandr-konovalov added the release notes: added PRs introducing changes that have since been mentioned in the release notes label Feb 23, 2019
@fingolfin fingolfin removed this from the GAP 4.10.1 milestone Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-4.10-DONE kind: bug: wrong result Issues describing bugs that result in mathematically or otherwise wrong results, and PRs fixing them kind: bug Issues describing general bugs, and PRs fixing them release notes: added PRs introducing changes that have since been mentioned in the release notes topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants