diff --git a/src/MPoly.jl b/src/MPoly.jl index 0489a9dc6b..d9b27d88cb 100644 --- a/src/MPoly.jl +++ b/src/MPoly.jl @@ -486,31 +486,6 @@ function is_monomial(x::MPolyRingElem{T}) where T <: RingElement return length(x) == 1 && isone(first(coefficients(x))) end -@doc raw""" - is_homogeneous(x::MPolyRingElem{T}) where T <: RingElement - -Return `true` if the given polynomial is homogeneous with respect to the standard grading and `false` otherwise. -""" -function is_homogeneous(x::MPolyRingElem{T}) where {T <: RingElement} - last_deg = 0 - is_first = true - - for e in exponent_vectors(x) - d = sum(e) - if !is_first - if d != last_deg - return false - else - last_deg = d - end - else - is_first = false - last_deg = d - end - end - return true -end - ############################################################################### # # Iterators diff --git a/src/generic/MPoly.jl b/src/generic/MPoly.jl index 68d9b164a2..a765189b84 100644 --- a/src/generic/MPoly.jl +++ b/src/generic/MPoly.jl @@ -634,6 +634,31 @@ function is_gen(x::MPoly{T}) where {T <: RingElement} return is_gen(x, Val(internal_ordering(parent(x)))) end +@doc raw""" + is_homogeneous(x::MPoly{T}) where {T <: RingElement} + +Return `true` if the given polynomial is homogeneous with respect to the standard grading and `false` otherwise. +""" +function is_homogeneous(x::MPoly{T}) where {T <: RingElement} + last_deg = 0 + is_first = true + + for e in exponent_vectors(x) + d = sum(e) + if !is_first + if d != last_deg + return false + else + last_deg = d + end + else + is_first = false + last_deg = d + end + end + return true +end + @doc raw""" coeff(x::MPoly, i::Int) diff --git a/src/generic/exports.jl b/src/generic/exports.jl index 72b9009b5b..f5bf2a3193 100644 --- a/src/generic/exports.jl +++ b/src/generic/exports.jl @@ -49,6 +49,7 @@ export invmod export is_compatible export is_divisible_by export is_free +export is_homogeneous export is_power export is_rimhook export is_submodule diff --git a/src/generic/imports.jl b/src/generic/imports.jl index dd8b28b306..3e3820f85e 100644 --- a/src/generic/imports.jl +++ b/src/generic/imports.jl @@ -148,7 +148,6 @@ import ..AbstractAlgebra: is_domain_type import ..AbstractAlgebra: is_exact_type import ..AbstractAlgebra: is_finite import ..AbstractAlgebra: is_gen -import ..AbstractAlgebra: is_homogeneous import ..AbstractAlgebra: is_monomial import ..AbstractAlgebra: is_power import ..AbstractAlgebra: is_square