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

126 lines
3.9 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-01-02 15:50:14 +01:00
@test x isa
2019-01-09 16:44:04 +01:00
Groups.WreathProductElem{3, perm{Int}, 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
2017-07-23 17:09:50 +02:00
@test B3(b) == Groups.WreathProductElem(B3.N(), b)
@test B3(aa) == Groups.WreathProductElem(aa, S_3())
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-01-09 16:44:04 +01:00
@test elem_type(B3) == Groups.WreathProductElem{3, perm{Int}, perm{Int}}
2018-07-30 15:20:37 +02:00
2019-01-09 16:44:04 +01:00
@test parent_type(typeof(B3())) == Groups.WreathProduct{3, parent_type(typeof(B3.N.group())), Generic.PermGroup{Int}}
2018-07-30 15:20:37 +02:00
2018-09-21 19:11:37 +02:00
@test parent(B3()) == Groups.WreathProduct(S_2,S_3)
2018-07-30 15:20:37 +02:00
@test parent(B3()) == B3
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
2018-09-21 19:11:37 +02:00
B4 = Groups.WreathProduct(AdditiveGroup(GF(3)), PermutationGroup(4))
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
x = B4((0,1,2,0), perm"(1,2,3)(4)")
@test inv(x) == B4((1,0,2,0), perm"(1,3,2)(4)")
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
y = B4((1,0,1,2), perm"(1,4)(2,3)")
@test inv(y) == B4((1,2,0,2), perm"(1,4)(2,3)")
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
@test x*y == B4((0,2,0,2), perm"(1,3,4)(2)")
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
@test y*x == B4((1,2,2,2), perm"(1,4,2)(3)")
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
@test inv(x)*y == B4((2,1,2,2), perm"(1,2,4)(3)")
2017-07-23 17:09:50 +02:00
2019-01-02 15:50:14 +01:00
@test y*inv(x) == B4((1,2,1,0), perm"(1,4,3)(2)")
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
B3_a = Groups.WreathProduct(AdditiveGroup(GF(3)), S_3)
@test order(B3_a) == 3^3*6
@test collect(B3_a) isa Vector{
2019-01-09 16:44:04 +01:00
WreathProductElem{3, AddGrpElem{AbstractAlgebra.gfelem{Int}}, perm{Int}}}
2018-07-30 15:20:37 +02:00
2019-01-03 02:43:48 +01:00
B3_m = Groups.WreathProduct(MultiplicativeGroup(GF(3)), S_3)
@test order(B3_m) == 2^3*6
@test collect(B3_m) isa Vector{
2019-01-09 16:44:04 +01:00
WreathProductElem{3, MltGrpElem{AbstractAlgebra.gfelem{Int}}, perm{Int}}}
2019-01-03 02:43:48 +01:00
@test length(Set([B3_a, B3_m, B3_a])) == 2
2017-07-23 17:09:50 +02:00
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-01-09 16:44:04 +01:00
@test elts isa Vector{Groups.WreathProductElem{4, perm{Int}, perm{Int}}}
2019-01-02 15:50:14 +01:00
@test order(Wr) == 2^4*factorial(4)
2017-07-23 17:09:50 +02:00
@test length(elts) == order(Wr)
2018-09-21 19:11:37 +02:00
@test all([g*inv(g) == 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
2019-01-03 02:43:48 +01:00
@testset "Misc" begin
B3_a = Groups.WreathProduct(AdditiveGroup(GF(3)), S_3)
@test string(B3_a) == "Wreath Product of The additive group of Finite field F_3 by Permutation group over 3 elements"
@test string(B3_a(perm"(1,3)")) == "([0,0,0]≀(1,3))"
B3_m = Groups.WreathProduct(MultiplicativeGroup(GF(3)), S_3)
@test string(B3_m) == "Wreath Product of The multiplicative group of Finite field F_3 by Permutation group over 3 elements"
@test string(B3_m(perm"(1,3)")) == "([1,1,1]≀(1,3))"
end
2017-07-23 17:09:50 +02:00
end