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

Jaa/is nilpotent #1974

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

Conversation

JohnAAbbott
Copy link
Contributor

Usefully faster implementation of is_nilpotent(::ResElem), but it is longer...

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.98%. Comparing base (5b2186c) to head (baa6317).

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.
📢 Have feedback on the report? Share it here.

src/flint/fmpq.jl Outdated Show resolved Hide resolved
@@ -20,6 +20,8 @@ base_ring(a::ZZModRing) = ZZ

parent(a::ZZModRingElem) = a.parent

is_domain_type(::Type{ZZModRingElem}) = false
Copy link
Member

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

src/HeckeMoreStuff.jl Outdated Show resolved Hide resolved
src/HeckeMoreStuff.jl Outdated Show resolved Hide resolved
src/flint/nmod.jl Outdated Show resolved Hide resolved
src/flint/nmod_poly.jl Outdated Show resolved Hide resolved
@JohnAAbbott
Copy link
Contributor Author

The new code (or most of it) has been moved into AbstractAlgebra.

@JohnAAbbott
Copy link
Contributor Author

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)
Copy link
Member

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

Comment on lines +139 to +140
nilp720 = filter((r -> is_nilpotent(ZZmod720(r))), 0:719);
@test length(nilp720) == 24 # 720/(2*3*5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better expressed like so:

Suggested change
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)

Comment on lines +144 to +148
# 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))
Copy link
Member

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?

Copy link
Contributor Author

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?

src/flint/fmpq.jl Outdated Show resolved Hide resolved
src/flint/fmpz.jl Outdated Show resolved Hide resolved
src/flint/nmod_mpoly.jl Outdated Show resolved Hide resolved
is_unit(a::fqPolyRepMPolyRingElem) even was wrong (it return true for zero)
The generic code is actually faster than those
@JohnAAbbott
Copy link
Contributor Author

I am wondering whether all tests related to is_nilpotent should be moved into AbstractAlgebra since the implementation now resides there. The distinction between what AbstractAlgebra handles and what Nemo handles is not entirely clear to me.
Maybe some tests need to be duplicated? If I load the package AbstractAlgebra, there is already a function to create residue_ring(ZZ,720); but if I load Nemo (or all of Oscar) as well then residue_ring(ZZ,720) calls a different function, presumably using a different interna; representation. So probably the tests should be made both in the AbstractAlgebra tests and in the Nemo tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants