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

90 lines
2.4 KiB
Julia
Raw Normal View History

2019-01-02 15:50:14 +01:00
@testset "DirectPowers" begin
2017-07-23 03:27:03 +02:00
2019-01-02 15:50:14 +01:00
×(a,b) = Groups.DirectPower(a,b)
2018-09-21 19:11:37 +02:00
2017-07-23 03:27:03 +02:00
@testset "Constructors" begin
2020-03-25 13:48:44 +01:00
G = SymmetricGroup(3)
2017-07-23 03:27:03 +02:00
2019-01-02 15:50:14 +01:00
@test Groups.DirectPowerGroup(G,2) isa AbstractAlgebra.Group
2018-07-30 15:20:37 +02:00
@test G×G isa AbstractAlgebra.Group
2020-03-25 13:48:44 +01:00
@test Groups.DirectPowerGroup(G,2) isa Groups.DirectPowerGroup{2, Generic.SymmetricGroup{Int64}}
2017-07-23 03:27:03 +02:00
2019-01-02 15:50:14 +01:00
@test (G×G)×G == DirectPowerGroup(G, 3)
2018-07-30 15:20:37 +02:00
@test (G×G)×G == (G×G)×G
2017-07-23 03:27:03 +02:00
2019-01-02 15:50:14 +01:00
GG = DirectPowerGroup(G,2)
2019-11-14 09:21:11 +01:00
@test one(G×G) isa GroupElem
@test (G×G)((one(G), one(G))) isa GroupElem
@test (G×G)([one(G), one(G)]) isa GroupElem
2017-07-23 03:27:03 +02:00
2019-11-14 09:21:11 +01:00
@test Groups.DirectPowerGroupElem((one(G), one(G))) == one(G×G)
@test GG(one(G), one(G)) == one(G×G)
2018-07-30 15:20:37 +02:00
2019-01-02 15:50:14 +01:00
g = perm"(1,2,3)"
@test GG(g, g^2) isa GroupElem
2019-10-30 16:25:09 +01:00
@test GG(g, g^2) isa Groups.DirectPowerGroupElem{2, Generic.Perm{Int64}}
2017-07-23 03:27:03 +02:00
2019-01-02 15:50:14 +01:00
h = GG(g,g^2)
2017-07-23 03:27:03 +02:00
@test h == GG(h)
2018-07-30 15:20:37 +02:00
@test GG(g, g^2) isa GroupElem
2019-01-02 15:50:14 +01:00
@test GG(g, g^2) isa Groups.DirectPowerGroupElem
2017-07-23 03:27:03 +02:00
2019-01-02 15:50:14 +01:00
@test_throws MethodError GG(g,g,g)
2017-07-23 03:27:03 +02:00
@test GG(g,g^2) == h
@test h[1] == g
@test h[2] == g^2
2019-11-14 09:21:11 +01:00
h = GG(g, one(G))
@test h == GG(g, one(G))
2017-07-23 03:27:03 +02:00
end
2018-07-30 15:20:37 +02:00
@testset "Basic arithmetic" begin
2020-03-25 13:48:44 +01:00
G = SymmetricGroup(3)
2019-01-02 15:50:14 +01:00
GG = G×G
i = perm"(1,3)"
g = perm"(1,2,3)"
2019-10-30 16:25:09 +01:00
2019-01-02 15:50:14 +01:00
h = GG(g,g^2)
k = GG(g^3, g^2)
2018-07-30 15:20:37 +02:00
2019-01-02 15:50:14 +01:00
@test h^2 == GG(g^2,g)
2019-11-14 09:21:11 +01:00
@test h^6 == one(GG)
2017-07-23 03:27:03 +02:00
2018-07-30 15:20:37 +02:00
@test h*h == h^2
2019-01-02 15:50:14 +01:00
@test h*k == GG(g,g)
2017-07-23 03:27:03 +02:00
2019-11-14 09:21:11 +01:00
@test h*inv(h) == one(G×G)
2019-10-30 16:25:09 +01:00
2019-01-02 15:50:14 +01:00
w = GG(g,i)*GG(i,g)
@test w == GG(perm"(1,2)(3)", perm"(2,3)")
@test w == inv(w)
2019-11-14 09:21:11 +01:00
@test w^2 == w*w == one(GG)
2017-07-23 03:27:03 +02:00
end
2018-07-30 15:20:37 +02:00
@testset "elem/parent_types" begin
2020-03-25 13:48:44 +01:00
G = SymmetricGroup(3)
2019-01-02 15:50:14 +01:00
g = perm"(1,2,3)"
2017-07-23 03:27:03 +02:00
2019-01-02 15:50:14 +01:00
@test elem_type(G×G) == DirectPowerGroupElem{2, elem_type(G)}
@test elem_type(G×G×G) == DirectPowerGroupElem{3, elem_type(G)}
@test parent_type(typeof((G×G)(g,g^2))) == Groups.DirectPowerGroup{2, typeof(G)}
@test parent(DirectPowerGroupElem((g,g^2,g^3))) == DirectPowerGroup(G,3)
2017-07-23 03:27:03 +02:00
end
@testset "Misc" begin
2020-03-25 13:48:44 +01:00
G = SymmetricGroup(3)
2019-01-02 15:50:14 +01:00
GG = Groups.DirectPowerGroup(G,3)
@test order(GG) == 216
2018-07-30 15:20:37 +02:00
2019-01-02 15:50:14 +01:00
@test isa(collect(GG), Vector{Groups.DirectPowerGroupElem{3, elem_type(G)}})
elts = vec(collect(GG))
2017-07-23 03:27:03 +02:00
2019-01-02 15:50:14 +01:00
@test length(elts) == 216
2019-11-14 09:21:11 +01:00
@test all([g*inv(g) == one(GG) for g in elts])
2017-07-23 03:27:03 +02:00
@test all(inv(g*h) == inv(h)*inv(g) for g in elts for h in elts)
end
end