Skip to content

Commit

Permalink
add map_entries for matrix groups
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBreuer committed Feb 8, 2024
1 parent a0913ed commit 0c6f391
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/src/Groups/matgroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ end
matrix_group(R::Ring, m::Int, V::AbstractVector{T}; check::Bool=true) where T<:Union{MatElem,MatrixGroupElem}
MatrixGroup{RE<:RingElem, T<:MatElem{RE}}
MatrixGroupElem{RE<:RingElem, T<:MatElem{RE}}
base_ring(G::MatrixGroup)
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)
```

## Elements of matrix groups
Expand Down
47 changes: 47 additions & 0 deletions src/Groups/matrices/MatGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,53 @@ function order(::Type{T}, G::MatrixGroup) where T <: IntegerUnion
return T(res)::T
end

"""
map_entries(f, G::MatrixGroup)
Return the matrix group obtained by applying `f` element-wise to
each generator of `G`.
`f` can be a ring or a field, a suitable map, or a Julia function.
# Examples
```jldoctest
julia> mat = matrix(ZZ, 2, 2, [1, 1, 0, 1]);
julia> G = matrix_group(mat);
julia> G2 = map_entries(x -> -x, G)
Matrix group of degree 2
over integer ring
julia> is_finite(G2)
false
julia> order(map_entries(GF(3), G))
3
```
"""
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)
end

function map_entries(mp::Map, G::MatrixGroup)
imgs = [map_entries(mp, matrix(x)) for x in gens(G)]
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


########################################################################
#
# Constructors
Expand Down
32 changes: 32 additions & 0 deletions test/Groups/matrixgroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,38 @@ end
@test_throws ArgumentError matrix_group([x1,x3])
end

@testset "map_entries for matrix groups" begin
mat = matrix(ZZ, 2, 2, [1, 1, 0, 1])
G = matrix_group(mat)
T = trivial_subgroup(G)[1]
@test length(gens(T)) == 0
for R in [GF(2), GF(3, 2), residue_ring(ZZ, 6)[1]]
red = map_entries(R, G)
@test matrix(gen(red, 1)) == map_entries(R, mat)
red = map_entries(R, T)
@test matrix(one(red)) == map_entries(R, one(mat))
end

F = GF(2)
mp = MapFromFunc(ZZ, F, x -> F(x))
red = map_entries(mp, G)
@test red == map_entries(F, G)
red = map_entries(mp, T)
@test red == map_entries(F, T)

G1 = special_linear_group(2, 9)
G2 = map_entries(x -> x^3, G1)
@test gens(G1) != gens(G2)
@test G1 == G2
T = trivial_subgroup(G1)[1]
@test length(gens(T)) == 0
@test map_entries(x -> x^3, T) == trivial_subgroup(G2)[1]

mat = matrix(QQ, 2, 2, [2, 1, 0, 1])
G = matrix_group(mat)
@test_throws ArgumentError map_entries(GF(2), G)
end

@testset "Iterator" begin
G = SL(2,3)
N = 0
Expand Down

0 comments on commit 0c6f391

Please sign in to comment.