@@ -20,6 +20,10 @@ base_ring_type(::Type{QuotientModule{T}}) where T <: RingElement = parent_type(T
2020
2121base_ring (N:: QuotientModule{T} ) where T <: RingElement = N. base_ring:: parent_type (T)
2222
23+ coefficient_ring_type (T:: Type{QuotientModule} ) = base_ring_type (T)
24+
25+ coefficient_ring (N:: QuotientModule ) = base_ring (N)
26+
2327number_of_generators (N:: QuotientModule{T} ) where T <: RingElement = length (N. gen_cols)
2428
2529gens (N:: QuotientModule{T} ) where T <: RingElement = elem_type (N)[gen (N, i) for i = 1 : ngens (N)]
@@ -28,7 +32,7 @@ rank(M::QuotientModule{T}) where T <: FieldElement = dim(M)
2832
2933function gen (N:: QuotientModule{T} , i:: Int ) where T <: RingElement
3034 @boundscheck 1 <= i <= ngens (N) || throw (ArgumentError (" generator index out of range" ))
31- R = base_ring (N)
35+ R = coefficient_ring (N)
3236 mat = matrix (R, 1 , ngens (N),
3337 [(j == i ? one (R) : zero (R)) for j = 1 : ngens (N)])
3438 return QuotientModuleElem {T} (N, mat)
@@ -70,15 +74,15 @@ function show(io::IO, N::QuotientModule{T}) where T <: RingElement
7074 @show_name (io, N)
7175 @show_special (io, N)
7276 print (io, " Quotient module over " )
73- print (terse (pretty (io)), Lowercase (), base_ring (N))
77+ print (terse (pretty (io)), Lowercase (), coefficient_ring (N))
7478 show_gens_rels (io, N)
7579end
7680
7781function show (io:: IO , N:: QuotientModule{T} ) where T <: FieldElement
7882 @show_name (io, N)
7983 @show_special (io, N)
8084 print (io, " Quotient space over " )
81- print (terse (pretty (io)), Lowercase (), base_ring (N))
85+ print (terse (pretty (io)), Lowercase (), coefficient_ring (N))
8286 show_gens_rels (io, N)
8387end
8488
114118
115119# Reduce the vector v by the relations vrels starting at column start of v
116120function reduce_mod_rels (v:: AbstractAlgebra.MatElem{T} , vrels:: Vector{<:AbstractAlgebra.MatElem{T}} , start:: Int ) where T <: RingElement
117- R = base_ring (v)
121+ R = coefficient_ring (v)
118122 v = deepcopy (v) # don't destroy input
119123 i = 1
120124 t1 = R ()
136140
137141function (N:: QuotientModule{T} )(v:: Vector{T} ) where T <: RingElement
138142 length (v) != ngens (N) && error (" Length of vector does not match number of generators" )
139- mat = matrix (base_ring (N), 1 , length (v), v)
143+ mat = matrix (coefficient_ring (N), 1 , length (v), v)
140144 mat = reduce_mod_rels (mat, rels (N), 1 )
141145 return QuotientModuleElem {T} (N, mat)
142146end
155159
156160function (M:: QuotientModule{T} )(a:: AbstractAlgebra.FPModuleElem{T} ) where T <: RingElement
157161 N = parent (a)
158- R = base_ring (N)
159- base_ring (M) != R && error (" Incompatible modules" )
162+ R = coefficient_ring (N)
163+ coefficient_ring (M) != R && error (" Incompatible modules" )
160164 if M === N
161165 return a
162166 else
180184# ##############################################################################
181185
182186function projection (v:: AbstractAlgebra.MatElem{T} , crels:: AbstractAlgebra.MatElem{T} , N:: QuotientModule{T} ) where {T <: RingElement }
183- R = base_ring (N)
187+ R = coefficient_ring (N)
184188 # remove zero rows
185189 nr = nrows (crels)
186190 while nr > 0 && is_zero_row (crels, nr)
203207
204208function compute_combined_rels (m:: AbstractAlgebra.FPModule{T} , srels:: Vector{S} ) where {T <: RingElement , S <: AbstractAlgebra.MatElem{T} }
205209 # concatenate relations in m and new rels
206- R = base_ring (m)
210+ R = coefficient_ring (m)
207211 old_rels = rels (m)
208212 combined_rels = zero_matrix (R, length (old_rels) + length (srels), ngens (m))
209213 for i = 1 : length (old_rels)
@@ -265,7 +269,7 @@ function quo(m::AbstractAlgebra.FPModule{T}, subm::Submodule{T}) where T <: Ring
265269 @assert is_submodule (m, subm)
266270 end
267271
268- R = base_ring (m)
272+ R = coefficient_ring (m)
269273 if subm === m # quotient of submodule by itself
270274 srels = dense_matrix_type (T)[_matrix (v) for v in gens (subm)]
271275 combined_rels = compute_combined_rels (m, srels)
@@ -305,7 +309,7 @@ function quo(m::AbstractAlgebra.FPModule{T}, subm::AbstractAlgebra.FPModule{T})
305309 srels = dense_matrix_type (T)[_matrix (v) for v in gens (subm)]
306310 combined_rels = compute_combined_rels (m, srels)
307311 M = QuotientModule {T} (m, combined_rels)
308- R = base_ring (m)
312+ R = coefficient_ring (m)
309313 f = ModuleHomomorphism (m, M, matrix (R, ngens (m), 0 , []))
310314 M. map = f
311315 return M, f
0 commit comments