diff --git a/docs/src/Groups/matgroup.md b/docs/src/Groups/matgroup.md index fd85e992b70a..df733faa6e50 100644 --- a/docs/src/Groups/matgroup.md +++ b/docs/src/Groups/matgroup.md @@ -14,7 +14,7 @@ MatrixGroupElem{RE<:RingElem, T<:MatElem{RE}} base_ring(G::MatrixGroup{RE}) where RE <: RingElem degree(G::MatrixGroup) centralizer(G::MatrixGroup{T}, x::MatrixGroupElem{T}) where T <: FinFieldElem -map_entries(R::Ring, G::MatrixGroup) +map_entries(f, G::MatrixGroup) ``` ## Elements of matrix groups diff --git a/src/Groups/matrices/MatGrp.jl b/src/Groups/matrices/MatGrp.jl index 1c09d1c78458..92896f6d0339 100644 --- a/src/Groups/matrices/MatGrp.jl +++ b/src/Groups/matrices/MatGrp.jl @@ -102,13 +102,7 @@ function Base.deepcopy_internal(x::MatrixGroupElem, dict::IdDict) error("$x has neither :X nor :elm") end -function change_base_ring(R::Ring, G::MatrixGroup) - g = dense_matrix_type(R)[] - for h in gens(G) - push!(g, map_entries(R, h.elm)) - end - return matrix_group(g) -end +change_base_ring(R::Ring, G::MatrixGroup) = map_entries(R, G) ######################################################################## # @@ -572,6 +566,17 @@ julia> order(map_entries(GF(3), G)) 3 ``` """ +function map_entries(f, G::MatrixGroup) + Ggens = gens(G) + if length(Ggens) == 0 + z = f(zero(base_ring(G))) + return matrix_group(parent(z), degree(G), MatrixGroupElem[]) + else + imgs = [map_entries(f, matrix(x)) for x in gens(G)] + return matrix_group(imgs) + end +end + function map_entries(R::Ring, G::MatrixGroup) imgs = [map_entries(R, matrix(x)) for x in gens(G)] return matrix_group(R, degree(G), imgs) @@ -582,17 +587,6 @@ function map_entries(mp::Map, G::MatrixGroup) return matrix_group(codomain(mp), degree(G), imgs) end -function map_entries(f::Function, G::MatrixGroup) - Ggens = gens(G) - if length(Ggens) == 0 - o = map_entries(f, matrix(one(G))) - return matrix_group(base_ring(o), degree(G), typeof(o)[]) - else - imgs = [map_entries(f, matrix(x)) for x in gens(G)] - return matrix_group(imgs) - end -end - ######################################################################## #