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

use perms{Int8} in AutGroup and in tests

This commit is contained in:
kalmarek 2018-03-22 17:24:23 +01:00
parent 203e084ff3
commit 0233aedc41
4 changed files with 21 additions and 22 deletions

View File

@ -19,7 +19,7 @@ immutable FlipAut
end
immutable PermAut
p::Nemo.Generic.perm
p::Nemo.Generic.perm{Int8}
end
immutable Identity end
@ -86,7 +86,7 @@ end
# taken from ValidatedNumerics, under under the MIT "Expat" License:
# https://github.com/JuliaIntervals/ValidatedNumerics.jl/blob/master/LICENSE.md
function subscriptify(n::Int)
function subscriptify(n::Integer)
subscript_0 = Int(0x2080) # Char(0x2080) -> subscript 0
return join([Char(subscript_0 + i) for i in reverse(digits(n))])
end
@ -115,7 +115,7 @@ function flip_autsymbol(i; pow::Int=1)
end
end
function perm_autsymbol(p::Generic.perm; pow::Int=1)
function perm_autsymbol(p::Generic.perm{Int8}; pow::Int=1)
p = p^pow
if p == parent(p)()
return id_autsymbol()
@ -125,9 +125,9 @@ function perm_autsymbol(p::Generic.perm; pow::Int=1)
end
end
function perm_autsymbol(a::Vector{Int})
G = PermutationGroup(length(a))
return perm_autsymbol(G(a))
function perm_autsymbol(a::Vector{T}) where T<:Integer
G = PermutationGroup(Int8(length(a)))
return perm_autsymbol(G(Vector{Int8}(a)))
end
domain(G::AutGroup) = deepcopy(G.domain)
@ -152,7 +152,7 @@ function AutGroup(G::FreeGroup; special=false)
if !special
flips = [flip_autsymbol(i) for i in 1:n]
syms = [perm_autsymbol(p) for p in elements(PermutationGroup(n))][2:end]
syms = [perm_autsymbol(p) for p in elements(PermutationGroup(Int8(n)))][2:end]
append!(S, [flips; syms])

View File

@ -1,6 +1,6 @@
@testset "Automorphisms" begin
using Nemo
G = PermutationGroup(4)
G = PermutationGroup(Int8(4))
@testset "AutSymbol" begin
@test_throws MethodError Groups.AutSymbol("a")
@ -8,7 +8,7 @@
f = Groups.AutSymbol("a", 1, Groups.FlipAut(2))
@test isa(f, Groups.GSymbol)
@test isa(f, Groups.AutSymbol)
@test isa(Groups.perm_autsymbol(G([1,2,3,4])), Groups.AutSymbol)
@test isa(Groups.perm_autsymbol([1,2,3,4]), Groups.AutSymbol)
@test isa(Groups.rmul_autsymbol(1,2), Groups.AutSymbol)
@test isa(Groups.lmul_autsymbol(3,4), Groups.AutSymbol)
@test isa(Groups.flip_autsymbol(3), Groups.AutSymbol)
@ -29,21 +29,21 @@
end
@testset "perm_autsymbol correctness" begin
σ = Groups.perm_autsymbol(G([1,2,3,4]))
@test σ(domain) == domain
@test inv(σ)(domain) == domain
σ = Groups.perm_autsymbol([1,2,3,4])
σ = Groups.perm_autsymbol(G([2,3,4,1]))
@test σ(domain) == [b, c, d, a]
@test inv(σ)(domain) == [d, a, b, c]
σ = Groups.perm_autsymbol([2,3,4,1])
σ = Groups.perm_autsymbol(G([2,1,4,3]))
@test σ(domain) == [b, a, d, c]
@test inv(σ)(domain) == [b, a, d, c]
σ = Groups.perm_autsymbol([2,1,4,3])
σ = Groups.perm_autsymbol(G([2,3,1,4]))
@test σ(domain) == [b,c,a,d]
@test inv(σ)(domain) == [c,a,b,d]
σ = Groups.perm_autsymbol([2,3,1,4])
end
@testset "rmul/lmul_autsymbol correctness" begin
@ -115,21 +115,20 @@
@test isa(A(Groups.flip_autsymbol(2)), AutGroupElem)
@test A(Groups.flip_autsymbol(2)) in gens
@test isa(A(Groups.perm_autsymbol(PermutationGroup(2)([2,1]))),
AutGroupElem)
@test A(Groups.perm_autsymbol(PermutationGroup(2)([2,1]))) in gens
@test isa(A(Groups.perm_autsymbol([2,1])), AutGroupElem)
@test A(Groups.perm_autsymbol([2,1])) in gens
end
A = AutGroup(FreeGroup(4))
@testset "eltary functions" begin
f = Groups.perm_autsymbol(G([2,3,4,1]))
f = Groups.perm_autsymbol([2,3,4,1])
@test (Groups.change_pow(f, 2)).pow == 1
@test (Groups.change_pow(f, -2)).pow == 1
@test (inv(f)).pow == 1
f = Groups.perm_autsymbol(G([2,1,4,3]))
f = Groups.perm_autsymbol([2,1,4,3])
@test isa(inv(f), Groups.AutSymbol)
@test_throws DomainError f^-1
@ -139,7 +138,7 @@
end
@testset "reductions/arithmetic" begin
f = Groups.perm_autsymbol(G([2,3,4,1]))
f = Groups.perm_autsymbol([2,3,4,1])
= Groups.r_multiply(A(f), [f], reduced=false)
@test Groups.simplify_perms!() == false

View File

@ -8,7 +8,7 @@
@testset "Constructors" begin
@test isa(Groups.DirectProductGroup(G,2), Nemo.Group)
@test isa(G×G, Nemo.Group)
@test isa(Groups.DirectProductGroup(G,2), Groups.DirectProductGroup{Generic.PermGroup})
@test isa(Groups.DirectProductGroup(G,2), Groups.DirectProductGroup{Generic.PermGroup{Int64}})
GG = Groups.DirectProductGroup(G,2)
@ -18,7 +18,7 @@
@test GG(G(), G()) == GG()
@test isa(GG([g, g^2]), GroupElem)
@test isa(GG([g, g^2]), Groups.DirectProductGroupElem{Generic.perm})
@test isa(GG([g, g^2]), Groups.DirectProductGroupElem{Generic.perm{Int64}})
h = GG([g,g^2])

View File

@ -73,7 +73,7 @@
Wr = WreathProduct(PermutationGroup(2),S_3)
@test isa([elements(Wr)...], Vector{Groups.WreathProductElem{Generic.perm}})
@test isa([elements(Wr)...], Vector{Groups.WreathProductElem{Generic.perm{Int64}}})
elts = [elements(Wr)...]