Skip to content

is_gen is not supported for various polynomial rings #2063

@HechtiDerLachs

Description

@HechtiDerLachs
julia> using Oscar

julia> S, (x, y, z) = graded_polynomial_ring(QQ, ["x", "y", "z"]; weights=[[0, 1], [1, 1], [2, 1]])
(Graded multivariate polynomial ring in 3 variables over QQ, MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}[x, y, z])

julia> is_gen(S[1])
ERROR: MethodError: no method matching is_gen(::MPolyDecRingElem{QQFieldElem, QQMPolyRingElem})
The function `is_gen` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  is_gen(::MPolyRingElem, ::Int64)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EAjNg/src/MPoly.jl:132
  is_gen(::QQPolyRingElem)
   @ Nemo ~/.julia/packages/Nemo/Dukvj/src/flint/fmpq_poly.jl:63
  is_gen(::zzModMPolyRingElem, ::Int64)
   @ Nemo ~/.julia/packages/Nemo/Dukvj/src/flint/nmod_mpoly.jl:63
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[24]:1

Suggestion for a catchall implementation:

 function is_gen(a::MPolyRingElem)
   is_zero(a) && return false
   !is_one(length(a)) && return false
   e = only(AbstractAlgebra.exponent_vectors(a))
   is_one(only(AbstractAlgebra.coefficients(a))) || return false
   i = findfirst(is_one, e)
   isnothing(i) && return false
   return all(k == i || is_zero(n) for (k, n) in enumerate(e))
 end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions