diff --git a/docs/src/ring_interface.md b/docs/src/ring_interface.md index da5bdd32c4..ec5cd45391 100644 --- a/docs/src/ring_interface.md +++ b/docs/src/ring_interface.md @@ -900,7 +900,7 @@ function ==(f::ConstPoly{T}, g::ConstPoly{T}) where T <: RingElement end function isequal(f::ConstPoly{T}, g::ConstPoly{T}) where T <: RingElement - check_parent(f, g) + parent(f) == parent(g) || return false return isequal(f.c, g.c) end diff --git a/src/AbsSeries.jl b/src/AbsSeries.jl index cfd27ec9d0..719bb1867f 100644 --- a/src/AbsSeries.jl +++ b/src/AbsSeries.jl @@ -522,9 +522,8 @@ power series are precisely the same, to the same precision, are they declared equal by this function. """ function isequal(x::AbsPowerSeriesRingElem{T}, y::AbsPowerSeriesRingElem{T}) where T <: RingElement - if parent(x) != parent(y) - return false - end + parent(x) == parent(y) || return false + if precision(x) != precision(y) || length(x) != length(y) return false end diff --git a/src/Fraction.jl b/src/Fraction.jl index 8fe08fbc65..a8abbe22e5 100644 --- a/src/Fraction.jl +++ b/src/Fraction.jl @@ -436,9 +436,7 @@ inexact, e.g. power series. Only if the power series are precisely the same, to the same precision, are they declared equal by this function. """ function isequal(x::FracElem{T}, y::FracElem{T}) where {T <: RingElem} - if parent(x) != parent(y) - return false - end + parent(x) == parent(y) || return false return isequal(numerator(x, false)*denominator(y, false), denominator(x, false)*numerator(y, false)) end diff --git a/src/Matrix.jl b/src/Matrix.jl index 2565f82b8a..c3d33cbd32 100644 --- a/src/Matrix.jl +++ b/src/Matrix.jl @@ -1323,8 +1323,7 @@ series. Only if the power series are precisely the same, to the same precision, are they declared equal by this function. """ function isequal(x::MatrixElem{T}, y::MatrixElem{T}) where {T <: NCRingElement} - b = check_parent(x, y, false) - !b && return false + parent(x) == parent(y) || return false for i = 1:nrows(x) for j = 1:ncols(x) if !isequal(x[i, j], y[i, j]) diff --git a/src/NCPoly.jl b/src/NCPoly.jl index 91ca1eb074..87383213ce 100644 --- a/src/NCPoly.jl +++ b/src/NCPoly.jl @@ -363,9 +363,7 @@ power series. Only if the power series are precisely the same, to the same precision, are they declared equal by this function. """ function isequal(x::NCPolyRingElem{T}, y::NCPolyRingElem{T}) where T <: NCRingElem - if parent(x) != parent(y) - return false - end + parent(x) == parent(y) || return false if length(x) != length(y) return false end diff --git a/src/Poly.jl b/src/Poly.jl index e8925a322b..d25095d1df 100644 --- a/src/Poly.jl +++ b/src/Poly.jl @@ -861,9 +861,8 @@ power series. Only if the power series are precisely the same, to the same precision, are they declared equal by this function. """ function isequal(x::PolyRingElem{T}, y::PolyRingElem{T}) where T <: RingElement - if parent(x) != parent(y) - return false - end + parent(x) == parent(y) || return false + if length(x) != length(y) return false end diff --git a/src/RelSeries.jl b/src/RelSeries.jl index dfc3eb8a76..a0f5899b36 100644 --- a/src/RelSeries.jl +++ b/src/RelSeries.jl @@ -761,9 +761,8 @@ power series are precisely the same, to the same precision, are they declared equal by this function. """ function isequal(x::RelPowerSeriesRingElem{T}, y::RelPowerSeriesRingElem{T}) where T <: RingElement - if parent(x) != parent(y) - return false - end + parent(x) == parent(y) || return false + if precision(x) != precision(y) || pol_length(x) != pol_length(y) || valuation(x) != valuation(y) return false diff --git a/src/Residue.jl b/src/Residue.jl index 0fa8b3dbe8..b506d34408 100644 --- a/src/Residue.jl +++ b/src/Residue.jl @@ -256,8 +256,7 @@ Only if the power series are precisely the same, to the same precision, are they declared equal by this function. """ function isequal(a::ResElem{T}, b::ResElem{T}) where {T <: RingElement} - fl = check_parent(a, b, false) - !fl && return false + parent(a) == parent(b) || return false return isequal(data(a), data(b)) end diff --git a/src/generic/LaurentSeries.jl b/src/generic/LaurentSeries.jl index d0d1c29394..b0e3ac4230 100644 --- a/src/generic/LaurentSeries.jl +++ b/src/generic/LaurentSeries.jl @@ -1093,9 +1093,7 @@ power series are precisely the same, to the same precision, are they declared equal by this function. """ function isequal(x::LaurentSeriesElem{T}, y::LaurentSeriesElem{T}) where {T <: RingElement} - if parent(x) != parent(y) - return false - end + parent(x) == parent(y) || return false if precision(x) != precision(y) || pol_length(x) != pol_length(y) || valuation(x) != valuation(y) || scale(x) != scale(y) return false diff --git a/src/generic/PuiseuxSeries.jl b/src/generic/PuiseuxSeries.jl index 46ac6cf4b1..2ad0ca50a9 100644 --- a/src/generic/PuiseuxSeries.jl +++ b/src/generic/PuiseuxSeries.jl @@ -564,6 +564,7 @@ function ==(a::PuiseuxSeriesElem{T}, b::PuiseuxSeriesElem{T}) where T <: RingEle end function isequal(a::PuiseuxSeriesElem{T}, b::PuiseuxSeriesElem{T}) where T <: RingElement + parent(a) == parent(b) || return false return a.scale == b.scale && isequal(a.data, b.data) end diff --git a/test/algorithms/GenericFunctions-test.jl b/test/algorithms/GenericFunctions-test.jl index 6b4db98da4..0166dc386e 100644 --- a/test/algorithms/GenericFunctions-test.jl +++ b/test/algorithms/GenericFunctions-test.jl @@ -170,7 +170,7 @@ function ==(f::ConstPoly{T}, g::ConstPoly{T}) where T <: RingElement end function isequal(f::ConstPoly{T}, g::ConstPoly{T}) where T <: RingElement - check_parent(f, g) + parent(f) == parent(g) || return false return isequal(f.c, g.c) end