From 61cc89c5cbc76b9078dca735819298084abcea95 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 4 Jul 2024 17:23:54 +0200 Subject: [PATCH] Turn zzModRing & ZZModRing into ResidueRing subtypes 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. --- src/flint/FlintTypes.jl | 4 ++-- test/flint/fq_default_embed-test.jl | 16 ++++++++-------- test/flint/fq_embed-test.jl | 16 ++++++++-------- test/flint/fq_nmod_embed-test.jl | 16 ++++++++-------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/flint/FlintTypes.jl b/src/flint/FlintTypes.jl index 9640539f9..35c48d5ee 100644 --- a/src/flint/FlintTypes.jl +++ b/src/flint/FlintTypes.jl @@ -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 @@ -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 diff --git a/test/flint/fq_default_embed-test.jl b/test/flint/fq_default_embed-test.jl index f19f326e3..772e54d32 100644 --- a/test/flint/fq_default_embed-test.jl +++ b/test/flint/fq_default_embed-test.jl @@ -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 diff --git a/test/flint/fq_embed-test.jl b/test/flint/fq_embed-test.jl index 811400228..ba154acb8 100644 --- a/test/flint/fq_embed-test.jl +++ b/test/flint/fq_embed-test.jl @@ -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 diff --git a/test/flint/fq_nmod_embed-test.jl b/test/flint/fq_nmod_embed-test.jl index 4e98630f4..80e02ee3c 100644 --- a/test/flint/fq_nmod_embed-test.jl +++ b/test/flint/fq_nmod_embed-test.jl @@ -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