Skip to content

Commit

Permalink
Add many base_ring_type methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Apr 30, 2024
1 parent 004a31c commit 2ee21e8
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/AlgAss/AlgAss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ end

base_ring(A::StructureConstantAlgebra{T}) where {T} = A.base_ring::parent_type(T)

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

has_one(A::StructureConstantAlgebra) = A.has_one

iszero(A::StructureConstantAlgebra) = A.iszero
Expand Down
6 changes: 4 additions & 2 deletions src/AlgAss/AlgGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ denominator_of_multiplication_table(A::GroupAlgebra{QQFieldElem}) = one(ZZ)

base_ring(A::GroupAlgebra{T}) where {T} = A.base_ring::parent_type(T)

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

Generic.dim(A::GroupAlgebra) = size(multiplication_table(A, copy = false), 1)

elem_type(::Type{GroupAlgebra{T, S, R}}) where {T, S, R} = GroupAlgebraElem{T, GroupAlgebra{T, S, R}}
Expand All @@ -16,8 +18,8 @@ order_type(::GroupAlgebra{QQFieldElem, S, R}) where { S, R } = AlgAssAbsOrd{Grou

order_type(::Type{GroupAlgebra{QQFieldElem, S, R}}) where { S, R } = AlgAssAbsOrd{GroupAlgebra{QQFieldElem, S, R}, elem_type(GroupAlgebra{QQFieldElem, S, R})}

order_type(::GroupAlgebra{T, S, R}) where { T <: NumFieldElem, S, R } = AlgAssRelOrd{T, fractional_ideal_type(order_type(parent_type(T)))}
order_type(::Type{GroupAlgebra{T, S, R}}) where { T <: NumFieldElem, S, R } = AlgAssRelOrd{T, fractional_ideal_type(order_type(parent_type(T)))}
order_type(::GroupAlgebra{T, S, R}) where { T <: NumFieldElem, S, R } = AlgAssRelOrd{T, fractional_ideal_type(order_type(parent_type(T))), GroupAlgebra{T, S, R}}
order_type(::Type{GroupAlgebra{T, S, R}}) where { T <: NumFieldElem, S, R } = AlgAssRelOrd{T, fractional_ideal_type(order_type(parent_type(T))), GroupAlgebra{T, S, R}}

@doc raw"""
group(A::GroupAlgebra) -> Group
Expand Down
2 changes: 2 additions & 0 deletions src/AlgAss/AlgMat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ dim(A::MatAlgebra) = A.dim

base_ring(A::MatAlgebra{T, S}) where {T, S} = A.base_ring::parent_type(T)

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

coefficient_ring(A::MatAlgebra) = A.coefficient_ring

basis(A::MatAlgebra) = A.basis
Expand Down
2 changes: 2 additions & 0 deletions src/AlgAss/AlgQuat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ dim(A::QuaternionAlgebra) = 4

base_ring(A::QuaternionAlgebra{T}) where {T} = A.base_ring::parent_type(T)

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

multiplication_table(A::QuaternionAlgebra; copy = false) = A.mult_table

standard_form(A::QuaternionAlgebra) = A.std
Expand Down
2 changes: 2 additions & 0 deletions src/AlgAssAbsOrd/Order.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ _algebra(O::AlgAssAbsOrd) = algebra(O)

base_ring(O::AlgAssAbsOrd) = FlintZZ

base_ring_type(::Type{AlgAssAbsOrd}) = ZZRing

@doc raw"""
is_commutative(O::AlgAssAbsOrd) -> Bool
Expand Down
2 changes: 2 additions & 0 deletions src/AlgAssRelOrd/Order.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Returns an order $R$ in the base ring of the algebra of $O$, such that $O$ is an
"""
base_ring(O::AlgAssRelOrd) = order(basis_pmatrix(O, copy = false).coeffs[1])

base_ring_type(::Type{<:AlgAssRelOrd{S, T, U}}) where {S, T, U} = order_type(base_ring_type(U))

@doc raw"""
is_commutative(O::AlgAssRelOrd) -> Bool
Expand Down
2 changes: 2 additions & 0 deletions src/GenOrd/GenOrd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ end

base_ring(O::GenOrd) = O.R

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

coefficient_ring(O::GenOrd) = O.R

field(O::GenOrd) = O.F
Expand Down
2 changes: 2 additions & 0 deletions src/GrpAb/ChainComplex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ map_type(C::ComplexOfMorphisms) = valtype(C.maps)

Hecke.base_ring(::FinGenAbGroup) = ZZ

Hecke.base_ring_type(::Type{FinGenAbGroup}) = ZZRing

function pres_show(io::IO, C::ComplexOfMorphisms)
name_mod = String[]
rank_mod = Int[]
Expand Down
4 changes: 4 additions & 0 deletions src/GrpAb/stable_sub.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ function base_ring(M::ZpnGModule)
return M.R
end

function base_ring_type(::Type{ZpnGModule})
return Nemo.zzModRing
end

function show(io::IO, M::ZpnGModule)
print(io, "Module over Z/", M.R.n, "Z with structure ", M.V)
end
Expand Down
2 changes: 2 additions & 0 deletions src/Misc/FactoredElem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ parent(x::FacElem) = x.parent

base_ring(x::FacElemMon) = x.base_ring

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

base_ring(x::FacElem) = base_ring(parent(x))

base(x::FacElem) = keys(x.fac)
Expand Down
2 changes: 2 additions & 0 deletions src/Misc/PIDIdeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ end

base_ring(x::PIDIdeal) = parent(x.gen)

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

_can_canonicalize(::Type{ZZRingElem}) = true

_can_canonicalize(::Type{<:PolyRingElem{T}}) where {T <: FieldElem} = true
Expand Down
2 changes: 2 additions & 0 deletions src/Misc/PseudoPolynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ iszero(f::PseudoPoly) = iszero(polynomial(f))

base_ring(f::PseudoPoly) = parent(polynomial(f))

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

pseudo_polynomial(f, A) = PseudoPoly(f, A)

polynomial(f::PseudoPoly) = f.poly
Expand Down
8 changes: 6 additions & 2 deletions src/NumField/Embedded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ elem_type(::Type{EmbeddedNumField{S, E}}) where {S, E} = EmbeddedNumFieldElem{el

parent_type(::Type{EmbeddedNumFieldElem{T}}) where {T} = EmbeddedNumField{parent_type(T), embedding_type(parent_type(T))}

base_ring(::EmbeddedNumField) = FlintQQ

base_ring_type(::Type{<:EmbeddedNumField}) = QQField

data(x::EmbeddedNumFieldElem) = x.element

function embedded_field(K::SimpleNumField, i::NumFieldEmb)
Expand Down Expand Up @@ -213,8 +217,8 @@ is_negative(x::EmbeddedNumFieldElem) = x < 0
#
################################################################################

function sign(x::EmbeddedNumFieldElem)
if is_zero(x)
function sign(x::EmbeddedNumFieldElem)
if is_zero(x)
return x
end
if x > 0
Expand Down
2 changes: 2 additions & 0 deletions src/NumField/NfAbs/NonSimple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

@inline base_ring(K::AbsNonSimpleNumField) = FlintQQ

@inline base_ring_type(K::AbsNonSimpleNumField) = QQField

@inline base_field(K::AbsNonSimpleNumField) = FlintQQ

@inline degree(K::AbsNonSimpleNumField) = K.degree
Expand Down
4 changes: 4 additions & 0 deletions src/NumFieldOrd/NfOrd/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ This function returns the $R$ that was used to defined $M$.
"""
base_ring(M::PMat{T, S}) where {T, S} = nrows(M) >= 1 ? order(M.coeffs[1]) : M.base_ring::order_type(parent_type(T))

base_ring_type(::Type{PMat{T, S}}) where {T, S} = order_type(parent_type(T))

function pseudo_matrix(m::AbstractAlgebra.MatElem{T}, c::Vector{S}) where {T, S}
# sanity checks
@assert nrows(m) == length(c)
Expand Down Expand Up @@ -1577,6 +1579,8 @@ end

base_ring(M::ModDed) = M.base_ring

base_ring_type(::Type{ModDed}) = AbsSimpleNumFieldOrder

function show(io::IO, M::ModDed)
print(io, "Module over $(M.base_ring) with defining pseudo-matrix")
for i in 1:nrows(M.pmatrix.matrix)
Expand Down
4 changes: 3 additions & 1 deletion src/NumFieldOrd/NfOrd/NfOrd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ fractional_ideal_type(::AbsNumFieldOrder{S, T}) where {S, T} = AbsSimpleNumField

fractional_ideal_type(::Type{AbsNumFieldOrder{S, T}}) where {S, T} = AbsSimpleNumFieldOrderFractionalIdeal

Nemo.base_ring(::AbsNumFieldOrder) = FlintZZ
base_ring(::AbsNumFieldOrder) = FlintZZ

base_ring_type(::Type{<:AbsNumFieldOrder}) = ZZRing

@doc raw"""
parent(O::AbsNumFieldOrder) -> AbsNumFieldOrderSet
Expand Down
2 changes: 2 additions & 0 deletions src/NumFieldOrd/NfOrd/ResidueRing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ end

base_ring(Q::AbsOrdQuoRing) = Q.base_ring

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

ideal(Q::AbsOrdQuoRing) = Q.ideal

basis_matrix(Q::AbsOrdQuoRing) = Q.basis_matrix
Expand Down
2 changes: 2 additions & 0 deletions src/NumFieldOrd/NfRelOrd/NfRelOrd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ parent(O::RelNumFieldOrder) = O.parent

base_ring(O::RelNumFieldOrder) = order(pseudo_basis(O, copy = false)[1][2])

base_ring_type(::Type{RelNumFieldOrder{T, S, U}}) where {T, S, U} = order_type(base_ring_type(NumField{T}))

elem_type(::Type{RelNumFieldOrder{T, S, U}}) where {T, S, U} = RelNumFieldOrderElem{T, U}

ideal_type(::RelNumFieldOrder{T, S, U}) where {T, S, U} = RelNumFieldOrderIdeal{T, S, U}
Expand Down
2 changes: 2 additions & 0 deletions src/NumFieldOrd/NfRelOrd/ResidueRing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ end

base_ring(Q::RelOrdQuoRing) = Q.base_ring

base_ring_type(::Type{RelOrdQuoRing{T1, T2, T3}}) where {T1, T2, T3} = T1

ideal(Q::RelOrdQuoRing) = Q.ideal

basis_pmatrix(Q::RelOrdQuoRing) = Q.basis_pmatrix
Expand Down
3 changes: 3 additions & 0 deletions src/QuadForm/Quad/Spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,7 @@ end
local_quad_space_class(K, prime::IntegerUnion, n, d, hasse_inv, k)=local_quad_space_class(K,ideal(ZZ,prime),n,d,hasse_inv,k)

base_ring(G::LocalQuadSpaceCls) = G.K
base_ring_type(::Type{LocalQuadSpaceCls{S, T, U}}) where {S, T, U} = S
prime(G::LocalQuadSpaceCls) = G.p

@doc raw"""
Expand Down Expand Up @@ -2406,6 +2407,8 @@ det_ndeg(g::QuadSpaceCls) = det_nondegenerate_part(g)

base_ring(g::QuadSpaceCls) = g.K

base_ring_type(::Type{LocalQuadSpaceCls{S, T, U, V}}) where {S, T, U, V} = S

@doc raw"""
dim_radical(g::QuadSpaceCls) -> Int
Expand Down
2 changes: 2 additions & 0 deletions src/QuadForm/Quad/ZLattices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ambient_space(L::ZZLat) = L.space

base_ring(L::ZZLat) = FlintZZ

base_ring_type(::Type{ZZLat}) = ZZRing

base_field(L::ZZLat) = base_ring(gram_matrix(ambient_space(L)))

################################################################################
Expand Down
2 changes: 2 additions & 0 deletions src/QuadForm/QuadBin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ end

base_ring(f::QuadBin{T}) where {T} = f.base_ring::parent_type(T)

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

###############################################################################
#
# Coefficients
Expand Down
2 changes: 2 additions & 0 deletions src/RCF/class_fields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ function base_ring(A::ClassField)
return order(codomain(A.rayclassgroupmap))
end

base_ring_type(A::ClassField) = AbsNumFieldOrder{AbsSimpleNumField, AbsSimpleNumFieldElem}

@doc raw"""
base_field(A::ClassField)
Expand Down
2 changes: 2 additions & 0 deletions src/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ end

base_ring(A::SMatSpace{T}) where {T} = A.base_ring::parent_type(T)

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

parent(A::SMat) = SMatSpace(base_ring(A), A.r, A.c)

base_ring(A::SMat{T}) where {T} = A.base_ring::parent_type(T)
Expand Down
2 changes: 2 additions & 0 deletions src/Sparse/Row.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ function base_ring(A::SRow{T}) where {T}
end
end

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

==(x::SRow{T}, y::SRow{T}) where {T} = (x.pos == y.pos) && (x.values == y.values)

################################################################################
Expand Down

0 comments on commit 2ee21e8

Please sign in to comment.