Skip to content

Commit

Permalink
Add all_primitive_groups and all_transitive_groups variants takin…
Browse files Browse the repository at this point in the history
…g a single int or int range (#3404)

(cherry picked from commit 83f0575)
  • Loading branch information
lgoettgens authored and benlorenz committed Feb 27, 2024
1 parent 1a621a1 commit 62e71ad
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Groups/libraries/primitivegroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,16 @@ The following functions are currently supported as values for `func`:
The type of the returned groups is `PermGroup`.
If no conditions beside the degree are used, one can also use the shorthand
`all_primitive_groups(degree)` where `degree` is an integer or a list or range of integers.
# Examples
```jldoctest
julia> all_primitive_groups(4)
2-element Vector{PermGroup}:
Alt(4)
Sym(4)
julia> all_primitive_groups(degree => 3:5, is_abelian)
2-element Vector{PermGroup}:
Alt(3)
Expand All @@ -200,4 +208,16 @@ function all_primitive_groups(L...)
return [PermGroup(x) for x in K]
end

function all_primitive_groups(deg::Integer)
return all_primitive_groups(degree => deg)
end

function all_primitive_groups(degs::Vector{<:Integer})
return all_primitive_groups(degree => degs)
end

function all_primitive_groups(degs::AbstractRange{<:Integer})
return all_primitive_groups(degree => degs)
end

# TODO: turn this into an iterator, possibly using PrimitiveGroupsIterator
23 changes: 23 additions & 0 deletions src/Groups/libraries/transitivegroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,19 @@ The following functions are currently supported as values for `func`:
The type of the returned groups is `PermGroup`.
If no conditions beside the degree are used, one can also use the shorthand
`all_transitive_groups(degree)` where `degree` is an integer or a list or range of integers.
# Examples
```jldoctest
julia> all_transitive_groups(4)
5-element Vector{PermGroup}:
Permutation group of degree 4
Permutation group of degree 4
Permutation group of degree 4
Alt(4)
Sym(4)
julia> all_transitive_groups(degree => 3:5, is_abelian)
4-element Vector{PermGroup}:
Alt(3)
Expand All @@ -197,4 +208,16 @@ function all_transitive_groups(L...)
return [PermGroup(x) for x in K]
end

function all_transitive_groups(deg::Integer)
return all_transitive_groups(degree => deg)
end

function all_transitive_groups(degs::Vector{<:Integer})
return all_transitive_groups(degree => degs)
end

function all_transitive_groups(degs::AbstractRange{<:Integer})
return all_transitive_groups(degree => degs)
end

# TODO: turn this into an iterator, possibly using PrimitiveGroupsIterator
8 changes: 8 additions & 0 deletions test/Groups/libraries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ end
@test is_regular(H,[1,2])

@test_throws ArgumentError transitive_group(1, 2)

@test issetequal(all_transitive_groups(3:2:9), all_transitive_groups(degree => 3:2:9))
@test issetequal(all_transitive_groups(collect(3:2:9)), all_transitive_groups(3:2:9))
@test issetequal(reduce(vcat, (all_transitive_groups(i) for i in 3:2:9)), all_transitive_groups(3:2:9))
end

@testset "Perfect groups" begin
Expand Down Expand Up @@ -156,6 +160,10 @@ end
@test has_primitive_groups(50)
@test_throws ArgumentError primitive_group(1, 1)
@test number_of_primitive_groups(50) == 9

@test issetequal(all_primitive_groups(3:2:9), all_primitive_groups(degree => 3:2:9))
@test issetequal(all_primitive_groups(collect(3:2:9)), all_primitive_groups(3:2:9))
@test issetequal(reduce(vcat, (all_primitive_groups(i) for i in 3:2:9)), all_primitive_groups(3:2:9))
end

@testset "Atlas groups" begin
Expand Down

0 comments on commit 62e71ad

Please sign in to comment.