mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 06:30:29 +01:00
docs and headers
This commit is contained in:
parent
34f93e0a6e
commit
a54ebbcede
@ -8,6 +8,11 @@ import Base: inv, reduce, *, ^
|
|||||||
import Base: findfirst, findnext
|
import Base: findfirst, findnext
|
||||||
import Base: deepcopy_internal
|
import Base: deepcopy_internal
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# ParentType / ObjectType definition
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
doc"""
|
doc"""
|
||||||
::GSymbol
|
::GSymbol
|
||||||
@ -48,12 +53,28 @@ end
|
|||||||
|
|
||||||
export GSymbol, GWord
|
export GSymbol, GWord
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Type and parent object methods
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
parent{T<:GSymbol}(w::GWord{T}) = w.parent
|
parent{T<:GSymbol}(w::GWord{T}) = w.parent
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# ParentType / ObjectType constructors
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
GWord{T<:GSymbol}(s::T) = GWord{T}(T[s])
|
GWord{T<:GSymbol}(s::T) = GWord{T}(T[s])
|
||||||
convert{T<:GSymbol}(::Type{GWord{T}}, s::T) = GWord{T}(T[s])
|
convert{T<:GSymbol}(::Type{GWord{T}}, s::T) = GWord{T}(T[s])
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Basic manipulation
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
function hash(W::GWord, h::UInt)
|
function hash(W::GWord, h::UInt)
|
||||||
W.modified && reduce!(W)
|
W.modified && reduce!(W)
|
||||||
@ -108,8 +129,17 @@ doc"""
|
|||||||
"""
|
"""
|
||||||
reduce(W::GWord) = reduce!(deepcopy(W))
|
reduce(W::GWord) = reduce!(deepcopy(W))
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# String I/O
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
doc"""
|
||||||
|
show(io::IO, W::GWord)
|
||||||
|
> The actual string produced by show depends on the eltype of W.symbols.
|
||||||
|
|
||||||
|
"""
|
||||||
function show(io::IO, W::GWord)
|
function show(io::IO, W::GWord)
|
||||||
if length(W) == 0
|
if length(W) == 0
|
||||||
print(io, "(id)")
|
print(io, "(id)")
|
||||||
@ -118,6 +148,12 @@ function show(io::IO, W::GWord)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Comparison
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
function (==)(W::GWord, Z::GWord)
|
function (==)(W::GWord, Z::GWord)
|
||||||
parent(W) == parent(Z) || return false
|
parent(W) == parent(Z) || return false
|
||||||
W.modified && reduce!(W) # reduce clears the flag and calculates savedhash
|
W.modified && reduce!(W) # reduce clears the flag and calculates savedhash
|
||||||
@ -125,6 +161,12 @@ function (==)(W::GWord, Z::GWord)
|
|||||||
return W.savedhash == Z.savedhash && W.symbols == Z.symbols
|
return W.savedhash == Z.savedhash && W.symbols == Z.symbols
|
||||||
end
|
end
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Binary operators
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
function r_multiply!(W::GWord, x; reduced::Bool=true)
|
function r_multiply!(W::GWord, x; reduced::Bool=true)
|
||||||
if length(x) > 0
|
if length(x) > 0
|
||||||
push!(W.symbols, x...)
|
push!(W.symbols, x...)
|
||||||
@ -184,6 +226,10 @@ end
|
|||||||
|
|
||||||
(^)(x::GWord, n::Integer) = power_by_squaring(x,n)
|
(^)(x::GWord, n::Integer) = power_by_squaring(x,n)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Inversion
|
||||||
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function inv{T}(W::GWord{T})
|
function inv{T}(W::GWord{T})
|
||||||
@ -197,6 +243,12 @@ function inv{T}(W::GWord{T})
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Replacement of symbols / sub-words
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
is_subsymbol(s::GSymbol, t::GSymbol) =
|
is_subsymbol(s::GSymbol, t::GSymbol) =
|
||||||
s.str == t.str && (0 ≤ s.pow ≤ t.pow || 0 ≥ s.pow ≥ t.pow)
|
s.str == t.str && (0 ≤ s.pow ≤ t.pow || 0 ≥ s.pow ≥ t.pow)
|
||||||
|
|
||||||
@ -266,7 +318,12 @@ end
|
|||||||
|
|
||||||
replace_all(W::GWord, subst_dict::Dict{GWord, GWord}) = replace_all!(deepcopy(W), subst_dict)
|
replace_all(W::GWord, subst_dict::Dict{GWord, GWord}) = replace_all!(deepcopy(W), subst_dict)
|
||||||
|
|
||||||
include("free_groups.jl")
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Includes
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
include("automorphism_groups.jl")
|
include("automorphism_groups.jl")
|
||||||
|
|
||||||
end # of module Groups
|
end # of module Groups
|
||||||
|
Loading…
Reference in New Issue
Block a user