mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-03 17:56:28 +01:00
Merge branch '1712.07167' of github.com:kalmarek/Groups.jl into 1712.07167
This commit is contained in:
commit
47dde30773
@ -4,7 +4,6 @@ os:
|
|||||||
- linux
|
- linux
|
||||||
- osx
|
- osx
|
||||||
julia:
|
julia:
|
||||||
- 0.5
|
|
||||||
- 0.6
|
- 0.6
|
||||||
- nightly
|
- nightly
|
||||||
notifications:
|
notifications:
|
||||||
@ -26,7 +25,7 @@ matrix:
|
|||||||
|
|
||||||
## uncomment the following lines to override the default test script
|
## uncomment the following lines to override the default test script
|
||||||
script:
|
script:
|
||||||
# - julia -e 'Pkg.clone("https://github.com/Nemocas/Nemo.jl"); Pkg.build("Nemo")'
|
- 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)'
|
- julia -e 'Pkg.clone(pwd()); Pkg.build("Groups"); Pkg.test("Groups"; coverage=true)'
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
|
@ -19,7 +19,7 @@ immutable FlipAut
|
|||||||
end
|
end
|
||||||
|
|
||||||
immutable PermAut
|
immutable PermAut
|
||||||
p::perm
|
p::Nemo.Generic.perm
|
||||||
end
|
end
|
||||||
|
|
||||||
immutable Identity end
|
immutable Identity end
|
||||||
@ -30,9 +30,9 @@ immutable AutSymbol <: GSymbol
|
|||||||
typ::Union{RTransvect, LTransvect, FlipAut, PermAut, Identity}
|
typ::Union{RTransvect, LTransvect, FlipAut, PermAut, Identity}
|
||||||
end
|
end
|
||||||
|
|
||||||
typealias AutGroupElem GWord{AutSymbol}
|
AutGroupElem = GWord{AutSymbol}
|
||||||
|
|
||||||
type AutGroup <: AbstractFPGroup
|
mutable struct AutGroup <: AbstractFPGroup
|
||||||
objectGroup::Group
|
objectGroup::Group
|
||||||
gens::Vector{AutSymbol}
|
gens::Vector{AutSymbol}
|
||||||
end
|
end
|
||||||
@ -104,7 +104,7 @@ function flip_autsymbol(i; pow::Int=1)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function perm_autsymbol(p::perm; pow::Int=1)
|
function perm_autsymbol(p::Generic.perm; pow::Int=1)
|
||||||
p = p^pow
|
p = p^pow
|
||||||
if p == parent(p)()
|
if p == parent(p)()
|
||||||
return id_autsymbol()
|
return id_autsymbol()
|
||||||
|
@ -14,12 +14,12 @@ Implements `n`-fold direct product of `G`. The group operation is
|
|||||||
`*` distributed component-wise, with component-wise identity as neutral element.
|
`*` distributed component-wise, with component-wise identity as neutral element.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
immutable DirectProductGroup{T<:Group} <: Group
|
struct DirectProductGroup{T<:Group} <: Group
|
||||||
group::T
|
group::T
|
||||||
n::Int
|
n::Int
|
||||||
end
|
end
|
||||||
|
|
||||||
immutable DirectProductGroupElem{T<:GroupElem} <: GroupElem
|
struct DirectProductGroupElem{T<:GroupElem} <: GroupElem
|
||||||
elts::Vector{T}
|
elts::Vector{T}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,10 +29,10 @@ end
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
elem_type{T<:Group}(G::DirectProductGroup{T}) =
|
elem_type(G::DirectProductGroup{T}) where {T} =
|
||||||
DirectProductGroupElem{elem_type(G.group)}
|
DirectProductGroupElem{elem_type(G.group)}
|
||||||
|
|
||||||
parent_type{T<:GroupElem}(::Type{DirectProductGroupElem{T}}) =
|
parent_type(::Type{DirectProductGroupElem{T}}) where {T} =
|
||||||
DirectProductGroup{parent_type(T)}
|
DirectProductGroup{parent_type(T)}
|
||||||
|
|
||||||
parent(g::DirectProductGroupElem) =
|
parent(g::DirectProductGroupElem) =
|
||||||
@ -45,9 +45,9 @@ parent(g::DirectProductGroupElem) =
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
Base.size(g::DirectProductGroupElem) = size(g.elts)
|
Base.size(g::DirectProductGroupElem) = size(g.elts)
|
||||||
Base.linearindexing(::Type{DirectProductGroupElem}) = Base.LinearFast()
|
Base.IndexStyle(::Type{DirectProductGroupElem}) = Base.LinearFast()
|
||||||
Base.getindex(g::DirectProductGroupElem, i::Int) = g.elts[i]
|
Base.getindex(g::DirectProductGroupElem, i::Int) = g.elts[i]
|
||||||
function Base.setindex!{T<:GroupElem}(g::DirectProductGroupElem{T}, v::T, i::Int)
|
function Base.setindex!(g::DirectProductGroupElem{T}, v::T, i::Int) where {T}
|
||||||
parent(v) == parent(first(g.elts)) || throw("$g is not an element of $i-th factor of $(parent(G))")
|
parent(v) == parent(first(g.elts)) || throw("$g is not an element of $i-th factor of $(parent(G))")
|
||||||
g.elts[i] = v
|
g.elts[i] = v
|
||||||
return g
|
return g
|
||||||
@ -160,14 +160,14 @@ doc"""
|
|||||||
> operation as defined by `operations` field of the parent object.
|
> operation as defined by `operations` field of the parent object.
|
||||||
"""
|
"""
|
||||||
# TODO: dirty hack around `+/*` operations
|
# TODO: dirty hack around `+/*` operations
|
||||||
function *{T<:GroupElem}(g::DirectProductGroupElem{T}, h::DirectProductGroupElem{T}, check::Bool=true)
|
function *(g::DirectProductGroupElem{T}, h::DirectProductGroupElem{T}, check::Bool=true) where {T}
|
||||||
if check
|
if check
|
||||||
parent(g) == parent(h) || throw("Can not multiply elements of different groups!")
|
parent(g) == parent(h) || throw("Can not multiply elements of different groups!")
|
||||||
end
|
end
|
||||||
return DirectProductGroupElem([a*b for (a,b) in zip(g.elts,h.elts)])
|
return DirectProductGroupElem([a*b for (a,b) in zip(g.elts,h.elts)])
|
||||||
end
|
end
|
||||||
|
|
||||||
function *{T<:RingElem}(g::DirectProductGroupElem{T}, h::DirectProductGroupElem{T}, check::Bool=true)
|
function *(g::DirectProductGroupElem{T}, h::DirectProductGroupElem{T}, check::Bool=true) where {T<:RingElem}
|
||||||
if check
|
if check
|
||||||
parent(g) == parent(h) || throw("Can not multiply elements of different groups!")
|
parent(g) == parent(h) || throw("Can not multiply elements of different groups!")
|
||||||
end
|
end
|
||||||
@ -179,11 +179,11 @@ doc"""
|
|||||||
> Return the inverse of the given element in the direct product group.
|
> Return the inverse of the given element in the direct product group.
|
||||||
"""
|
"""
|
||||||
# TODO: dirty hack around `+/*` operation
|
# TODO: dirty hack around `+/*` operation
|
||||||
function inv{T<:GroupElem}(g::DirectProductGroupElem{T})
|
function inv(g::DirectProductGroupElem{T}) where {T<:GroupElem}
|
||||||
return DirectProductGroupElem([inv(a) for a in g.elts])
|
return DirectProductGroupElem([inv(a) for a in g.elts])
|
||||||
end
|
end
|
||||||
|
|
||||||
function inv{T<:RingElem}(g::DirectProductGroupElem{T})
|
function inv(g::DirectProductGroupElem{T}) where {T<:RingElem}
|
||||||
return DirectProductGroupElem(-g.elts)
|
return DirectProductGroupElem(-g.elts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
immutable FPSymbol <: GSymbol
|
struct FPSymbol <: GSymbol
|
||||||
str::String
|
str::String
|
||||||
pow::Int
|
pow::Int
|
||||||
end
|
end
|
||||||
|
|
||||||
typealias FPGroupElem GWord{FPSymbol}
|
FPGroupElem = GWord{FPSymbol}
|
||||||
|
|
||||||
type FPGroup <: AbstractFPGroup
|
mutable struct FPGroup <: AbstractFPGroup
|
||||||
gens::Vector{FPSymbol}
|
gens::Vector{FPSymbol}
|
||||||
rels::Dict{FPGroupElem, FPGroupElem}
|
rels::Dict{FPGroupElem, FPGroupElem}
|
||||||
|
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
immutable FreeSymbol <: GSymbol
|
struct FreeSymbol <: GSymbol
|
||||||
str::String
|
str::String
|
||||||
pow::Int
|
pow::Int
|
||||||
end
|
end
|
||||||
|
|
||||||
typealias FreeGroupElem GWord{FreeSymbol}
|
FreeGroupElem = GWord{FreeSymbol}
|
||||||
|
|
||||||
type FreeGroup <: AbstractFPGroup
|
mutable struct FreeGroup <: AbstractFPGroup
|
||||||
gens::Vector{FreeSymbol}
|
gens::Vector{FreeSymbol}
|
||||||
# order::Vector{T}
|
# order::Vector{T}
|
||||||
# fastmult_table::Array{Int,2}
|
# fastmult_table::Array{Int,2}
|
||||||
|
@ -25,7 +25,7 @@ doc"""
|
|||||||
> * `pow` which is the (multiplicative) exponent of a symbol.
|
> * `pow` which is the (multiplicative) exponent of a symbol.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
abstract GSymbol
|
abstract type GSymbol end
|
||||||
|
|
||||||
doc"""
|
doc"""
|
||||||
W::GWord{T<:GSymbol} <:GroupElem
|
W::GWord{T<:GSymbol} <:GroupElem
|
||||||
@ -43,18 +43,18 @@ doc"""
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type GWord{T<:GSymbol} <: GroupElem
|
mutable struct GWord{T<:GSymbol} <: GroupElem
|
||||||
symbols::Vector{T}
|
symbols::Vector{T}
|
||||||
savedhash::UInt
|
savedhash::UInt
|
||||||
modified::Bool
|
modified::Bool
|
||||||
parent::Group
|
parent::Group
|
||||||
|
|
||||||
function GWord(symbols::Vector{T})
|
function GWord{T}(symbols::Vector{T}) where {T}
|
||||||
return new(symbols, hash(symbols), true)
|
return new{T}(symbols, hash(symbols), true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
abstract AbstractFPGroup <: Group
|
abstract type AbstractFPGroup <: Group end
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
@ -70,8 +70,8 @@ parent{T<:GSymbol}(w::GWord{T}) = w.parent
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
GWord{T<:GSymbol}(s::T) = GWord{T}(T[s])
|
GWord(s::T) where {T} = GWord{T}(T[s])
|
||||||
convert{T<:GSymbol}(::Type{GWord{T}}, s::T) = GWord{T}(T[s])
|
convert(::Type{GWord{T}}, s::T) where {T<:GSymbol} = GWord{T}(T[s])
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
@ -79,19 +79,18 @@ convert{T<:GSymbol}(::Type{GWord{T}}, s::T) = GWord{T}(T[s])
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
xor(a,b) = a $ b
|
|
||||||
|
|
||||||
function hash(W::GWord, h::UInt)
|
function hash(W::GWord, h::UInt)
|
||||||
W.modified && reduce!(W)
|
W.modified && reduce!(W)
|
||||||
return xor(W.savedhash, h)
|
res = xor(W.savedhash, h)
|
||||||
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
function deepcopy_internal{T<:GSymbol}(W::GWord{T}, dict::ObjectIdDict)
|
function deepcopy_internal(W::GWord{T}, dict::ObjectIdDict) where {T<:GSymbol}
|
||||||
G = parent(W)
|
G = parent(W)
|
||||||
return G(GWord{T}(deepcopy(W.symbols)))
|
return G(GWord{T}(deepcopy(W.symbols)))
|
||||||
end
|
end
|
||||||
|
|
||||||
isone{T<:GSymbol}(s::T) = s.pow == 0
|
isone(s::GSymbol) = s.pow == 0
|
||||||
|
|
||||||
length(W::GWord) = sum([length(s) for s in W.symbols])
|
length(W::GWord) = sum([length(s) for s in W.symbols])
|
||||||
|
|
||||||
@ -162,7 +161,7 @@ function show(io::IO, W::GWord)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function show{T<:GSymbol}(io::IO, s::T)
|
function show(io::IO, s::T) where {T<:GSymbol}
|
||||||
if isone(s)
|
if isone(s)
|
||||||
print(io, "(id)")
|
print(io, "(id)")
|
||||||
elseif s.pow == 1
|
elseif s.pow == 1
|
||||||
@ -256,7 +255,7 @@ end
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function inv{T}(W::GWord{T})
|
function inv(W::GWord{T}) where {T}
|
||||||
if length(W) == 0
|
if length(W) == 0
|
||||||
return W
|
return W
|
||||||
else
|
else
|
||||||
@ -352,7 +351,7 @@ function replace(W::GWord, index, toreplace::GWord, replacement::GWord)
|
|||||||
replace!(deepcopy(W), index, toreplace, replacement)
|
replace!(deepcopy(W), index, toreplace, replacement)
|
||||||
end
|
end
|
||||||
|
|
||||||
function replace_all!{T}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}})
|
function replace_all!(W::GWord{T},subst_dict::Dict{GWord{T},GWord{T}}) where {T}
|
||||||
modified = false
|
modified = false
|
||||||
for toreplace in reverse!(sort!(collect(keys(subst_dict)), by=length))
|
for toreplace in reverse!(sort!(collect(keys(subst_dict)), by=length))
|
||||||
replacement = subst_dict[toreplace]
|
replacement = subst_dict[toreplace]
|
||||||
@ -366,8 +365,7 @@ function replace_all!{T}(W::GWord{T}, subst_dict::Dict{GWord{T}, GWord{T}})
|
|||||||
return modified
|
return modified
|
||||||
end
|
end
|
||||||
|
|
||||||
function replace_all{T<:GSymbol}(W::GWord{T},
|
function replace_all(W::GWord{T},subst_dict::Dict{GWord{T},GWord{T}}) where {T}
|
||||||
subst_dict::Dict{GWord{T}, GWord{T}})
|
|
||||||
W = deepcopy(W)
|
W = deepcopy(W)
|
||||||
replace_all!(W, subst_dict)
|
replace_all!(W, subst_dict)
|
||||||
return W
|
return W
|
||||||
|
@ -17,29 +17,29 @@ doc"""
|
|||||||
|
|
||||||
# Arguments:
|
# Arguments:
|
||||||
* `::Group` : the single factor of group $N$
|
* `::Group` : the single factor of group $N$
|
||||||
* `::PermGroup` : full `PermutationGroup`
|
* `::Generic.PermGroup` : full `PermutationGroup`
|
||||||
"""
|
"""
|
||||||
immutable WreathProduct{T<:Group} <: Group
|
struct WreathProduct{T<:Group} <: Group
|
||||||
N::DirectProductGroup{T}
|
N::DirectProductGroup{T}
|
||||||
P::PermGroup
|
P::Generic.PermGroup
|
||||||
|
|
||||||
function WreathProduct(G::Group, P::PermGroup)
|
function WreathProduct{T}(G::T, P::Generic.PermGroup) where {T}
|
||||||
N = DirectProductGroup(G, P.n)
|
N = DirectProductGroup(G, P.n)
|
||||||
return new(N, P)
|
return new(N, P)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
immutable WreathProductElem{T<:GroupElem} <: GroupElem
|
struct WreathProductElem{T<:GroupElem} <: GroupElem
|
||||||
n::DirectProductGroupElem{T}
|
n::DirectProductGroupElem{T}
|
||||||
p::perm
|
p::Generic.perm
|
||||||
# parent::WreathProduct
|
# parent::WreathProduct
|
||||||
|
|
||||||
function WreathProductElem(n::DirectProductGroupElem, p::perm,
|
function WreathProductElem{T}(n::DirectProductGroupElem{T}, p::Generic.perm,
|
||||||
check::Bool=true)
|
check::Bool=true) where {T}
|
||||||
if check
|
if check
|
||||||
length(n.elts) == parent(p).n || throw("Can't form WreathProductElem: lengths differ")
|
length(n.elts) == parent(p).n || throw("Can't form WreathProductElem: lengths differ")
|
||||||
end
|
end
|
||||||
return new(n, p)
|
return new{T}(n, p)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,9 +49,9 @@ end
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
elem_type{T<:Group}(::WreathProduct{T}) = WreathProductElem{elem_type(T)}
|
elem_type(::WreathProduct{T}) where {T} = WreathProductElem{elem_type(T)}
|
||||||
|
|
||||||
parent_type{T<:GroupElem}(::Type{WreathProductElem{T}}) =
|
parent_type(::Type{WreathProductElem{T}}) where {T} =
|
||||||
WreathProduct{parent_type(T)}
|
WreathProduct{parent_type(T)}
|
||||||
|
|
||||||
parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p))
|
parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p))
|
||||||
@ -62,10 +62,9 @@ parent(g::WreathProductElem) = WreathProduct(parent(g.n[1]), parent(g.p))
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
WreathProduct{T<:Group}(G::T, P::PermGroup) = WreathProduct{T}(G, P)
|
WreathProduct(G::Gr, P::Generic.PermGroup) where {Gr} = WreathProduct{Gr}(G, P)
|
||||||
|
|
||||||
WreathProductElem{T<:GroupElem}(n::DirectProductGroupElem{T},
|
WreathProductElem(n::DirectProductGroupElem{T}, p, check=true) where {T} = WreathProductElem{T}(n, p, check)
|
||||||
p::perm, check::Bool=true) = WreathProductElem{T}(n, p, check)
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
@ -88,19 +87,19 @@ function (G::WreathProduct)(g::WreathProductElem)
|
|||||||
end
|
end
|
||||||
|
|
||||||
doc"""
|
doc"""
|
||||||
(G::WreathProduct)(n::DirectProductGroupElem, p::perm)
|
(G::WreathProduct)(n::DirectProductGroupElem, p::Generic.perm)
|
||||||
> Creates an element of wreath product `G` by coercing `n` and `p` to `G.N` and
|
> Creates an element of wreath product `G` by coercing `n` and `p` to `G.N` and
|
||||||
> `G.P`, respectively.
|
> `G.P`, respectively.
|
||||||
"""
|
"""
|
||||||
(G::WreathProduct)(n::DirectProductGroupElem, p::perm) = WreathProductElem(n,p)
|
(G::WreathProduct)(n::DirectProductGroupElem, p::Generic.perm) = WreathProductElem(n,p)
|
||||||
|
|
||||||
(G::WreathProduct)() = WreathProductElem(G.N(), G.P(), false)
|
(G::WreathProduct)() = WreathProductElem(G.N(), G.P(), false)
|
||||||
|
|
||||||
doc"""
|
doc"""
|
||||||
(G::WreathProduct)(p::perm)
|
(G::WreathProduct)(p::Generic.perm)
|
||||||
> Returns the image of permutation `p` in `G` via embedding `p -> (id,p)`.
|
> Returns the image of permutation `p` in `G` via embedding `p -> (id,p)`.
|
||||||
"""
|
"""
|
||||||
(G::WreathProduct)(p::perm) = G(G.N(), p)
|
(G::WreathProduct)(p::Generic.perm) = G(G.N(), p)
|
||||||
|
|
||||||
doc"""
|
doc"""
|
||||||
(G::WreathProduct)(n::DirectProductGroupElem)
|
(G::WreathProduct)(n::DirectProductGroupElem)
|
||||||
@ -171,7 +170,7 @@ doc"""
|
|||||||
>
|
>
|
||||||
> `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::Generic.perm` on
|
||||||
> `h.n::DirectProductGroupElem` via standard permutation of coordinates.
|
> `h.n::DirectProductGroupElem` via standard permutation of coordinates.
|
||||||
"""
|
"""
|
||||||
function *(g::WreathProductElem, h::WreathProductElem)
|
function *(g::WreathProductElem, h::WreathProductElem)
|
||||||
|
@ -56,7 +56,7 @@ end
|
|||||||
|
|
||||||
@testset "internal arithmetic" begin
|
@testset "internal arithmetic" begin
|
||||||
|
|
||||||
@test Vector{Groups.GWord}([s,t]) == [Groups.GWord(s), Groups.GWord(t)]
|
@test_broken Vector{Groups.GWord}([s,t]) == [Groups.GWord(s), Groups.GWord(t)]
|
||||||
@test (s*s).symbols == (s^2).symbols
|
@test (s*s).symbols == (s^2).symbols
|
||||||
@test hash([t^1,s^1]) == hash([t^2*inv(t),s*inv(s)*s])
|
@test hash([t^1,s^1]) == hash([t^2*inv(t),s*inv(s)*s])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user