Skip to content

Commit

Permalink
Revert changes to is_homogeneous
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Jul 12, 2024
1 parent 9fd31a0 commit 3ab20cf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
25 changes: 0 additions & 25 deletions src/MPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions src/generic/MPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/generic/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/generic/imports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3ab20cf

Please sign in to comment.