Skip to content

Commit

Permalink
Fix bug in power_mod and is_zero(::Ideal) (#1273)
Browse files Browse the repository at this point in the history
(Found by M. Kirschmer)
  • Loading branch information
thofma authored Nov 4, 2023
1 parent c4b9e50 commit f83ab8e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/AlgAssAbsOrd/ICM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

###############################################################################
Expand Down
6 changes: 6 additions & 0 deletions src/HeckeTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/NumFieldOrd/NfOrd/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions test/NfOrd/Ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f83ab8e

Please sign in to comment.