-
Notifications
You must be signed in to change notification settings - Fork 59
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
Jaa/is nilpotent #1974
base: master
Are you sure you want to change the base?
Jaa/is nilpotent #1974
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1974 +/- ##
==========================================
- Coverage 87.98% 87.98% -0.01%
==========================================
Files 98 98
Lines 36060 36021 -39
==========================================
- Hits 31729 31693 -36
+ Misses 4331 4328 -3 ☔ View full report in Codecov by Sentry. |
…o JAA/is_nilpotent
src/flint/fmpz_mod.jl
Outdated
@@ -20,6 +20,8 @@ base_ring(a::ZZModRing) = ZZ | |||
|
|||
parent(a::ZZModRingElem) = a.parent | |||
|
|||
is_domain_type(::Type{ZZModRingElem}) = false |
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.
This is not necessary as we have this in AA:
# Type can only represent elements of domains
# false unless explicitly specified
is_domain_type(R::Type{T}) where T <: RingElem = false
The new code (or most of it) has been moved into |
Bother! This PR will work only with the revised AA (see PR 1933 there) |
@@ -128,6 +131,21 @@ end | |||
@test_throws Exception R6(R22(1)) | |||
@test_throws Exception R2(R3(1)) | |||
@test_throws Exception R3(R2(1)) | |||
|
|||
ZZmod720,_ = residue_ring(ZZ,720) |
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.
This is a different ring, so the test for that one should be in nmod-test.jl
.
We also generally place a space after commas in our code
nilp720 = filter((r -> is_nilpotent(ZZmod720(r))), 0:719); | ||
@test length(nilp720) == 24 # 720/(2*3*5) |
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.
Better expressed like so:
nilp720 = filter((r -> is_nilpotent(ZZmod720(r))), 0:719); | |
@test length(nilp720) == 24 # 720/(2*3*5) | |
@test count(is_nilpotent, ZZmod720) == 24 # 720/(2*3*5) |
# 64-bit overflow test: **ASSUMES** Int is 64 bits | ||
rr = 4*3^20 | ||
mm = 3*rr | ||
R_overflow,_ = residue_ring(ZZ, mm) | ||
@test is_nilpotent(R_overflow(rr)) |
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.
What exactly is this testing? Clearly it is related to Int
overflowing, but which aspect of that / where is it coming into play here?
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 current implementation of is_nilpotent
works correctly for this input, but an earlier version was incorrect (even though the code looked right). I prefer to keep this test example in case someone in the future modifies the code, and mishandles integer overflow. Maybe this should be in nmod-test
too?
is_unit(a::fqPolyRepMPolyRingElem) even was wrong (it return true for zero)
The generic code is actually faster than those
I am wondering whether all tests related to |
Usefully faster implementation of
is_nilpotent(::ResElem)
, but it is longer...