Skip to content

Commit

Permalink
Add base_ring_type methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed May 1, 2024
1 parent d2636fb commit 6378a21
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 3 deletions.
1 change: 1 addition & 0 deletions experimental/GModule/Cohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ _rank(M) = rank(M)

Oscar.dim(C::GModule) = _rank(C.M)
Oscar.base_ring(C::GModule) = base_ring(C.M)
Oscar.base_ring_type(::Type{GModule{gT, mT}}) where {gT, mT} = base_ring_type(mT)
Oscar.group(C::GModule) = C.G

###########################################################
Expand Down
2 changes: 2 additions & 0 deletions experimental/LinearQuotients/src/cox_rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

base_ring(HBB::HomBasisBuilder) = HBB.R

base_ring_type(::Type{HomBasisBuilder{RingType, RingElemType}}) where {RingType, RingElemType} = RingType

power_product_cache(HBB::HomBasisBuilder) = HBB.C

group(HBB::HomBasisBuilder) = HBB.G
Expand Down
1 change: 1 addition & 0 deletions experimental/LinearQuotients/src/linear_quotients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ end

group(L::LinearQuotient) = L.group
base_ring(L::LinearQuotient) = base_ring(group(L))
base_ring_type(::Type{LinearQuotient{S, T}}) where {S, T} = base_ring_type(MatrixGroup{S, T})

function fixed_root_of_unity(L::LinearQuotient)
if isdefined(L, :root_of_unity)
Expand Down
4 changes: 4 additions & 0 deletions src/Groups/matrices/MatGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ Return the base ring of the underlying matrix of `x`.
"""
base_ring(x::MatrixGroupElem) = x.parent.ring

base_ring_type(::Type{<:MatrixGroupElem{RE}}) where {RE} = parent_type(RE)

parent(x::MatrixGroupElem) = x.parent

"""
Expand Down Expand Up @@ -491,6 +493,8 @@ Return the base ring of the matrix group `G`.
"""
base_ring(G::MatrixGroup{RE}) where RE <: RingElem = G.ring::parent_type(RE)

base_ring_type(::Type{<:MatrixGroup{RE}}) where {RE} = parent_type(RE)

"""
degree(G::MatrixGroup)
Expand Down
2 changes: 2 additions & 0 deletions src/Modules/ModulesGraded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,8 @@ Return the underlying ring of `F`.
"""
base_ring(F::FreeMod_dec) = forget_decoration(F).R

base_ring_type(::Type{FreeMod_dec{T}}) where {T} = base_ring_type(FreeMod{T})

@doc raw"""
rank(F::FreeMod_dec)
Expand Down
2 changes: 2 additions & 0 deletions src/Modules/UngradedModules/ModuleGens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ function base_ring(M::ModuleGens)
return base_ring(M.F)
end

base_ring_type(::Type{ModuleGens{T}}) where {T} = base_ring_type(FreeMod{T})

@doc raw"""
singular_generators(M::ModuleGens)
Expand Down
3 changes: 3 additions & 0 deletions src/Modules/UngradedModules/SubModuleOfFreeModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ function base_ring(M::SubModuleOfFreeModule)
return base_ring(M.F)
end

base_ring_type(::Type{SubModuleOfFreeModule{T}}) where {T} = base_ring_type(FreeMod{T})


@doc raw"""
ambient_free_module(M::SubModuleOfFreeModule)
Expand Down
4 changes: 3 additions & 1 deletion src/Modules/UngradedModules/SubquoModuleElem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,9 @@ number_of_generators(M::SubquoModule) = number_of_generators(M.sub)
Given an `R`-module `M`, return `R`.
"""
base_ring(M::SubquoModule) = base_ring(M.F)::base_ring_type(M.F)
base_ring(M::SubquoModule) = base_ring(M.F)::base_ring_type(M)

base_ring_type(::Type{SubquoModule{T}}) where {T} = base_ring_type(FreeMod{T})

@doc raw"""
zero(M::SubquoModule)
Expand Down
1 change: 1 addition & 0 deletions src/Rings/AlgClosureFp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ end

base_field(A::AlgClosure) = A.k
base_ring(A::AlgClosure) = A.k
base_ring_type(::Type{AlgClosure{T}}) where {T} = T
characteristic(k::AlgClosure) = characteristic(base_field(k))

struct AlgClosureElem{T} <: FieldElem
Expand Down
2 changes: 2 additions & 0 deletions src/Rings/FractionalIdeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ function base_ring(a::FractionalIdeal)
return base_ring(numerator(a))
end

base_ring_type(::Type{FractionalIdeal{S, T}}) where {S, T} = base_ring_type(S)

function iszero(a::FractionalIdeal)
return iszero(numerator(a))
end
Expand Down
4 changes: 4 additions & 0 deletions src/Rings/FreeAssAlgIdeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ function base_ring(I::FreeAssAlgIdeal{T}) where T
return I.gens.Ox::parent_type(T)
end

function base_ring_type(::Type{<:FreeAssAlgIdeal{T}}) where T
return parent_type(T)
end

function number_of_generators(a::FreeAssAlgIdeal)
return length(a.gens)
end
Expand Down
2 changes: 2 additions & 0 deletions src/Rings/Laurent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ end

base_ring(I::LaurentMPolyIdeal{T}) where {T} = I.R::parent_type(T)

base_ring_type(::Type{LaurentMPolyIdeal{T}}) where {T} = parent_type(T)

gens(I::LaurentMPolyIdeal) = I.gens

@enable_all_show_via_expressify LaurentMPolyIdeal
Expand Down
1 change: 1 addition & 0 deletions src/Rings/MPolyQuo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ gens(Q::MPolyQuoRing) = [Q(x) for x = gens(base_ring(Q))]
number_of_generators(Q::MPolyQuoRing) = number_of_generators(base_ring(Q))
gen(Q::MPolyQuoRing, i::Int) = Q(gen(base_ring(Q), i))
base_ring(Q::MPolyQuoRing) = base_ring(Q.I)
base_ring_type(::Type{MPolyQuoRing{S}}) where {S} = base_ring_type(S)
coefficient_ring(Q::MPolyQuoRing) = coefficient_ring(base_ring(Q))
modulus(Q::MPolyQuoRing) = Q.I
oscar_groebner_basis(Q::MPolyQuoRing) = _groebner_basis(Q) && return Q.I.gb[Q.ordering].O
Expand Down
2 changes: 2 additions & 0 deletions src/Rings/PBWAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ function base_ring(a::PBWAlgIdeal)
return a.basering
end

base_ring_type(::Type{PBWAlgIdeal{D, T, S}}) where {D, T, S} = PBWAlgRing{T, S}

function number_of_generators(a::PBWAlgIdeal)
return number_of_generators(a.sdata)
end
Expand Down
4 changes: 3 additions & 1 deletion src/Rings/PBWAlgebraQuo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ coefficient_ring(a::PBWAlgQuoElem) = coefficient_ring(parent(a))

modulus(Q::PBWAlgQuo) = Q.I

base_ring(Q::PBWAlgQuo) = Q.I.basering
base_ring(Q::PBWAlgQuo) = base_ring(Q.I)

base_ring_type(::Type{PBWAlgQuo{T, S}}) where {T, S} = base_ring_type(PBWAlgIdeal{0, T, S})

base_ring(a::PBWAlgQuoElem) = base_ring(parent(a))

Expand Down
1 change: 1 addition & 0 deletions src/Rings/lazypolys.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ end

base_ring(F::LazyPolyRing) = F.base_ring

base_ring_type(::Type{LazyPolyRing{T, R}}) where {T,R} = R

## LazyPoly

Expand Down
1 change: 1 addition & 0 deletions src/Rings/mpoly-graded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,7 @@ function homogeneous_component(a::MPolyDecRingElem, g::Vector{<:IntegerUnion})
end

base_ring(W::MPolyDecRing) = base_ring(forget_decoration(W))
base_ring_type(::Type{MPolyDecRing{T, S}}) where {T, S} = base_ring_type(S)
number_of_generators(W::MPolyDecRing) = number_of_generators(forget_decoration(W))
gens(W::MPolyDecRing) = map(W, gens(forget_decoration(W)))
gen(W::MPolyDecRing, i::Int) = W(gen(forget_decoration(W), i))
Expand Down
2 changes: 2 additions & 0 deletions src/Rings/mpoly-ideals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,8 @@ function base_ring(I::MPolyIdeal{S}) where {S}
return I.gens.Ox::parent_type(S)
end

base_ring_type(::Type{MPolyIdeal{S}}) where {S} = parent_type(S)

#######################################################
@doc raw"""
coefficient_ring(I::MPolyIdeal)
Expand Down
1 change: 1 addition & 0 deletions src/Rings/mpoly-local.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function Base.show(io::IO, w::MPolyRingElemLoc)
end

base_ring(R::MPolyRingLoc) = R.base_ring
base_ring_type(::Type{MPolyRingLoc{T}}) where {T} = MPolyRing{T}
symbols(R::MPolyRingLoc) = symbols(base_ring(R))
number_of_variables(R::MPolyRingLoc) = number_of_variables(base_ring(R))
parent(f::MPolyRingElemLoc) = f.parent
Expand Down
2 changes: 2 additions & 0 deletions src/Rings/mpoly-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ end

### required getter functions
base_ring(W::MPolyLocRing) = W.R
base_ring_type(::Type{MPolyLocRing{BRT, BRET, RT, RET, MST}}) where {BRT, BRET, RT, RET, MST} = BRT
inverted_set(W::MPolyLocRing) = W.S

### additional getter functions
Expand Down Expand Up @@ -1308,6 +1309,7 @@ end
gens(I::MPolyLocalizedIdeal) = copy(I.gens)
gen(I::MPolyLocalizedIdeal, i::Int) = I.gens[i]
base_ring(I::MPolyLocalizedIdeal) = I.W
base_ring_type(::Type{MPolyLocalizedIdeal{LRT, LRET}}) where {LRT, LRET} = LRT

### type getters
ideal_type(::Type{MPolyLocalizedRingType}) where {MPolyLocalizedRingType<:MPolyLocRing} = MPolyLocalizedIdeal{MPolyLocalizedRingType, elem_type(MPolyLocalizedRingType)}
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/mpolyquo-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ coefficient_ring_elem_type(::Type{MPolyQuoLocRing{BRT, BRET, RT, RET, MST}}) whe
coefficient_ring_elem_type(L::MPolyQuoLocRing{BRT, BRET, RT, RET, MST}) where {BRT, BRET, RT, RET, MST} = coefficient_ring_elem_type(typeof(L))

base_ring_type(::Type{MPolyQuoLocRing{BRT, BRET, RT, RET, MST}}) where {BRT, BRET, RT, RET, MST} = RT
base_ring_type(L::MPolyQuoLocRing{BRT, BRET, RT, RET, MST}) where {BRT, BRET, RT, RET, MST} = base_ring_type(typeof(L))
base_ring_elem_type(::Type{MPolyQuoLocRing{BRT, BRET, RT, RET, MST}}) where {BRT, BRET, RT, RET, MST} = RET
base_ring_elem_type(L::MPolyQuoLocRing{BRT, BRET, RT, RET, MST}) where {BRT, BRET, RT, RET, MST} = base_ring_elem_type(typeof(L))

Expand Down Expand Up @@ -1711,6 +1710,7 @@ end
gens(I::MPolyQuoLocalizedIdeal) = copy(I.gens)
gen(I::MPolyQuoLocalizedIdeal, i::Int) = I.gens[i]
base_ring(I::MPolyQuoLocalizedIdeal) = I.W
base_ring_type(::Type{MPolyQuoLocalizedIdeal{LRT, LET, MPT}}) where {LRT, LET, MPT} = LRT

### additional getter functions
map_from_base_ring(I::MPolyQuoLocalizedIdeal) = I.map_from_base_ring
Expand Down
4 changes: 4 additions & 0 deletions src/Rings/orderings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ end

base_ring(a::MonomialOrdering) = a.R

base_ring_type(::Type{MonomialOrdering{S}}) where {S} = S

@doc raw"""
support(o::MonomialOrdering)
Expand Down Expand Up @@ -1770,6 +1772,8 @@ end

base_ring(a::ModuleOrdering) = a.M

base_ring_type(::Type{ModuleOrdering{S}}) where {S} = S

mutable struct ModProdOrdering <: AbsModOrdering
a::AbsOrdering
b::AbsOrdering
Expand Down
2 changes: 2 additions & 0 deletions src/Rings/slpolys.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ SLPolyRing(r::Ring, v::Pair{<:VarName,

base_ring(S::SLPolyRing) = S.base_ring

base_ring_type(::Type{SLPolyRing{T,R}}) where {T,R} = R

elem_type(::Type{S}) where {T,S<:SLPolyRing{T}} = SLPoly{T,S}

symbols(S::SLPolyRing) = S.S
Expand Down
1 change: 1 addition & 0 deletions test/Rings/integer-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ end

### required getter functions
base_ring(W::FmpzLocalizedRing) = ZZ::ZZRing
base_ring_type(::Type{<:FmpzLocalizedRing}) = ZZRing
inverted_set(W::FmpzLocalizedRing{MultSetType}) where {MultSetType} = W.S::MultSetType

### required extensions of the localization function
Expand Down
1 change: 1 addition & 0 deletions test/Rings/nmod-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ end

### required getter functions
base_ring(W::NmodLocalizedRing) = W.R::zzModRing
base_ring_type(::Type{<:NmodLocalizedRing}) = zzModRing
inverted_set(W::NmodLocalizedRing{MultSetType}) where {MultSetType} = W.S::MultSetType

### required extension of the localization function
Expand Down

0 comments on commit 6378a21

Please sign in to comment.