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 . mpoly_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 ) = base_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,23 +30,21 @@ 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
33+ mpoly_ring (S:: UniversalPolyRing ) = base_ring (S)
3634
37- number_of_variables (S:: UniversalPolyRing ) = number_of_variables (mpoly_ring (S))
35+ number_of_variables (S:: UniversalPolyRing ) = number_of_variables (base_ring (S))
3836
39- number_of_generators (S:: UniversalPolyRing ) = number_of_generators (mpoly_ring (S))
37+ number_of_generators (S:: UniversalPolyRing ) = number_of_generators (base_ring (S))
4038
41- symbols (S:: UniversalPolyRing ) = symbols (mpoly_ring (S))
39+ symbols (S:: UniversalPolyRing ) = symbols (base_ring (S))
4240
4341function vars (p:: UnivPoly{T} ) where {T}
4442 S = parent (p)
4543 V = vars (data (p))
4644 return [UnivPoly {T} (v, S) for v in V]
4745end
4846
49- internal_ordering (p:: UniversalPolyRing ) = internal_ordering (mpoly_ring (p))
47+ internal_ordering (p:: UniversalPolyRing ) = internal_ordering (base_ring (p))
5048
5149data (p:: UnivPoly{T} ) where {T<: RingElement } = p. p:: mpoly_type (T)
5250
@@ -84,7 +82,7 @@ function coeff(p::UnivPoly, exps::Vector{Int})
8482 n = nvars (parent (data (p)))
8583 if len > n
8684 if ! iszero (exps[n + 1 : len])
87- return base_ring (S)()
85+ return coefficient_ring (S)()
8886 end
8987 return coeff (data (p), exps[1 : n])
9088 end
@@ -96,7 +94,7 @@ function coeff(p::UnivPoly, exps::Vector{Int})
9694end
9795
9896function setcoeff! (p:: UnivPoly , exps:: Vector{Int} , c:: T ) where T <: RingElement
99- c = base_ring (data (p))(c)
97+ c = coefficient_ring (data (p))(c)
10098 S = parent (p)
10199 len = length (exps)
102100 if len != nvars (parent (data (p)))
120118#
121119# ##############################################################################
122120
123- zero (R:: UniversalPolyRing{T} ) where {T} = UnivPoly {T} (zero (mpoly_ring (R)), R)
121+ zero (R:: UniversalPolyRing{T} ) where {T} = UnivPoly {T} (zero (base_ring (R)), R)
124122
125- one (R:: UniversalPolyRing{T} ) where {T} = UnivPoly {T} (one (mpoly_ring (R)), R)
123+ one (R:: UniversalPolyRing{T} ) where {T} = UnivPoly {T} (one (base_ring (R)), R)
126124
127125iszero (p:: UnivPoly ) = iszero (data (p))
128126
@@ -155,7 +153,7 @@ function coeff(p::UnivPoly{T}, m::UnivPoly{T}) where {T}
155153 v1 = first (exponent_vectors (m))
156154 len = length (v1)
157155 n = nvars (parent (data (p)))
158- R = base_ring (p)
156+ R = coefficient_ring (p)
159157 if len > n
160158 if ! iszero (v1[n + 1 : len])
161159 return zero (R)
@@ -261,7 +259,7 @@ function _ensure_variables(S::UniversalPolyRing, v::Vector{<:VarName})
261259 end
262260 if ! isempty (added_symbols)
263261 new_symbols = vcat (current_symbols, added_symbols)
264- S. mpoly_ring = AbstractAlgebra. polynomial_ring_only (base_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
262+ S. mpoly_ring = AbstractAlgebra. polynomial_ring_only (coefficient_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
265263 end
266264 return idx
267265end
@@ -272,14 +270,14 @@ function gen(S::UniversalPolyRing, s::VarName)
272270 new_symbols = copy (symbols (S))
273271 push! (new_symbols, Symbol (s))
274272 i = length (new_symbols)
275- S. mpoly_ring = AbstractAlgebra. polynomial_ring_only (base_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
273+ S. mpoly_ring = AbstractAlgebra. polynomial_ring_only (coefficient_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
276274 end
277275 return @inbounds gen (S, i)
278276end
279277
280278function gen (S:: UniversalPolyRing{T} , i:: Int ) where {T}
281279 @boundscheck 1 <= i <= nvars (S) || throw (ArgumentError (" generator index out of range" ))
282- return UnivPoly {T} (gen (mpoly_ring (S), i), S)
280+ return UnivPoly {T} (gen (base_ring (S), i), S)
283281end
284282
285283function gens (S:: UniversalPolyRing{T} ) where {T}
@@ -293,7 +291,7 @@ function _univ_poly_gens(S::UniversalPolyRing{T}, vars::Vector{Symbol}) where {T
293291 idx = _ensure_variables (S, vars)
294292 # TRICK: @varnames_interface expects two return values, but we only care
295293 # for the second; so just return literally nothing for the first
296- return nothing , [UnivPoly {T} (gen (mpoly_ring (S), i), S) for i in idx]
294+ return nothing , [UnivPoly {T} (gen (base_ring (S), i), S) for i in idx]
297295end
298296
299297AbstractAlgebra. @varnames_interface _univ_poly_gens (R:: UniversalPolyRing{T} , s) where {T}
314312
315313canonical_unit (p:: UnivPoly ) = canonical_unit (data (p))
316314
317- characteristic (R:: UniversalPolyRing ) = characteristic (base_ring (R))
315+ characteristic (R:: UniversalPolyRing ) = characteristic (coefficient_ring (R))
318316
319317function Base. hash (p:: UnivPoly , h:: UInt )
320318 b = 0xcf418d4529109236 % UInt
@@ -377,7 +375,7 @@ function show(io::IO, R::UniversalPolyRing)
377375 @show_name (io, R)
378376 @show_special (io, R)
379377 print (io, " Universal Polynomial Ring over " )
380- show (io, base_ring (R))
378+ show (io, coefficient_ring (R))
381379end
382380
383381function expressify (a:: UnivPoly , x = symbols (parent (a)); context = nothing )
808806# ##############################################################################
809807
810808function evaluate (a:: UnivPoly{T} , A:: Vector{T} ) where {T <: RingElem }
811- R = base_ring (a)
809+ R = coefficient_ring (a)
812810 n = length (A)
813811 num = nvars (parent (data (a)))
814812 if n > num
@@ -852,7 +850,7 @@ function evaluate(a::UnivPoly{T}, A::Vector{V}) where {T <: RingElement, V <: Ri
852850 end
853851 if n < num
854852 if n == 0
855- R = base_ring (a)
853+ R = coefficient_ring (a)
856854 return evaluate (data (a), [zero (R) for _ in 1 : num])
857855 else
858856 R = parent (A[1 ])
@@ -963,7 +961,7 @@ is_univariate(p::UnivPoly) = is_univariate(data(p))
963961
964962is_univariate_with_data (p:: UnivPoly ) = is_univariate_with_data (data (p))
965963
966- is_univariate (R:: UniversalPolyRing ) = is_univariate (mpoly_ring (R))
964+ is_univariate (R:: UniversalPolyRing ) = is_univariate (base_ring (R))
967965
968966function coefficients_of_univariate (p:: UnivPoly , check_univariate:: Bool = true )
969967 return coefficients_of_univariate (data (p), check_univariate)
@@ -983,7 +981,7 @@ function _change_univ_poly_ring(R, Rx, cached::Bool)
983981end
984982
985983function change_base_ring (R:: Ring , p:: UnivPoly{T} ; cached:: Bool = true , parent:: UniversalPolyRing = _change_univ_poly_ring (R, parent (p), cached)) where {T <: RingElement }
986- base_ring (parent) != R && error (" Base rings do not match." )
984+ coefficient_ring (parent) != R && error (" Base rings do not match." )
987985 return _map (R, p, parent)
988986end
989987
997995#
998996# ###############################################################################
999997
1000- 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
998+ 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
1001999 return _map (f, p, parent)
10021000end
10031001
@@ -1037,7 +1035,7 @@ RandomExtensions.maketype(S::AbstractAlgebra.UniversalPolyRing, _, _, _) = elem_
10371035
10381036function RandomExtensions. make (S:: AbstractAlgebra.UniversalPolyRing , term_range:: AbstractUnitRange{Int} ,
10391037 exp_bound:: AbstractUnitRange{Int} , vs... )
1040- R = base_ring (S)
1038+ R = coefficient_ring (S)
10411039 if length (vs) == 1 && elem_type (R) == Random. gentype (vs[1 ])
10421040 Make (S, term_range, exp_bound, vs[1 ])
10431041 else
@@ -1050,7 +1048,7 @@ function rand(rng::AbstractRNG, sp::SamplerTrivial{<:Make4{
10501048 S, term_range, exp_bound, v = sp[][1 : end ]
10511049 f = S ()
10521050 g = gens (S)
1053- R = base_ring (S)
1051+ R = coefficient_ring (S)
10541052 for i = 1 : rand (rng, term_range)
10551053 term = S (1 )
10561054 for j = 1 : length (g)
@@ -1198,7 +1196,7 @@ end
11981196function upgrade (S:: UniversalPolyRing{T} , pp:: MPoly{T} ) where {T}
11991197 alloc = length (pp. coeffs)
12001198 n = nvars (S) - nvars (parent (pp))
1201- ctx = MPolyBuildCtx (mpoly_ring (S))
1199+ ctx = MPolyBuildCtx (base_ring (S))
12021200 v0 = zeros (Int, n)
12031201 for (c, v) in zip (coefficients (pp), exponent_vectors (pp))
12041202 push_term! (ctx, c, vcat (v, v0))
@@ -1210,7 +1208,7 @@ end
12101208
12111209function upgrade (S:: UniversalPolyRing{T} , pp:: MPolyRingElem{T} ) where {T}
12121210 n = nvars (S) - nvars (parent (pp))
1213- ctx = MPolyBuildCtx (mpoly_ring (S))
1211+ ctx = MPolyBuildCtx (base_ring (S))
12141212 v0 = zeros (Int, n)
12151213 for (c, v) in zip (coefficients (pp), exponent_vectors (pp))
12161214 push_term! (ctx, c, vcat (v, v0))
@@ -1219,19 +1217,19 @@ function upgrade(S::UniversalPolyRing{T}, pp::MPolyRingElem{T}) where {T}
12191217end
12201218
12211219function (a:: UniversalPolyRing{T} )(b:: RingElement ) where {T <: RingElement }
1222- return a (base_ring (a)(b))
1220+ return a (coefficient_ring (a)(b))
12231221end
12241222
12251223function (a:: UniversalPolyRing{T} )() where {T <: RingElement }
1226- return UnivPoly {T} (mpoly_ring (a)(), a)
1224+ return UnivPoly {T} (base_ring (a)(), a)
12271225end
12281226
12291227function (a:: UniversalPolyRing{T} )(b:: Union{Integer, Rational, AbstractFloat} ) where {T <: RingElement }
1230- return UnivPoly {T} (mpoly_ring (a)(b), a)
1228+ return UnivPoly {T} (base_ring (a)(b), a)
12311229end
12321230
12331231function (a:: UniversalPolyRing{T} )(b:: T ) where {T <: RingElem }
1234- return UnivPoly {T} (mpoly_ring (a)(b), a)
1232+ return UnivPoly {T} (base_ring (a)(b), a)
12351233end
12361234
12371235function (S:: UniversalPolyRing{T} )(p:: UnivPoly{T} ) where {T <: RingElement }
@@ -1246,12 +1244,12 @@ end
12461244function (a:: UniversalPolyRing{T} )(b:: Vector{T} , m:: Vector{Vector{Int}} ) where {T <: RingElement }
12471245 if length (m) != 0
12481246 len = length (m[1 ])
1249- num = nvars (mpoly_ring (a))
1247+ num = nvars (base_ring (a))
12501248 if len != num
12511249 for i = 1 : length (m)
12521250 m[i] = vcat (m[i], zeros (Int, num - len))
12531251 end
12541252 end
12551253 end
1256- return UnivPoly {T} (mpoly_ring (a)(b, m), a)
1254+ return UnivPoly {T} (base_ring (a)(b, m), a)
12571255end
0 commit comments