From f6a4083ac545fe0a91830f54fb3d2146c148aec1 Mon Sep 17 00:00:00 2001 From: Tommy Hofmann Date: Sat, 4 Nov 2023 11:03:05 +0100 Subject: [PATCH] Fix bug in power_mod and is_zero(::Ideal) (Found by M. Kirschmer) --- src/AlgAssAbsOrd/ICM.jl | 2 +- src/HeckeTypes.jl | 6 ++++++ src/NumFieldOrd/NfOrd/Elem.jl | 3 +-- test/NfOrd/Ideal.jl | 11 +++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/AlgAssAbsOrd/ICM.jl b/src/AlgAssAbsOrd/ICM.jl index df070c6599..761e8e459b 100644 --- a/src/AlgAssAbsOrd/ICM.jl +++ b/src/AlgAssAbsOrd/ICM.jl @@ -86,7 +86,7 @@ function is_isomorphic(I::T, J::T) where { T <: Union{ NfAbsOrdIdl, NfOrdFracIdl end function ring_of_multipliers(I::NfOrdFracIdl) - return ring_of_multipliers(numerator(I, copy = false)*denominator(I, copy = false)) + return ring_of_multipliers(numerator(I, copy = false)) end ############################################################################### diff --git a/src/HeckeTypes.jl b/src/HeckeTypes.jl index 71f35d208b..51c6e51e77 100644 --- a/src/HeckeTypes.jl +++ b/src/HeckeTypes.jl @@ -1042,6 +1042,9 @@ const NfAbsOrdIdlSetID = Dict{NfAbsOrd, NfAbsOrdIdlSet}() C.princ_gen_fac_elem = FacElem(nf(O)(x)) C.is_principal = 1 C.princ_gen_special = (1, abs(x), ZZRingElem(0)) + if is_zero(x) + C.iszero = 1 + end C.gen_one = ZZRingElem(x) C.gen_two = O(x) C.norm = ZZRingElem(abs(x))^degree(O) @@ -1059,6 +1062,9 @@ const NfAbsOrdIdlSetID = Dict{NfAbsOrd, NfAbsOrdIdlSet}() C.princ_gen_fac_elem = FacElem(nf(O)(x)) C.is_principal = 1 C.princ_gen_special = (2, Int(0), abs(x)) + if is_zero(x) + C.iszero = 1 + end C.gen_one = x C.gen_two = O(x) C.norm = abs(x)^degree(O) diff --git a/src/NumFieldOrd/NfOrd/Elem.jl b/src/NumFieldOrd/NfOrd/Elem.jl index 432141f211..8f4b386d00 100644 --- a/src/NumFieldOrd/NfOrd/Elem.jl +++ b/src/NumFieldOrd/NfOrd/Elem.jl @@ -290,8 +290,7 @@ end function powermod(a::NfAbsOrdElem, i::ZZRingElem, p::ZZRingElem) - #if contains_equation_order(parent(a))#This doesn't work! - if is_defining_polynomial_nice(nf(parent(a))) + if is_defining_polynomial_nice(nf(parent(a))) && contains_equation_order(parent(a)) return powermod_fast(a, i, p) else return powermod_gen(a, i, p) diff --git a/test/NfOrd/Ideal.jl b/test/NfOrd/Ideal.jl index 95e23ea361..b4c85cc634 100644 --- a/test/NfOrd/Ideal.jl +++ b/test/NfOrd/Ideal.jl @@ -36,6 +36,9 @@ Ib = basis(I2) II = ideal(O2, Ib) @test I2 == II + + @test is_zero(ideal(O1, 0)) + @test is_zero(ideal(O1, ZZ(0))) end I = ideal(O1, -17) @@ -189,6 +192,14 @@ @testset "p-Radical" begin I = @inferred pradical(O1, 2) @test I == ideal(O1, FlintZZ[2 0 0; 0 1 0; 0 0 1]) + + # An order which does not contain the equation order + P, x = polynomial_ring(QQ) + f = x^5 + x^3 - x^2 - x - 1 + K, a = number_field(f) + R = maximal_order(K) + OO = Order(K, basis(5*R)) + pradical(OO, 2) end @testset "Prime Decomposition" begin