Skip to content

Commit

Permalink
Drop redundant check_parent methods (#1542)
Browse files Browse the repository at this point in the history
... in favor of generic one from AA 0.41.9
  • Loading branch information
fingolfin authored Jun 12, 2024
1 parent 0ff72f1 commit a12d236
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 98 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ GAPExt = "GAP"
PolymakeExt = "Polymake"

[compat]
AbstractAlgebra = "^0.41.5"
AbstractAlgebra = "^0.41.9"
Dates = "1.6"
Distributed = "1.6"
GAP = "0.9.6, 0.10, 0.11"
Expand Down
4 changes: 0 additions & 4 deletions examples/Round2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ Nemo.canonical_unit(a::OrderElem) = OrderElem(parent(a), ZZRingElem(1))

Base.deepcopy_internal(a::OrderElem, dict::IdDict) = OrderElem(parent(a), Base.deepcopy_internal(a.data, dict))

check_parent(a::OrderElem, b::OrderElem) = parent(a) == parent(b) || error("Incompatible orders")

+(a::OrderElem, b::OrderElem) = check_parent(a, b) && OrderElem(parent(a), a.data + b.data)
-(a::OrderElem, b::OrderElem) = check_parent(a, b) && OrderElem(parent(a), a.data - b.data)
-(a::OrderElem) = OrderElem(parent(a), -a.data)
Expand Down Expand Up @@ -849,8 +847,6 @@ function expressify(a::HessQRElem; context = nothing)
expressify(a.g, context = context)))
end

check_parent(a::HessQRElem, b::HessQRElem) = parent(a) == parent(b) || error("Incompatible rings")

function Hecke.integral_split(a::Generic.RationalFunctionFieldElem{QQFieldElem}, S::HessQR)
if iszero(a)
return zero(S), one(S)
Expand Down
18 changes: 4 additions & 14 deletions src/AlgAssAbsOrd/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ parent_type(::Type{AlgAssAbsOrdElem{S, T}}) where {S, T} = AlgAssAbsOrd{S, T}

Base.hash(x::AlgAssAbsOrdElem, h::UInt) = hash(elem_in_algebra(x, copy = false), h)

################################################################################
#
# Parent check
#
################################################################################

function check_parent(x::AlgAssAbsOrdElem{S, T}, y::AlgAssAbsOrdElem{S, T}) where {S, T}
return parent(x) === parent(y)
end

################################################################################
#
# Parent object overloading
Expand Down Expand Up @@ -175,12 +165,12 @@ end
###############################################################################

function *(x::T, y::T) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } }
!check_parent(x, y) && error("Wrong parents")
check_parent(x, y)
return parent(x)(elem_in_algebra(x, copy = false)*elem_in_algebra(y, copy = false))
end

function +(x::T, y::T) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } }
!check_parent(x, y) && error("Wrong parents")
check_parent(x, y)
z = parent(x)(elem_in_algebra(x, copy = false) + elem_in_algebra(y, copy = false))
if x.has_coord && y.has_coord
z.coordinates = [ x.coordinates[i] + y.coordinates[i] for i = 1:degree(parent(x)) ]
Expand All @@ -190,7 +180,7 @@ function +(x::T, y::T) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem }
end

function -(x::T, y::T) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } }
!check_parent(x, y) && error("Wrong parents")
check_parent(x, y)
z = parent(x)(elem_in_algebra(x, copy = false) - elem_in_algebra(y, copy = false))
if x.has_coord && y.has_coord
z.coordinates = [ x.coordinates[i] - y.coordinates[i] for i = 1:degree(parent(x)) ]
Expand All @@ -213,7 +203,7 @@ end

# Computes a/b if action is :right and b\a if action is :left (and if this is possible)
function divexact(a::T, b::T, action::Symbol, check::Bool = true) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } }
!check_parent(a, b) && error("Wrong parents")
check_parent(a, b)
O = parent(a)
c = divexact(elem_in_algebra(a, copy = false), elem_in_algebra(b, copy = false), action)
if check
Expand Down
10 changes: 0 additions & 10 deletions src/AlgAssRelOrd/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ Returns the order containing $x$.
"""
@inline parent(x::AlgAssRelOrdElem) = x.parent

################################################################################
#
# Parent check
#
################################################################################

function check_parent(x::AlgAssRelOrdElem{S, T, U}, y::AlgAssRelOrdElem{S, T, U}) where {S, T, U}
return parent(x) === parent(y)
end

################################################################################
#
# Parent object overloading
Expand Down
4 changes: 0 additions & 4 deletions src/FunField/DegreeLocalization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ end

parent(a::KInftyElem{T}) where T <: FieldElement = a.parent

function check_parent(a::KInftyElem{T}, b::KInftyElem{T}) where T <: FieldElement
parent(a) != parent(b) && error("Parent objects do not match")
end

function Base.hash(a::KInftyElem, h::UInt)
b = 0x32ba43ad011affd1%UInt
return xor(b, hash(data(a), h))
Expand Down
2 changes: 0 additions & 2 deletions src/FunField/HessQR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ function expressify(a::HessQRElem; context = nothing)
expressify(a.g, context = context)))
end

check_parent(a::HessQRElem, b::HessQRElem) = parent(a) == parent(b) || error("Incompatible rings")

function Hecke.integral_split(a::Generic.RationalFunctionFieldElem{QQFieldElem}, S::HessQR)
if iszero(a)
return zero(S), one(S)
Expand Down
11 changes: 0 additions & 11 deletions src/GenOrd/GenOrd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,6 @@ function AbstractAlgebra.promote_rule(::Type{GenOrdElem{S, T}}, ::Type{U}) where
return Union{}
end

################################################################################
#
# Parent check
#
################################################################################

function check_parent(a::GenOrdElem, b::GenOrdElem)
parent(a) == parent(b) || error("Incompatible orders")
return nothing
end

################################################################################
#
# Arithmetic
Expand Down
7 changes: 0 additions & 7 deletions src/LocalField/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,6 @@ function valuation(a::LocalFieldElem{S, UnramifiedLocalField}) where S <: FieldE
return v
end

function check_parent(a::LocalFieldElem{S, T}, b::LocalFieldElem{S, T}) where {S <: FieldElem, T <: LocalFieldParameter}
if parent(a) !== parent(b)
error("Wrong parents!")
end
return nothing
end

################################################################################
#
# Representation matrix
Expand Down
5 changes: 0 additions & 5 deletions src/Misc/OrdLocalization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ nf(a::OrdLocElem{T}) where {T <: AbsSimpleNumFieldElem} = nf(parent(a))

parent(a::OrdLocElem{T}) where {T <: AbsSimpleNumFieldElem} = a.parent

function check_parent(a::OrdLocElem{T}, b::OrdLocElem{T}) where {T <: AbsSimpleNumFieldElem}
parent(a) != parent(b) && error("Parent objects do not match")
end


###############################################################################
#
# Basic manipulation
Expand Down
10 changes: 0 additions & 10 deletions src/NumFieldOrd/NfOrd/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ end

(O::AbsNumFieldOrder)() = AbsNumFieldOrderElem(O)

################################################################################
#
# Parent check
#
################################################################################

function check_parent(x::AbsNumFieldOrderElem{S, T}, y::AbsNumFieldOrderElem{S, T}) where {S, T}
return parent(x) === parent(y)
end

################################################################################
#
# "Assure" functions for fields
Expand Down
13 changes: 0 additions & 13 deletions src/NumFieldOrd/NfOrd/ResidueRing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,6 @@ function lift(a::AbsSimpleNumFieldOrderQuoRingElem)
return a.elem
end

################################################################################
#
# Parent check
#
################################################################################

function check_parent(x::AbsOrdQuoRingElem, y::AbsOrdQuoRingElem)
if parent(x) !== parent(y)
error("Elements must have same parents")
end
return true
end

################################################################################
#
# Arithmetic
Expand Down
13 changes: 0 additions & 13 deletions src/NumFieldOrd/NfRelOrd/ResidueRing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,6 @@ end

Nemo.residue_ring(O::Union{RelNumFieldOrder, AlgAssRelOrd}, I::Union{RelNumFieldOrderIdeal, AlgAssRelOrdIdl}) = RelOrdQuoRing(O, I)

################################################################################
#
# Parent check
#
################################################################################

function check_parent(x::RelOrdQuoRingElem, y::RelOrdQuoRingElem)
if parent(x) !== parent(y)
error("Elements must have same parents")
end
return true
end

################################################################################
#
# Arithmetic
Expand Down
8 changes: 4 additions & 4 deletions src/NumFieldOrd/NumFieldOrdElem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ end
###############################################################################

function *(x::T, y::T) where T <: NumFieldOrderElem
@req check_parent(x, y) "Wrong parents"
check_parent(x, y)
z = parent(x)()
z.elem_in_nf = x.elem_in_nf*y.elem_in_nf
return z
end

function +(x::T, y::T) where T <: NumFieldOrderElem
@req check_parent(x, y) "Wrong parents"
check_parent(x, y)
z = parent(x)()
z.elem_in_nf = x.elem_in_nf + y.elem_in_nf
if x.has_coord && y.has_coord
Expand All @@ -107,7 +107,7 @@ function +(x::T, y::T) where T <: NumFieldOrderElem
end

function -(x::T, y::T) where T <: NumFieldOrderElem
@req check_parent(x, y) "Wrong parents"
check_parent(x, y)
z = parent(x)()
z.elem_in_nf = x.elem_in_nf - y.elem_in_nf
if x.has_coord && y.has_coord
Expand All @@ -118,7 +118,7 @@ function -(x::T, y::T) where T <: NumFieldOrderElem
end

function divexact(x::T, y::T; check::Bool = true) where T <: NumFieldOrderElem
@req check_parent(x, y) "Wrong parents"
check_parent(x, y)
a = divexact(x.elem_in_nf, y.elem_in_nf)
if check && !(in(a, parent(x)))
throw(ArgumentError("Quotient not an element of the order."))
Expand Down

0 comments on commit a12d236

Please sign in to comment.