From 75d5563fdf2a9d45650cb7a04de74ea6303a2e6c Mon Sep 17 00:00:00 2001 From: ThomasBreuer Date: Fri, 27 Sep 2024 14:35:46 +0200 Subject: [PATCH] more functionality for collector objects create an Oscar collector from a GAP collector --- src/Groups/pcgroup.jl | 60 ++++++++++++++++++++++++++++++++++++++++++ test/Groups/pcgroup.jl | 10 +++++++ 2 files changed, 70 insertions(+) diff --git a/src/Groups/pcgroup.jl b/src/Groups/pcgroup.jl index 923170798e44..380df8850d5c 100644 --- a/src/Groups/pcgroup.jl +++ b/src/Groups/pcgroup.jl @@ -365,3 +365,63 @@ function pc_group(c::GAP_Collector) end end + +# Create an Oscar collector from a GAP collector. + +""" + collector([::Type{T} = ZZRingElem, ]G::PcGroup) where T <: IntegerUnion + +Return a collector object for `G`. + +# Examples +```jldoctest +julia> g = small_group(12, 3) +Pc group of order 12 + +julia> c = collector(g); + +julia> gc = pc_group(c) +Pc group of order 12 + +julia> is_isomorphic(g, gc) +true +``` +""" +function collector(::Type{T}, G::PcGroup) where T <: IntegerUnion + Fam = GAPWrap.ElementsFamily(GAPWrap.FamilyObj(GapObj(G))) + GapC = GAP.getbangproperty(Fam, :rewritingSystem)::GapObj + + n = GAP.getbangindex(GapC, 3)::Int + c = collector(n, T) + + c.relorders = Vector{T}(GAP.getbangindex(GapC, 6)::GapObj) + + Gap_powers = GAP.gap_to_julia(GAP.getbangindex(GapC, 7)::GapObj, recursive = false) + for i in 1:length(Gap_powers) + if Gap_powers[i] !== nothing + l = GAPWrap.ExtRepOfObj(Gap_powers[i]) + c.powers[i] = Pair{Int,T}[l[k-1] => T(l[k]) for k in 2:2:length(l)] + end + end + + Gap_conj = GAP.gap_to_julia(GAP.getbangindex(GapC, 8)::GapObj, recursive = false) + for i in 1:length(Gap_conj) + Gap_conj_i = GAP.gap_to_julia(Gap_conj[i]::GapObj, recursive = false) + for j in 1:length(Gap_conj_i) + if Gap_conj_i[j] !== nothing + l = GAPWrap.ExtRepOfObj(Gap_conj_i[j]) + c.conjugates[j,i] = Pair{Int,T}[l[k-1] => T(l[k]) for k in 2:2:length(l)] + end + end + end + +# c.X = GapC +# c.F = FPGroup(GAP.getbangproperty(GAP.getbangindex(GapC, 1)::GapObj, :freeGroup)::GapObj) +#TODO: Set these known data. +# Currently this does not work because somehow `GroupByRws` +# requires a *mutable* GAP collector, and `GapC` is immutable. + + return c +end + +collector(G::PcGroup) = collector(ZZRingElem, G) diff --git a/test/Groups/pcgroup.jl b/test/Groups/pcgroup.jl index 8ec1f2c3cd3c..32d622c192e7 100644 --- a/test/Groups/pcgroup.jl +++ b/test/Groups/pcgroup.jl @@ -82,3 +82,13 @@ end @test GAP.Globals.IsMutable(cgg) @test cgg !== c.X end + +@testset "create collectors from polycyclic groups" begin + for i in rand(1:number_small_groups(96), 10) + g = small_group(96, i) + c = collector(Int64, g) + gc = pc_group(c) + f = hom(g, gc, gens(gc)) + @test is_bijective(f) + end +end