1010#
1111# ##############################################################################
1212
13- base_ring_type (:: Type{<:UniversalPolyRing{T}} ) where T = parent_type (T)
14- base_ring (S:: UniversalPolyRing ) = base_ring ( mpoly_ring (S)) :: base_ring_type (S)
13+ base_ring_type (:: Type{<:UniversalPolyRing{T}} ) where T = mpoly_ring_type (T)
14+ base_ring (S:: UniversalPolyRing ) = S . base_ring :: base_ring_type (S)
1515
16- coefficient_ring_type (T :: Type{<:UniversalPolyRing} ) = base_ring_type (T)
17- coefficient_ring (S:: UniversalPolyRing ) = base_ring (S)
16+ coefficient_ring_type (:: Type{<:UniversalPolyRing{T}} ) where T = parent_type (T)
17+ coefficient_ring (S:: UniversalPolyRing ) = coefficient_ring ( base_ring (S)) :: coefficient_ring_type (S)
1818
1919function is_domain_type (:: Type{<:UnivPoly{S}} ) where {S <: RingElement }
2020 return is_domain_type (S)
@@ -30,17 +30,13 @@ elem_type(::Type{UniversalPolyRing{T}}) where {T<:RingElement} = UnivPoly{T}
3030
3131parent_type (:: Type{UnivPoly{T}} ) where {T<: RingElement } = UniversalPolyRing{T}
3232
33- function mpoly_ring (S:: UniversalPolyRing{T} ) where {T<: RingElement }
34- return S. mpoly_ring:: mpoly_ring_type (T)
35- end
36-
37- number_of_variables (S:: UniversalPolyRing ) = number_of_variables (mpoly_ring (S))
33+ number_of_variables (S:: UniversalPolyRing ) = number_of_variables (base_ring (S))
3834
39- number_of_generators (S:: UniversalPolyRing ) = number_of_generators (mpoly_ring (S))
35+ number_of_generators (S:: UniversalPolyRing ) = number_of_generators (base_ring (S))
4036
41- symbols (S:: UniversalPolyRing ) = symbols (mpoly_ring (S))
37+ symbols (S:: UniversalPolyRing ) = symbols (base_ring (S))
4238
43- internal_ordering (p:: UniversalPolyRing ) = internal_ordering (mpoly_ring (p))
39+ internal_ordering (p:: UniversalPolyRing ) = internal_ordering (base_ring (p))
4440
4541data (p:: UnivPoly{T} ) where {T<: RingElement } = p. p:: mpoly_type (T)
4642
@@ -76,7 +72,7 @@ function coeff(p::UnivPoly, exps::Vector{Int})
7672 n = nvars (parent (data (p)))
7773 if len > n
7874 if ! iszero (exps[n + 1 : len])
79- return base_ring (S)()
75+ return coefficient_ring (S)()
8076 end
8177 return coeff (data (p), exps[1 : n])
8278 end
@@ -88,7 +84,7 @@ function coeff(p::UnivPoly, exps::Vector{Int})
8884end
8985
9086function setcoeff! (p:: UnivPoly , exps:: Vector{Int} , c:: T ) where T <: RingElement
91- c = base_ring (data (p))(c)
87+ c = coefficient_ring (data (p))(c)
9288 S = parent (p)
9389 len = length (exps)
9490 upgrade! (p)
110106#
111107# ##############################################################################
112108
113- zero (R:: UniversalPolyRing{T} ) where {T} = UnivPoly {T} (zero (mpoly_ring (R)), R)
109+ zero (R:: UniversalPolyRing{T} ) where {T} = UnivPoly {T} (zero (base_ring (R)), R)
114110
115- one (R:: UniversalPolyRing{T} ) where {T} = UnivPoly {T} (one (mpoly_ring (R)), R)
111+ one (R:: UniversalPolyRing{T} ) where {T} = UnivPoly {T} (one (base_ring (R)), R)
116112
117113iszero (p:: UnivPoly ) = iszero (data (p))
118114
@@ -231,7 +227,7 @@ function _ensure_variables(S::UniversalPolyRing, v::Vector{<:VarName})
231227 end
232228 if ! isempty (added_symbols)
233229 new_symbols = vcat (current_symbols, added_symbols)
234- S. mpoly_ring = AbstractAlgebra. polynomial_ring_only (base_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
230+ S. base_ring = AbstractAlgebra. polynomial_ring_only (coefficient_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
235231 end
236232 return idx
237233end
@@ -242,14 +238,14 @@ function gen(S::UniversalPolyRing, s::VarName)
242238 new_symbols = copy (symbols (S))
243239 push! (new_symbols, Symbol (s))
244240 i = length (new_symbols)
245- S. mpoly_ring = AbstractAlgebra. polynomial_ring_only (base_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
241+ S. base_ring = AbstractAlgebra. polynomial_ring_only (coefficient_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
246242 end
247243 return @inbounds gen (S, i)
248244end
249245
250246function gen (S:: UniversalPolyRing{T} , i:: Int ) where {T}
251247 @boundscheck 1 <= i <= nvars (S) || throw (ArgumentError (" generator index out of range" ))
252- return UnivPoly {T} (gen (mpoly_ring (S), i), S)
248+ return UnivPoly {T} (gen (base_ring (S), i), S)
253249end
254250
255251function gens (S:: UniversalPolyRing{T} ) where {T}
@@ -263,7 +259,7 @@ function _univ_poly_gens(S::UniversalPolyRing{T}, vars::Vector{Symbol}) where {T
263259 idx = _ensure_variables (S, vars)
264260 # TRICK: @varnames_interface expects two return values, but we only care
265261 # for the second; so just return literally nothing for the first
266- return nothing , [UnivPoly {T} (gen (mpoly_ring (S), i), S) for i in idx]
262+ return nothing , [UnivPoly {T} (gen (base_ring (S), i), S) for i in idx]
267263end
268264
269265AbstractAlgebra. @varnames_interface _univ_poly_gens (R:: UniversalPolyRing{T} , s) where {T}
286282
287283canonical_unit (p:: UnivPoly ) = canonical_unit (data (p))
288284
289- characteristic (R:: UniversalPolyRing ) = characteristic (base_ring (R))
285+ characteristic (R:: UniversalPolyRing ) = characteristic (coefficient_ring (R))
290286
291287function Base. hash (p:: UnivPoly , h:: UInt )
292288 b = 0xcf418d4529109236 % UInt
@@ -349,7 +345,7 @@ function show(io::IO, R::UniversalPolyRing)
349345 @show_name (io, R)
350346 @show_special (io, R)
351347 print (io, " Universal Polynomial Ring over " )
352- show (io, base_ring (R))
348+ show (io, coefficient_ring (R))
353349end
354350
355351function expressify (a:: UnivPoly , x = symbols (parent (a)); context = nothing )
@@ -828,7 +824,7 @@ is_univariate(p::UnivPoly) = is_univariate(data(p))
828824
829825is_univariate_with_data (p:: UnivPoly ) = is_univariate_with_data (data (p))
830826
831- is_univariate (R:: UniversalPolyRing ) = is_univariate (mpoly_ring (R))
827+ is_univariate (R:: UniversalPolyRing ) = is_univariate (base_ring (R))
832828
833829function coefficients_of_univariate (p:: UnivPoly , check_univariate:: Bool = true )
834830 return coefficients_of_univariate (data (p), check_univariate)
@@ -844,7 +840,7 @@ _change_univ_poly_ring(R, Rx, cached::Bool) = universal_polynomial_ring(R, symbo
844840
845841function change_base_ring (R:: Ring , p:: UnivPoly{T} ; cached:: Bool = true , parent:: UniversalPolyRing = _change_univ_poly_ring (R, parent (p), cached)) where {T <: RingElement }
846842 upgrade! (p)
847- return UnivPoly (change_base_ring (R, data (p); parent = mpoly_ring (parent)), parent)
843+ return UnivPoly (change_base_ring (R, data (p); parent = base_ring (parent)), parent)
848844end
849845
850846function change_coefficient_ring (R:: Ring , p:: UnivPoly{T} ; cached:: Bool = true , parent:: UniversalPolyRing = _change_univ_poly_ring (R, parent (p), cached)) where {T <: RingElement }
857853#
858854# ###############################################################################
859855
860- function map_coefficients (f:: T , p:: UnivPoly ; cached:: Bool = true , parent:: UniversalPolyRing = _change_univ_poly_ring (parent (f (zero (base_ring (p)))), parent (p), cached)) where T
856+ function map_coefficients (f:: T , p:: UnivPoly ; cached:: Bool = true , parent:: UniversalPolyRing = _change_univ_poly_ring (parent (f (zero (coefficient_ring (p)))), parent (p), cached)) where T
861857 upgrade! (p)
862- return UnivPoly (map_coefficients (f, data (p); parent = mpoly_ring (parent)), parent)
858+ return UnivPoly (map_coefficients (f, data (p); parent = base_ring (parent)), parent)
863859end
864860
865861# ##############################################################################
@@ -888,7 +884,7 @@ RandomExtensions.maketype(S::AbstractAlgebra.UniversalPolyRing, _, _, _) = elem_
888884
889885function RandomExtensions. make (S:: AbstractAlgebra.UniversalPolyRing , term_range:: AbstractUnitRange{Int} ,
890886 exp_bound:: AbstractUnitRange{Int} , vs... )
891- R = base_ring (S)
887+ R = coefficient_ring (S)
892888 if length (vs) == 1 && elem_type (R) == Random. gentype (vs[1 ])
893889 Make (S, term_range, exp_bound, vs[1 ])
894890 else
@@ -901,7 +897,7 @@ function rand(rng::AbstractRNG, sp::SamplerTrivial{<:Make4{
901897 S, term_range, exp_bound, v = sp[][1 : end ]
902898 f = S ()
903899 g = gens (S)
904- R = base_ring (S)
900+ R = coefficient_ring (S)
905901 for i = 1 : rand (rng, term_range)
906902 term = S (1 )
907903 for j = 1 : length (g)
@@ -1049,7 +1045,7 @@ end
10491045function upgrade (S:: UniversalPolyRing{T} , pp:: MPolyRingElem{T} ) where {T}
10501046 n = nvars (S) - nvars (parent (pp))
10511047 if n > 0
1052- ctx = MPolyBuildCtx (mpoly_ring (S))
1048+ ctx = MPolyBuildCtx (base_ring (S))
10531049 v0 = zeros (Int, n)
10541050 for (c, v) in zip (coefficients (pp), exponent_vectors (pp))
10551051 push_term! (ctx, c, vcat (v, v0))
@@ -1066,19 +1062,19 @@ function upgrade!(p::UnivPoly)
10661062end
10671063
10681064function (a:: UniversalPolyRing{T} )(b:: RingElement ) where {T <: RingElement }
1069- return a (base_ring (a)(b))
1065+ return a (coefficient_ring (a)(b))
10701066end
10711067
10721068function (a:: UniversalPolyRing{T} )() where {T <: RingElement }
1073- return UnivPoly {T} (mpoly_ring (a)(), a)
1069+ return UnivPoly {T} (base_ring (a)(), a)
10741070end
10751071
10761072function (a:: UniversalPolyRing{T} )(b:: JuliaRingElement ) where {T <: RingElement }
1077- return UnivPoly {T} (mpoly_ring (a)(b), a)
1073+ return UnivPoly {T} (base_ring (a)(b), a)
10781074end
10791075
10801076function (a:: UniversalPolyRing{T} )(b:: T ) where {T <: RingElem }
1081- return UnivPoly {T} (mpoly_ring (a)(b), a)
1077+ return UnivPoly {T} (base_ring (a)(b), a)
10821078end
10831079
10841080function (S:: UniversalPolyRing{T} )(p:: UnivPoly{T} ) where {T <: RingElement }
@@ -1089,12 +1085,12 @@ end
10891085function (a:: UniversalPolyRing{T} )(b:: Vector{T} , m:: Vector{Vector{Int}} ) where {T <: RingElement }
10901086 if length (m) != 0
10911087 len = length (m[1 ])
1092- num = nvars (mpoly_ring (a))
1088+ num = nvars (base_ring (a))
10931089 if len != num
10941090 for i = 1 : length (m)
10951091 m[i] = vcat (m[i], zeros (Int, num - len))
10961092 end
10971093 end
10981094 end
1099- return UnivPoly {T} (mpoly_ring (a)(b, m), a)
1095+ return UnivPoly {T} (base_ring (a)(b, m), a)
11001096end
0 commit comments