Skip to content

Commit

Permalink
Merge pull request #40 from kalmarek/mk/fix/schr_sims_extend_gens
Browse files Browse the repository at this point in the history
fix: Always extend gens in Schreier-Sims algorithm
  • Loading branch information
Marek Kaluba committed Feb 7, 2024
2 parents 68d302c + 045faea commit 93c1d80
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PermutationGroups"
uuid = "8bc5a954-2dfc-11e9-10e6-cd969bffa420"
authors = ["Marek Kaluba <kalmar@amu.edu.pl>", "tweisser <tillmann.weisser@web.de>"]
version = "0.6.0"
version = "0.6.1"

[deps]
AbstractPermutations = "36d08e8a-54dd-435f-8c9e-38a475050b11"
Expand Down
4 changes: 2 additions & 2 deletions src/schreier_sims.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ function extend_gens!(
end
end

if length(tr) > l # if there are new points in the orbit
push!(stabch.gens, g) # add the new generator and recompute the orbit
push!(stabch.gens, g) # add the new generator and
if length(tr) > l # recompute the orbit if necessary
for (idx, δ) in enumerate(orbit(stabch))
idx l && continue # moving only the newly added points
for g in gens(stabch) # now with all generators
Expand Down
39 changes: 39 additions & 0 deletions test/perm_groups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
@test perm"(1,2)" A
@test perm"(1,3,4)" in A

@testset "Schreier-Sims: add generator even when orbit is unchanged" begin
H = PermGroup([perm"(1,5,4,3,2)", perm"(1,4,5,3)"])
# when missing a generator on the second level order is 90
@test order(Int, H) == 120
@test perm"(2,3)" in H
end

@testset "Iterate over PermGroup" begin
K1 = PermGroup(Perm{UInt32}[perm"(5,6)", perm"(1,2,3,4,5,6)"]) # Symmetric group on 6 symbols
elements = [g for g in K1]
Expand All @@ -86,4 +93,36 @@

G = PermGroup(perm"(1,4,6)(3,5)", perm"(1,5,4,3)")
@test order(Int, G) == 120

@testset "Random subgroups of Sym(n): conjugacy classes" begin
function conjugacy_classes_orbit(grp::GroupsCore.Group)
id = one(grp)
S = gens(grp)
ordG = order(Int, grp)

cclasses = [PermutationGroups.Orbit([id])]
elts_counted = 1

for g in grp
any(ccl -> g ccl, cclasses) && continue
ccl_g = PermutationGroups.Orbit(g, S, conj)
elts_counted += length(ccl_g)
push!(cclasses, ccl_g)
elts_counted == ordG && break
end

elts_counted == ordG || @warn "$elts_counted$ordG"
return cclasses
end

for n in 2:6
G = PermGroup(perm"(1,2)", Perm([2:n; 1]))
for _ in 1:10
S = rand(G, 2)
H = PermGroup(S)
ccls = conjugacy_classes_orbit(H)
@test sum(length, ccls) == order(Int, H) factorial(n)
end
end
end
end

2 comments on commit 93c1d80

@kalmarek
Copy link
Owner

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/100396

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.1 -m "<description of version>" 93c1d80b8bbb1783b8d12311ec80939599db878c
git push origin v0.6.1

Please sign in to comment.