Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop redundant check_parent methods #1784

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RandomExtensions = "fb686558-2515-59ef-acaa-46db3789a887"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[compat]
AbstractAlgebra = "0.41.8"
AbstractAlgebra = "0.41.9"
FLINT_jll = "^300.100.100"
Libdl = "1.6"
LinearAlgebra = "1.6"
Expand Down
4 changes: 0 additions & 4 deletions src/antic/nf_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ the generator of the given number field.
"""
var(a::AbsSimpleNumField) = a.S

function check_parent(a::AbsSimpleNumFieldElem, b::AbsSimpleNumFieldElem)
a.parent != b.parent && error("Incompatible number field elements")
end

characteristic(::AbsSimpleNumField) = 0

defining_polynomial(K::AbsSimpleNumField) = K.pol
Expand Down
4 changes: 0 additions & 4 deletions src/arb/Complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ end

# TODO: implement hash

function check_parent(a::ComplexFieldElem, b::ComplexFieldElem)
return true
end
lgoettgens marked this conversation as resolved.
Show resolved Hide resolved

characteristic(::ComplexField) = 0

################################################################################
Expand Down
6 changes: 0 additions & 6 deletions src/arb/ComplexMat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ base_ring(a::ComplexMat) = ComplexField()

dense_matrix_type(::Type{ComplexFieldElem}) = ComplexMat

function check_parent(x::ComplexMat, y::ComplexMat, throw::Bool = true)
fl = (nrows(x) != nrows(y) || ncols(x) != ncols(y) || base_ring(x) != base_ring(y))
fl && throw && error("Incompatible matrices")
return !fl
end

function getindex!(z::ComplexFieldElem, x::ComplexMat, r::Int, c::Int)
GC.@preserve x begin
v = ccall((:acb_mat_entry_ptr, libflint), Ptr{ComplexFieldElem},
Expand Down
4 changes: 0 additions & 4 deletions src/arb/Real.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ function canonical_unit(x::RealFieldElem)
return x
end

function check_parent(a::RealFieldElem, b::RealFieldElem)
return true
end

lgoettgens marked this conversation as resolved.
Show resolved Hide resolved
characteristic(::RealField) = 0

################################################################################
Expand Down
6 changes: 0 additions & 6 deletions src/arb/RealMat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ base_ring(a::RealMat) = RealField()

dense_matrix_type(::Type{RealFieldElem}) = RealMat

function check_parent(x::RealMat, y::RealMat, throw::Bool = true)
fl = (nrows(x) != nrows(y) || ncols(x) != ncols(y) || base_ring(x) != base_ring(y))
fl && throw && error("Incompatible matrices")
return !fl
end

function getindex!(z::ArbFieldElem, x::RealMat, r::Int, c::Int)
GC.@preserve x begin
v = ccall((:arb_mat_entry_ptr, libflint), Ptr{RealFieldElem},
Expand Down
5 changes: 0 additions & 5 deletions src/arb/acb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ end

# TODO: implement hash

function check_parent(a::AcbFieldElem, b::AcbFieldElem)
parent(a) != parent(b) &&
error("Incompatible AcbFieldElem elements")
end

characteristic(::AcbField) = 0

################################################################################
Expand Down
6 changes: 0 additions & 6 deletions src/arb/acb_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ dense_matrix_type(::Type{AcbFieldElem}) = AcbMatrix

precision(x::AcbMatSpace) = precision(base_ring(x))

function check_parent(x::AcbMatrix, y::AcbMatrix, throw::Bool = true)
fl = (nrows(x) != nrows(y) || ncols(x) != ncols(y) || base_ring(x) != base_ring(y))
fl && throw && error("Incompatible matrices")
return !fl
end

function getindex!(z::AcbFieldElem, x::AcbMatrix, r::Int, c::Int)
GC.@preserve x begin
v = ccall((:acb_mat_entry_ptr, libflint), Ptr{AcbFieldElem},
Expand Down
5 changes: 0 additions & 5 deletions src/arb/arb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ function canonical_unit(x::ArbFieldElem)
return x
end

function check_parent(a::ArbFieldElem, b::ArbFieldElem)
parent(a) != parent(b) &&
error("Incompatible ArbFieldElem elements")
end

characteristic(::ArbField) = 0

################################################################################
Expand Down
6 changes: 0 additions & 6 deletions src/arb/arb_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ dense_matrix_type(::Type{ArbFieldElem}) = ArbMatrix

precision(x::ArbMatSpace) = precision(x.base_ring)

function check_parent(x::ArbMatrix, y::ArbMatrix, throw::Bool = true)
fl = (nrows(x) != nrows(y) || ncols(x) != ncols(y) || base_ring(x) != base_ring(y))
fl && throw && error("Incompatible matrices")
return !fl
end

function getindex!(z::ArbFieldElem, x::ArbMatrix, r::Int, c::Int)
GC.@preserve x begin
v = ccall((:arb_mat_entry_ptr, libflint), Ptr{ArbFieldElem},
Expand Down
6 changes: 0 additions & 6 deletions src/calcium/ca.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ function deepcopy_internal(a::CalciumFieldElem, dict::IdDict)
return r
end

function check_parent(a::CalciumFieldElem, b::CalciumFieldElem, throw::Bool = true)
b = (parent(a) != parent(b))
b && throw && error("Different parents")
return !b
end

function _isspecial(a::CalciumFieldElem)
return (a.field & 3) != 0
end
Expand Down
2 changes: 0 additions & 2 deletions src/calcium/qqbar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ base_ring(::QQBarField) = Union{}

is_domain_type(::Type{QQBarFieldElem}) = true

check_parent(a::QQBarFieldElem, b::QQBarFieldElem, throw::Bool = true) = true
lgoettgens marked this conversation as resolved.
Show resolved Hide resolved

characteristic(::QQBarField) = 0

###############################################################################
Expand Down
5 changes: 0 additions & 5 deletions src/flint/flint_puiseux_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ end

is_exact_type(a::Type{T}) where T <: FlintPuiseuxSeriesElem = false

function check_parent(a::FlintPuiseuxSeriesElem, b::FlintPuiseuxSeriesElem)
parent(a) != parent(b) &&
error("Incompatible Puiseux series rings in Puiseux series operation")
end

function characteristic(R::FlintPuiseuxSeriesRing{T}) where T <: RingElem
return characteristic(base_ring(R))
end
Expand Down
6 changes: 0 additions & 6 deletions src/flint/fmpq_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ base_ring(a::QQMatrix) = QQ

dense_matrix_type(::Type{QQFieldElem}) = QQMatrix

function check_parent(a::QQMatrix, b::QQMatrix, throw::Bool = true)
fl = (nrows(a) != nrows(b) || ncols(a) != ncols(b) || base_ring(a) != base_ring(b))
fl && throw && error("Incompatible matrices")
return !fl
end

###############################################################################
#
# Similar & zero
Expand Down
4 changes: 0 additions & 4 deletions src/flint/fmpq_mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ symbols(a::QQMPolyRing) = a.S

parent(a::QQMPolyRingElem) = a.parent

function check_parent(a::QQMPolyRingElem, b::QQMPolyRingElem)
parent(a) != parent(b) &&
error("Incompatible polynomial rings in polynomial operation")
end

number_of_variables(a::QQMPolyRing) = ccall((:fmpq_mpoly_ctx_nvars, libflint), Int,
(Ref{QQMPolyRing}, ), a)
Expand Down
5 changes: 0 additions & 5 deletions src/flint/fmpz_laurent_series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ is_exact_type(a::Type{ZZLaurentSeriesRingElem}) = false

var(a::ZZLaurentSeriesRing) = a.S

function check_parent(a::ZZLaurentSeriesRingElem, b::ZZLaurentSeriesRingElem)
parent(a) != parent(b) &&
error("Incompatible power series rings in Laurent series operation")
end

###############################################################################
#
# Basic manipulation
Expand Down
6 changes: 0 additions & 6 deletions src/flint/fmpz_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ base_ring(a::ZZMatrix) = ZZ

dense_matrix_type(::Type{ZZRingElem}) = ZZMatrix

function check_parent(a::ZZMatrix, b::ZZMatrix, throw::Bool = true)
b = (nrows(a) != nrows(b) || ncols(a) != ncols(b))
b && throw && error("Incompatible matrices")
return !b
end

###############################################################################
#
# similar & zero
Expand Down
4 changes: 0 additions & 4 deletions src/flint/fmpz_mod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ base_ring(a::ZZModRing) = ZZ

parent(a::ZZModRingElem) = a.parent

function check_parent(a::ZZModRingElem, b::ZZModRingElem)
a.parent != b.parent && error("Operations on distinct residue rings not supported")
end

###############################################################################
#
# Basic manipulation
Expand Down
9 changes: 0 additions & 9 deletions src/flint/fmpz_mod_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@

dense_matrix_type(::Type{ZZModRingElem}) = ZZModMatrix

function check_parent(x::T, y::T, throw::Bool = true) where T <: Zmod_fmpz_mat
fl = base_ring(x) != base_ring(y)
fl && throw && error("Residue rings must be equal")
fl && return false
fl = (ncols(x) != ncols(y)) && (nrows(x) != nrows(y))
fl && throw && error("Matrices have wrong dimensions")
return !fl
end

###############################################################################
#
# Similar
Expand Down
5 changes: 0 additions & 5 deletions src/flint/fmpz_mod_mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ for (etype, rtype, ftype, ctype) in (

parent(a::($etype)) = a.parent

function check_parent(a::($etype), b::($etype))
parent(a) != parent(b) &&
error("Incompatible polynomial rings in polynomial operation")
end

number_of_variables(a::($rtype)) = a.nvars

base_ring(a::($rtype)) = a.base_ring
Expand Down
5 changes: 0 additions & 5 deletions src/flint/fmpz_mod_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ parent_type(::Type{ZZModPolyRingElem}) = ZZModPolyRing

dense_poly_type(::Type{ZZModRingElem}) = ZZModPolyRingElem

function check_parent(x::T, y::T) where {T <: Zmodn_fmpz_poly}
parent(x) != parent(y) && error("Parents must coincide")
nothing
end

function _is_one_or_throw(f, y)
R = base_ring(y)
if !isone(f)
Expand Down
5 changes: 0 additions & 5 deletions src/flint/fmpz_mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ symbols(a::ZZMPolyRing) = a.S

parent(a::ZZMPolyRingElem) = a.parent

function check_parent(a::ZZMPolyRingElem, b::ZZMPolyRingElem)
parent(a) != parent(b) &&
error("Incompatible polynomial rings in polynomial operation")
end

number_of_variables(a::ZZMPolyRing) = ccall((:fmpz_mpoly_ctx_nvars, libflint), Int,
(Ref{ZZMPolyRing}, ), a)

Expand Down
4 changes: 0 additions & 4 deletions src/flint/fq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ parent(a::FqPolyRepFieldElem) = a.parent

is_domain_type(::Type{FqPolyRepFieldElem}) = true

function check_parent(a::FqPolyRepFieldElem, b::FqPolyRepFieldElem)
a.parent != b.parent && error("Operations on distinct finite fields not supported")
end

###############################################################################
#
# Basic manipulation
Expand Down
4 changes: 0 additions & 4 deletions src/flint/fq_default.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ parent(a::FqFieldElem) = a.parent

is_domain_type(::Type{FqFieldElem}) = true

function check_parent(a::FqFieldElem, b::FqFieldElem)
a.parent != b.parent && error("Operations on distinct finite fields not supported")
end

###############################################################################
#
# Basic manipulation
Expand Down
9 changes: 0 additions & 9 deletions src/flint/fq_default_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@

dense_matrix_type(::Type{FqFieldElem}) = FqMatrix

function check_parent(x::FqMatrix, y::FqMatrix, throw::Bool = true)
fl = base_ring(x) != base_ring(y)
fl && throw && error("Residue rings must be equal")
fl && return false
fl = (ncols(x) != ncols(y)) && (nrows(x) != nrows(y))
fl && throw && error("Matrices have wrong dimensions")
return !fl
end

###############################################################################
#
# Similar & zero
Expand Down
5 changes: 0 additions & 5 deletions src/flint/fq_default_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ parent(a::FqPolyRingElem) = a.parent

var(a::FqPolyRing) = a.S

function check_parent(a::FqPolyRingElem, b::FqPolyRingElem)
a.parent != b.parent &&
error("Operations on distinct polynomial rings not supported")
end

################################################################################
#
# Basic manipulation
Expand Down
9 changes: 0 additions & 9 deletions src/flint/fq_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@

dense_matrix_type(::Type{FqPolyRepFieldElem}) = FqPolyRepMatrix

function check_parent(x::FqPolyRepMatrix, y::FqPolyRepMatrix, throw::Bool = true)
fl = base_ring(x) != base_ring(y)
fl && throw && error("Residue rings must be equal")
fl && return false
fl = (ncols(x) != ncols(y)) && (nrows(x) != nrows(y))
fl && throw && error("Matrices have wrong dimensions")
return !fl
end

###############################################################################
#
# Similar & zero
Expand Down
4 changes: 0 additions & 4 deletions src/flint/fq_nmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ parent(a::fqPolyRepFieldElem) = a.parent

is_domain_type(::Type{fqPolyRepFieldElem}) = true

function check_parent(a::fqPolyRepFieldElem, b::fqPolyRepFieldElem)
a.parent != b.parent && error("Operations on distinct finite fields not supported")
end

###############################################################################
#
# Basic manipulation
Expand Down
9 changes: 0 additions & 9 deletions src/flint/fq_nmod_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@

dense_matrix_type(::Type{fqPolyRepFieldElem}) = fqPolyRepMatrix

function check_parent(x::fqPolyRepMatrix, y::fqPolyRepMatrix, throw::Bool = true)
fl = base_ring(x) != base_ring(y)
fl && throw && error("Residue rings must be equal")
fl && return false
fl = (ncols(x) != ncols(y)) && (nrows(x) != nrows(y))
fl && throw && error("Matrices have wrong dimensions")
return !fl
end

###############################################################################
#
# Similar & zero
Expand Down
5 changes: 0 additions & 5 deletions src/flint/fq_nmod_mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ symbols(a::fqPolyRepMPolyRing) = a.S

parent(a::fqPolyRepMPolyRingElem) = a.parent

function check_parent(a::fqPolyRepMPolyRingElem, b::fqPolyRepMPolyRingElem)
parent(a) != parent(b) &&
error("Incompatible polynomial rings in polynomial operation")
end

number_of_variables(a::fqPolyRepMPolyRing) = a.nvars

base_ring(a::fqPolyRepMPolyRing) = a.base_ring
Expand Down
5 changes: 0 additions & 5 deletions src/flint/fq_nmod_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ parent(a::fqPolyRepPolyRingElem) = a.parent

var(a::fqPolyRepPolyRing) = a.S

function check_parent(a::fqPolyRepPolyRingElem, b::fqPolyRepPolyRingElem)
a.parent != b.parent &&
error("Operations on distinct polynomial rings not supported")
end

################################################################################
#
# Basic manipulation
Expand Down
5 changes: 0 additions & 5 deletions src/flint/fq_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ parent(a::FqPolyRepPolyRingElem) = a.parent

var(a::FqPolyRepPolyRing) = a.S

function check_parent(a::FqPolyRepPolyRingElem, b::FqPolyRepPolyRingElem)
a.parent != b.parent &&
error("Operations on distinct polynomial rings not supported")
end

################################################################################
#
# Basic manipulation
Expand Down
Loading
Loading