From cdbd483e9e58351d2879d10432abe445cc4c7dfa Mon Sep 17 00:00:00 2001 From: kalmarek Date: Mon, 20 Apr 2020 02:41:24 +0200 Subject: [PATCH] more tests for AutGroup --- src/AutGroup.jl | 2 +- src/DirectPower.jl | 7 +----- test/AutGroup-tests.jl | 49 ++++++++++++++++++++++++++---------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/AutGroup.jl b/src/AutGroup.jl index 232d98d..dcbb1e1 100644 --- a/src/AutGroup.jl +++ b/src/AutGroup.jl @@ -262,7 +262,7 @@ end function show(io::IO, G::AutGroup) print(io, "Automorphism Group of $(G.objectGroup)\n") - print(io, "Generated by $(join(G.gens, ","))") + print(io, "Generated by $(gens(G))") end ############################################################################### diff --git a/src/DirectPower.jl b/src/DirectPower.jl index fe87840..567444e 100644 --- a/src/DirectPower.jl +++ b/src/DirectPower.jl @@ -31,11 +31,6 @@ function DirectPower(G::DirectPowerGroup{N}, H::Group) where N return DirectPowerGroup(G.group, N+1) end -function DirectPower(R::AbstractAlgebra.Ring, n::Int) - @warn "Creating DirectPower of the multilplicative group!" - return DirectPowerGroup(MultiplicativeGroup(R), n) -end - struct DirectPowerGroupElem{N, T<:GroupElem} <: GroupElem elts::NTuple{N,T} end @@ -188,7 +183,6 @@ end ############################################################################### order(G::DirectPowerGroup{N}) where N = order(G.group)^N -Base.length(G::DirectPowerGroup) = order(G) function iterate(G::DirectPowerGroup{N}) where N elts = collect(G.group) @@ -212,3 +206,4 @@ function iterate(G::DirectPowerGroup{N}, state) where N end eltype(::Type{DirectPowerGroup{N, G}}) where {N, G} = DirectPowerGroupElem{N, elem_type(G)} +Base.length(G::DirectPowerGroup) = order(G) diff --git a/test/AutGroup-tests.jl b/test/AutGroup-tests.jl index 17fefcf..54cc0f0 100644 --- a/test/AutGroup-tests.jl +++ b/test/AutGroup-tests.jl @@ -6,13 +6,17 @@ @test_throws MethodError Groups.AutSymbol(:a) @test_throws MethodError Groups.AutSymbol(:a, 1) f = Groups.AutSymbol(:a, 1, Groups.FlipAut(2)) - @test isa(f, Groups.GSymbol) - @test isa(f, Groups.AutSymbol) - @test isa(Groups.AutSymbol(perm"(4)"), Groups.AutSymbol) - @test isa(Groups.AutSymbol(perm"(1,2,3,4)"), Groups.AutSymbol) - @test isa(Groups.transvection_R(1,2), Groups.AutSymbol) - @test isa(Groups.transvection_R(3,4), Groups.AutSymbol) - @test isa(Groups.flip(3), Groups.AutSymbol) + @test f isa Groups.GSymbol + @test f isa Groups.AutSymbol + @test Groups.AutSymbol(perm"(4)") isa Groups.AutSymbol + @test Groups.AutSymbol(perm"(1,2,3,4)") isa Groups.AutSymbol + @test Groups.transvection_R(1,2) isa Groups.AutSymbol + @test Groups.transvection_R(3,4) isa Groups.AutSymbol + @test Groups.flip(3) isa Groups.AutSymbol + + @test Groups.id_autsymbol() isa Groups.AutSymbol + @test inv(Groups.id_autsymbol()) isa Groups.AutSymbol + @test inv(Groups.id_autsymbol()) == Groups.id_autsymbol() end a,b,c,d = gens(FreeGroup(4)) @@ -88,35 +92,44 @@ @test isa(Automorphism{3}(f), Automorphism) @test isa(AutGroup(FreeGroup(3)), AbstractAlgebra.Group) @test isa(AutGroup(FreeGroup(1)), Groups.AbstractFPGroup) + A = AutGroup(FreeGroup(1)) - @test isa(Groups.gens(A), Vector{Automorphism{1}}) + @test Groups.gens(A) isa Vector{Automorphism{1}} @test length(Groups.gens(A)) == 1 + @test length(Groups.gens(Aut(FreeGroup(1)))) == 1 + @test Groups.gens(A) == [A(Groups.flip(1))] + A = AutGroup(FreeGroup(1), special=true) - @test length(Groups.gens(A)) == 0 + @test isempty(Groups.gens(A)) + @test Groups.gens(SAut(FreeGroup(1))) == Automorphism{1}[] + A = AutGroup(FreeGroup(2)) @test length(Groups.gens(A)) == 7 Agens = Groups.gens(A) + @test A(first(Agens)) isa Automorphism - @test isa(A(Groups.transvection_R(1,2)), Automorphism) + @test A(Groups.transvection_R(1,2)) isa Automorphism @test A(Groups.transvection_R(1,2)) in Agens - @test isa(A(Groups.transvection_R(2,1)), Automorphism) + @test A(Groups.transvection_R(2,1)) isa Automorphism @test A(Groups.transvection_R(2,1)) in Agens - @test isa(A(Groups.transvection_R(1,2)), Automorphism) + @test A(Groups.transvection_R(1,2)) isa Automorphism @test A(Groups.transvection_R(1,2)) in Agens - @test isa(A(Groups.transvection_R(2,1)), Automorphism) + @test A(Groups.transvection_R(2,1)) isa Automorphism @test A(Groups.transvection_R(2,1)) in Agens - @test isa(A(Groups.flip(1)), Automorphism) + @test A(Groups.flip(1)) isa Automorphism @test A(Groups.flip(1)) in Agens - @test isa(A(Groups.flip(2)), Automorphism) + @test A(Groups.flip(2)) isa Automorphism @test A(Groups.flip(2)) in Agens - @test isa(A(Groups.AutSymbol(perm"(1,2)")), Automorphism) + @test A(Groups.AutSymbol(perm"(1,2)")) isa Automorphism @test A(Groups.AutSymbol(perm"(1,2)")) in Agens + + @test A(Groups.id_autsymbol()) isa Automorphism end A = AutGroup(FreeGroup(4)) @@ -144,8 +157,8 @@ @test f²^2 == one(A) @test !isone(f²) - a = A(Groups.transvection_L(1,2))*Groups.flip(2) - b = Groups.flip(2)*A(inv(Groups.transvection_L(1,2))) + a = A(Groups.λ(1,2))*Groups.ε(2) + b = Groups.ε(2)*A(inv(Groups.λ(1,2))) @test a*b == b*a @test a^3 * b^3 == one(A) g,h = Groups.gens(A)[[1,8]] # (g, h) = (ϱ₁₂, ϱ₃₂)