Merge `monomials_of_degree` and `monomial_basis` ?
topic: commutative algebra
These two functions do very similar things and probably should be merged (with one left as a synonym for the other perhaps?) But note that they currently support different inputs (with some overlap)
The function `monomials_of_degree` is from the invariant theory code and works for plain polynomial rings as well as graded rings. Its second argument is always an integer (though it has an optional third argument that can be used to select a subset of variables), and it returns an iterator:
```julia-repl
julia> R, = polynomial_ring(QQ,:x=>1:3)
(Multivariate polynomial ring in 3 variables over QQ, QQMPolyRingElem[x[1], x[2], x[3]])
julia> S, = grade(R)
(Graded multivariate polynomial ring in 3 variables over QQ, MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}[x[1], x[2], x[3]])
julia> monomials_of_degree(R,2)
Iterator over the monomials of degree 2
of multivariate polynomial ring in 3 variables over QQ
julia> collect(ans)
6-element Vector{QQMPolyRingElem}:
x[1]^2
x[1]*x[2]
x[1]*x[3]
x[2]^2
x[2]*x[3]
x[3]^2
```
The function `monomial_basis` has methods for `MPolyDecRing`, `MPolyQuoRing`, `MonoidAlgebra` but *not* for `MPolyRing`. It can take an integer as second argument but also a `FinGenAbGroupElem`, and there is even a unary version (for finite dimensional inputs). It returns a `Vector`:
```julia-repl
julia> monomial_basis(S,2)
6-element Vector{MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}}:
x[3]^2
x[2]*x[3]
x[2]^2
x[1]*x[3]
x[1]*x[2]
x[1]^2
```
(Note that there is also `vector_space_basis`, but that's only for `SubquoModule` -- see issue #2719)
0 条评论