-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add conformance tests for MPolyRing, and fix bugs in ^ and is_unit for MPoly #1950
base: master
Are you sure you want to change the base?
Conversation
If the coefficient ring is not a domain then the `n`-th power of an element `f` may have degree less than `n*deg(f)`.
6a86b49
to
b90fb4e
Compare
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.
I avoided calling constant_coefficient
because it might iterate over the terms in f
, but then we iterate again over the terms in f
in the main loop. Here is a partial demonstration:
julia> P,(x,y) = polynomial_ring(QQ, ["x","y"]);
julia> f = (2*x+3*y-4)^3 + (3*x-2*y-6)^3;
julia> f999 = f^999;
julia> @time constant_coefficient(f999);
3.127883 seconds (17.98 M allocations: 5.133 GiB, 15.79% gc time)
I have just tried a more realistic test, which actually calls the code I wrote:
julia> P,(x,y) = polynomial_ring(ZZmod720, ["x","y"]);
julia> f = (2*x+3*y-4)^3 + (3*x-2*y-6)^3;
julia> f9999 = f^9999; # takes a long time
julia> @time constant_coefficient(f9999);
0.052131 seconds (1.00 M allocations: 76.614 MiB, 18.73% gc time)
julia> @time is_unit(f9999)
0.000009 seconds (1 allocation: 80 bytes)
false
So in this case, calling constant_coefficient
will be a bit slower. That said, @fingolfin code is neater.
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.
More importantly, my new code is less wrong ;-).
julia> R,_ = residue_ring(ZZ,ZZ(720));
julia> S,(x,y)=R[:x,:y];
julia> is_unit(30*x)
true
I am happy if somebody adjusts the code to be faster again, but to me correctness trumps speed.
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.
OK I thought about it and I think I found a better way, we'll see.
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.
The version with constant_term_is_unit
looks fine to me: i.e. should be both fast and correct
Tests fail inside
What is going on here is that there is test code starting out like this:
Note that we take a quotient of Which is part of my motivation for opening #1943 to discuss adding an But I digress: I can of course adjust the failing test to instead work over
So it sounds as if this is almost kinda intentionally supported-but-with-some-pitfalls? urgh |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1950 +/- ##
==========================================
+ Coverage 88.22% 88.23% +0.01%
==========================================
Files 119 119
Lines 30425 30429 +4
==========================================
+ Hits 26842 26849 +7
+ Misses 3583 3580 -3 ☔ View full report in Codecov by Sentry. |
Wonderful, this PR found a bug in Nemo: function is_unit(a::fqPolyRepMPolyRingElem)
return is_constant(a)
end |
No description provided.