diff --git a/src/automorphism_groups.jl b/src/automorphism_groups.jl index 5793068..2fac4c6 100644 --- a/src/automorphism_groups.jl +++ b/src/automorphism_groups.jl @@ -2,6 +2,12 @@ using Permutations import Base: convert +############################################################################### +# +# AutSymbol/ AutGroup / AutGroupElem +# +############################################################################### + immutable AutSymbol <: GSymbol gen::String pow::Int @@ -18,11 +24,21 @@ end export AutSymbol, AutGroupElem, AutGroup +############################################################################### +# +# Type and parent object methods +# +############################################################################### elem_type(::AutGroup) = AutGroupElem parent_type(::AutGroupElem) = AutGroup +############################################################################### +# +# AutSymbol defining functions +# +############################################################################### function ϱ(i,j, pow=1) # @assert i ≠ j @@ -85,6 +101,12 @@ function getperm(s::AutSymbol) end end +############################################################################### +# +# AutGroup / AutGroupElem constructors +# +############################################################################### + function AutGroup(G::FPGroup; outer=false, special=false) length(G.rels) == 0 || throw("Don't know how to construct AutGroup of $G.") n = length(G.generators) @@ -103,6 +125,11 @@ function AutGroup(G::FPGroup; outer=false, special=false) return new(G, S) end +############################################################################### +# +# Types call overloads +# +############################################################################### function (f::AutSymbol){T}(v::Vector{GWord{T}}) if f.pow == 0 @@ -118,6 +145,11 @@ function (F::AutGroupElem)(v) return v end +############################################################################### +# +# Basic manipulation +# +############################################################################### hash(s::AutSymbol, h::UInt) = hash(s.gen, hash(s.pow, hash(:AutSymbol, h))) @@ -145,11 +177,40 @@ end generators(G::AutGroup) = [G(AutGroupElem(elt)) for elt in G.generators] +############################################################################### +# +# String I/O +# +############################################################################### + +############################################################################### +# +# Comparison +# +############################################################################### + (==)(s::AutSymbol, t::AutSymbol) = s.gen == t.gen && s.pow == t.pow +############################################################################### +# +# Binary operators +# +############################################################################### + +############################################################################### +# +# Inversion +# +############################################################################### inv(f::AutSymbol) = change_pow(f, -f.pow) +############################################################################### +# +# Misc +# +############################################################################### + function simplify_perms!(W::AutGroupElem) reduced = true for i in 1:length(W.symbols) - 1