re-parametrize WreathProducts

This commit is contained in:
kalmarek 2019-01-09 16:44:04 +01:00
parent d579dd8f35
commit 883b85a7dc
2 changed files with 21 additions and 22 deletions

View File

@ -19,28 +19,27 @@ export WreathProduct, WreathProductElem
* `N::Group` : the single factor of the group $N$
* `P::Generic.PermGroup` : full `PermutationGroup`
"""
struct WreathProduct{N, T<:Group, I<:Integer} <: Group
struct WreathProduct{N, T<:Group, PG<:Generic.PermGroup} <: Group
N::DirectPowerGroup{N, T}
P::Generic.PermGroup{I}
P::PG
function WreathProduct(Gr::T, P::Generic.PermGroup{I}) where {T, I}
function WreathProduct(Gr::T, P::PG) where {T, PG<:Generic.PermGroup}
N = DirectPowerGroup(Gr, Int(P.n))
return new{Int(P.n), T, I}(N, P)
return new{Int(P.n), T, PG}(N, P)
end
end
struct WreathProductElem{N, T<:GroupElem, I<:Integer} <: GroupElem
struct WreathProductElem{N, T<:GroupElem, P<:Generic.perm} <: GroupElem
n::DirectPowerGroupElem{N, T}
p::Generic.perm{I}
# parent::WreathProduct
p::P
function WreathProductElem(n::DirectPowerGroupElem{N,T}, p::Generic.perm{I},
check::Bool=true) where {N, T, I}
function WreathProductElem(n::DirectPowerGroupElem{N,T}, p::P,
check::Bool=true) where {N, T, P<:Generic.perm}
if check
length(n.elts) == length(p.d) || throw(DomainError(
N == length(p.d) || throw(DomainError(
"Can't form WreathProductElem: lengths differ"))
end
return new{N, T, I}(n, p)
return new{N, T, P}(n, p)
end
end
@ -50,10 +49,10 @@ end
#
###############################################################################
elem_type(::Type{WreathProduct{N, T, I}}) where {N, T, I} = WreathProductElem{N, elem_type(T), I}
elem_type(::Type{WreathProduct{N, T, PG}}) where {N, T, PG} = WreathProductElem{N, elem_type(T), elem_type(PG)}
parent_type(::Type{WreathProductElem{N, T, I}}) where {N, T, I} =
WreathProduct{N, parent_type(T), I}
parent_type(::Type{WreathProductElem{N, T, P}}) where {N, T, P} =
WreathProduct{N, parent_type(T), parent_type(P)}
parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p))
@ -205,7 +204,7 @@ function iterate(G::WreathProduct, state)
return G(n,p), (state_N, p, state_P)
end
eltype(::Type{WreathProduct{N,G,I}}) where {N,G,I} = WreathProductElem{N, elem_type(G), I}
eltype(::Type{WreathProduct{N,G,PG}}) where {N,G,PG} = WreathProductElem{N, elem_type(G), elem_type(PG)}
order(G::WreathProduct) = order(G.P)*order(G.N)
length(G::WreathProduct) = order(G)

View File

@ -8,7 +8,7 @@
@test Groups.WreathProduct(S_2, S_3) isa AbstractAlgebra.Group
B3 = Groups.WreathProduct(S_2, S_3)
@test B3 isa Groups.WreathProduct
@test B3 isa WreathProduct{3, AbstractAlgebra.Generic.PermGroup{Int}, Int}
@test B3 isa WreathProduct{3, Generic.PermGroup{Int}, Generic.PermGroup{Int}}
aa = Groups.DirectPowerGroupElem((a^0 ,a, a^2))
@ -16,7 +16,7 @@
x = Groups.WreathProductElem(aa, b)
@test x isa Groups.WreathProductElem
@test x isa
Groups.WreathProductElem{3, AbstractAlgebra.Generic.perm{Int}, Int}
Groups.WreathProductElem{3, perm{Int}, perm{Int}}
@test B3.N == Groups.DirectPowerGroup(S_2, 3)
@test B3.P == S_3
@ -35,9 +35,9 @@
@testset "Types" begin
B3 = Groups.WreathProduct(S_2, S_3)
@test elem_type(B3) == Groups.WreathProductElem{3, perm{Int}, Int}
@test elem_type(B3) == Groups.WreathProductElem{3, perm{Int}, perm{Int}}
@test parent_type(typeof(B3())) == Groups.WreathProduct{3, parent_type(typeof(B3.N.group())), Int}
@test parent_type(typeof(B3())) == Groups.WreathProduct{3, parent_type(typeof(B3.N.group())), Generic.PermGroup{Int}}
@test parent(B3()) == Groups.WreathProduct(S_2,S_3)
@test parent(B3()) == B3
@ -89,19 +89,19 @@
B3_a = Groups.WreathProduct(AdditiveGroup(GF(3)), S_3)
@test order(B3_a) == 3^3*6
@test collect(B3_a) isa Vector{
WreathProductElem{3, AddGrpElem{AbstractAlgebra.gfelem{Int}}, Int}}
WreathProductElem{3, AddGrpElem{AbstractAlgebra.gfelem{Int}}, perm{Int}}}
B3_m = Groups.WreathProduct(MultiplicativeGroup(GF(3)), S_3)
@test order(B3_m) == 2^3*6
@test collect(B3_m) isa Vector{
WreathProductElem{3, MltGrpElem{AbstractAlgebra.gfelem{Int}}, Int}}
WreathProductElem{3, MltGrpElem{AbstractAlgebra.gfelem{Int}}, perm{Int}}}
@test length(Set([B3_a, B3_m, B3_a])) == 2
Wr = WreathProduct(PermutationGroup(2),PermutationGroup(4))
elts = collect(Wr)
@test elts isa Vector{Groups.WreathProductElem{4, Generic.perm{Int}, Int}}
@test elts isa Vector{Groups.WreathProductElem{4, perm{Int}, perm{Int}}}
@test order(Wr) == 2^4*factorial(4)
@test length(elts) == order(Wr)