Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all_primitive_groups and all_transitive_groups variants taking a single int or int range #3404

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions src/Groups/libraries/primitivegroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,15 @@ 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)
Alt(4)
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
Sym(4)

julia> all_primitive_groups(degree => 3:5, is_abelian)
2-element Vector{PermGroup}:
Alt(3)
Expand All @@ -200,4 +207,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 @@ -141,6 +145,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
Loading