1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-25 18:15:29 +01:00
Groups.jl/test/WreathProd-tests.jl

99 lines
3.0 KiB
Julia

@testset "WreathProducts" begin
S_3 = SymmetricGroup(3)
S_2 = SymmetricGroup(2)
b = perm"(1,2,3)"
a = perm"(1,2)"
@testset "Constructors" begin
@test Groups.WreathProduct(S_2, S_3) isa AbstractAlgebra.Group
B3 = Groups.WreathProduct(S_2, S_3)
@test B3 isa Groups.WreathProduct
@test B3 isa WreathProduct{3, Generic.SymmetricGroup{Int}, Generic.SymmetricGroup{Int}}
aa = Groups.DirectPowerGroupElem((a^0 ,a, a^2))
@test Groups.WreathProductElem(aa, b) isa AbstractAlgebra.GroupElem
x = Groups.WreathProductElem(aa, b)
@test x isa Groups.WreathProductElem
@test x isa
Groups.WreathProductElem{3, Generic.Perm{Int}, Generic.Perm{Int}}
@test B3.N == Groups.DirectPowerGroup(S_2, 3)
@test B3.P == S_3
@test B3(aa, b) == Groups.WreathProductElem(aa, b)
w = B3(aa, b)
@test B3(w) == w
@test B3(b) == Groups.WreathProductElem(one(B3.N), b)
@test B3(aa) == Groups.WreathProductElem(aa, one(S_3))
@test B3((a^0 ,a, a^2), b) isa WreathProductElem
@test B3((a^0 ,a, a^2), b) == B3(aa, b)
end
@testset "Types" begin
B3 = Groups.WreathProduct(S_2, S_3)
@test elem_type(B3) == Groups.WreathProductElem{3, Generic.Perm{Int}, Generic.Perm{Int}}
@test parent_type(typeof(one(B3))) == Groups.WreathProduct{3, parent_type(typeof(one(B3.N.group))), Generic.SymmetricGroup{Int}}
@test parent(one(B3)) == Groups.WreathProduct(S_2,S_3)
@test parent(one(B3)) == B3
end
@testset "Basic operations on WreathProductElem" begin
aa = Groups.DirectPowerGroupElem((a^0 ,a, a^2))
B3 = Groups.WreathProduct(S_2, S_3)
g = B3(aa, b)
@test g.p == b
@test g.n == DirectPowerGroupElem(aa.elts)
h = deepcopy(g)
@test h == g
@test !(g === h)
g = B3(Groups.DirectPowerGroupElem((a ,a, a^2)), g.p)
@test g.n[1] == parent(g.n[1])(a)
@test g != h
@test hash(g) != hash(h)
end
@testset "Group arithmetic" begin
B4 = Groups.WreathProduct(SymmetricGroup(3), SymmetricGroup(4))
id, a, b = perm"(3)", perm"(1,2)(3)", perm"(1,2,3)"
x = B4((id,a,b,id), perm"(1,2,3)(4)")
@test inv(x) == B4((inv(b),id, a,id), perm"(1,3,2)(4)")
y = B4((a,id,a,b), perm"(1,4)(2,3)")
@test inv(y) == B4((inv(b), a,id, a), perm"(1,4)(2,3)")
@test x*y == B4((id,id,b*a,b), perm"(1,3,4)(2)")
@test y*x == B4(( a, b, id,b), perm"(1,4,2)(3)")
@test inv(x)*y == B4((inv(b)*a,a,a,b), perm"(1,2,4)(3)")
@test y*inv(x) == B4((a,a,a,id), perm"(1,4,3)(2)")
@test (x*y)^6 == ((x*y)^2)^3
end
@testset "Iteration" begin
Wr = WreathProduct(SymmetricGroup(2),SymmetricGroup(4))
elts = collect(Wr)
@test elts isa Vector{Groups.WreathProductElem{4, Generic.Perm{Int}, Generic.Perm{Int}}}
@test order(Wr) == 2^4*factorial(4)
@test length(elts) == order(Wr)
@test all((g*inv(g) == one(Wr) for g in elts))
@test all(inv(g*h) == inv(h)*inv(g) for g in elts for h in elts)
end
end