Skip to content

Commit

Permalink
Add is_abelian for groups (#1907)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Nov 19, 2024
1 parent 21aac12 commit 429961e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export inverse_image_fn
export inverse_mat
export invmod
export iroot
export is_abelian
export is_associated
export is_compatible
export is_constant
Expand Down
2 changes: 2 additions & 0 deletions src/generic/PermGroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,8 @@ order(::Type{T}, G::SymmetricGroup) where {T} = convert(T, factorial(T(G.n)))
order(::Type{T}, g::Perm) where {T} =
convert(T, foldl(lcm, length(c) for c in cycles(g)))

is_abelian(G::SymmetricGroup) = G.n <= 2

@doc raw"""
matrix_repr(a::Perm)
Expand Down
1 change: 1 addition & 0 deletions src/generic/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export inverse_fn
export inverse_image_fn
export inverse_mat
export invmod
export is_abelian
export is_compatible
export is_divisible_by
export is_free
Expand Down
7 changes: 7 additions & 0 deletions test/generic/Perm-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ end
@test collect(cycles(p^5)) == [T[1,9], T[2], T[3], T[4], T[5], T[6,10,8], T[7]]
@test Generic.permtype(p^5) == [3, 2, 1, 1, 1, 1, 1]
@test order(p^5) == 6

@test is_abelian(SymmetricGroup(T(1)))
@test is_abelian(SymmetricGroup(T(2)))
@test !is_abelian(SymmetricGroup(T(3)))
@test !is_abelian(SymmetricGroup(T(4)))
@test !is_abelian(SymmetricGroup(T(5)))
@test !is_abelian(SymmetricGroup(T(10)))
end

@testset "Perm.characters" begin
Expand Down

0 comments on commit 429961e

Please sign in to comment.