Skip to content

Commit

Permalink
Turn zzModRing & ZZModRing into ResidueRing subtypes
Browse files Browse the repository at this point in the history
Since the element types of these ring types are subtypes of ResElem, the
rings should be subtypes of ResidueRing. Otherwise some generic code
gets confused (notably check_parent for ResElem).

This lead to a wrong error in the OSCAR book's introduction notebook.
  • Loading branch information
fingolfin committed Jul 5, 2024
1 parent 4e6ffb0 commit 61cc89c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
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}
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

0 comments on commit 61cc89c

Please sign in to comment.