Skip to content

Commit d76bdf0

Browse files
authored
Add coefficient_ring_type (#2086)
1 parent 86ad3de commit d76bdf0

17 files changed

+26
-6
lines changed

src/FreeAssociativeAlgebra.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#
1111
###############################################################################
1212

13+
coefficient_ring_type(T::Type{<:FreeAssociativeAlgebra}) = base_ring_type(T)
1314
coefficient_ring(R::FreeAssociativeAlgebra{T}) where T <: RingElement = base_ring(R)
1415

1516
function is_domain_type(::Type{S}) where {T <: RingElement, S <: FreeAssociativeAlgebraElem{T}}

src/MPoly.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
base_ring_type(::Type{<:MPolyRing{T}}) where T<:RingElement = parent_type(T)
1414

15+
coefficient_ring_type(T::Type{<:MPolyRing}) = base_ring_type(T)
1516
coefficient_ring(R::MPolyRing) = base_ring(R)
1617

1718
@doc raw"""

src/NCPoly.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
base_ring_type(::Type{<:NCPolyRing{T}}) where T<:NCRingElement = parent_type(T)
1414

15+
coefficient_ring_type(T::Type{<:NCPolyRing}) = base_ring_type(T)
1516
coefficient_ring(R::NCPolyRing) = base_ring(R)
1617

1718
function is_exact_type(a::Type{T}) where {S <: NCRingElem, T <: NCPolyRingElem{S}}

src/Poly.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
base_ring_type(::Type{<:PolyRing{T}}) where T<:RingElement = parent_type(T)
1414

15+
coefficient_ring_type(T::Type{<:PolyRing}) = base_ring_type(T)
1516
coefficient_ring(R::PolyRing) = base_ring(R)
1617

1718
dense_poly_type(::Type{T}) where T<:RingElement = Generic.Poly{T}

src/exports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export check_parent
154154
export codomain
155155
export coeff
156156
export coefficient_ring
157+
export coefficient_ring_type
157158
export coefficients
158159
export coefficients_of_univariate
159160
export collength

src/fundamental_interface.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ base_ring_type(T::DataType) = throw(MethodError(base_ring_type, (T,)))
130130
# generic coefficient_ring method
131131
coefficient_ring(x::NCRingElement) = coefficient_ring(parent(x))
132132

133+
coefficient_ring_type(x) = coefficient_ring_type(typeof(x))
134+
coefficient_ring_type(x::Type{<:NCRingElement}) = coefficient_ring_type(parent_type(x))
135+
coefficient_ring_type(x::Type{<:ModuleElem}) = coefficient_ring_type(parent_type(x))
136+
coefficient_ring_type(x::Type{<:Ideal}) = coefficient_ring_type(parent_type(x))
137+
coefficient_ring_type(T::DataType) = throw(MethodError(coefficient_ring_type, (T,)))
138+
133139
###############################################################################
134140
#
135141
# Special elements

src/generic/LaurentMPoly.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ elem_type(::Type{LaurentMPolyWrapRing{T, PR}}) where {T, PR} =
1818
parent(p::LaurentMPolyWrap) = p.parent
1919

2020
base_ring_type(::Type{<:LaurentMPolyWrapRing{T}}) where {T} = parent_type(T)
21-
2221
base_ring(R::LaurentMPolyWrapRing) = base_ring(R.mpolyring)::base_ring_type(R)
2322

23+
coefficient_ring_type(::Type{LaurentMPolyWrapRing{T, PR}}) where {T, PR} = coefficient_ring_type(PR)
2424
coefficient_ring(R::LaurentMPolyWrapRing) = coefficient_ring(R.mpolyring)
2525

2626
symbols(R::LaurentMPolyWrapRing) = symbols(R.mpolyring)
2727

2828
number_of_variables(R::LaurentMPolyWrapRing) = number_of_variables(R.mpolyring)
29-
3029
number_of_generators(R::LaurentMPolyWrapRing) = number_of_variables(R.mpolyring)
3130

3231
characteristic(R::LaurentMPolyWrapRing) = characteristic(R.mpolyring)

src/generic/LaurentPoly.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ elem_type(::Type{LaurentPolyWrapRing{T, PR}}) where {T, PR} =
1717

1818
parent(p::LaurentPolyWrap) = p.parent
1919

20-
coefficient_ring(R::LaurentPolyWrapRing) = coefficient_ring(R.polyring)
21-
2220
base_ring_type(::Type{<:LaurentPolyWrapRing{T}}) where {T} = parent_type(T)
23-
2421
base_ring(R::LaurentPolyWrapRing) = base_ring(R.polyring)::base_ring_type(R)
2522

23+
coefficient_ring_type(::Type{LaurentPolyWrapRing{T, PR}}) where {T, PR} = coefficient_ring_type(PR)
24+
coefficient_ring(R::LaurentPolyWrapRing) = coefficient_ring(R.polyring)
25+
2626
var(R::LaurentPolyWrapRing) = var(R.polyring)
2727

2828
symbols(R::LaurentPolyWrapRing) = symbols(R.polyring)

src/generic/UnivPoly.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
###############################################################################
1212

1313
base_ring_type(::Type{<:UniversalPolyRing{T}}) where T = parent_type(T)
14-
1514
base_ring(S::UniversalPolyRing) = S.base_ring::base_ring_type(S)
1615

16+
coefficient_ring_type(T::Type{<:UniversalPolyRing}) = base_ring_type(T)
1717
coefficient_ring(S::UniversalPolyRing) = base_ring(S)
1818

1919
function is_domain_type(::Type{<:UnivPoly{S}}) where {S <: RingElement}

src/generic/imports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ import ..AbstractAlgebra: check_parent
108108
import ..AbstractAlgebra: codomain
109109
import ..AbstractAlgebra: coeff
110110
import ..AbstractAlgebra: coefficient_ring
111+
import ..AbstractAlgebra: coefficient_ring_type
111112
import ..AbstractAlgebra: coefficients
112113
import ..AbstractAlgebra: coefficients_of_univariate
113114
import ..AbstractAlgebra: compose

0 commit comments

Comments
 (0)