From ff7bbe8e21377611fa8d087520f8da718ff36b65 Mon Sep 17 00:00:00 2001 From: kalmar Date: Thu, 6 Jul 2017 09:45:14 +0200 Subject: [PATCH 01/62] allow for different group operation in generate_balls/products --- src/Groups.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Groups.jl b/src/Groups.jl index 14267d1..ef1156f 100644 --- a/src/Groups.jl +++ b/src/Groups.jl @@ -371,12 +371,12 @@ replace_all{T<:GSymbol}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}}) = rep # ############################################################################### -function products{T<:GroupElem}(X::AbstractVector{T}, Y::AbstractVector{T}) +function products{T<:GroupElem}(X::AbstractVector{T}, Y::AbstractVector{T}, op=*) result = Vector{T}() seen = Set{T}() for x in X for y in Y - z = x*y + z = op(x,y) if !in(z, seen) push!(seen, z) push!(result, z) @@ -386,12 +386,12 @@ function products{T<:GroupElem}(X::AbstractVector{T}, Y::AbstractVector{T}) return result end -function generate_balls{T<:GroupElem}(S::Vector{T}, Id::T; radius=2) +function generate_balls{T<:GroupElem}(S::Vector{T}, Id::T; radius=2, op=*) sizes = Vector{Int}() S = unshift!(S, Id) B = [Id] for i in 1:radius - B = products(B, S); + B = products(B, S, op); push!(sizes, length(B)) end return B, sizes From 32f07e1315cb4ac5b64c16fc0c2203e61e62f051 Mon Sep 17 00:00:00 2001 From: kalmar Date: Thu, 6 Jul 2017 10:04:39 +0200 Subject: [PATCH 02/62] git fix typealias --- src/FPGroups.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FPGroups.jl b/src/FPGroups.jl index 4ab27c8..aef6a62 100644 --- a/src/FPGroups.jl +++ b/src/FPGroups.jl @@ -9,7 +9,7 @@ immutable FPSymbol <: GSymbol pow::Int end -typealias FPGroupElem = GWord{FPSymbol} +typealias FPGroupElem GWord{FPSymbol} type FPGroup <: AbstractFPGroup gens::Vector{FPSymbol} From 4492c4451ea33c859f945e2a40760f008e2ed0ae Mon Sep 17 00:00:00 2001 From: kalmar Date: Tue, 11 Jul 2017 16:26:26 +0200 Subject: [PATCH 03/62] fix skipped tests --- test/FreeGroup-tests.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/FreeGroup-tests.jl b/test/FreeGroup-tests.jl index 698dc38..5a556b4 100644 --- a/test/FreeGroup-tests.jl +++ b/test/FreeGroup-tests.jl @@ -38,12 +38,14 @@ end end @testset "eltary functions" begin - @test_skip (s*s).symbols == (s^2).symbols - @test_skip Vector{Groups.GWord{Groups.FreeSymbol}}([s,t]) == - Vector{FreeGroupElem}([s,t]) - @test_skip Vector{Groups.GWord}([s,t]) == - [Groups.GWord(s), Groups.GWord(t)] - @test_skip hash([t^1,s^1]) == hash([t^2*inv(t),s*inv(s)*s]) + G = FreeGroup(["s", "t"]) + s = G(s) + t = G(t) + @test Vector{Groups.GWord}([s,t]) == [Groups.GWord(s), Groups.GWord(t)] + + @test (s*s).symbols == (s^2).symbols + + @test hash([t^1,s^1]) == hash([t^2*inv(t),s*inv(s)*s]) end end @@ -55,8 +57,6 @@ end @test isa(G(), FreeGroupElem) @test eltype(G.gens) == Groups.FreeSymbol @test length(G.gens) == 2 - @test_skip eltype(G.rels) == FreeGroupElem - @test_skip length(G.rels) == 0 @test eltype(Nemo.gens(G)) == FreeGroupElem @test length(Nemo.gens(G)) == 2 end From c2f23644a08ce5141e89e79258f0e8c40ceaef8a Mon Sep 17 00:00:00 2001 From: kalmar Date: Tue, 11 Jul 2017 16:33:38 +0200 Subject: [PATCH 04/62] update .travis.yml for julia 0.6 --- .travis.yml | 4 +++- README.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a32517e..426f41c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,13 @@ os: - linux - osx julia: - - release + - 0.5 + - 0.6 - nightly matrix: fast_finish: true allow_failures: + - julia: 0.6 - julia: nightly notifications: diff --git a/README.md b/README.md index 9e070e8..c6573a4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # Groups -[![Build Status](https://travis-ci.org/abulak/Groups.jl.svg?branch=master)](https://travis-ci.org/abulak/Groups.jl) +[![Build Status](https://travis-ci.org/kalmarek/Groups.jl.svg?branch=master)](https://travis-ci.org/kalmarek/Groups.jl) From 331143ad4229fcac52aa2ded24af9ab0d86e2619 Mon Sep 17 00:00:00 2001 From: kalmar Date: Tue, 11 Jul 2017 16:36:15 +0200 Subject: [PATCH 05/62] no need to pull Permutations.jl anymore --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 426f41c..21cf5fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ notifications: # uncomment the following lines to override the default test script script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'Pkg.clone("https://github.com/scheinerman/Permutations.jl.git")' - julia -e 'Pkg.clone(pwd()); Pkg.build("Groups"); Pkg.test("Groups"; coverage=true)' after_success: # push coverage results to Coveralls From b07550cd375a640834890038a5b75042d533b811 Mon Sep 17 00:00:00 2001 From: kalmar Date: Tue, 11 Jul 2017 16:36:28 +0200 Subject: [PATCH 06/62] email me on failures --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 21cf5fd..3f50e22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: - julia: nightly notifications: - email: false + email: true # uncomment the following lines to override the default test script script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi From 8631e5d16bc72a803e5664c50ff9aab3061e8c81 Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 12 Jul 2017 21:05:21 +0200 Subject: [PATCH 07/62] type DirectProductGroup/Elems after type of single factor This limits the scope of DirectProductGroup/Elems to pure direct products --- src/DirectProducts.jl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index df722f7..080f24d 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -14,16 +14,12 @@ Implements direct product of groups as vector factors. The group operation is `*` distributed component-wise, with component-wise identity as neutral element. """ -type DirectProductGroup <: Group - factors::Vector{Group} - operations::Vector{Function} +immutable DirectProductGroup{T<:Group} <: Group + factors::Vector{T} end -type DirectProductGroupElem <: GroupElem - elts::Vector{GroupElem} - parent::DirectProductGroup - - DirectProductGroupElem{T<:GroupElem}(a::Vector{T}) = new(a) +immutable DirectProductGroupElem{T<:GroupElem} <: GroupElem + elts::Vector{T} end ############################################################################### From 78eded0124975b953043f0fb441f233964fcd5c6 Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 12 Jul 2017 21:05:55 +0200 Subject: [PATCH 08/62] construct parent object on the fly --- src/DirectProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 080f24d..74512c1 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -32,7 +32,7 @@ elem_type(G::DirectProductGroup) = DirectProductGroupElem parent_type(::Type{DirectProductGroupElem}) = DirectProductGroup -parent(g::DirectProductGroupElem) = g.parent +parent(g::DirectProductGroupElem) = DirectProductGroup([parent(h) for h in g.elts]) ############################################################################### # From 6b84254416d92c8a78587eb5ba66ad4feda1d132 Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 12 Jul 2017 21:06:07 +0200 Subject: [PATCH 09/62] typed elem_type --- src/DirectProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 74512c1..a34d3fd 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -28,7 +28,7 @@ end # ############################################################################### -elem_type(G::DirectProductGroup) = DirectProductGroupElem +elem_type{T<:Group}(G::DirectProductGroup{T}) = DirectProductGroupElem{elem_type(first(G.factors))} parent_type(::Type{DirectProductGroupElem}) = DirectProductGroup From 799878ded5ebc3ff624643ca57c9be16cd5cb61b Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 12 Jul 2017 21:07:05 +0200 Subject: [PATCH 10/62] Brave new constructors --- src/DirectProducts.jl | 50 ++++++------------------------------------- 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index a34d3fd..b0084b9 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -40,30 +40,11 @@ parent(g::DirectProductGroupElem) = DirectProductGroup([parent(h) for h in g.elt # ############################################################################### -DirectProductGroup(G::Group, H::Group) = DirectProductGroup([G, H], Function[(*),(*)]) - -DirectProductGroup(G::Group, H::Ring) = DirectProductGroup([G, H], Function[(*),(+)]) - -DirectProductGroup(G::Ring, H::Group) = DirectProductGroup([G, H], Function[(+),(*)]) - -DirectProductGroup(G::Ring, H::Ring) = DirectProductGroup([G, H], Function[(+),(+)]) - -DirectProductGroup{T<:Ring}(X::Vector{T}) = DirectProductGroup(Group[X...], Function[(+) for _ in X]) - -×(G::Group, H::Group) = DirectProductGroup(G,H) - -function DirectProductGroup{T<:Group, S<:Group}(G::Tuple{T, Function}, H::Tuple{S, Function}) - return DirectProductGroup([G[1], H[1]], Function[G[2],H[2]]) end -function DirectProductGroup(groups::Vector) - for G in groups - typeof(G) <: Group || throw("$G is not a group!") - end - ops = Function[typeof(G) <: Ring ? (+) : (*) for G in groups] +DirectProductGroup{T<:Group}(G::T, H::T) = DirectProductGroup{T}([G, H]) - return DirectProductGroup(groups, ops) -end +×(G::Group, H::Group) = DirectProductGroup([G,H]) ############################################################################### # @@ -71,16 +52,9 @@ end # ############################################################################### -(G::DirectProductGroup)() = G([H() for H in G.factors]; checked=false) +(G::DirectProductGroup)() = G([H() for H in G.factors]) -function (G::DirectProductGroup)(g::DirectProductGroupElem; checked=true) - if checked - return G(g.elts) - else - g.parent = G - return g - end -end +(G::DirectProductGroup)(g::DirectProductGroupElem) = G(g.elts) doc""" (G::DirectProductGroup)(a::Vector; checked=true) @@ -89,21 +63,11 @@ doc""" > `false` no checks on the correctness are performed. """ -function (G::DirectProductGroup)(a::Vector; checked=true) +function (G::DirectProductGroup){T<:GroupElem}(a::Vector{T}) length(a) == length(G.factors) || throw("Cannot coerce $a to $G: they have different number of factors") - if checked - for (F,g) in zip(G.factors, a) - try - F(g) - catch - throw("Cannot coerce to $G: $g cannot be coerced to $F.") - end - end - end - elt = DirectProductGroupElem([F(g) for (F,g) in zip(G.factors, a)]) - elt.parent = G - return elt + @assert elem_type(first(G.factors)) == T + return DirectProductGroupElem(a) end ############################################################################### From a3eeee07281b318e4a7d51299ac8df8d2fa0acca Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 12 Jul 2017 21:10:01 +0200 Subject: [PATCH 11/62] AbstractVector interface for DirectProductGroupElem --- src/DirectProducts.jl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index b0084b9..dce8f4b 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -36,12 +36,24 @@ parent(g::DirectProductGroupElem) = DirectProductGroup([parent(h) for h in g.elt ############################################################################### # -# DirectProductGroup / DirectProductGroupElem constructors +# AbstractVector interface # ############################################################################### +Base.size(g::DirectProductGroupElem) = size(g.elts) +Base.linearindexing(::Type{DirectProductGroupElem}) = Base.LinearFast() +Base.getindex(g::DirectProductGroupElem, i::Int) = g.elts[i] +function Base.setindex!{T<:GroupElem}(g::DirectProductGroupElem{T}, v::T, i::Int) + p.part[i] = v + return p end +############################################################################### +# +# DirectProductGroup / DirectProductGroupElem constructors +# +############################################################################### + DirectProductGroup{T<:Group}(G::T, H::T) = DirectProductGroup{T}([G, H]) ×(G::Group, H::Group) = DirectProductGroup([G,H]) From 674fa9f9d3ab1dda94918ee7233fce143d2fe14f Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 12 Jul 2017 21:10:31 +0200 Subject: [PATCH 12/62] never access parent filed directly --- src/DirectProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index dce8f4b..f324b29 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -98,7 +98,7 @@ function hash(G::DirectProductGroup, h::UInt) end function hash(g::DirectProductGroupElem, h::UInt) - return hash(g.elts, hash(g.parent, hash(DirectProductGroupElem, h))) + return hash(g.elts, hash(parent(g), hash(DirectProductGroupElem, h))) end doc""" From a5a67bd7d3a7d9811b0e2e63db076991560bb9c8 Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 12 Jul 2017 21:11:12 +0200 Subject: [PATCH 13/62] operations field is no more --- src/DirectProducts.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index f324b29..4e6b7a5 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -94,7 +94,7 @@ function deepcopy_internal(g::DirectProductGroupElem, dict::ObjectIdDict) end function hash(G::DirectProductGroup, h::UInt) - return hash(G.factors, hash(G.operations, hash(DirectProductGroup,h))) + return hash(G.factors, hash(DirectProductGroup,h)) end function hash(g::DirectProductGroupElem, h::UInt) @@ -131,7 +131,6 @@ end function (==)(G::DirectProductGroup, H::DirectProductGroup) G.factors == H.factors || return false - G.operations == H.operations || return false return true end From d2cb646119a632e2100baeed337b07b134fa7007 Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 12 Jul 2017 21:11:50 +0200 Subject: [PATCH 14/62] use additive group for objects involving Rings --- src/DirectProducts.jl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 4e6b7a5..1ff2ef9 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -152,9 +152,13 @@ end ############################################################################### function direct_mult(g::DirectProductGroupElem, h::DirectProductGroupElem) - parent(g) == parent(h) || throw("Can't multiply elements from different groups: $g, $h") - G = parent(g) - return G([op(a,b) for (op,a,b) in zip(G.operations, g.elts, h.elts)]) + G = parent(g) + # G == parent(h) || throw("Can't multiply elements from different groups: $G, $parent(h)") + if isa(first(G.factors), Ring) + return G(.+(g.elts,h.elts)) + else + return G(.*(g.elts,h.elts)) + end end doc""" @@ -179,7 +183,11 @@ doc""" # TODO: dirty hack around `+` operation function inv(g::DirectProductGroupElem) G = parent(g) - return G([(op == (*) ? inv(elt): -elt) for (op,elt) in zip(G.operations, g.elts)]) + if isa(first(G.factors), Ring) + return DirectProductGroupElem([-a for a in g.elts]) + else + return DirectProductGroupElem([inv(a) for a in g.elts]) + end end ############################################################################### From a78e4ccea29a4ad84e96c9b542078e28ddbcce09 Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 16 Jul 2017 21:43:43 +0200 Subject: [PATCH 15/62] spacing --- src/WreathProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 82ccc77..9ab4ba6 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -175,7 +175,7 @@ function wreath_multiplication(g::WreathProductElem, h::WreathProductElem) parent(g) == parent(h) || throw("Can not multiply elements from different groups!") G = parent(g) - w=G.N((h.n).elts[inv(g.p).d]) + w = G.N((h.n).elts[inv(g.p).d]) return G(g.n*w, g.p*h.p) end From 9cab1dd23627a46cba629eea78550978eb723723 Mon Sep 17 00:00:00 2001 From: kalmar Date: Mon, 17 Jul 2017 20:17:59 +0200 Subject: [PATCH 16/62] comment the standard script lines --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f50e22..f5e3940 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,9 @@ matrix: notifications: email: true # uncomment the following lines to override the default test script -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'Pkg.clone(pwd()); Pkg.build("Groups"); Pkg.test("Groups"; coverage=true)' +# script: +# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi +# - julia -e 'Pkg.clone(pwd()); Pkg.build("Groups"); Pkg.test("Groups"; coverage=true)' after_success: # push coverage results to Coveralls - julia -e 'cd(Pkg.dir("Groups")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' From d02c5afc6520aea3b7879d5960df68d617e7903f Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:19:56 +0200 Subject: [PATCH 17/62] store only single factor and multiplicity in DirectProductGroup --- src/DirectProducts.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 1ff2ef9..fc74356 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -9,13 +9,14 @@ export DirectProductGroup, DirectProductGroupElem ############################################################################### doc""" - DirectProductGroup(factors::Vector{Group}) <: Group -Implements direct product of groups as vector factors. The group operation is + DirectProductGroup(G::Group, n::Int) <: Group +Implements `n`-fold direct product of `G`. The group operation is `*` distributed component-wise, with component-wise identity as neutral element. """ immutable DirectProductGroup{T<:Group} <: Group - factors::Vector{T} + group::T + n::Int end immutable DirectProductGroupElem{T<:GroupElem} <: GroupElem From 7f1b6f61d0c312c90c6f83cebeb5048d05671db3 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:20:31 +0200 Subject: [PATCH 18/62] fine tuned elem_type, parent_type --- src/DirectProducts.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index fc74356..0842f37 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -29,9 +29,11 @@ end # ############################################################################### -elem_type{T<:Group}(G::DirectProductGroup{T}) = DirectProductGroupElem{elem_type(first(G.factors))} +elem_type{T<:Group}(G::DirectProductGroup{T}) = + DirectProductGroupElem{elem_type(G.group)} -parent_type(::Type{DirectProductGroupElem}) = DirectProductGroup +parent_type{T<:GroupElem}(::Type{DirectProductGroupElem{T}}) = + DirectProductGroup{parent_type(T)} parent(g::DirectProductGroupElem) = DirectProductGroup([parent(h) for h in g.elts]) From 7f67a681763af78d11d6bcaec29398aff5630145 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:21:38 +0200 Subject: [PATCH 19/62] compute parent of element as needed ==> avoid calling parent(g) --- src/DirectProducts.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 0842f37..2fa86bc 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -35,7 +35,8 @@ elem_type{T<:Group}(G::DirectProductGroup{T}) = parent_type{T<:GroupElem}(::Type{DirectProductGroupElem{T}}) = DirectProductGroup{parent_type(T)} -parent(g::DirectProductGroupElem) = DirectProductGroup([parent(h) for h in g.elts]) +parent(g::DirectProductGroupElem) = + DirectProductGroup(parent(first(g.elts)), length(g.elts)) ############################################################################### # From 6820274f65429744d2d71f7c3fdc8d0b4826ab31 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:22:47 +0200 Subject: [PATCH 20/62] handled by inner constructor --- src/DirectProducts.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 2fa86bc..d1fb3a4 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -58,8 +58,6 @@ end # ############################################################################### -DirectProductGroup{T<:Group}(G::T, H::T) = DirectProductGroup{T}([G, H]) - ×(G::Group, H::Group) = DirectProductGroup([G,H]) ############################################################################### From ae97c20e62c525f9840360cd939596da7670a5a3 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:23:16 +0200 Subject: [PATCH 21/62] update \times outer constructor --- src/DirectProducts.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index d1fb3a4..b907274 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -58,7 +58,10 @@ end # ############################################################################### -×(G::Group, H::Group) = DirectProductGroup([G,H]) +function ×(G::Group, H::Group) + G == H || throw("Direct products are defined only for the same groups") + return DirectProductGroup(G,2) +end ############################################################################### # @@ -66,8 +69,6 @@ end # ############################################################################### -(G::DirectProductGroup)() = G([H() for H in G.factors]) - (G::DirectProductGroup)(g::DirectProductGroupElem) = G(g.elts) doc""" From ba4400efbb682f7a9be9375f4af8cac7a5934594 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:25:34 +0200 Subject: [PATCH 22/62] optionally coerce to G when called G(a::Vector) --- src/DirectProducts.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index b907274..028b7c1 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -72,16 +72,16 @@ end (G::DirectProductGroup)(g::DirectProductGroupElem) = G(g.elts) doc""" - (G::DirectProductGroup)(a::Vector; checked=true) -> Constructs element of the direct product group `G` by coercing each element -> of vector `a` to the corresponding factor of `G`. If `checked` flag is set to -> `false` no checks on the correctness are performed. - + (G::DirectProductGroup)(a::Vector, check::Bool=true) +> Constructs element of the $n$-fold direct product group `G` by coercing each +> element of vector `a` to `G.group`. If `check` flag is set to `false` no +> checks on the correctness are performed. """ -function (G::DirectProductGroup){T<:GroupElem}(a::Vector{T}) - length(a) == length(G.factors) || throw("Cannot coerce $a to $G: they have - different number of factors") - @assert elem_type(first(G.factors)) == T +function (G::DirectProductGroup)(a::Vector, check::Bool=true) + if check + G.n == length(a) || throw("Can not coerce to DirectProductGroup: lengths differ") + a = G.group.(a) + end return DirectProductGroupElem(a) end From 10022fd31c2be5d38ba10be0a7e3cbefb4e77b3e Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:27:00 +0200 Subject: [PATCH 23/62] DirectProductGroup overloads: with vector and GroupElem --- src/DirectProducts.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 028b7c1..6386982 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -69,8 +69,6 @@ end # ############################################################################### -(G::DirectProductGroup)(g::DirectProductGroupElem) = G(g.elts) - doc""" (G::DirectProductGroup)(a::Vector, check::Bool=true) > Constructs element of the $n$-fold direct product group `G` by coercing each @@ -85,6 +83,10 @@ function (G::DirectProductGroup)(a::Vector, check::Bool=true) return DirectProductGroupElem(a) end +(G::DirectProductGroup)() = DirectProductGroupElem([G.group() for _ in 1:G.n]) + +(G::DirectProductGroup)(g::DirectProductGroupElem) = G(g.elts) + ############################################################################### # # Basic manipulation From 7989967cc40c5cec1f3c7bd751722118c507fc34 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:27:27 +0200 Subject: [PATCH 24/62] vararg version of overload -- with mandatory checking --- src/DirectProducts.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 6386982..9e8f45d 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -87,6 +87,8 @@ end (G::DirectProductGroup)(g::DirectProductGroupElem) = G(g.elts) +(G::DirectProductGroup){T<:GroupElem, N}(a::Vararg{T, N}) = G([a...]) + ############################################################################### # # Basic manipulation From 610defe354af57d57de869db7f9a302950995676 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:27:54 +0200 Subject: [PATCH 25/62] update hash according to changes in type --- src/DirectProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 9e8f45d..6bf5374 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -101,7 +101,7 @@ function deepcopy_internal(g::DirectProductGroupElem, dict::ObjectIdDict) end function hash(G::DirectProductGroup, h::UInt) - return hash(G.factors, hash(DirectProductGroup,h)) + return hash(G.group, hash(G.n, hash(DirectProductGroup,h))) end function hash(g::DirectProductGroupElem, h::UInt) From ca23485b5e68629c8e3fc8e414a8c5665a5bb235 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:28:19 +0200 Subject: [PATCH 26/62] trivial updates to show, == --- src/DirectProducts.jl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 6bf5374..6194bdf 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -122,12 +122,11 @@ eye(G::DirectProductGroup) = G() ############################################################################### function show(io::IO, G::DirectProductGroup) - println(io, "Direct product of groups") - join(io, G.factors, ", ", " and ") + println(io, "$(G.n)-fold direct product of $(G.group)") end function show(io::IO, g::DirectProductGroupElem) - print(io, "("*join(g.elts,",")*")") + print(io, "($(join(g.elts,",")))") end ############################################################################### @@ -136,15 +135,19 @@ end # ############################################################################### +doc""" + ==(g::DirectProductGroup, h::DirectProductGroup) +> Checks if two direct product groups are the same. +""" function (==)(G::DirectProductGroup, H::DirectProductGroup) - G.factors == H.factors || return false + G.group == H.group || return false + G.n == G.n || return false return true end doc""" ==(g::DirectProductGroupElem, h::DirectProductGroupElem) -> Return `true` if the given elements of direct products are equal, otherwise return `false`. - +> Checks if two direct product group elements are the same. """ function (==)(g::DirectProductGroupElem, h::DirectProductGroupElem) parent(g) == parent(h) || return false From 83f9ed61b86e709d8a8c6bbf944aae78274759bc Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:30:35 +0200 Subject: [PATCH 27/62] multiple dispatch style solutions for * and inv for rings --- src/DirectProducts.jl | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 6194bdf..5acfc52 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -161,23 +161,25 @@ end # ############################################################################### -function direct_mult(g::DirectProductGroupElem, h::DirectProductGroupElem) - G = parent(g) - # G == parent(h) || throw("Can't multiply elements from different groups: $G, $parent(h)") - if isa(first(G.factors), Ring) - return G(.+(g.elts,h.elts)) - else - return G(.*(g.elts,h.elts)) - end -end - doc""" *(g::DirectProductGroupElem, h::DirectProductGroupElem) > Return the direct-product group operation of elements, i.e. component-wise > operation as defined by `operations` field of the parent object. - """ -(*)(g::DirectProductGroupElem, h::DirectProductGroupElem) = direct_mult(g,h) +# TODO: dirty hack around `+/*` operations +function *{T<:GroupElem}(g::DirectProductGroupElem{T}, h::DirectProductGroupElem{T}, check::Bool=true) + if check + parent(g) == parent(h) || throw("Can not multiply elements of different groups!") + end + return DirectProductGroupElem([a*b for (a,b) in zip(g.elts,h.elts)]) +end + +function *{T<:RingElem}(g::DirectProductGroupElem{T}, h::DirectProductGroupElem{T}, check::Bool=true) + if check + parent(g) == parent(h) || throw("Can not multiply elements of different groups!") + end + return DirectProductGroupElem([a+b for (a,b) in zip(g.elts,h.elts)]) +end ############################################################################### # @@ -188,16 +190,14 @@ doc""" doc""" inv(g::DirectProductGroupElem) > Return the inverse of the given element in the direct product group. - """ -# TODO: dirty hack around `+` operation -function inv(g::DirectProductGroupElem) - G = parent(g) - if isa(first(G.factors), Ring) - return DirectProductGroupElem([-a for a in g.elts]) - else - return DirectProductGroupElem([inv(a) for a in g.elts]) - end +# TODO: dirty hack around `+/*` operation +function inv{T<:GroupElem}(g::DirectProductGroupElem{T}) + return DirectProductGroupElem([inv(a) for a in g.elts]) +end + +function inv{T<:RingElem}(g::DirectProductGroupElem{T}) + return DirectProductGroupElem([-a for a in g.elts]) end ############################################################################### From 16f3b6b44e2b03a583dab14e88cb0399fb86be6e Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:31:42 +0200 Subject: [PATCH 28/62] update elements, order --- src/DirectProducts.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 5acfc52..3d9cbe2 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -208,15 +208,15 @@ end doc""" elements(G::DirectProductGroup) -> Returns `Task` that produces all elements of group `G` (provided that factors -> implement the elements function). - +> Returns `generator` that produces all elements of group `G` (provided that +> `G.group` implements the `elements` method). """ # TODO: can Base.product handle generators? # now it returns nothing's so we have to collect ellements... function elements(G::DirectProductGroup) - cartesian_prod = Base.product([collect(elements(H)) for H in G.factors]...) - return (G(collect(elt)) for elt in cartesian_prod) + elts = collect(elements(G.group)) + cartesian_prod = Base.product([elts for _ in 1:G.n]...) + return (DirectProductGroupElem([elt...]) for elt in cartesian_prod) end doc""" @@ -224,4 +224,4 @@ doc""" > Returns the order (number of elements) in the group. """ -order(G::DirectProductGroup) = prod([order(H) for H in G.factors]) +order(G::DirectProductGroup) = order(G.group)^G.n From 125e4a52637d9e60ba7db16c203669128bcf08d4 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:32:34 +0200 Subject: [PATCH 29/62] remove eye --- src/DirectProducts.jl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 3d9cbe2..fcbda58 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -108,13 +108,6 @@ function hash(g::DirectProductGroupElem, h::UInt) return hash(g.elts, hash(parent(g), hash(DirectProductGroupElem, h))) end -doc""" - eye(G::DirectProductGroup) -> Return the identity element for the given direct product of groups. - -""" -eye(G::DirectProductGroup) = G() - ############################################################################### # # String I/O From fa996d68fbfafc4330050244cacbb261500397fe Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:33:40 +0200 Subject: [PATCH 30/62] make WreathProduct{Elem} concrete & immutable parametrize by WreathProduct{Elem} by T<:Group{Elem} --- src/WreathProducts.jl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 9ab4ba6..659e361 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -18,24 +18,23 @@ doc""" * `::Group` : the single factor of group N * `::PermutationGroup` : full PermutationGroup """ +immutable WreathProduct{T<:Group} <: Group + N::DirectProductGroup{T} + P::PermGroup -type WreathProduct <: Group - N::DirectProductGroup - P::PermutationGroup - - function WreathProduct(G::Group, P::PermutationGroup) - N = DirectProductGroup(typeof(G)[G for _ in 1:P.n]) + function WreathProduct(G::Group, P::PermGroup) + N = DirectProductGroup(G, P.n) return new(N, P) end end -type WreathProductElem <: GroupElem - n::DirectProductGroupElem +immutable WreathProductElem{T<:GroupElem} <: GroupElem + n::DirectProductGroupElem{T} p::perm - parent::WreathProduct + # parent::WreathProduct function WreathProductElem(n::DirectProductGroupElem, p::perm) - length(n.elts) == parent(p).n + length(n.elts) == parent(p).n || throw("Can't form WreathProductElem: lengths differ") return new(n, p) end end From a6f0685313734d7b192464fa8e2ec9a441599ade Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:36:04 +0200 Subject: [PATCH 31/62] concrete updates to elem_type, parent_type --- src/WreathProducts.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 659e361..6b294e0 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -45,9 +45,11 @@ end # ############################################################################### -elem_type(::WreathProduct) = WreathProductElem +elem_type{T<:Group}(G::WreathProduct{T}) = + WreathProductElem{G.N.n, elem_type(T)} -parent_type(::WreathProductElem) = WreathProduct +parent_type{T<:GroupElem}(::WreathProductElem{T}) = + WreathProduct{parent_type(T)} parent(g::WreathProductElem) = g.parent From 4fa7d744c24d8a58c92589837cb15910a79ab14f Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:36:39 +0200 Subject: [PATCH 32/62] parent(WreathProductElem) is now computed on the fly ==> slow --- src/WreathProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 6b294e0..12816d9 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -51,7 +51,7 @@ elem_type{T<:Group}(G::WreathProduct{T}) = parent_type{T<:GroupElem}(::WreathProductElem{T}) = WreathProduct{parent_type(T)} -parent(g::WreathProductElem) = g.parent +parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p)) ############################################################################### # From 06a4e50a2d7fc83fe0e7067d4cdebe784ffff112 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:37:28 +0200 Subject: [PATCH 33/62] don't compute G.N(p.n) and G.P(g.p) twice when coercing --- src/WreathProducts.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 12816d9..3d086a3 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -68,18 +68,18 @@ parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p)) ############################################################################### function (G::WreathProduct)(g::WreathProductElem) - try + n = try G.N(g.n) catch throw("Can't coerce $(g.n) to $(G.N) factor of $G") end - try + p = try G.P(g.p) catch throw("Can't coerce $(g.p) to $(G.P) factor of $G") end - elt = WreathProductElem(G.N(g.n), G.P(g.p)) - elt.parent = G + elt = WreathProductElem(n, p) + # elt.parent = G return elt end From b89e60e50816103ab256d389e2938f5a0d7933a9 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 13:40:54 +0200 Subject: [PATCH 34/62] standard outer constructors for WreathProduct{Elem} --- src/WreathProducts.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 3d086a3..e034052 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -59,7 +59,10 @@ parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p)) # ############################################################################### -# converts??? +WreathProduct{T<:Group}(G::T, P::PermGroup) = WreathProduct{T}(G, P) + +WreathProductElem{T<:GroupElem}(n::DirectProductGroupElem{T}, + p::perm) = WreathProductElem{T}(n, p) ############################################################################### # From 89b89f13a510e85aa8000f0fcf649664a40b9c20 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 14:23:47 +0200 Subject: [PATCH 35/62] there is no parent field --- src/WreathProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index e034052..56d2a07 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -94,7 +94,7 @@ doc""" """ function (G::WreathProduct)(n::DirectProductGroupElem, p::perm) result = WreathProductElem(n,p) - result.parent = G + # result.parent = G return result end From 7c1a96b64e20414a456fc125dd8218eea1089027 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 14:29:38 +0200 Subject: [PATCH 36/62] don't compare parents when parents are constructable --- src/DirectProducts.jl | 1 - src/WreathProducts.jl | 1 - 2 files changed, 2 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index fcbda58..8bac17f 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -143,7 +143,6 @@ doc""" > Checks if two direct product group elements are the same. """ function (==)(g::DirectProductGroupElem, h::DirectProductGroupElem) - parent(g) == parent(h) || return false g.elts == h.elts || return false return true end diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 56d2a07..1b02ed5 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -163,7 +163,6 @@ function (==)(G::WreathProduct, H::WreathProduct) end function (==)(g::WreathProductElem, h::WreathProductElem) - parent(g) == parent(h) || return false g.n == h.n || return false g.p == h.p || return false return true From 68df946c81bc5536632f2d555fad82cdc0f408d8 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 14:30:48 +0200 Subject: [PATCH 37/62] don't construct parent(::WreatProductElem) when not necessary --- src/WreathProducts.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 1b02ed5..fecbeba 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -122,8 +122,7 @@ doc""" ############################################################################### function deepcopy_internal(g::WreathProductElem, dict::ObjectIdDict) - G = parent(g) - return G(deepcopy(g.n), deepcopy(g.p)) + return WreathProductElem(deepcopy(g.n), deepcopy(g.p)) end function hash(G::WreathProduct, h::UInt) From 354da7876988c99926be086e3597301e769e8fa7 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 14:31:05 +0200 Subject: [PATCH 38/62] clean-up show --- src/WreathProducts.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index fecbeba..7dc6893 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -140,12 +140,10 @@ end ############################################################################### function show(io::IO, G::WreathProduct) - print(io, "Wreath Product of $(G.N.factors[1]) and $(G.P)") + print(io, "Wreath Product of $(G.N.group) by $(G.P)") end function show(io::IO, g::WreathProductElem) - # println(io, "Element of WreathProduct over $T of size $(size(X)):") - # show(io, "text/plain", matrix_repr(X)) print(io, "($(g.n)≀$(g.p))") end From 620b970f621ddc8bdeed0c5dc57582af69b18e8a Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 14:33:53 +0200 Subject: [PATCH 39/62] merge Binary operators and Inversion as Group operations --- src/WreathProducts.jl | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 7dc6893..2970c69 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -167,7 +167,7 @@ end ############################################################################### # -# Binary operators +# Group operations # ############################################################################### @@ -191,11 +191,6 @@ doc""" (*)(g::WreathProductElem, h::WreathProductElem) = wreath_multiplication(g,h) -############################################################################### -# -# Inversion -# -############################################################################### doc""" inv(g::WreathProductElem) From 36a0e8593d6674ddd4e91b8ca0135887515a090f Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 15:59:47 +0200 Subject: [PATCH 40/62] new multiplication --- src/WreathProducts.jl | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 2970c69..3ad96fd 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -171,14 +171,6 @@ end # ############################################################################### -function wreath_multiplication(g::WreathProductElem, h::WreathProductElem) - parent(g) == parent(h) || throw("Can not multiply elements from different - groups!") - G = parent(g) - w = G.N((h.n).elts[inv(g.p).d]) - return G(g.n*w, g.p*h.p) -end - doc""" *(g::WreathProductElem, h::WreathProductElem) > Return the wreath product group operation of elements, i.e. @@ -188,9 +180,10 @@ doc""" > where g.p(h.n) denotes the action of `g.p::perm` on > `h.n::DirectProductGroupElem` via standard permutation of coordinates. """ -(*)(g::WreathProductElem, h::WreathProductElem) = wreath_multiplication(g,h) - - +function *(g::WreathProductElem, h::WreathProductElem) + w = DirectProductGroupElem((h.n).elts[inv(g.p).d]) + return WreathProductElem(g.n*w, g.p*h.p) +end doc""" inv(g::WreathProductElem) From 0519d06baa1f9b7bce08a95968b57f32a30a6343 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 16:00:19 +0200 Subject: [PATCH 41/62] add check argument to WreathProductElem constructor --- src/WreathProducts.jl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 3ad96fd..461b302 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -33,8 +33,11 @@ immutable WreathProductElem{T<:GroupElem} <: GroupElem p::perm # parent::WreathProduct - function WreathProductElem(n::DirectProductGroupElem, p::perm) - length(n.elts) == parent(p).n || throw("Can't form WreathProductElem: lengths differ") + function WreathProductElem(n::DirectProductGroupElem, p::perm, + check::Bool=true) + if check + length(n.elts) == parent(p).n || throw("Can't form WreathProductElem: lengths differ") + end return new(n, p) end end @@ -62,7 +65,7 @@ parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p)) WreathProduct{T<:Group}(G::T, P::PermGroup) = WreathProduct{T}(G, P) WreathProductElem{T<:GroupElem}(n::DirectProductGroupElem{T}, - p::perm) = WreathProductElem{T}(n, p) + p::perm, check::Bool=true) = WreathProductElem{T}(n, p, check) ############################################################################### # @@ -98,7 +101,7 @@ function (G::WreathProduct)(n::DirectProductGroupElem, p::perm) return result end -(G::WreathProduct)() = G(G.N(), G.P()) +(G::WreathProduct)() = WreathProductElem(G.N(), G.P(), false) doc""" (G::WreathProduct)(p::perm) @@ -122,7 +125,7 @@ doc""" ############################################################################### function deepcopy_internal(g::WreathProductElem, dict::ObjectIdDict) - return WreathProductElem(deepcopy(g.n), deepcopy(g.p)) + return WreathProductElem(deepcopy(g.n), deepcopy(g.p), false) end function hash(G::WreathProduct, h::UInt) @@ -182,7 +185,7 @@ doc""" """ function *(g::WreathProductElem, h::WreathProductElem) w = DirectProductGroupElem((h.n).elts[inv(g.p).d]) - return WreathProductElem(g.n*w, g.p*h.p) + return WreathProductElem(g.n*w, g.p*h.p, false) end doc""" From 70a8a9b72d7aeaa8aa9f53f3d7a986d380e68726 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 16:02:07 +0200 Subject: [PATCH 42/62] get rid of the old parent stuff --- src/WreathProducts.jl | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 461b302..9f850c2 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -84,22 +84,15 @@ function (G::WreathProduct)(g::WreathProductElem) catch throw("Can't coerce $(g.p) to $(G.P) factor of $G") end - elt = WreathProductElem(n, p) - # elt.parent = G - return elt + return WreathProductElem(n, p) end doc""" (G::WreathProduct)(n::DirectProductGroupElem, p::perm) > Creates an element of wreath product `G` by coercing `n` and `p` to `G.N` and > `G.P`, respectively. - """ -function (G::WreathProduct)(n::DirectProductGroupElem, p::perm) - result = WreathProductElem(n,p) - # result.parent = G - return result -end +(G::WreathProduct)(n::DirectProductGroupElem, p::perm) = WreathProductElem(n,p) (G::WreathProduct)() = WreathProductElem(G.N(), G.P(), false) From c60e5a8c5c5e20adf5bbd5482e9b8584fb349095 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 16:02:44 +0200 Subject: [PATCH 43/62] reworked inv + doc --- src/WreathProducts.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 9f850c2..ca02615 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -184,12 +184,11 @@ end doc""" inv(g::WreathProductElem) > Returns the inverse of element of a wreath product, according to the formula -> g^-1 = (g.n, g.p)^-1 = (g.p^-1(g.n^-1), g.p^-1). +> `g^-1 = (g.n, g.p)^-1 = (g.p^-1(g.n^-1), g.p^-1)`. """ function inv(g::WreathProductElem) - G = parent(g) - w = G.N(inv(g.n).elts[g.p.d]) - return G(w, inv(g.p)) + w = DirectProductGroupElem(inv(g.n).elts[g.p.d]) + return WreathProductElem(w, inv(g.p), false) end ############################################################################### From d668574805fb269555f393e59cb82732ab984e4e Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 16:03:26 +0200 Subject: [PATCH 44/62] parent is constructable, don't use it in hash --- src/WreathProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index ca02615..e8dc4b5 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -126,7 +126,7 @@ function hash(G::WreathProduct, h::UInt) end function hash(g::WreathProductElem, h::UInt) - return hash(g.n, hash(g.p, hash(parent(g), h))) + return hash(g.n, hash(g.p, hash(WreathProductElem, h))) end ############################################################################### From 6f08259466bb3277368a23ec9af68dd25af07cb9 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 16:04:11 +0200 Subject: [PATCH 45/62] Don't multiply if not necessary -> directly create element --- src/WreathProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index e8dc4b5..2599b54 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -201,7 +201,7 @@ matrix_repr(g::WreathProductElem) = Any[matrix_repr(g.p) g.n] function elements(G::WreathProduct) iter = Base.product(collect(elements(G.N)), collect(elements(G.P))) - return (G(n)*G(p) for (n,p) in iter) + return (WreathProductElem(n, p, false) for (n,p) in iter) end order(G::WreathProduct) = order(G.P)*order(G.N) From 6fa01d87ef80e9b3dadb9a5f0eece7fb1aa8a239 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 16:04:45 +0200 Subject: [PATCH 46/62] faster versions of * and inv for products of rings --- src/DirectProducts.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index 8bac17f..ffe9426 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -170,7 +170,7 @@ function *{T<:RingElem}(g::DirectProductGroupElem{T}, h::DirectProductGroupElem{ if check parent(g) == parent(h) || throw("Can not multiply elements of different groups!") end - return DirectProductGroupElem([a+b for (a,b) in zip(g.elts,h.elts)]) + return DirectProductGroupElem(g.elts + h.elts) end ############################################################################### @@ -189,7 +189,7 @@ function inv{T<:GroupElem}(g::DirectProductGroupElem{T}) end function inv{T<:RingElem}(g::DirectProductGroupElem{T}) - return DirectProductGroupElem([-a for a in g.elts]) + return DirectProductGroupElem(-g.elts) end ############################################################################### From b7151d1fc29f783b6f4f656738ba499c959ddc82 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 16:05:49 +0200 Subject: [PATCH 47/62] docs --- src/WreathProducts.jl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 2599b54..ccacb9b 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -7,16 +7,17 @@ export WreathProduct, WreathProductElem ############################################################################### doc""" - WreathProduct <: Group -> Implements Wreath product of a group N by permutation (sub)group P < Sₖ, + WreathProduct{T<:Group} <: Group +> Implements Wreath product of a group $N$ by permutation (sub)group $P < S_k$, > usually written as $N \wr P$. > The multiplication inside wreath product is defined as -> (n, σ) * (m, τ) = (n*ψ(σ)(m), σ*τ), -> where ψ:P → Aut(Nᵏ) is the permutation representation of Sₖ restricted to P. +> $$(n, \sigma) * (m, \tau) = (n\psi(\sigma)(m), \sigma\tau),$$ +> where $\psi:P → Aut(N^k)$ is the permutation representation of $S_k$ +> restricted to $P$. # Arguments: -* `::Group` : the single factor of group N -* `::PermutationGroup` : full PermutationGroup +* `::Group` : the single factor of group $N$ +* `::PermGroup` : full `PermutationGroup` """ immutable WreathProduct{T<:Group} <: Group N::DirectProductGroup{T} @@ -99,7 +100,6 @@ doc""" doc""" (G::WreathProduct)(p::perm) > Returns the image of permutation `p` in `G` via embedding `p -> (id,p)`. - """ (G::WreathProduct)(p::perm) = G(G.N(), p) @@ -107,7 +107,6 @@ doc""" (G::WreathProduct)(n::DirectProductGroupElem) > Returns the image of `n` in `G` via embedding `n -> (n,())`. This is the > embedding that makes sequence `1 -> N -> G -> P -> 1` exact. - """ (G::WreathProduct)(n::DirectProductGroupElem) = G(n, G.P()) @@ -171,9 +170,9 @@ doc""" *(g::WreathProductElem, h::WreathProductElem) > Return the wreath product group operation of elements, i.e. > -> g*h = (g.n*g.p(h.n), g.p*h.p), +> `g*h = (g.n*g.p(h.n), g.p*h.p)`, > -> where g.p(h.n) denotes the action of `g.p::perm` on +> where `g.p(h.n)` denotes the action of `g.p::perm` on > `h.n::DirectProductGroupElem` via standard permutation of coordinates. """ function *(g::WreathProductElem, h::WreathProductElem) From aad2907c5108ed33f354f7ed9bb724c39c0fe4fd Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 17:14:55 +0200 Subject: [PATCH 48/62] fix: WreathProductElem is typed only after GroupElem --- src/WreathProducts.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index ccacb9b..5a727a6 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -49,8 +49,7 @@ end # ############################################################################### -elem_type{T<:Group}(G::WreathProduct{T}) = - WreathProductElem{G.N.n, elem_type(T)} +elem_type{T<:Group}(G::WreathProduct{T}) = WreathProductElem{elem_type(T)} parent_type{T<:GroupElem}(::WreathProductElem{T}) = WreathProduct{parent_type(T)} From cb649333a8841c5feff49a6cb08e7dd20694f0e4 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 23:36:19 +0200 Subject: [PATCH 49/62] checkout the master of Nemo --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f5e3940..0a1df47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,10 +15,11 @@ matrix: notifications: email: true -# uncomment the following lines to override the default test script -# script: -# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi -# - julia -e 'Pkg.clone(pwd()); Pkg.build("Groups"); Pkg.test("Groups"; coverage=true)' +## uncomment the following lines to override the default test script +script: + - julia -e 'Pkg.clone("https://github.com/Nemocas/Nemo.jl"); Pkg.build("Nemo")' + - julia -e 'Pkg.clone(pwd()); Pkg.build("Groups"); Pkg.test("Groups"; coverage=true)' + after_success: # push coverage results to Coveralls - julia -e 'cd(Pkg.dir("Groups")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' From 7328e24137b717777e4b005ddd10befb3438211d Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 23:37:30 +0200 Subject: [PATCH 50/62] trivial updates to the latest version of PkgDev --- .travis.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a1df47..13fb7c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,14 +7,24 @@ julia: - 0.5 - 0.6 - nightly +notifications: + email: true +git: + depth: 99999999 matrix: fast_finish: true allow_failures: - julia: 0.6 - julia: nightly -notifications: - email: true +## uncomment and modify the following lines to manually install system packages +#addons: +# apt: # apt-get for linux +# packages: +# - gfortran +#before_script: # homebrew for mac +# - if [ $TRAVIS_OS_NAME = osx ]; then brew install gcc; fi + ## uncomment the following lines to override the default test script script: - julia -e 'Pkg.clone("https://github.com/Nemocas/Nemo.jl"); Pkg.build("Nemo")' From eedc7c2b718f7ac4e9179d586370a43eb9fccd5b Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 21 Jul 2017 23:38:05 +0200 Subject: [PATCH 51/62] don't allow failures on julia-v0.6 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 13fb7c8..47a23da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,6 @@ git: matrix: fast_finish: true allow_failures: - - julia: 0.6 - julia: nightly ## uncomment and modify the following lines to manually install system packages From 251fdd4afad9ffc7d83e9b014605ed312c91cb84 Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 03:24:05 +0200 Subject: [PATCH 52/62] fix setindex! --- src/DirectProducts.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index ffe9426..e8b9b5c 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -48,8 +48,9 @@ Base.size(g::DirectProductGroupElem) = size(g.elts) Base.linearindexing(::Type{DirectProductGroupElem}) = Base.LinearFast() Base.getindex(g::DirectProductGroupElem, i::Int) = g.elts[i] function Base.setindex!{T<:GroupElem}(g::DirectProductGroupElem{T}, v::T, i::Int) - p.part[i] = v - return p + parent(v) == parent(first(g.elts)) || throw("$g is not an element of $i-th factor of $(parent(G))") + g.elts[i] = v + return g end ############################################################################### From b04a472063f6f5275e5403889de264d8b9ac9a61 Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 03:24:40 +0200 Subject: [PATCH 53/62] combine * and inv under "Group Operations" label --- src/DirectProducts.jl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index e8b9b5c..d05c5bb 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -150,7 +150,7 @@ end ############################################################################### # -# Binary operators +# Group operations # ############################################################################### @@ -174,12 +174,6 @@ function *{T<:RingElem}(g::DirectProductGroupElem{T}, h::DirectProductGroupElem{ return DirectProductGroupElem(g.elts + h.elts) end -############################################################################### -# -# Inversion -# -############################################################################### - doc""" inv(g::DirectProductGroupElem) > Return the inverse of the given element in the direct product group. From 8a8d2237c59248bc665eef91e94ce67952a2ca7b Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 03:27:03 +0200 Subject: [PATCH 54/62] Add tests for DirectProductGroups --- test/DirectProd-tests.jl | 84 ++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 1 + 2 files changed, 85 insertions(+) create mode 100644 test/DirectProd-tests.jl diff --git a/test/DirectProd-tests.jl b/test/DirectProd-tests.jl new file mode 100644 index 0000000..ae7b9fc --- /dev/null +++ b/test/DirectProd-tests.jl @@ -0,0 +1,84 @@ +@testset "DirectProducts" begin + using Nemo + + G = PermutationGroup(3) + g = G([2,3,1]) + F, a = FiniteField(2,3,"a") + + @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{Nemo.PermGroup}) + + GG = Groups.DirectProductGroup(G,2) + + @test GG == Groups.DirectProductGroup(G,2) + + @test Groups.DirectProductGroupElem([G(), G()]) == GG() + @test GG(G(), G()) == GG() + + @test isa(GG([g, g^2]), GroupElem) + @test isa(GG([g, g^2]), Groups.DirectProductGroupElem{Nemo.perm}) + + 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_throws String GG(g,g,g) + @test GG(g,g^2) == h + + @test size(h) == (2,) + @test h[1] == g + @test h[2] == g^2 + h[2] = G() + @test h == GG(g, G()) + end + + @testset "Types" begin + GG = Groups.DirectProductGroup(G,2) + FF = Groups.DirectProductGroup(F,2) + + @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 "Basis arithmetic" begin + g = G([2,3,1]) + h = GG([g,g^2]) + + @test h^2 == GG(g^2,g) + @test h^6 == GG() + + @test h*h == h^2 + + @test h*inv(h) == GG() + + @test FF([0,a])*FF([a,1]) == FF(a,1+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]) + end + + @testset "Misc" begin + @test order(GG) == 36 + @test order(FF) == 64 + + + @test isa([elements(GG)...], Vector{Groups.DirectProductGroupElem{elem_type(G)}}) + elts = [elements(GG)...] + + @test length(elts) == 36 + @test all([g*inv(g) for g in elts] .== GG()) + @test all(inv(g*h) == inv(h)*inv(g) for g in elts for h in elts) + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 336260f..86cc369 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,4 +6,5 @@ using Base.Test @testset "Groups" begin include("FreeGroup-tests.jl") include("AutGroup-tests.jl") + include("DirectProd-tests.jl") end From 166c4c217bd5dd8342af14962042fc56ff4ae9b5 Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 17:01:11 +0200 Subject: [PATCH 55/62] parent_type dispatches after Type of element --- src/WreathProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 5a727a6..80cbdd1 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -51,7 +51,7 @@ end elem_type{T<:Group}(G::WreathProduct{T}) = WreathProductElem{elem_type(T)} -parent_type{T<:GroupElem}(::WreathProductElem{T}) = +parent_type{T<:GroupElem}(::Type{WreathProductElem{T}}) = WreathProduct{parent_type(T)} parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p)) From 93d380094efa9cb48cf87a140ccfe34067c317a8 Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 17:03:28 +0200 Subject: [PATCH 56/62] define GG, FF globally for inner testsets --- test/DirectProd-tests.jl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/DirectProd-tests.jl b/test/DirectProd-tests.jl index ae7b9fc..115919b 100644 --- a/test/DirectProd-tests.jl +++ b/test/DirectProd-tests.jl @@ -37,10 +37,10 @@ @test h == GG(g, G()) end - @testset "Types" begin - GG = Groups.DirectProductGroup(G,2) - FF = Groups.DirectProductGroup(F,2) + 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)} @@ -52,7 +52,7 @@ @test_throws MethodError FF(1,0) end - @testset "Basis arithmetic" begin + @testset "Group arithmetic" begin g = G([2,3,1]) h = GG([g,g^2]) @@ -73,7 +73,6 @@ @test order(GG) == 36 @test order(FF) == 64 - @test isa([elements(GG)...], Vector{Groups.DirectProductGroupElem{elem_type(G)}}) elts = [elements(GG)...] From cac63058526c3825efd258147e98683fac424166 Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 17:04:22 +0200 Subject: [PATCH 57/62] trivial changes in docs --- src/DirectProducts.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DirectProducts.jl b/src/DirectProducts.jl index d05c5bb..af26aee 100644 --- a/src/DirectProducts.jl +++ b/src/DirectProducts.jl @@ -73,8 +73,8 @@ end doc""" (G::DirectProductGroup)(a::Vector, check::Bool=true) > Constructs element of the $n$-fold direct product group `G` by coercing each -> element of vector `a` to `G.group`. If `check` flag is set to `false` no -> checks on the correctness are performed. +> element of vector `a` to `G.group`. If `check` flag is set to `false` neither +> check on the correctness nor coercion is performed. """ function (G::DirectProductGroup)(a::Vector, check::Bool=true) if check From f8dfa919808a2c3b68e16606be64068bc0a5cedd Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 17:06:34 +0200 Subject: [PATCH 58/62] update FreeGroupsSymbols manipulation --- test/FreeGroup-tests.jl | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/test/FreeGroup-tests.jl b/test/FreeGroup-tests.jl index 5a556b4..e41ea93 100644 --- a/test/FreeGroup-tests.jl +++ b/test/FreeGroup-tests.jl @@ -23,30 +23,19 @@ end end -@testset "FreeGroupElems" begin +@testset "FreeGroupSymbols manipulation" begin s = Groups.FreeSymbol("s") t = Groups.FreeSymbol("t", -2) - @testset "defines" begin - @test isa(Groups.GWord(s), Groups.GWord) - @test isa(Groups.GWord(s), FreeGroupElem) - @test isa(FreeGroupElem(s), Groups.GWord) - @test isa(convert(FreeGroupElem, s), Groups.GWord) - @test isa(convert(FreeGroupElem, s), FreeGroupElem) - @test isa(Vector{FreeGroupElem}([s,t]), Vector{FreeGroupElem}) - @test length(FreeGroupElem(s)) == 1 - @test length(FreeGroupElem(t)) == 2 - end - @testset "eltary functions" begin - G = FreeGroup(["s", "t"]) - s = G(s) - t = G(t) - @test Vector{Groups.GWord}([s,t]) == [Groups.GWord(s), Groups.GWord(t)] + @test isa(Groups.GWord(s), Groups.GWord) + @test isa(Groups.GWord(s), FreeGroupElem) + @test isa(FreeGroupElem(s), Groups.GWord) + @test isa(convert(FreeGroupElem, s), Groups.GWord) + @test isa(convert(FreeGroupElem, s), FreeGroupElem) + @test isa(Vector{FreeGroupElem}([s,t]), Vector{FreeGroupElem}) + @test length(FreeGroupElem(s)) == 1 + @test length(FreeGroupElem(t)) == 2 - @test (s*s).symbols == (s^2).symbols - - @test hash([t^1,s^1]) == hash([t^2*inv(t),s*inv(s)*s]) - end end @testset "FreeGroup" begin From 2e6372576e38f88abd521bf454306098c6d9bfc6 Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 17:07:21 +0200 Subject: [PATCH 59/62] argument name is not used in elem_type --- src/WreathProducts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WreathProducts.jl b/src/WreathProducts.jl index 80cbdd1..a490905 100644 --- a/src/WreathProducts.jl +++ b/src/WreathProducts.jl @@ -49,7 +49,7 @@ end # ############################################################################### -elem_type{T<:Group}(G::WreathProduct{T}) = WreathProductElem{elem_type(T)} +elem_type{T<:Group}(::WreathProduct{T}) = WreathProductElem{elem_type(T)} parent_type{T<:GroupElem}(::Type{WreathProductElem{T}}) = WreathProduct{parent_type(T)} From 8335001397585ea61837d2cb2dd02f75fff58333 Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 17:08:32 +0200 Subject: [PATCH 60/62] add minimal internal arithmetic for Freesymbols --- test/FreeGroup-tests.jl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/FreeGroup-tests.jl b/test/FreeGroup-tests.jl index e41ea93..a3d424d 100644 --- a/test/FreeGroup-tests.jl +++ b/test/FreeGroup-tests.jl @@ -1,7 +1,9 @@ + @testset "Groups.FreeSymbols" begin s = Groups.FreeSymbol("s") t = Groups.FreeSymbol("t") - @testset "defines" begin + + @testset "constructors" begin @test isa(Groups.FreeSymbol("aaaaaaaaaaaaaaaa"), Groups.GSymbol) @test Groups.FreeSymbol("abc").pow == 1 @test isa(s, Groups.FreeSymbol) @@ -53,6 +55,11 @@ end s, t = Nemo.gens(G) @testset "internal arithmetic" begin + + @test Vector{Groups.GWord}([s,t]) == [Groups.GWord(s), Groups.GWord(t)] + @test (s*s).symbols == (s^2).symbols + @test hash([t^1,s^1]) == hash([t^2*inv(t),s*inv(s)*s]) + t_symb = Groups.FreeSymbol("t") tt = deepcopy(t) @test string(Groups.r_multiply!(tt,[inv(t_symb)]; reduced=true)) == @@ -85,7 +92,7 @@ end @test Groups.reduce!(w).symbols ==Vector{Groups.FreeSymbol}([]) end - @testset "binary/inv operations" begin + @testset "Group operations" begin @test parent(s) == G @test parent(s) === parent(deepcopy(s)) @test isa(s*t, FreeGroupElem) From ec787e9d21f61b974b00ee672e69b610070a1f8d Mon Sep 17 00:00:00 2001 From: kalmar Date: Sun, 23 Jul 2017 17:09:50 +0200 Subject: [PATCH 61/62] Tests for WreathProducts --- test/WreathProd-tests.jl | 85 ++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 1 + 2 files changed, 86 insertions(+) create mode 100644 test/WreathProd-tests.jl diff --git a/test/WreathProd-tests.jl b/test/WreathProd-tests.jl new file mode 100644 index 0000000..010fe8f --- /dev/null +++ b/test/WreathProd-tests.jl @@ -0,0 +1,85 @@ +@testset "WreathProducts" begin + S_3 = PermutationGroup(3) + F, a = FiniteField(2,3,"a") + b = S_3([2,3,1]) + + @testset "Constructors" begin + @test isa(Groups.WreathProduct(F, S_3), Nemo.Group) + @test isa(Groups.WreathProduct(F, S_3), Groups.WreathProduct) + @test isa(Groups.WreathProduct(F, S_3), Groups.WreathProduct{Nemo.FqNmodFiniteField}) + + aa = Groups.DirectProductGroupElem([a^0 ,a, a^2]) + + @test isa(Groups.WreathProductElem(aa, b), Nemo.GroupElem) + @test isa(Groups.WreathProductElem(aa, b), Groups.WreathProductElem) + @test isa(Groups.WreathProductElem(aa, b), Groups.WreathProductElem{typeof(a)}) + + B3 = Groups.WreathProduct(F, S_3) + + @test B3.N == Groups.DirectProductGroup(F, 3) + @test B3.P == S_3 + + @test B3(aa, b) == Groups.WreathProductElem(aa, b) + @test B3(b) == Groups.WreathProductElem(B3.N(), b) + @test B3(aa) == Groups.WreathProductElem(aa, S_3()) + + g = B3(aa, b) + + @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) + end + + @testset "Types" begin + B3 = Groups.WreathProduct(F, S_3) + + @test elem_type(B3) == Groups.WreathProductElem{elem_type(F)} + + @test parent_type(typeof(B3())) == Groups.WreathProduct{parent_type(typeof(B3.N.group()))} + + @test parent(B3()) == Groups.WreathProduct(F,S_3) + @test parent(B3()) == B3 + end + + @testset "Group arithmetic" begin + B3 = Groups.WreathProduct(F, S_3) + + 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 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])) + + @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])) + + @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])) + + end + + @testset "Misc" begin + B3 = Groups.WreathProduct(FiniteField(2,1,"a")[1], S_3) + @test order(B3) == 48 + + Wr = WreathProduct(PermutationGroup(2),S_3) + + @test isa([elements(Wr)...], Vector{Groups.WreathProductElem{Nemo.perm}}) + + elts = [elements(Wr)...] + + @test length(elts) == order(Wr) + @test all([g*inv(g) for g in elts] .== Wr()) + @test all(inv(g*h) == inv(h)*inv(g) for g in elts for h in elts) + end + +end diff --git a/test/runtests.jl b/test/runtests.jl index 86cc369..d85ec40 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,4 +7,5 @@ using Base.Test include("FreeGroup-tests.jl") include("AutGroup-tests.jl") include("DirectProd-tests.jl") + include("WreathProd-tests.jl") end From a71f99670c5bb0428a64f0eb1efa3ef3d1eddc26 Mon Sep 17 00:00:00 2001 From: kalmar Date: Tue, 8 Aug 2017 19:15:55 +0200 Subject: [PATCH 62/62] deepcopy S to avoid external changes --- src/Groups.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Groups.jl b/src/Groups.jl index af2e929..1983a3d 100644 --- a/src/Groups.jl +++ b/src/Groups.jl @@ -395,6 +395,7 @@ end function generate_balls{T<:GroupElem}(S::Vector{T}, Id::T; radius=2, op=*) sizes = Vector{Int}() + S = deepcopy(S) S = unshift!(S, Id) B = [Id] for i in 1:radius