1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 14:35:28 +01:00
Groups.jl/test/DirectProd-tests.jl

193 lines
5.5 KiB
Julia
Raw Normal View History

2017-07-23 03:27:03 +02:00
@testset "DirectProducts" begin
2018-09-21 19:11:37 +02:00
×(a,b) = Groups.pow(a,b)
2017-07-23 03:27:03 +02:00
@testset "Constructors" begin
2018-07-30 15:20:37 +02:00
G = PermutationGroup(3)
g = G([2,3,1])
2017-07-23 03:27:03 +02:00
2018-07-30 15:20:37 +02:00
@test Groups.DirectProductGroup(G,2) isa AbstractAlgebra.Group
@test G×G isa AbstractAlgebra.Group
@test Groups.DirectProductGroup(G,2) isa Groups.DirectProductGroup{Generic.PermGroup{Int64}}
2017-07-23 03:27:03 +02:00
2018-07-30 15:20:37 +02:00
@test (G×G)×G == DirectProductGroup(G, 3)
@test (G×G)×G == (G×G)×G
2017-07-23 03:27:03 +02:00
2018-07-30 15:20:37 +02:00
F = GF(13)
FF = F×F
@test FF×F == F×FF
2017-07-23 03:27:03 +02:00
2018-07-30 15:20:37 +02:00
GG = DirectProductGroup(G,2)
@test Groups.DirectProductGroupElem([G(), G()]) == (G×G)()
@test GG(G(), G()) == (G×G)()
@test GG([g, g^2]) isa GroupElem
@test GG([g, g^2]) isa Groups.DirectProductGroupElem{Generic.perm{Int64}}
2017-07-23 03:27:03 +02:00
h = GG([g,g^2])
@test h == GG(h)
2018-07-30 15:20:37 +02:00
@test GG(g, g^2) isa GroupElem
@test GG(g, g^2) isa Groups.DirectProductGroupElem
2017-07-23 03:27:03 +02: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
h[2] = G()
@test h == GG(g, G())
2018-07-30 15:20:37 +02:00
2017-07-23 03:27:03 +02:00
end
2018-07-30 15:20:37 +02:00
@testset "Basic arithmetic" begin
G = PermutationGroup(3)
g = G([2,3,1])
h = (G×G)([g,g^2])
@test h^2 == (G×G)(g^2,g)
@test h^6 == (G×G)()
2017-07-23 03:27:03 +02:00
2018-07-30 15:20:37 +02:00
@test h*h == h^2
2017-07-23 03:27:03 +02:00
2018-07-30 15:20:37 +02:00
@test h*inv(h) == (G×G)()
2017-07-23 03:27:03 +02:00
end
2018-07-30 15:20:37 +02:00
@testset "elem/parent_types" begin
G = PermutationGroup(3)
2017-07-23 03:27:03 +02:00
g = G([2,3,1])
2018-07-30 15:20:37 +02:00
@test elem_type(G×G) == DirectProductGroupElem{elem_type(G)}
@test parent_type(typeof((G×G)(g,g^2))) == Groups.DirectProductGroup{typeof(G)}
@test parent((G×G)(g,g^2)) == DirectProductGroup(G,2)
2017-07-23 03:27:03 +02:00
2018-09-21 19:11:37 +02:00
F = AdditiveGroup(GF(13))
2018-07-30 15:20:37 +02:00
2018-09-21 19:11:37 +02:00
@test elem_type(F×F) == DirectProductGroupElem{Groups.AddGrpElem{AbstractAlgebra.gfelem{Int}}}
@test parent_type(typeof((F×F)(1,5))) == Groups.DirectProductGroup{Groups.AddGrp{AbstractAlgebra.GFField{Int}}}
2018-07-30 15:20:37 +02:00
parent((F×F)(1,5)) == DirectProductGroup(F,2)
end
@testset "Additive/Multiplicative groups" begin
R, x = PolynomialRing(QQ, "x")
F, a = NumberField(x^3 + x + 1, "a")
G = PermutationGroup(3)
GG = Groups.DirectProductGroup(G,2)
FF = Groups.DirectProductGroup(F,2)
@testset "MltGrp basic functionality" begin
Gr = MltGrp(F)
@test Gr(a) isa MltGrpElem
g = Gr(a)
@test deepcopy(g) isa MltGrpElem
@test inv(g) == Gr(a^-1)
@test Gr() == Gr(1)
@test inv(g)*g == Gr()
end
@testset "AddGrp basic functionality" begin
Gr = AddGrp(F)
@test Gr(a) isa AddGrpElem
g = Gr(a)
@test deepcopy(g) isa AddGrpElem
@test inv(g) == Gr(-a)
@test Gr() == Gr(0)
@test inv(g)*g == Gr()
end
end
2017-07-23 03:27:03 +02:00
2018-07-30 15:20:37 +02:00
@testset "Direct Product of Multiplicative Groups" begin
2017-07-23 03:27:03 +02:00
2018-07-30 15:20:37 +02:00
R, x = PolynomialRing(QQ, "x")
F, a = NumberField(x^3 + x + 1, "a")
FF = Groups.DirectProductGroup(MltGrp(F),2)
@test FF([a,1]) isa GroupElem
@test FF([a,1]) isa DirectProductGroupElem
@test FF([a,1]) isa DirectProductGroupElem{MltGrpElem{elem_type(F)}}
@test_throws MethodError FF(1,0)
@test_throws MethodError FF([0,1])
@test_throws MethodError FF([1,0])
2018-07-30 15:20:37 +02:00
@test MltGrp(F) isa AbstractAlgebra.Group
@test MltGrp(F) isa MultiplicativeGroup
@test DirectProductGroup(MltGrp(F), 2) isa AbstractAlgebra.Group
@test DirectProductGroup(MltGrp(F), 2) isa DirectProductGroup{MltGrp{typeof(F)}}
F, a = NumberField(x^3 + x + 1, "a")
FF = DirectProductGroup(MltGrp(F), 2)
@test FF(a,a+1) == FF([a,a+1])
@test FF([1,a+1])*FF([a,a]) == FF(a,a^2+a)
2017-07-23 03:27:03 +02:00
x, y = FF([1,a]), FF([a^2,1])
2018-07-30 15:20:37 +02:00
@test x*y == FF([a^2, a])
@test inv(x) == FF([1,-a^2-1])
@test parent(x) == FF
end
@testset "Direct Product of Additive Groups" begin
R, x = PolynomialRing(QQ, "x")
F, a = NumberField(x^3 + x + 1, "a")
# Additive Group
@test AddGrp(F) isa AbstractAlgebra.Group
@test AddGrp(F) isa AdditiveGroup
@test DirectProductGroup(AddGrp(F), 2) isa AbstractAlgebra.Group
@test DirectProductGroup(AddGrp(F), 2) isa DirectProductGroup{AddGrp{typeof(F)}}
FF = DirectProductGroup(AdditiveGroup(F), 2)
@test FF([0,a]) isa AbstractAlgebra.GroupElem
@test FF(F(0),a) isa DirectProductGroupElem
@test FF(0,0) isa DirectProductGroupElem{AddGrpElem{elem_type(F)}}
@test FF(F(1),a+1) == FF([1,a+1])
@test FF([F(1),a+1])*FF([a,a]) == FF(1+a,2a+1)
x, y = FF([1,a]), FF([a^2,1])
@test x*y == FF(a^2+1, a+1)
@test inv(x) == FF([F(-1),-a])
@test parent(x) == FF
2017-07-23 03:27:03 +02:00
end
@testset "Misc" begin
2018-07-30 15:20:37 +02:00
F = GF(5)
2018-09-21 19:11:37 +02:00
FF = DirectProductGroup(AdditiveGroup(F),2)
2018-07-30 15:20:37 +02:00
@test order(FF) == 25
elts = vec(collect(elements(FF)))
@test length(elts) == 25
2018-09-21 19:11:37 +02:00
@test all([g*inv(g) == FF() for g in elts])
2018-07-30 15:20:37 +02:00
@test all(inv(g*h) == inv(h)*inv(g) for g in elts for h in elts)
FF = DirectProductGroup(MultiplicativeGroup(F), 3)
2017-07-23 03:27:03 +02:00
@test order(FF) == 64
2018-07-30 15:20:37 +02:00
elts = vec(collect(elements(FF)))
@test length(elts) == 64
2018-09-21 19:11:37 +02:00
@test all([g*inv(g) == FF() for g in elts])
2018-07-30 15:20:37 +02:00
@test all(inv(g*h) == inv(h)*inv(g) for g in elts for h in elts)
G = PermutationGroup(3)
GG = Groups.DirectProductGroup(G,2)
@test order(GG) == 36
2017-07-23 03:27:03 +02:00
@test isa([elements(GG)...], Vector{Groups.DirectProductGroupElem{elem_type(G)}})
2018-07-30 15:20:37 +02:00
elts = vec(collect(elements(GG)))
2017-07-23 03:27:03 +02:00
@test length(elts) == 36
2018-09-21 19:11:37 +02:00
@test all([g*inv(g) == 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