Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/Groups/pcgroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -923,3 +923,57 @@ function collector(::Type{T}, G::PcGroup) where T <: IntegerUnion
end

collector(G::PcGroup) = collector(ZZRingElem, G)

# GAP wrappers for group encoding / decoding

"""
code_pcgroup(G::PcGroup)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some doubts about the function names now: in OSCAR convention we don't normally denote the input type. So by that logic, this function should just be called code.

The reverse function pcgroup_code could then either be called just pc_group (it'd be different from other methods for that in that it would take two ZZRingElem as argument); or have a speaking name, such as pcgroup_from_code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I ref to #5456 (comment) and #5456 (comment), at least Thomas and I agree with you


Return a `ZZRingElem` representing the polycyclic group `G`, using the same
encoding as GAP's `CodePcGroup` and Magma's `SmallGroupEncoding`.
Currently only defined for `PcGroup`, not `SubPcGroup`.

# Examples
```jldoctest
julia> G = small_group(12, 2)
Pc group of order 12

julia> code = code_pcgroup(G)
266

julia> H = pcgroup_code(code, order(G))
Pc group of order 12

julia> code_pcgroup(G) == code_pcgroup(H)
true
```
"""
function code_pcgroup(G::PcGroup)
return ZZ(GAP.Globals.CodePcGroup(GapObj(G))::GapInt)
end

"""
pcgroup_code(code::IntegerUnion, order::IntegerUnion)

Given an integer `code` and an integer `order`, return the polycyclic group it encodes.
Both `code` and `order` can be of type `Int`, `BigInt`, or `ZZRingElem`. Internally, these are converted to `GapInt` before calling the GAP function `PcGroupCode`.
The accepted codes and resulting groups match those of GAP's `PcGroupCode` and Magma's `SmallGroupDecoding`.

# Examples
```jldoctest
julia> G = small_group(12, 2)
Pc group of order 12

julia> code = code_pcgroup(G)
266

julia> H = pcgroup_code(code, order(G))
Pc group of order 12

julia> code_pcgroup(G) == code_pcgroup(H)
true
```
"""
function pcgroup_code(code::IntegerUnion, order::IntegerUnion)
return PcGroup(GAP.Globals.PcGroupCode(GAP.GapInt(BigInt(code)),GAP.GapInt(BigInt(order))))
Copy link
Member

@fingolfin fingolfin Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @lgoettgens pointed out this is inefficient. We will add a GAP.GapInt constructor in GAP.jl so that one can directly write GAP.GapInt(code)

Copy link
Member

@lgoettgens lgoettgens Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See oscar-system/GAP.jl#1283. Once that and oscar-system/GAP.jl#1284 are merged (and further 20 minutes have passed), this line can be changed to

Suggested change
return PcGroup(GAP.Globals.PcGroupCode(GAP.GapInt(BigInt(code)),GAP.GapInt(BigInt(order))))
return PcGroup(GAP.Globals.PcGroupCode(GapInt(code), GapInt(order)))

At the same time, please change

GAP = "0.16.0"
to "0.16.1"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GAP.jl 0.16.1 is out now, so this can be done.

end
2 changes: 2 additions & 0 deletions src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ export cobases
export cochain_complex
export cocircuits
export cocycle_matroid
export code_pcgroup
export codim
export codomain
export codomain_covering
Expand Down Expand Up @@ -1409,6 +1410,7 @@ export partitions
export patches
export pbw_algebra
export pc_group
export pcgroup_code
export pcore
export pentagonal_hexecontahedron
export pentagonal_icositetrahedron
Expand Down
17 changes: 17 additions & 0 deletions test/Groups/pcgroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,20 @@ end
@test is_bijective(f)
end
end

@testset "pcgroup code and reconstruction" begin
groups = [
cyclic_group(6),
cyclic_group(12),
dihedral_group(10),
small_group(PcGroup, 12, 2)
]

for G in groups
code = code_pcgroup(G)
H = pcgroup_code(code, order(G))
@test hom(G, H, gens(H)) isa Map
@test order(G) == order(H)
@test code_pcgroup(H) == code
end
end
Loading