Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/ncpolynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/Deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions src/MPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 5 additions & 9 deletions src/NCPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
8 changes: 4 additions & 4 deletions src/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/generic/Misc/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/generic/Misc/Rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/generic/SparsePoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions test/generic/Poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading