Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more inputs for gens(::UniversalPolyRing, ...) #1809

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/AbsMSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,7 @@ when it was created.
function rand(S::MSeriesRing, term_range, v...)
rand(GLOBAL_RNG, S, term_range, v...)
end

@varnames_interface Generic.power_series_ring(R::Ring, prec::Int, s)
@varnames_interface Generic.power_series_ring(R::Ring, weights::Vector{Int}, prec::Int, s) macros=:no # use keyword `weights=...` instead
@varnames_interface Generic.power_series_ring(R::Ring, prec::Vector{Int}, s) n=:no macros=:no # `n` variant would clash with line above; macro would be the same as for `prec::Int`
2 changes: 1 addition & 1 deletion src/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const FieldElement = Union{FieldElem, Rational, AbstractFloat}
###############################################################################

include("fundamental_interface.jl")
include("misc/VarNames.jl")

################################################################################
#
Expand Down Expand Up @@ -344,7 +345,6 @@ end

include("misc/ProductIterator.jl")
include("misc/Evaluate.jl")
include("misc/VarNames.jl")

###############################################################################
#
Expand Down
2 changes: 2 additions & 0 deletions src/FreeAssociativeAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,5 @@ end
function rand(S::FreeAssociativeAlgebra, term_range, exp_bound, v...)
rand(GLOBAL_RNG, S, term_range, exp_bound, v...)
end

@varnames_interface Generic.free_associative_algebra(R::Ring, s)
2 changes: 2 additions & 0 deletions src/LaurentMPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ For information about the many ways to specify `varnames...` refer to [`polynomi
specification in [`AbstractAlgebra.@varnames_interface`](@ref).
"""
laurent_polynomial_ring(R::Ring, s::Vector{Symbol})

@varnames_interface Generic.laurent_polynomial_ring(R::Ring, s)
2 changes: 2 additions & 0 deletions src/MPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,8 @@ function polynomial_ring(R::Ring, s::Vector{Symbol}; kw...)
(S, gens(S))
end

@varnames_interface polynomial_ring(R::Ring, s)

"""
polynomial_ring(R::Ring, varnames...; cached=true, internal_ordering=:lex)
polynomial_ring(R::Ring, varnames::Tuple; cached=true, internal_ordering=:lex)
Expand Down
2 changes: 2 additions & 0 deletions src/RationalFunctionField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
function rational_function_field(k::Field, s::VarName; cached::Bool=true)
return Generic.rational_function_field(k, Symbol(s); cached=cached)
end

@varnames_interface Generic.rational_function_field(K::Field, s)
5 changes: 4 additions & 1 deletion src/generic/UnivPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ function gen(S::UniversalPolyRing{T}, s::VarName) where {T <: RingElement}
return UnivPoly{T}(gen(mpoly_ring(S), i), S)
end

gens(S::UniversalPolyRing, v::Vector{<:VarName}) = tuple([gen(S, s) for s in v]...)
# @varnames_interface expects the
gens(S::UniversalPolyRing, varnames...) = _gens(S, varnames...)[2:end]
_gens(S::UniversalPolyRing, v::Vector{Symbol}) = nothing, [gen(S, s) for s in v]
@varnames_interface _gens(S::UniversalPolyRing, s)

function gen(S::UniversalPolyRing{T}, i::Int) where {T}
@boundscheck 1 <= i <= nvars(S) || throw(ArgumentError("generator index out of range"))
Expand Down
1 change: 1 addition & 0 deletions src/generic/imports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import ..AbstractAlgebra: @attributes
import ..AbstractAlgebra: @enable_all_show_via_expressify
import ..AbstractAlgebra: @show_name
import ..AbstractAlgebra: @show_special
import ..AbstractAlgebra: @varnames_interface
import ..AbstractAlgebra: CacheDictType
import ..AbstractAlgebra: CycleDec
import ..AbstractAlgebra: Dedent
Expand Down
10 changes: 0 additions & 10 deletions src/misc/VarNames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,3 @@ macro varnames_interface(e::Expr, options::Expr...)
$(varnames_macro(d[:f], length(d[:argnames]), opts[:macros], opts[:n], opts[:range]))
end
end

@varnames_interface Generic.free_associative_algebra(R::Ring, s)
@varnames_interface Generic.laurent_polynomial_ring(R::Ring, s)
@varnames_interface Generic.rational_function_field(K::Field, s)

@varnames_interface Generic.power_series_ring(R::Ring, prec::Int, s)
@varnames_interface Generic.power_series_ring(R::Ring, weights::Vector{Int}, prec::Int, s) macros=:no # use keyword `weights=...` instead
@varnames_interface Generic.power_series_ring(R::Ring, prec::Vector{Int}, s) n=:no macros=:no # `n` variant would clash with line above; macro would be the same as for `prec::Int`

@varnames_interface polynomial_ring(R::Ring, s)
6 changes: 6 additions & 0 deletions test/generic/UnivPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ end
@test vars(2x2^2 + 3x2 + 1) == [x]

@test characteristic(S) == 0

xs, ys = gens(S, :x => (1:4), :y =>(1:2, 1:3))
@test xs isa Vector{elem_type(S)}
@test length(xs) == 4
@test ys isa Matrix{elem_type(S)}
@test size(ys) == (2, 3)
end
end
end
Expand Down
Loading