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

99 lines
3.0 KiB
Julia
Raw Normal View History

2017-07-23 17:09:50 +02:00
@testset "WreathProducts" begin
S_3 = PermutationGroup(3)
2018-09-21 19:11:37 +02:00
S_2 = PermutationGroup(2)
2019-01-02 15:50:14 +01:00
b = perm"(1,2,3)"
a = perm"(1,2)"
2017-07-23 17:09:50 +02:00
@testset "Constructors" begin
2019-01-02 15:50:14 +01:00
@test Groups.WreathProduct(S_2, S_3) isa AbstractAlgebra.Group
2018-09-21 19:11:37 +02:00
B3 = Groups.WreathProduct(S_2, S_3)
@test B3 isa Groups.WreathProduct
2019-01-09 16:44:04 +01:00
@test B3 isa WreathProduct{3, Generic.PermGroup{Int}, Generic.PermGroup{Int}}
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
aa = Groups.DirectPowerGroupElem((a^0 ,a, a^2))
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
@test Groups.WreathProductElem(aa, b) isa AbstractAlgebra.GroupElem
2018-09-21 19:11:37 +02:00
x = Groups.WreathProductElem(aa, b)
@test x isa Groups.WreathProductElem
2019-10-30 16:25:09 +01:00
@test x isa
Groups.WreathProductElem{3, Generic.Perm{Int}, Generic.Perm{Int}}
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
@test B3.N == Groups.DirectPowerGroup(S_2, 3)
2017-07-23 17:09:50 +02:00
@test B3.P == S_3
@test B3(aa, b) == Groups.WreathProductElem(aa, b)
2019-01-03 02:43:48 +01:00
w = B3(aa, b)
@test B3(w) == w
2019-11-14 09:21:11 +01:00
@test B3(b) == Groups.WreathProductElem(one(B3.N), b)
@test B3(aa) == Groups.WreathProductElem(aa, one(S_3))
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
@test B3((a^0 ,a, a^2), b) isa WreathProductElem
2018-07-30 15:20:37 +02:00
2019-01-02 15:50:14 +01:00
@test B3((a^0 ,a, a^2), b) == B3(aa, b)
2018-07-30 15:20:37 +02:00
end
@testset "Types" begin
2018-09-21 19:11:37 +02:00
B3 = Groups.WreathProduct(S_2, S_3)
2018-07-30 15:20:37 +02:00
2019-10-30 16:25:09 +01:00
@test elem_type(B3) == Groups.WreathProductElem{3, Generic.Perm{Int}, Generic.Perm{Int}}
2018-07-30 15:20:37 +02:00
2019-11-14 09:21:11 +01:00
@test parent_type(typeof(one(B3))) == Groups.WreathProduct{3, parent_type(typeof(one(B3.N.group))), Generic.PermGroup{Int}}
2018-07-30 15:20:37 +02:00
2019-11-14 09:21:11 +01:00
@test parent(one(B3)) == Groups.WreathProduct(S_2,S_3)
@test parent(one(B3)) == B3
2018-07-30 15:20:37 +02:00
end
@testset "Basic operations on WreathProductElem" begin
2019-01-02 15:50:14 +01:00
aa = Groups.DirectPowerGroupElem((a^0 ,a, a^2))
2018-09-21 19:11:37 +02:00
B3 = Groups.WreathProduct(S_2, S_3)
2017-07-23 17:09:50 +02:00
g = B3(aa, b)
@test g.p == b
2019-01-02 15:50:14 +01:00
@test g.n == DirectPowerGroupElem(aa.elts)
2018-07-30 15:20:37 +02:00
2017-07-23 17:09:50 +02:00
h = deepcopy(g)
2018-07-30 15:20:37 +02:00
@test h == g
@test !(g === h)
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
g = B3(Groups.DirectPowerGroupElem((a ,a, a^2)), g.p)
2017-07-23 17:09:50 +02:00
2018-07-30 15:20:37 +02:00
@test g.n[1] == parent(g.n[1])(a)
@test g != h
@test hash(g) != hash(h)
2017-07-23 17:09:50 +02:00
end
2018-07-30 15:20:37 +02:00
@testset "Group arithmetic" begin
2019-10-30 16:22:58 +01:00
B4 = Groups.WreathProduct(PermutationGroup(3), PermutationGroup(4))
2017-07-23 17:09:50 +02:00
2019-10-30 16:22:58 +01:00
id, a, b = perm"(3)", perm"(1,2)(3)", perm"(1,2,3)"
2017-07-23 17:09:50 +02:00
2019-10-30 16:22:58 +01:00
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)")
2017-07-23 17:09:50 +02:00
2019-10-30 16:22:58 +01:00
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)")
2017-07-23 17:09:50 +02:00
2019-10-30 16:22:58 +01:00
@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)")
2017-07-23 17:09:50 +02:00
2019-10-30 16:22:58 +01:00
@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)")
2017-07-23 17:09:50 +02:00
2019-01-03 02:43:48 +01:00
@test (x*y)^6 == ((x*y)^2)^3
2017-07-23 17:09:50 +02:00
end
2019-01-03 02:43:48 +01:00
@testset "Iteration" begin
2018-07-30 15:20:37 +02:00
Wr = WreathProduct(PermutationGroup(2),PermutationGroup(4))
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
elts = collect(Wr)
2019-10-30 16:25:09 +01:00
@test elts isa Vector{Groups.WreathProductElem{4, Generic.Perm{Int}, Generic.Perm{Int}}}
@test order(Wr) == 2^4*factorial(4)
2017-07-23 17:09:50 +02:00
@test length(elts) == order(Wr)
2019-11-14 09:21:11 +01:00
@test all((g*inv(g) == one(Wr) for g in elts))
2017-07-23 17:09:50 +02:00
@test all(inv(g*h) == inv(h)*inv(g) for g in elts for h in elts)
end
end