diff --git a/docs/src/ideal.md b/docs/src/ideal.md index 599404be3d..96294e4de5 100644 --- a/docs/src/ideal.md +++ b/docs/src/ideal.md @@ -60,7 +60,7 @@ contain duplicates, zero entries or be empty. **Examples** ```jldoctest -julia> R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:degrevlex) +julia> R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:degrevlex) (Multivariate polynomial ring in 2 variables over integers, AbstractAlgebra.Generic.MPoly{BigInt}[x, y]) julia> V = [3*x^2*y - 3*y^2, 9*x^2*y + 7*x*y] @@ -170,7 +170,7 @@ normal_form(::U, ::Generic.Ideal{U}) where {T <: RingElement, U <: Union{PolyRin **Examples** ```jldoctest -julia> R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:degrevlex) +julia> R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:degrevlex) (Multivariate polynomial ring in 2 variables over integers, AbstractAlgebra.Generic.MPoly{BigInt}[x, y]) julia> V = [3*x^2*y - 3*y^2, 9*x^2*y + 7*x*y] diff --git a/docs/src/mpoly_interface.md b/docs/src/mpoly_interface.md index 3402ed115e..161a46f1dd 100644 --- a/docs/src/mpoly_interface.md +++ b/docs/src/mpoly_interface.md @@ -143,7 +143,7 @@ Return the $i$-th generator (variable) of the given polynomial ring (as a polynomial). ```julia -ordering(S::MyMPolyRing{T}) +internal_ordering(S::MyMPolyRing{T}) ``` Return the ordering of the given polynomial ring as a symbol. Supported values currently diff --git a/docs/src/mpolynomial.md b/docs/src/mpolynomial.md index 543243241e..cf6998a48d 100644 --- a/docs/src/mpolynomial.md +++ b/docs/src/mpolynomial.md @@ -71,7 +71,7 @@ ring. **Examples** ```jldoctest -julia> R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:deglex) +julia> R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:deglex) (Multivariate polynomial ring in 2 variables over integers, AbstractAlgebra.Generic.MPoly{BigInt}[x, y]) julia> T, (z, t) = QQ["z", "t"] @@ -231,7 +231,7 @@ gen(S::MPolyRing, i::Int) ``` ```julia -ordering(S::MPolyRing{T}) +internal_ordering(S::MPolyRing{T}) ``` Note that the currently supported orderings are `:lex`, `:deglex` and @@ -430,7 +430,7 @@ x^3*y julia> setcoeff!(f, [3, 1], 12) 12*x^3*y + 3*x*y^2 + 1 -julia> S, (x, y) = polynomial_ring(QQ, ["x", "y"]; ordering=:deglex) +julia> S, (x, y) = polynomial_ring(QQ, ["x", "y"]; internal_ordering=:deglex) (Multivariate polynomial ring in 2 variables over rationals, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}[x, y]) julia> V = symbols(S) @@ -443,7 +443,7 @@ julia> X = gens(S) x y -julia> ord = ordering(S) +julia> ord = internal_ordering(S) :deglex julia> S, (x, y) = polynomial_ring(ZZ, ["x", "y"]) @@ -836,7 +836,7 @@ tail(::MPolyRingElem{T}) where T <: RingElement ```julia using AbstractAlgebra -R,(x,y) = polynomial_ring(ZZ, ["x", "y"], ordering=:deglex) +R,(x,y) = polynomial_ring(ZZ, ["x", "y"], internal_ordering=:deglex) p = 2*x*y + 3*y^3 + 1 leading_term(p) leading_monomial(p) diff --git a/docs/src/univpolynomial.md b/docs/src/univpolynomial.md index 079fe171b3..518f271cd8 100644 --- a/docs/src/univpolynomial.md +++ b/docs/src/univpolynomial.md @@ -42,7 +42,7 @@ The universal polynomial ring over a given base ring `R` is constructed with one of the following constructor functions. ```julia -UniversalPolynomialRing(R::Ring; cached::Bool = true, ordering::Symbol=:lex) +UniversalPolynomialRing(R::Ring; cached::Bool = true, internal_ordering::Symbol=:lex) ``` Given a base ring `R` and an array `S` of strings, return an object representing diff --git a/src/AbstractAlgebra.jl b/src/AbstractAlgebra.jl index 7c81740f7e..932c8692b6 100644 --- a/src/AbstractAlgebra.jl +++ b/src/AbstractAlgebra.jl @@ -592,6 +592,7 @@ import .Generic: hash import .Generic: hooklength import .Generic: image_fn import .Generic: image_map +import .Generic: internal_ordering import .Generic: interreduce! import .Generic: inv! import .Generic: inverse_fn @@ -637,7 +638,6 @@ import .Generic: normalise import .Generic: num_coeff import .Generic: one import .Generic: order -import .Generic: ordering import .Generic: parity import .Generic: partitionseq import .Generic: perm @@ -858,6 +858,7 @@ export image_fn export image_map export inflate export integral +export internal_ordering export interpolate export inv! export invariant_factors @@ -988,7 +989,6 @@ export O export one export one! export order -export ordering export parent_type export parity export Partition diff --git a/src/MPoly.jl b/src/MPoly.jl index 6349b8622a..c5f79d9c1c 100644 --- a/src/MPoly.jl +++ b/src/MPoly.jl @@ -373,7 +373,7 @@ function degree(f::MPolyRingElem{T}, i::Int) where T <: RingElement biggest = -1 if length(f) != 0 R = parent(f) - if ordering(R) == :lex && i == 1 + if internal_ordering(R) == :lex && i == 1 biggest = first(exponent_vectors(f))[1] else for v in exponent_vectors(f) @@ -402,7 +402,7 @@ Return an array of the degrees of the polynomial $f$ in terms of each variable. """ function degrees(f::MPolyRingElem{T}) where T <: RingElement R = parent(f) - if nvars(R) == 1 && ordering(R) == :lex && length(f) > 0 + if nvars(R) == 1 && internal_ordering(R) == :lex && length(f) > 0 return first(exponent_vectors(f)) else biggest = [-1 for i = 1:nvars(R)] @@ -1211,7 +1211,7 @@ end ################################################################################ function _change_mpoly_ring(R, Rx, cached) - P, _ = polynomial_ring(R, map(string, symbols(Rx)), ordering = ordering(Rx), cached = cached) + P, _ = polynomial_ring(R, map(string, symbols(Rx)); internal_ordering = internal_ordering(Rx), cached = cached) return P end @@ -1346,7 +1346,7 @@ end ############################################################################### @doc raw""" - polynomial_ring(R::Ring, varnames::Vector{Symbol}; cached=true, ordering=:lex) + polynomial_ring(R::Ring, varnames::Vector{Symbol}; cached=true, internal_ordering=:lex) Given a coefficient ring `R` and variable names, say `varnames = [:x1, :x2, ...]`, return a tuple `S, [x1, x2, ...]` of the polynomial ring $S = R[x1, x2, \dots]$ @@ -1357,7 +1357,8 @@ By default (`cached=true`), the output `S` will be cached, i.e. if (*identical*) ring is returned. Setting `cached` to `false` ensures a distinct new ring is returned, and will also prevent it from being cached. -The `ordering` of the polynomial ring can be one of `:lex`, `:deglex` or `:degrevlex`. +The monomial ordering used for the internal storage of polynomials in `S` can be +set with `internal_ordering` and must be one of `:lex`, `:deglex` or `:degrevlex`. See also: [`polynomial_ring(::Ring, ::Vararg)`](@ref), [`@polynomial_ring`](@ref). @@ -1374,8 +1375,8 @@ function polynomial_ring(R::Ring, s::Vector{Symbol}; kw...) end """ - polynomial_ring(R::Ring, varnames...; cached=true, ordering=:lex) - polynomial_ring(R::Ring, varnames::Tuple; cached=true, ordering=:lex) + polynomial_ring(R::Ring, varnames...; cached=true, internal_ordering=:lex) + polynomial_ring(R::Ring, varnames::Tuple; cached=true, internal_ordering=:lex) Like [`polynomial_ring(::Ring, ::Vector{Symbol})`](@ref) with more ways to give `varnames` as specified in [`variable_names`](@ref). @@ -1414,7 +1415,7 @@ julia> y polynomial_ring(R::Ring, varnames...) @doc raw""" - polynomial_ring(R::Ring, n::Int, s::Symbol=:x; cached=true, ordering=:lex) + polynomial_ring(R::Ring, n::Int, s::Symbol=:x; cached=true, internal_ordering=:lex) Same as [`polynomial_ring(::Ring, ["s$i" for i in 1:n])`](@ref polynomial_ring(::Ring, ::Vector{Symbol})). @@ -1428,7 +1429,7 @@ julia> S, x = polynomial_ring(ZZ, 3) polynomial_ring(R::Ring, n::Int, s::Symbol=:x) """ - @polynomial_ring(R::Ring, varnames...; cached=true, ordering=:lex) + @polynomial_ring(R::Ring, varnames...; cached=true, internal_ordering=:lex) Return polynomial ring from [`polynomial_ring(::Ring, ::Vararg)`](@ref) and introduce the generators into the current scope. @@ -1453,13 +1454,13 @@ true :(@polynomial_ring) """ - polynomial_ring_only(R::Ring, s::Vector{Symbol}; ordering::Symbol=:lex, cached::Bool=true) + polynomial_ring_only(R::Ring, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=true) Like [`polynomial_ring(R::Ring, s::Vector{Symbol})`](@ref) but return only the multivariate polynomial ring. """ -polynomial_ring_only(R::T, s::Vector{Symbol}; ordering::Symbol=:lex, cached::Bool=true) where T<:Ring = - mpoly_ring_type(T)(R, s, ordering, cached) +polynomial_ring_only(R::T, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=true) where T<:Ring = + mpoly_ring_type(T)(R, s, internal_ordering, cached) # Alternative constructors diff --git a/src/UnivPoly.jl b/src/UnivPoly.jl index 0bab23e7fe..a9dbdc3042 100644 --- a/src/UnivPoly.jl +++ b/src/UnivPoly.jl @@ -32,6 +32,6 @@ end # ############################################################################### -function UniversalPolynomialRing(R::Ring; ordering=:lex, cached::Bool=true) - return Generic.UniversalPolynomialRing(R; ordering=ordering, cached=cached) +function UniversalPolynomialRing(R::Ring; internal_ordering=:lex, cached::Bool=true) + return Generic.UniversalPolynomialRing(R; internal_ordering=internal_ordering, cached=cached) end diff --git a/src/generic/GenericTypes.jl b/src/generic/GenericTypes.jl index 88f31a166b..bb0903964d 100644 --- a/src/generic/GenericTypes.jl +++ b/src/generic/GenericTypes.jl @@ -351,11 +351,11 @@ end end end -function MPolyRing{T}(R::Ring, s::Vector{Symbol}, ordering::Symbol=:lex, cached::Bool=true) where T <: RingElement +function MPolyRing{T}(R::Ring, s::Vector{Symbol}, internal_ordering::Symbol=:lex, cached::Bool=true) where T <: RingElement @assert T == elem_type(R) N = length(s) - ordering in (:deglex, :degrevlex) && (N+=1) - return MPolyRing{T}(R, s, ordering, N, cached) + internal_ordering in (:deglex, :degrevlex) && (N+=1) + return MPolyRing{T}(R, s, internal_ordering, N, cached) end const MPolyID = CacheDictType{Tuple{Ring, Vector{Symbol}, Symbol, Int}, Ring}() diff --git a/src/generic/Ideal.jl b/src/generic/Ideal.jl index e10c4a5c9f..f86a617ad1 100644 --- a/src/generic/Ideal.jl +++ b/src/generic/Ideal.jl @@ -1320,7 +1320,7 @@ function reduce_gens(I::Ideal{U}; complete_reduction::Bool=true) where {T <: Rin # nothing to be done if only one poly if length(B) > 1 # make heap - V = ordering(parent(B[1])) + V = internal_ordering(parent(B[1])) N = nvars(base_ring(I)) heap = Vector{lmnode{U, V, N}}() for v in B @@ -2169,7 +2169,7 @@ function intersect(I::Ideal{T}, J::Ideal{T}) where {U <: RingElement, T <: Abstr R = base_ring(S) # coefficient ring # create ring with additional variable "t" with higher precedence tsym = gensym() - Sup, Supv = AbstractAlgebra.polynomial_ring(R, vcat(tsym, symbols(S)); cached=false, ordering=:degrevlex) + Sup, Supv = AbstractAlgebra.polynomial_ring(R, vcat(tsym, symbols(S)); cached=false, internal_ordering=:degrevlex) G1 = gens(I) G2 = gens(J) ISup = Ideal(Sup, elem_type(Sup)[f(Supv[2:end]...) for f in G1]) @@ -2192,7 +2192,7 @@ function intersect(I::Ideal{T}, J::Ideal{T}) where {U <: RingElement, T <: Abstr R = base_ring(S) # coefficient ring # create ring with additional variable "t" with higher precedence tsym = gensym() - Sup, Supv = AbstractAlgebra.polynomial_ring(R, vcat(tsym, symbols(S)); cached=false, ordering=ordering(S)) + Sup, Supv = AbstractAlgebra.polynomial_ring(R, vcat(tsym, symbols(S)); cached=false, internal_ordering=internal_ordering(S)) G1 = gens(I) G2 = gens(J) ISup = Ideal(Sup, elem_type(Sup)[f(Supv[2:end]...) for f in G1]) diff --git a/src/generic/MPoly.jl b/src/generic/MPoly.jl index c4d52a0f09..ef798643fd 100644 --- a/src/generic/MPoly.jl +++ b/src/generic/MPoly.jl @@ -104,12 +104,12 @@ function vars(p::MPoly{T}) where {T <: RingElement} end @doc raw""" - ordering(a::MPolyRing{T}) where {T <: RingElement} + internal_ordering(a::MPolyRing{T}) where {T <: RingElement} Return the ordering of the given polynomial ring as a symbol. The options are `:lex`, `:deglex` and `:degrevlex`. """ -function ordering(a::MPolyRing{T}) where {T <: RingElement} +function internal_ordering(a::MPolyRing{T}) where {T <: RingElement} return a.ord end @@ -815,7 +815,7 @@ Return the total degree of `f`. function total_degree(f::MPoly{T}) where {T <: RingElement} A = f.exps N = size(A, 1) - ord = ordering(parent(f)) + ord = internal_ordering(parent(f)) if ord == :lex if N == 1 return length(f) == 0 ? -1 : Int(A[1, N]) @@ -4102,7 +4102,7 @@ function (a::MPolyRing{T})(b::Vector{T}, m::Vector{Vector{Int}}) where {T <: Rin end N = a.N - ord = ordering(a) + ord = internal_ordering(a) Pe = Matrix{UInt}(undef, N, length(m)) if ord == :lex diff --git a/src/generic/UnivPoly.jl b/src/generic/UnivPoly.jl index d18b6da05b..927a279723 100644 --- a/src/generic/UnivPoly.jl +++ b/src/generic/UnivPoly.jl @@ -44,7 +44,7 @@ function vars(p::UnivPoly{T, U}) where {T, U} return [UnivPoly{T, U}(v, S) for v in V] end -ordering(p::UniversalPolyRing) = ordering(mpoly_ring(p)) +internal_ordering(p::UniversalPolyRing) = internal_ordering(mpoly_ring(p)) function check_parent(a::UnivPoly{T, U}, b::UnivPoly{T, U}, throw::Bool = true) where {T <: RingElement, U <: AbstractAlgebra.MPolyRingElem{T}} flag = parent(a) != parent(b) @@ -904,8 +904,8 @@ end ################################################################################ function _change_univ_poly_ring(R, Rx, cached::Bool) - P, _ = AbstractAlgebra.polynomial_ring(R, map(string, symbols(Rx)), ordering = ordering(Rx), cached = cached) - S = AbstractAlgebra.UniversalPolynomialRing(R; ordering=ordering(Rx), cached=cached) + P, _ = AbstractAlgebra.polynomial_ring(R, map(string, symbols(Rx)), internal_ordering = internal_ordering(Rx), cached = cached) + S = AbstractAlgebra.UniversalPolynomialRing(R; internal_ordering=internal_ordering(Rx), cached=cached) S.S = deepcopy(symbols(Rx)) S.mpoly_ring = P return S @@ -1120,10 +1120,10 @@ end # ############################################################################### -function UniversalPolynomialRing(R::Ring; ordering=:lex, cached::Bool=true) +function UniversalPolynomialRing(R::Ring; internal_ordering=:lex, cached::Bool=true) T = elem_type(R) U = Generic.MPoly{T} - return UniversalPolyRing{T, U}(R, ordering, cached) + return UniversalPolyRing{T, U}(R, internal_ordering, cached) end diff --git a/test/algorithms/MPolyEvaluate-test.jl b/test/algorithms/MPolyEvaluate-test.jl index 615e7ca9c5..2fdbdede99 100644 --- a/test/algorithms/MPolyEvaluate-test.jl +++ b/test/algorithms/MPolyEvaluate-test.jl @@ -33,7 +33,7 @@ end end @testset "MPolyEvaluate.ZZ(QQ)" begin - R, (x, y, z, t) = polynomial_ring(ZZ, ["x", "y", "z", "t"], ordering = :degrevlex) + R, (x, y, z, t) = polynomial_ring(ZZ, ["x", "y", "z", "t"], internal_ordering = :degrevlex) test_evaluate(zero(R), [QQ(), QQ(), QQ(), QQ()]) test_evaluate(one(R), [QQ(), QQ(), QQ(), QQ()]) for i in 1:100 diff --git a/test/generic/Ideal-test.jl b/test/generic/Ideal-test.jl index 312f82e416..7c216acac2 100644 --- a/test/generic/Ideal-test.jl +++ b/test/generic/Ideal-test.jl @@ -185,12 +185,12 @@ end end @testset "Generic.Ideal.ideal_reduction(multivariate)" begin - R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:degrevlex) + R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:degrevlex) for V in example_ideal_gens(x, y) @test testit(R, V) end - R, (x, y, z) = polynomial_ring(ZZ, ["x", "y", "z"]; ordering=:degrevlex) + R, (x, y, z) = polynomial_ring(ZZ, ["x", "y", "z"]; internal_ordering=:degrevlex) for V in example_ideal_gens(x, y, z) @test testit(R, V) end @@ -262,7 +262,7 @@ end @testset "Generic.Ideal.comparison" begin # multivariate - R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:degrevlex) + R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:degrevlex) ex = example_ideal_gens(x, y) for V in ex[1:28] # 29 and beyond are too slow for some RNG seeds @@ -306,7 +306,7 @@ end @testset "Generic.Ideal.containment" begin # multivariate - R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:degrevlex) + R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:degrevlex) ex = example_ideal_gens(x, y) for V in ex[1:15], W in ex[1:15] @@ -369,7 +369,7 @@ end @testset "Generic.Ideal.addition" begin # multivariate - R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:degrevlex) + R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:degrevlex) ex = example_ideal_gens(x, y) for V in ex[1:15], W in ex[1:15] @@ -431,7 +431,7 @@ end @testset "Generic.Ideal.multiplication" begin # multivariate - R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:degrevlex) + R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:degrevlex) ex = example_ideal_gens(x, y) for V in ex[1:10], W in ex[1:10], X in ex[1:10] @@ -499,7 +499,7 @@ end @testset "Generic.Ideal.adhoc_multiplication" begin # multivariate - R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:degrevlex) + R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:degrevlex) # random examples for V in example_ideal_gens(x, y) @@ -564,7 +564,7 @@ end @testset "Generic.Ideal.intersect" begin # multivariate - R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; ordering=:degrevlex) + R, (x, y) = polynomial_ring(ZZ, ["x", "y"]; internal_ordering=:degrevlex) ex = example_ideal_gens(x, y) for V in ex[1:10], W in ex[1:10] diff --git a/test/generic/MPoly-test.jl b/test/generic/MPoly-test.jl index 254f0e9230..fe20bd6d7f 100644 --- a/test/generic/MPoly-test.jl +++ b/test/generic/MPoly-test.jl @@ -5,12 +5,12 @@ var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) - @test polynomial_ring(R, var_names, ordering = ord, cached = true)[1] === polynomial_ring(R, var_names, ordering = ord, cached = true)[1] - @test polynomial_ring(R, var_names, ordering = ord, cached = false)[1] !== polynomial_ring(R, var_names, ordering = ord, cached = true)[1] - @test polynomial_ring(R, num_vars, "x", ordering = ord, cached = true)[1] === polynomial_ring(R, var_names, ordering = ord, cached = true)[1] - @test polynomial_ring(R, num_vars, ordering = ord, cached = true)[1] === polynomial_ring(R, var_names, ordering = ord, cached = true)[1] + @test polynomial_ring(R, var_names, internal_ordering = ord, cached = true)[1] === polynomial_ring(R, var_names, internal_ordering = ord, cached = true)[1] + @test polynomial_ring(R, var_names, internal_ordering = ord, cached = false)[1] !== polynomial_ring(R, var_names, internal_ordering = ord, cached = true)[1] + @test polynomial_ring(R, num_vars, "x", internal_ordering = ord, cached = true)[1] === polynomial_ring(R, var_names, internal_ordering = ord, cached = true)[1] + @test polynomial_ring(R, num_vars, internal_ordering = ord, cached = true)[1] === polynomial_ring(R, var_names, internal_ordering = ord, cached = true)[1] @test elem_type(S) == Generic.MPoly{elem_type(R)} @test elem_type(Generic.MPolyRing{elem_type(R)}) == Generic.MPoly{elem_type(R)} @@ -187,7 +187,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) g = gens(S) C = Generic.geobucket(S) @@ -208,7 +208,7 @@ end ord = rand_ordering(rng) @test ord in [:lex, :deglex, :degrevlex] - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) test_rand(S, 0:5, 0:100, 0:0, -100:100) end @@ -222,7 +222,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) g = gens(S) @test !is_gen(S(1)) @@ -292,8 +292,8 @@ end end max_degs, biggest = max_fields(f) - deg = is_degree(ordering(S)) - rev = is_reverse(ordering(S)) + deg = is_degree(internal_ordering(S)) + rev = is_reverse(internal_ordering(S)) if deg @test max_degs[num_vars + 1] <= 100*num_vars @@ -321,7 +321,7 @@ end @test max_degs[j] <= biggest end - @test ord == ordering(S) + @test ord == internal_ordering(S) @test nvars(parent(f)) == num_vars @test ngens(parent(f)) == num_vars @@ -350,7 +350,7 @@ end for num_vars = 1:4 var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(ZZ, var_names, ordering = ord) + S, varlist = polynomial_ring(ZZ, var_names, internal_ordering = ord) for iter = 1:10 @test is_homogeneous(zero(S)) @@ -406,7 +406,7 @@ end for iter = 1:5 ord = rand_ordering() - S, (x, y, z) = polynomial_ring(R, ["x", "y", "z"]; ordering=ord) + S, (x, y, z) = polynomial_ring(R, ["x", "y", "z"]; internal_ordering=ord) f = -8*x^5*y^3*z^5+9*x^5*y^2*z^3-8*x^4*y^5*z^4-10*x^4*y^3*z^2+8*x^3*y^2*z-10*x*y^3* z^4-4*x*y-10*x*z^2+8*y^2*z^5-9*y^2*z^3 @@ -426,7 +426,7 @@ end ord = rand_ordering() var_names = ["x$j" for j in 1:num_vars] - R, vars_R = polynomial_ring(ZZ, var_names; ordering=ord) + R, vars_R = polynomial_ring(ZZ, var_names; internal_ordering=ord) f = rand(R, 5:10, 1:10, -100:100) g = rand(R, 5:10, 1:10, -100:100) @@ -449,7 +449,7 @@ end for num_vars = 1:4 var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(ZZ, var_names, ordering = ord) + S, varlist = polynomial_ring(ZZ, var_names, internal_ordering = ord) for iter = 1:10 f = rand(S, 0:4, 0:5, -10:10) @@ -470,7 +470,7 @@ end for num_vars = 1:4 var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(ZZ, var_names, ordering = ord) + S, varlist = polynomial_ring(ZZ, var_names, internal_ordering = ord) for iter = 1:10 f = zero(S) @@ -523,7 +523,7 @@ end degrees = [] for nord = 1:20 ord = rand_ordering() - S, varlist = polynomial_ring(ZZ, var_names, ordering = ord) + S, varlist = polynomial_ring(ZZ, var_names, internal_ordering = ord) p = zero(S) for j = 1:nterms p += prod(varlist[i]^exps[i,j] for i = 1:nvars) @@ -542,7 +542,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:10 f = rand(S, 0:5, 0:100, 0:0, -100:100) @@ -559,7 +559,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:10 f = rand(S, 0:5, 0:100, 0:0, -100:100) @@ -584,7 +584,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:100 f = rand(S, 0:5, 0:100, 0:0, -100:100) @@ -625,7 +625,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:100 d = rand(-100:100) @@ -648,7 +648,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:10 f = rand(S, 0:5, 0:100, 0:0, -100:100) @@ -691,7 +691,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:10 f = S(0) @@ -724,7 +724,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(ZZ, var_names, ordering = ord) + S, varlist = polynomial_ring(ZZ, var_names, internal_ordering = ord) for iter = 1:10 f = rand(S, 0:5, 0:100, -100:100) @@ -760,7 +760,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:10 f = rand(S, 0:5, 0:100, 0:Int(p)) @@ -797,7 +797,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:10 f = S(0) @@ -825,7 +825,7 @@ end end - S, varlist = polynomial_ring(QQ, var_names, ordering = ord) + S, varlist = polynomial_ring(QQ, var_names, internal_ordering = ord) v = varlist[1+Int(round(rand() * (num_vars-1)))] @test divrem(v, 2*v) == (1//2, 0) end @@ -838,7 +838,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) @test divrem(varlist[1], elem_type(S)[]) == (elem_type(S)[], varlist[1]) @@ -886,7 +886,7 @@ end for num_vars = 1:4 var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(ZZ, var_names, ordering = ord) + S, varlist = polynomial_ring(ZZ, var_names, internal_ordering = ord) for iter = 1:10 p = rand(S, 0:4, 0:5, -10:10) @@ -927,7 +927,7 @@ end for num_vars = 1:4 var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(ZZ, var_names, ordering = ord) + S, varlist = polynomial_ring(ZZ, var_names, internal_ordering = ord) for iter = 1:10 f = rand(S, 0:4, 0:5, -10:10) @@ -946,7 +946,7 @@ end for num_vars = 1:4 var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(ZZ, var_names, ordering = ord) + S, varlist = polynomial_ring(ZZ, var_names, internal_ordering = ord) for iter = 1:10 f = rand(S, 0:4, 0:5, -10:10) @@ -973,7 +973,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:50 f = rand(S, 0:5, 0:100, 0:0, -100:100) @@ -1012,7 +1012,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:50 f = rand(S, 0:5, 0:100, 0:0, 0:0, -100:100) @@ -1034,7 +1034,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:10 eval_num = rand(0:num_vars) @@ -1128,7 +1128,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:50 f = rand(S, 0:5, 0:100, -100:100) @@ -1173,7 +1173,7 @@ end # Test ordering is correct, see issue #184 for iter = 1:10 ord = rand_ordering() - R, (x, y, z) = polynomial_ring(ZZ, ["x", "y", "z"], ordering = ord) + R, (x, y, z) = polynomial_ring(ZZ, ["x", "y", "z"], internal_ordering = ord) f = x*y^2*z^3 @@ -1257,7 +1257,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - S, varlist = polynomial_ring(R, var_names, ordering = ord) + S, varlist = polynomial_ring(R, var_names, internal_ordering = ord) for iter = 1:100 f = S() @@ -1293,7 +1293,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - R, vars = polynomial_ring(ZZ, var_names; ordering=ord) + R, vars = polynomial_ring(ZZ, var_names; internal_ordering=ord) j = 1 for v in vars @@ -1324,9 +1324,9 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - R, vars = polynomial_ring(ZZ, var_names; ordering=ord) + R, vars = polynomial_ring(ZZ, var_names; internal_ordering=ord) - F2x, varss = polynomial_ring(F2, var_names; ordering = ord) + F2x, varss = polynomial_ring(F2, var_names; internal_ordering = ord) @test typeof(AbstractAlgebra.Generic.change_base_ring(ZZ, R(1))) == AbstractAlgebra.Generic.MPoly{typeof(ZZ(1))} @test typeof(AbstractAlgebra.Generic.change_base_ring(ZZ, R(0))) == AbstractAlgebra.Generic.MPoly{typeof(ZZ(0))} @@ -1335,7 +1335,7 @@ end f = rand(R, 5:10, 1:10, -100:100) @test evaluate(change_base_ring(R, f), [one(R) for i=1:num_vars]) == sum(f.coeffs[i] for i=1:f.length) @test evaluate(change_base_ring(R, f), vars) == f - @test ordering(parent(change_base_ring(R, f))) == ordering(parent(f)) + @test internal_ordering(parent(change_base_ring(R, f))) == internal_ordering(parent(f)) g = change_base_ring(F2, f, parent = F2x) @test base_ring(g) === F2 @@ -1352,7 +1352,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - R, vars_R = polynomial_ring(ZZ, var_names; ordering=ord) + R, vars_R = polynomial_ring(ZZ, var_names; internal_ordering=ord) for iter in 1:10 f = rand(R, 5:10, 1:10, -100:100) @@ -1366,7 +1366,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - R, vars_R = polynomial_ring(ZZ, var_names; ordering=ord) + R, vars_R = polynomial_ring(ZZ, var_names; internal_ordering=ord) for iter in 1:10 f = R() @@ -1400,7 +1400,7 @@ end var_names = ["x$j" for j in 1:num_vars] ord = rand_ordering() - R, vars_R = polynomial_ring(ZZ, var_names; ordering=ord) + R, vars_R = polynomial_ring(ZZ, var_names; internal_ordering=ord) for iter in 1:10 f = R() @@ -1472,7 +1472,7 @@ end var_names = ["x$j" for j in 1:num_vars] - R, vars_R = polynomial_ring(ZZ, var_names; ordering=ord) + R, vars_R = polynomial_ring(ZZ, var_names; internal_ordering=ord) x = rand(vars_R) R_univ, x_univ = polynomial_ring(ZZ, "x") @@ -1498,7 +1498,7 @@ end ord = rand_ordering() var_names = ["x$j" for j in 1:num_vars] - R, vars_R = polynomial_ring(ZZ, var_names; ordering=ord) + R, vars_R = polynomial_ring(ZZ, var_names; internal_ordering=ord) @test length(AbstractAlgebra.Generic.coefficients_of_univariate(zero(R), true)) == 0 @test length(AbstractAlgebra.Generic.coefficients_of_univariate(zero(R), false)) == 0 @@ -1528,7 +1528,7 @@ end maxdeg = 20 # :deglex ordering - R, (x,y,z) = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, ["x", "y", "z"], ordering=:lex) + R, (x,y,z) = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, ["x", "y", "z"], internal_ordering=:lex) # Monomials of degree 2 @test isless(z^2, y*z) == true @test isless(y*z, y^2) == true @@ -1539,7 +1539,7 @@ end for n_vars = 1:maxdeg A = unique(sortslices(reshape(map(Int,map(round, rand(n_vars * n_mpolys) * maxval)), (n_mpolys, n_vars)), dims=1),dims=1) var_names = ["x$j" for j in 1:n_vars] - R, varsR = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, var_names, ordering=:lex) + R, varsR = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, var_names, internal_ordering=:lex) for i in 1:size(A)[1]-1 f = R([base_ring(R)(1)], [A[i,:]]) g = R([base_ring(R)(1)], [A[i+1,:]]) @@ -1548,7 +1548,7 @@ end end # :deglex ordering - R, (x,y,z) = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, ["x", "y", "z"], ordering=:deglex) + R, (x,y,z) = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, ["x", "y", "z"], internal_ordering=:deglex) @test isless(z^2, y*z) == true @test isless(y*z, x*z) == true @@ -1559,7 +1559,7 @@ end for n_vars=1:maxdeg A = reshape(map(Int,map(round, rand(n_vars * n_mpolys) * maxval)), (n_mpolys, n_vars)) var_names = ["x$j" for j in 1:n_vars] - R, varsR = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, var_names, ordering=:deglex) + R, varsR = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, var_names, internal_ordering=:deglex) for i in 1:size(A)[1]-1 f = R([base_ring(R)(1)], [A[i,:]]) @@ -1583,7 +1583,7 @@ end end # :degrevlex ordering - R, (x,y,z) = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, ["x", "y", "z"], ordering=:degrevlex) + R, (x,y,z) = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, ["x", "y", "z"], internal_ordering=:degrevlex) # Monomials of degree 2 @test isless(z^2, y*z) == true @test isless(y*z, x*z) == true @@ -1593,7 +1593,7 @@ end for n_vars = 1:maxdeg A = reshape(map(Int,map(round, rand(n_vars * n_mpolys) * maxval)), (n_mpolys, n_vars)) var_names = ["x$j" for j in 1:n_vars] - R, varsR = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, var_names, ordering=:degrevlex) + R, varsR = AbstractAlgebra.Generic.polynomial_ring(AbstractAlgebra.Generic.ZZ, var_names, internal_ordering=:degrevlex) for i in 1:size(A)[1]-1 f = R([base_ring(R)(1)], [A[i,:]]) g = R([base_ring(R)(1)], [A[i+1,:]]) diff --git a/test/generic/UnivPoly-test.jl b/test/generic/UnivPoly-test.jl index 05b121dac9..ba5bb23868 100644 --- a/test/generic/UnivPoly-test.jl +++ b/test/generic/UnivPoly-test.jl @@ -3,10 +3,10 @@ for iters = 1:5 ord = rand_ordering() - @test UniversalPolynomialRing(R; ordering=ord, cached = true) === UniversalPolynomialRing(R; ordering=ord, cached = true) - @test UniversalPolynomialRing(R; ordering=ord, cached = false) !== UniversalPolynomialRing(R; ordering=ord, cached = false) + @test UniversalPolynomialRing(R; internal_ordering=ord, cached = true) === UniversalPolynomialRing(R; internal_ordering=ord, cached = true) + @test UniversalPolynomialRing(R; internal_ordering=ord, cached = false) !== UniversalPolynomialRing(R; internal_ordering=ord, cached = false) - S = UniversalPolynomialRing(R; ordering=ord) + S = UniversalPolynomialRing(R; internal_ordering=ord) x = gen(S, "x") @test x == S[1] @@ -85,7 +85,7 @@ end for iters = 1:100 ord = rand_ordering() - S = UniversalPolynomialRing(R; ordering=ord, cached=false) + S = UniversalPolynomialRing(R; internal_ordering=ord, cached=false) @test symbols(S) == Symbol[] @test nvars(S) == 0 @@ -122,7 +122,7 @@ end @test vars(x*y + 1) == [x, y] @test vars(x*y + z) == [x, y, z] - @test ordering(S) == ord + @test internal_ordering(S) == ord end end end @@ -142,7 +142,7 @@ end for iters = 1:100 ord = rand_ordering() - S = UniversalPolynomialRing(R; ordering=ord, cached=false) + S = UniversalPolynomialRing(R; internal_ordering=ord, cached=false) x = gen(S, "x") y, z = gens(S, ["y", "z"])