diff --git a/docs/src/ncpolynomial.md b/docs/src/ncpolynomial.md index 09b7247b64..32e35ccc24 100644 --- a/docs/src/ncpolynomial.md +++ b/docs/src/ncpolynomial.md @@ -48,7 +48,7 @@ In order to construct polynomials in AbstractAlgebra.jl, one must first construc polynomial ring itself. This is accomplished with the following constructor. ```@docs -polynomial_ring(R::NCRing, s::VarName; cached::Bool = true) +polynomial_ring(R::NCRing, s::VarName; cached::Bool=true) ``` A shorthand version of this function is provided: given a base ring `R`, we abbreviate diff --git a/src/Deprecations.jl b/src/Deprecations.jl index b52c13a30e..f1257c5e11 100644 --- a/src/Deprecations.jl +++ b/src/Deprecations.jl @@ -63,3 +63,17 @@ import .Generic: degree; @deprecate degree(f::Generic.MPoly{T}, i::Int, ::Type{V @deprecate change_base_ring(p::MPolyRingElem{T}, g, new_polynomial_ring) where {T<:RingElement} map_coefficients(g, p, parent = new_polynomial_ring) @deprecate mulmod(a::S, b::S, mod::Vector{S}) where {S <: MPolyRingElem} Base.divrem(a * b, mod)[2] @deprecate var"@attr"(__source__::LineNumberNode, __module__::Base.Module, expr::Expr) var"@attr"(__source__, __module__, :Any, expr) # delegate `@attr functionexpression` to `@attr Any functionexpression` (macros are just functions with this weird extra syntax) + +# deprecated during 0.44.* +PolyRing(R::NCRing) = polynomial_ring_only(R, :x; cached=false) +#@deprecate PolyRing(R::NCRing) poly_ring(R) + +#polynomial_ring_only(R::T, s::Symbol; cached::Bool=true) where T<:NCRing = +# dense_poly_ring_type(T)(R, s, 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) + +polynomial_ring_only(R::T, s::Symbol; cached::Bool=true) where T<:NCRing = + poly_ring(R, s; cached) +polynomial_ring_only(R::T, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=true) where T<:Ring = + poly_ring(R, s; internal_ordering, cached) diff --git a/src/MPoly.jl b/src/MPoly.jl index a6301d5c8a..8aed001f5c 100644 --- a/src/MPoly.jl +++ b/src/MPoly.jl @@ -1423,8 +1423,8 @@ julia> S, generators = polynomial_ring(ZZ, [:x, :y, :z]) (Multivariate polynomial ring in 3 variables over integers, AbstractAlgebra.Generic.MPoly{BigInt}[x, y, z]) ``` """ -function polynomial_ring(R::Ring, s::Vector{Symbol}; kw...) - S = polynomial_ring_only(R, s; kw...) +function polynomial_ring(R::Ring, s::Vector{Symbol}; cached::Bool=true, kw...) + S = poly_ring(R, s; cached, kw...) (S, gens(S)) end @@ -1508,10 +1508,10 @@ true :(@polynomial_ring) """ - polynomial_ring_only(R::Ring, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=true) + poly_ring(R::Ring, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=false) Like [`polynomial_ring(R::Ring, s::Vector{Symbol})`](@ref) but return only the multivariate polynomial ring. """ -polynomial_ring_only(R::T, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=true) where T<:Ring = +poly_ring(R::T, s::Vector{Symbol}; internal_ordering::Symbol=:lex, cached::Bool=false) where T<:Ring = mpoly_ring_type(T)(R, s, internal_ordering, cached) diff --git a/src/Matrix.jl b/src/Matrix.jl index 9ece50331e..dfce51b69b 100644 --- a/src/Matrix.jl +++ b/src/Matrix.jl @@ -2328,7 +2328,7 @@ end function det_df(M::MatrixElem{T}) where {T <: RingElement} R = base_ring(M) - S = PolyRing(R) + S = poly_ring(R) n = nrows(M) p = charpoly(S, M) d = coeff(p, 0) diff --git a/src/NCPoly.jl b/src/NCPoly.jl index 5e45040a29..75e24f05a6 100644 --- a/src/NCPoly.jl +++ b/src/NCPoly.jl @@ -732,7 +732,7 @@ rand(S::NCPolyRing, deg_range, v...) = rand(Random.GLOBAL_RNG, S, deg_range, v.. ############################################################################### @doc raw""" - polynomial_ring(R::NCRing, s::VarName = :x; cached::Bool = true) + polynomial_ring(R::NCRing, s::VarName = :x; cached::Bool=true) Given a base ring `R` and symbol/string `s` specifying how the generator (variable) should be printed, return a tuple `S, x` representing the new @@ -751,20 +751,16 @@ julia> S, y = polynomial_ring(R, :y) (Univariate polynomial ring in y over univariate polynomial ring, y) ``` """ -function polynomial_ring(R::NCRing, s::VarName =:x; kw...) - S = polynomial_ring_only(R, Symbol(s); kw...) +function polynomial_ring(R::NCRing, s::VarName = :x; cached::Bool=true, kw...) + S = polynomial_ring_only(R, Symbol(s); cached, kw...) (S, gen(S)) end @doc raw""" - polynomial_ring_only(R::NCRing, s::Symbol; cached::Bool=true) + poly_ring(R::NCRing, s::Symbol; cached::Bool=false) Like [`polynomial_ring(R::NCRing, s::Symbol)`](@ref) but return only the polynomial ring. """ -polynomial_ring_only(R::T, s::Symbol; cached::Bool=true) where T<:NCRing = +poly_ring(R::T, s::Symbol = :x; cached::Bool=false) where T<:NCRing = dense_poly_ring_type(T)(R, s, cached) - -# Simplified constructor - -PolyRing(R::NCRing) = polynomial_ring_only(R, :x; cached=false) diff --git a/src/Poly.jl b/src/Poly.jl index 2bacc1643f..6aa3ed7adf 100644 --- a/src/Poly.jl +++ b/src/Poly.jl @@ -2944,16 +2944,16 @@ function polynomial_to_power_sums(f::PolyRingElem{T}, n::Int=degree(f)) where T end @doc raw""" - power_sums_to_polynomial(P::Vector{T}; - parent::PolyRing{T}=PolyRing(parent(P[1])) where T <: RingElement -> PolyRingElem{T} + power_sums_to_polynomial(P::Vector{T}) where T <: RingElement -> PolyRingElem{T} + parent::PolyRing{T}=poly_ring(parent(P[1])) where T <: RingElement -> PolyRingElem{T} Uses the Newton (or Newton-Girard) identities to obtain the polynomial with given sums of powers of roots. The list must be nonempty and contain `degree(f)` entries where $f$ is the polynomial to be recovered. The list must start with the sum of first powers of the roots. """ -function power_sums_to_polynomial(P::Vector{T}; - parent::PolyRing{T}=PolyRing(parent(P[1]))) where T <: RingElement +function power_sums_to_polynomial(P::Vector{T}; + parent::PolyRing{T}=poly_ring(parent(P[1]))) where T <: RingElement return power_sums_to_polynomial(P, parent) end diff --git a/src/generic/Misc/Poly.jl b/src/generic/Misc/Poly.jl index 3d50943a27..77dfde5ef4 100644 --- a/src/generic/Misc/Poly.jl +++ b/src/generic/Misc/Poly.jl @@ -23,7 +23,7 @@ end ################################################################################ function factor(R::Field, f::PolyRingElem) - Rt = AbstractAlgebra.PolyRing(R) + Rt = AbstractAlgebra.poly_ring(R) f1 = change_base_ring(R, f; parent = Rt) return factor(f1) end @@ -70,7 +70,7 @@ end Returns the roots of the polynomial `f` in the field `R` as an array. """ function roots(R::Field, f::PolyRingElem) - Rt = AbstractAlgebra.PolyRing(R) + Rt = AbstractAlgebra.poly_ring(R) f1 = change_base_ring(R, f, parent = Rt) return roots(f1) end diff --git a/src/generic/Misc/Rings.jl b/src/generic/Misc/Rings.jl index 0c8de67caf..c05d3ba22e 100644 --- a/src/generic/Misc/Rings.jl +++ b/src/generic/Misc/Rings.jl @@ -12,7 +12,7 @@ function is_power(a::RingElem, n::Int) return true, a end R = parent(a) - Rt = AbstractAlgebra.PolyRing(R) + Rt = AbstractAlgebra.poly_ring(R) x = gen(Rt) r = roots(x^n - a) if length(r) == 0 diff --git a/src/generic/SparsePoly.jl b/src/generic/SparsePoly.jl index 13046c2e4b..ac2daca5ac 100644 --- a/src/generic/SparsePoly.jl +++ b/src/generic/SparsePoly.jl @@ -564,7 +564,7 @@ function gcd(a::SparsePoly{T}, b::SparsePoly{T}, ignore_content::Bool = false) w # if we are in univariate case, convert to dense, take gcd, convert back if constant_coeffs # convert polys to univariate dense - R = AbstractAlgebra.PolyRing(base_ring(base_ring(a))) + R = AbstractAlgebra.poly_ring(base_ring(base_ring(a))) f = R() g = R() fit!(f, reinterpret(Int, a.exps[a.length] + 1)) diff --git a/test/generic/Poly-test.jl b/test/generic/Poly-test.jl index 0e5ac0716e..fab461f133 100644 --- a/test/generic/Poly-test.jl +++ b/test/generic/Poly-test.jl @@ -22,8 +22,8 @@ end @testset "Generic.Poly.constructors" begin - S1 = PolyRing(ZZ) - S2 = PolyRing(ZZ) + S1 = AbstractAlgebra.poly_ring(ZZ) + S2 = AbstractAlgebra.poly_ring(ZZ) @test S1 !== S2 @test isa(S1, Generic.PolyRing)