1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-03 01:46:28 +01:00

fix tests

This commit is contained in:
kalmarek 2018-07-30 15:20:37 +02:00
parent d373a0c7c2
commit 43b6d5bf40
4 changed files with 223 additions and 82 deletions

View File

@ -70,7 +70,6 @@
@test l(deepcopy(D)) == (a, b, c, c*d)
@test inv(l)(deepcopy(D)) == (a, b, c, c^-1*d)
i,j = 2,4
r = Groups.rmul_autsymbol(i,j)
l = Groups.lmul_autsymbol(i,j)
@ -81,19 +80,20 @@
end
@testset "AutGroup/Automorphism constructors" begin
f = Groups.AutSymbol("a", 1, Groups.FlipAut(1))
@test isa(Automorphism{3}(f), Groups.GWord)
@test isa(Automorphism{3}(f), Automorphism)
@test isa(AutGroup(FreeGroup(3)), Group)
@test isa(AutGroup(FreeGroup(3)), AbstractAlgebra.Group)
@test isa(AutGroup(FreeGroup(1)), Groups.AbstractFPGroup)
A = AutGroup(FreeGroup(1))
@test isa(gens(A), Vector{Automorphism{1}})
@test length(gens(A)) == 1
@test isa(Groups.gens(A), Vector{Automorphism{1}})
@test length(Groups.gens(A)) == 1
A = AutGroup(FreeGroup(1), special=true)
@test length(gens(A)) == 0
@test length(Groups.gens(A)) == 0
A = AutGroup(FreeGroup(2))
@test length(gens(A)) == 7
gens = gens(A)
@test length(Groups.gens(A)) == 7
gens = Groups.gens(A)
@test isa(A(Groups.rmul_autsymbol(1,2)), Automorphism)
@test A(Groups.rmul_autsymbol(1,2)) in gens
@ -146,15 +146,17 @@
b = Groups.flip_autsymbol(2)*A(inv(Groups.rmul_autsymbol(1,2)))
@test a*b == b*a
@test a^3 * b^3 == A()
g,h = gens(A)[[1,8]] # (g, h) = (ϱ₁₂, ϱ₃₂)
g,h = Groups.gens(A)[[1,8]] # (g, h) = (ϱ₁₂, ϱ₃₂)
@test Groups.domain(A) == NTuple{4, FreeGroupElem}(gens(A.objectGroup))
@test (g*h)(Groups.domain(A)) == (h*g)(Groups.domain(A))
@test (g*h).savedhash != (h*g).savedhash
@test (g*h).savedhash == zero(UInt)
@test (h*g).savedhash == zero(UInt)
a = g*h
b = h*g
@test hash(a) == hash(b)
@test hash(a) != zero(UInt)
@test hash(b) == hash(a)
@test a.savedhash == b.savedhash
@test length(unique([a,b])) == 1
@test length(unique([g*h, h*g])) == 1
@ -228,6 +230,9 @@
@test Groups.linear_repr(ϱ₁₂^-1) == M
@test Groups.linear_repr(λ₁₂^-1) == M
@test Groups.linear_repr(ϱ₁₂*λ₁₂^-1) == eye(N)
@test Groups.linear_repr(λ₁₂^-1*ϱ₁₂) == eye(N)
M = eye(N)
M[2,2] = -1
ε₂ = G(Groups.flip_autsymbol(2))
@ -235,7 +240,8 @@
@test Groups.linear_repr(ε₂) == M
@test Groups.linear_repr(ε₂^2) == eye(N)
M = [0.0 0.0 1.0; 1.0 0.0 0.0; 0.0 1.0 0.0]
M = [0 1 0; 0 0 1; 1 0 0]
σ = G(Groups.perm_autsymbol([2,3,1]))
@test Groups.linear_repr(σ) == M
@test Groups.linear_repr(σ^3) == eye(3)

View File

@ -1,32 +1,36 @@
@testset "DirectProducts" begin
G = PermutationGroup(3)
g = G([2,3,1])
F, a = FiniteField(2,3,"a")
@testset "Constructors" begin
@test isa(Groups.DirectProductGroup(G,2), AbstractArray.Group)
@test isa(G×G, AbstractAlgebra.Group)
@test isa(Groups.DirectProductGroup(G,2), Groups.DirectProductGroup{Generic.PermGroup{Int64}})
G = PermutationGroup(3)
g = G([2,3,1])
GG = Groups.DirectProductGroup(G,2)
@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}}
@test GG == Groups.DirectProductGroup(G,2)
@test (G×G)×G == DirectProductGroup(G, 3)
@test (G×G)×G == (G×G)×G
@test Groups.DirectProductGroupElem([G(), G()]) == GG()
@test GG(G(), G()) == GG()
F = GF(13)
FF = F×F
@test FF×F == F×FF
@test isa(GG([g, g^2]), GroupElem)
@test isa(GG([g, g^2]), Groups.DirectProductGroupElem{Generic.perm{Int64}})
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}}
h = GG([g,g^2])
@test h == GG(h)
@test isa(GG(g, g^2), GroupElem)
@test isa(GG(g, g^2), Groups.DirectProductGroupElem)
@test GG(g, g^2) isa GroupElem
@test GG(g, g^2) isa Groups.DirectProductGroupElem
@test_throws String GG(g,g,g)
@test_throws DomainError GG(g,g,g)
@test GG(g,g^2) == h
@test size(h) == (2,)
@ -34,46 +38,153 @@
@test h[2] == g^2
h[2] = G()
@test h == GG(g, G())
end
GG = Groups.DirectProductGroup(G,2)
FF = Groups.DirectProductGroup(F,2)
@testset "Types" begin
@test elem_type(GG) == Groups.DirectProductGroupElem{elem_type(G)}
@test elem_type(FF) == Groups.DirectProductGroupElem{elem_type(F)}
@test parent_type(typeof(GG(g,g^2))) == Groups.DirectProductGroup{typeof(G)}
@test parent_type(typeof(FF(a,a^2))) == Groups.DirectProductGroup{typeof(F)}
@test isa(FF([0,1]), GroupElem)
@test isa(FF([0,1]), Groups.DirectProductGroupElem)
@test isa(FF([0,1]), Groups.DirectProductGroupElem{elem_type(F)})
@test_throws MethodError FF(1,0)
end
@testset "Group arithmetic" begin
@testset "Basic arithmetic" begin
G = PermutationGroup(3)
g = G([2,3,1])
h = GG([g,g^2])
h = (G×G)([g,g^2])
@test h^2 == GG(g^2,g)
@test h^6 == GG()
@test h^2 == (G×G)(g^2,g)
@test h^6 == (G×G)()
@test h*h == h^2
@test h*inv(h) == GG()
@test h*inv(h) == (G×G)()
end
@test FF([0,a])*FF([a,1]) == FF(a,1+a)
@testset "elem/parent_types" begin
G = PermutationGroup(3)
g = G([2,3,1])
@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)
F = GF(13)
@test elem_type(F×F) == DirectProductGroupElem{Groups.AddGrpElem{elem_type(F)}}
@test parent_type(typeof((F×F)(1,5))) == Groups.DirectProductGroup{AddGrp{typeof(F)}}
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
@testset "Direct Product of Multiplicative Groups" begin
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 DomainError FF(1,0)
@test_throws DomainError FF([0,1])
@test_throws DomainError FF([1,0])
@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)
x, y = FF([1,a]), FF([a^2,1])
@test x*y == FF([a^2+1, a+1])
@test inv(x) == FF([1,a])
@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
end
@testset "Misc" begin
@test order(GG) == 36
F = GF(5)
FF = DirectProductGroup(F,2)
@test order(FF) == 25
elts = vec(collect(elements(FF)))
@test length(elts) == 25
@test all([g*inv(g) for g in elts] .== FF())
@test all(inv(g*h) == inv(h)*inv(g) for g in elts for h in elts)
FF = DirectProductGroup(MultiplicativeGroup(F), 3)
@test order(FF) == 64
elts = vec(collect(elements(FF)))
@test length(elts) == 64
@test all([g*inv(g) for g in elts] .== FF())
@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
@test isa([elements(GG)...], Vector{Groups.DirectProductGroupElem{elem_type(G)}})
elts = [elements(GG)...]
elts = vec(collect(elements(GG)))
@test length(elts) == 36
@test all([g*inv(g) for g in elts] .== GG())

View File

@ -41,7 +41,7 @@ end
end
@testset "FreeGroup" begin
@test isa(FreeGroup(["s", "t"]), Group)
@test isa(FreeGroup(["s", "t"]), AbstractAlgebra.Group)
G = FreeGroup(["s", "t"])
@testset "elements constructors" begin

View File

@ -1,18 +1,19 @@
@testset "WreathProducts" begin
S_3 = PermutationGroup(3)
F, a = FiniteField(2,3,"a")
R, x = PolynomialRing(QQ, "x")
F, a = NumberField(x^2 + 1, "a")
b = S_3([2,3,1])
@testset "Constructors" begin
@test isa(Groups.WreathProduct(F, S_3), AbstractAlgebra.Group)
@test isa(Groups.WreathProduct(F, S_3), Groups.WreathProduct)
@test isa(Groups.WreathProduct(F, S_3), Groups.WreathProduct{AbstractAlgebra.FqNmodFiniteField})
@test isa(Groups.WreathProduct(F, S_3), Groups.WreathProduct{AddGrp{Generic.ResField{Generic.Poly{Rational{BigInt}}}}, Int64})
aa = Groups.DirectProductGroupElem([a^0 ,a, a^2])
@test isa(Groups.WreathProductElem(aa, b), AbstractAlgebra.GroupElem)
@test isa(Groups.WreathProductElem(aa, b), Groups.WreathProductElem)
@test isa(Groups.WreathProductElem(aa, b), Groups.WreathProductElem{typeof(a)})
@test isa(Groups.WreathProductElem(aa, b), Groups.WreathProductElem{AddGrpElem{Generic.ResF{Generic.Poly{Rational{BigInt}}}}, Int64})
B3 = Groups.WreathProduct(F, S_3)
@ -23,26 +24,15 @@
@test B3(b) == Groups.WreathProductElem(B3.N(), b)
@test B3(aa) == Groups.WreathProductElem(aa, S_3())
g = B3(aa, b)
@test B3([a^0 ,a, a^2], perm"(1,2,3)") isa WreathProductElem
@test g.p == b
@test g.n == aa
h = deepcopy(g)
@test hash(g) == hash(h)
g.n[1] = a
@test g.n[1] == a
@test g != h
@test hash(g) != hash(h)
@test B3([a^0 ,a, a^2], perm"(1,2,3)") == B3(aa, b)
end
@testset "Types" begin
B3 = Groups.WreathProduct(F, S_3)
@test elem_type(B3) == Groups.WreathProductElem{elem_type(F), Int}
@test elem_type(B3) == Groups.WreathProductElem{AddGrpElem{elem_type(F)}, Int}
@test parent_type(typeof(B3())) == Groups.WreathProduct{parent_type(typeof(B3.N.group())), Int}
@ -50,30 +40,64 @@
@test parent(B3()) == B3
end
@testset "Group arithmetic" begin
@testset "Basic operations on WreathProductElem" begin
aa = Groups.DirectProductGroupElem([a^0 ,a, a^2])
B3 = Groups.WreathProduct(F, S_3)
g = B3(aa, b)
x = B3(B3.N([1,0,0]), B3.P([2,3,1]))
y = B3(B3.N([0,1,1]), B3.P([2,1,3]))
@test g.p == b
@test g.n == DirectProductGroupElem(AddGrpElem.(aa.elts))
@test x*y == B3(B3.N([0,0,1]), B3.P([3,2,1]))
@test y*x == B3(B3.N([0,0,1]), B3.P([1,3,2]))
h = deepcopy(g)
@test h == g
@test !(g === h)
@test inv(x) == B3(B3.N([0,0,1]), B3.P([3,1,2]))
@test inv(y) == B3(B3.N([1,0,1]), B3.P([2,1,3]))
g.n[1] = parent(g.n[1])(a)
@test inv(x)*y == B3(B3.N([1,1,1]), B3.P([1,3,2]))
@test y*inv(x) == B3(B3.N([0,1,0]), B3.P([3,2,1]))
@test g.n[1] == parent(g.n[1])(a)
@test g != h
@test hash(g) != hash(h)
g.n[1] = a
@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(GF(3), PermutationGroup(4))
x = B4([0,1,2,0], perm"(1,2,3)(4)")
@test inv(x) == B4([1,0,2,0], perm"(1,3,2)(4)")
y = B4([1,0,1,2], perm"(1,4)(2,3)")
@test inv(y) == B4([1,2,0,2], perm"(1,4)(2,3)")
@test x*y == B4([0,2,0,2], perm"(1,3,4)(2)")
@test y*x == B4([1,2,2,2], perm"(1,4,2)(3)")
@test inv(x)*y == B4([2,1,2,2], perm"(1,2,4)(3)")
@test y*inv(x) == B4([1,2,1,0], perm"(1,4,3)(2)")
end
@testset "Misc" begin
B3 = Groups.WreathProduct(FiniteField(2,1,"a")[1], S_3)
@test order(B3) == 48
B3 = Groups.WreathProduct(GF(3), S_3)
@test order(B3) == 3^3*6
Wr = WreathProduct(PermutationGroup(2),S_3)
B3 = Groups.WreathProduct(MultiplicativeGroup(GF(3)), S_3)
@test order(B3) == 2^3*6
Wr = WreathProduct(PermutationGroup(2),PermutationGroup(4))
@test isa([elements(Wr)...], Vector{Groups.WreathProductElem{Generic.perm{Int}, Int}})
@test order(Wr) == 2^4*factorial(4)
elts = [elements(Wr)...]