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

Turn zzModRing & ZZModRing into ResidueRing subtypes #1819

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/flint/FlintTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ The ring $\mathbb Z/n\mathbb Z$ for some $n$. See [`residue_ring`](@ref).
Implementation for the modulus being a machine integer [`Int`](@ref).
For the modulus being a [`ZZRingElem`](@ref) see [`ZZModRing`](@ref).
"""
@attributes mutable struct zzModRing <: Ring
@attributes mutable struct zzModRing <: ResidueRing{UInt}
Copy link
Member

Choose a reason for hiding this comment

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

I would argue that this should also be ResidueRing{ZZRingElem}?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well we have

julia> supertypes(zzModRingElem)
(zzModRingElem, ResElem{UInt64}, RingElem, NCRingElem, SetElem, Any)

and these should match, I think?

Copy link
Member

@thofma thofma Jul 8, 2024

Choose a reason for hiding this comment

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

makes sense, unfortunately

n::UInt
ninv::UInt

Expand Down Expand Up @@ -506,7 +506,7 @@ The ring $\mathbb Z/n\mathbb Z$ for some $n$. See [`residue_ring`](@ref).
Implementation for the modulus being a big integer [`ZZRingElem`](@ref).
For the modulus being an [`Int`](@ref) see [`zzModRing`](@ref).
"""
@attributes mutable struct ZZModRing <: Ring
@attributes mutable struct ZZModRing <: ResidueRing{ZZRingElem}
n::ZZRingElem
ninv::fmpz_mod_ctx_struct

Expand Down
16 changes: 8 additions & 8 deletions test/flint/fq_default_embed-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,32 @@ end
Z = Native.GF(p)
R, x = polynomial_ring(Z, "x")

P1 = R(rand(Z, 4)) + x^4
P1 = R(rand(0:p-1, 4)) + x^4
F1 = factor(P1)
P2 = R(rand(Z, 4)) + x^4
P2 = R(rand(0:p-1, 4)) + x^4
F2 = factor(P2)
P3 = R(rand(Z, 4)) + x^4
P3 = R(rand(0:p-1, 4)) + x^4
F3 = factor(P3)
P4 = R(rand(Z, 4)) + x^4
P4 = R(rand(0:p-1, 4)) + x^4
F4 = factor(P4)

while length(F1) != 1 || F1[collect(keys(F1.fac))[1]] != 1
P1 = R(rand(Z, 4)) + x^4
P1 = R(rand(0:p-1, 4)) + x^4
F1 = factor(P1)
end

while length(F2) != 1 || F2[collect(keys(F2.fac))[1]] != 1
P2 = R(rand(Z, 4)) + x^4
P2 = R(rand(0:p-1, 4)) + x^4
F2 = factor(P2)
end

while length(F3) != 1 || F3[collect(keys(F3.fac))[1]] != 1
P3 = R(rand(Z, 4)) + x^4
P3 = R(rand(0:p-1, 4)) + x^4
F3 = factor(P3)
end

while length(F4) != 1 || F4[collect(keys(F4.fac))[1]] != 1
P4 = R(rand(Z, 4)) + x^4
P4 = R(rand(0:p-1, 4)) + x^4
F4 = factor(P4)
end

Expand Down
16 changes: 8 additions & 8 deletions test/flint/fq_embed-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,32 @@ end
Z = GF(p)
R, x = polynomial_ring(Z, "x")

P1 = R(rand(Z, 4)) + x^4
P1 = R(rand(0:p-1, 4)) + x^4
F1 = factor(P1)
P2 = R(rand(Z, 4)) + x^4
P2 = R(rand(0:p-1, 4)) + x^4
F2 = factor(P2)
P3 = R(rand(Z, 4)) + x^4
P3 = R(rand(0:p-1, 4)) + x^4
F3 = factor(P3)
P4 = R(rand(Z, 4)) + x^4
P4 = R(rand(0:p-1, 4)) + x^4
F4 = factor(P4)

while length(F1) != 1 || F1[collect(keys(F1.fac))[1]] != 1
P1 = R(rand(Z, 4)) + x^4
P1 = R(rand(0:p-1, 4)) + x^4
F1 = factor(P1)
end

while length(F2) != 1 || F2[collect(keys(F2.fac))[1]] != 1
P2 = R(rand(Z, 4)) + x^4
P2 = R(rand(0:p-1, 4)) + x^4
F2 = factor(P2)
end

while length(F3) != 1 || F3[collect(keys(F3.fac))[1]] != 1
P3 = R(rand(Z, 4)) + x^4
P3 = R(rand(0:p-1, 4)) + x^4
F3 = factor(P3)
end

while length(F4) != 1 || F4[collect(keys(F4.fac))[1]] != 1
P4 = R(rand(Z, 4)) + x^4
P4 = R(rand(0:p-1, 4)) + x^4
F4 = factor(P4)
end

Expand Down
16 changes: 8 additions & 8 deletions test/flint/fq_nmod_embed-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,32 +130,32 @@ end
Z, = residue_ring(ZZ, p)
R, x = polynomial_ring(Z, "x")

P1 = R(rand(Z, 4)) + x^4
P1 = R(rand(0:p-1, 4)) + x^4
F1 = factor(P1)
P2 = R(rand(Z, 4)) + x^4
P2 = R(rand(0:p-1, 4)) + x^4
F2 = factor(P2)
P3 = R(rand(Z, 4)) + x^4
P3 = R(rand(0:p-1, 4)) + x^4
F3 = factor(P3)
P4 = R(rand(Z, 4)) + x^4
P4 = R(rand(0:p-1, 4)) + x^4
F4 = factor(P4)

while length(F1) != 1 || F1[collect(keys(F1.fac))[1]] != 1
P1 = R(rand(Z, 4)) + x^4
P1 = R(rand(0:p-1, 4)) + x^4
F1 = factor(P1)
end

while length(F2) != 1 || F2[collect(keys(F2.fac))[1]] != 1
P2 = R(rand(Z, 4)) + x^4
P2 = R(rand(0:p-1, 4)) + x^4
F2 = factor(P2)
end

while length(F3) != 1 || F3[collect(keys(F3.fac))[1]] != 1
P3 = R(rand(Z, 4)) + x^4
P3 = R(rand(0:p-1, 4)) + x^4
F3 = factor(P3)
end

while length(F4) != 1 || F4[collect(keys(F4.fac))[1]] != 1
P4 = R(rand(Z, 4)) + x^4
P4 = R(rand(0:p-1, 4)) + x^4
F4 = factor(P4)
end

Expand Down
Loading