@@ -65,7 +65,7 @@ function set_exponent_vector!(p::UnivPoly, i::Int, exps::Vector{Int})
6565 S = parent (p)
6666 len = length (exps)
6767 if len != nvars (parent (data (p)))
68- p. p = upgrade (S, data (p))
68+ p. p = AbstractAlgebra . _upgrade ( data (p), base_ring (S ))
6969 if len < nvars (S)
7070 exps = vcat (exps, zeros (Int, nvars (S) - len))
7171 end
@@ -96,7 +96,7 @@ function setcoeff!(p::UnivPoly, exps::Vector{Int}, c::T) where T <: RingElement
9696 S = parent (p)
9797 len = length (exps)
9898 if len != nvars (parent (data (p)))
99- p. p = upgrade (S, data (p))
99+ p. p = AbstractAlgebra . _upgrade ( data (p), base_ring (S ))
100100 if len < nvars (S)
101101 exps = vcat (exps, zeros (Int, nvars (S) - len))
102102 end
@@ -256,19 +256,16 @@ function _ensure_variables(S::UniversalPolyRing, v::Vector{<:VarName})
256256 end
257257 end
258258 if ! isempty (added_symbols)
259- new_symbols = vcat (current_symbols, added_symbols)
260- S. base_ring = AbstractAlgebra. polynomial_ring_only (coefficient_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
259+ S. base_ring = AbstractAlgebra. AbstractAlgebra. _add_gens (base_ring (S), added_symbols)
261260 end
262261 return idx
263262end
264263
265264function gen (S:: UniversalPolyRing , s:: VarName )
266265 i = findfirst (== (Symbol (s)), symbols (S))
267266 if i === nothing
268- new_symbols = copy (symbols (S))
269- push! (new_symbols, Symbol (s))
270- i = length (new_symbols)
271- S. base_ring = AbstractAlgebra. polynomial_ring_only (coefficient_ring (S), new_symbols; internal_ordering= internal_ordering (S), cached= false )
267+ S. base_ring = AbstractAlgebra. AbstractAlgebra. _add_gens (base_ring (S), [Symbol (s)])
268+ i = length (symbols (S))
272269 end
273270 return @inbounds gen (S, i)
274271end
@@ -639,10 +636,10 @@ function isless(a::UnivPoly{T}, b::UnivPoly{T}) where {T}
639636 s = data (a)
640637 t = data (b)
641638 if nvars (parent (s)) != num
642- s = upgrade (S, s )
639+ s = AbstractAlgebra . _upgrade (s, base_ring (S) )
643640 end
644641 if nvars (parent (t)) != num
645- t = upgrade (S, t )
642+ t = AbstractAlgebra . _upgrade (t, base_ring (S) )
646643 end
647644 return isless (s, t)
648645end
@@ -690,7 +687,7 @@ function deflate(p::UnivPoly{T}, shift::Vector{Int}, defl::Vector{Int}) where {T
690687 return UnivPoly {T} (deflate (pp, shift, defl), S)
691688 end
692689 if vlen > num
693- pp = upgrade (S, pp )
690+ pp = AbstractAlgebra . _upgrade (pp, base_ring (S) )
694691 num = nvars (parent (pp))
695692 end
696693 if vlen < num
@@ -714,7 +711,7 @@ function inflate(p::UnivPoly{T}, shift::Vector{Int}, defl::Vector{Int}) where {T
714711 return UnivPoly {T} (inflate (pp, shift, defl), S)
715712 end
716713 if vlen > num
717- pp = upgrade (S, pp )
714+ pp = AbstractAlgebra . _upgrade (pp, base_ring (S) )
718715 num = nvars (parent (pp))
719716 end
720717 if vlen < num
@@ -1186,16 +1183,6 @@ end
11861183#
11871184# ##############################################################################
11881185
1189- function upgrade (S:: UniversalPolyRing{T} , pp:: MPolyRingElem{T} ) where {T}
1190- n = nvars (S) - nvars (parent (pp))
1191- ctx = MPolyBuildCtx (base_ring (S))
1192- v0 = zeros (Int, n)
1193- for (c, v) in zip (coefficients (pp), exponent_vectors (pp))
1194- push_term! (ctx, c, vcat (v, v0))
1195- end
1196- return finish (ctx)
1197- end
1198-
11991186function (a:: UniversalPolyRing{T} )(b:: RingElement ) where {T <: RingElement }
12001187 return a (coefficient_ring (a)(b))
12011188end
@@ -1216,7 +1203,7 @@ function (S::UniversalPolyRing{T})(p::UnivPoly{T}) where {T <: RingElement}
12161203 parent (p) != = S && error (" Unable to coerce" )
12171204 n = nvars (S) - nvars (parent (data (p)))
12181205 if n != 0
1219- p = UnivPoly {T} (upgrade (S, data (p)), S)
1206+ p = UnivPoly {T} (AbstractAlgebra . _upgrade ( data (p), base_ring (S )), S)
12201207 end
12211208 return p
12221209end
0 commit comments