From df554480ea0f3031f98e2ef03135e1b857b31d17 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Tue, 10 Apr 2018 13:09:50 +0200 Subject: [PATCH] parametrize WreathProduct over Integers --- src/WreathProducts.jl | 28 ++++++++++++++-------------- test/WreathProd-tests.jl | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 9e13283..629fae4 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -19,27 +19,27 @@ doc""" * `::Group` : the single factor of group $N$ * `::Generic.PermGroup` : full `PermutationGroup` """ -struct WreathProduct{T<:Group} <: Group +struct WreathProduct{T<:Group, I<:Integer} <: Group N::DirectProductGroup{T} - P::Generic.PermGroup + P::Generic.PermGroup{I} - function WreathProduct{T}(G::T, P::Generic.PermGroup) where {T} - N = DirectProductGroup(G, P.n) + function WreathProduct{T, I}(Gr::T, P::Generic.PermGroup{I}) where {T, I} + N = DirectProductGroup(Gr, Int(P.n)) return new(N, P) end end -struct WreathProductElem{T<:GroupElem} <: GroupElem +struct WreathProductElem{T<:GroupElem, I<:Integer} <: GroupElem n::DirectProductGroupElem{T} - p::Generic.perm + p::Generic.perm{I} # parent::WreathProduct - function WreathProductElem{T}(n::DirectProductGroupElem{T}, p::Generic.perm, - check::Bool=true) where {T} + function WreathProductElem{T, I}(n::DirectProductGroupElem{T}, p::Generic.perm{I}, + check::Bool=true) where {T, I} if check length(n.elts) == parent(p).n || throw("Can't form WreathProductElem: lengths differ") end - return new{T}(n, p) + return new(n, p) end end @@ -49,10 +49,10 @@ end # ############################################################################### -elem_type(::WreathProduct{T}) where {T} = WreathProductElem{elem_type(T)} +elem_type(::WreathProduct{T, I}) where {T, I} = WreathProductElem{elem_type(T), I} -parent_type(::Type{WreathProductElem{T}}) where {T} = - WreathProduct{parent_type(T)} +parent_type(::Type{WreathProductElem{T, I}}) where {T, I} = + WreathProduct{parent_type(T), I} parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p)) @@ -62,9 +62,9 @@ parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p)) # ############################################################################### -WreathProduct(G::Gr, P::Generic.PermGroup) where {Gr} = WreathProduct{Gr}(G, P) +WreathProduct(G::T, P::Generic.PermGroup{I}) where {T, I} = WreathProduct{T, I}(G, P) -WreathProductElem(n::DirectProductGroupElem{T}, p, check=true) where {T} = WreathProductElem{T}(n, p, check) +WreathProductElem(n::DirectProductGroupElem{T}, p::Generic.perm{I}, check=true) where {T, I} = WreathProductElem{T, I}(n, p, check) ############################################################################### # diff --git a/test/WreathProd-tests.jl b/test/WreathProd-tests.jl index 1afa7e1..437280d 100644 --- a/test/WreathProd-tests.jl +++ b/test/WreathProd-tests.jl @@ -42,9 +42,9 @@ @testset "Types" begin B3 = Groups.WreathProduct(F, S_3) - @test elem_type(B3) == Groups.WreathProductElem{elem_type(F)} + @test elem_type(B3) == Groups.WreathProductElem{elem_type(F), Int} - @test parent_type(typeof(B3())) == Groups.WreathProduct{parent_type(typeof(B3.N.group()))} + @test parent_type(typeof(B3())) == Groups.WreathProduct{parent_type(typeof(B3.N.group())), Int} @test parent(B3()) == Groups.WreathProduct(F,S_3) @test parent(B3()) == B3 @@ -73,7 +73,7 @@ Wr = WreathProduct(PermutationGroup(2),S_3) - @test isa([elements(Wr)...], Vector{Groups.WreathProductElem{Generic.perm{Int64}}}) + @test isa([elements(Wr)...], Vector{Groups.WreathProductElem{Generic.perm{Int}, Int}}) elts = [elements(Wr)...]