mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-26 02:20:30 +01:00
headers
This commit is contained in:
parent
9570b8c84a
commit
f256f60ca3
@ -1,4 +1,8 @@
|
|||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# FPSymbol/FPGroupElem/FPGroup definition
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
immutable FPSymbol <: GSymbol
|
immutable FPSymbol <: GSymbol
|
||||||
str::String
|
str::String
|
||||||
@ -23,15 +27,31 @@ end
|
|||||||
|
|
||||||
export FPSymbol, FPGroupElem, FPGroup, generators
|
export FPSymbol, FPGroupElem, FPGroup, generators
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Type and parent object methods
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
parent_type(::Type{FPGroupElem}) = FPGroup
|
parent_type(::Type{FPGroupElem}) = FPGroup
|
||||||
|
|
||||||
elem_type(::FPGroup) = FPGroupElem
|
elem_type(::FPGroup) = FPGroupElem
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# FPSymbol constructors
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
FPSymbol(s::String) = FPSymbol(s,1)
|
FPSymbol(s::String) = FPSymbol(s,1)
|
||||||
|
|
||||||
FPGroup(a::Vector{String}) = FPGroup([FPSymbol(i) for i in a], FPGroupElem[])
|
FPGroup(a::Vector{String}) = FPGroup([FPSymbol(i) for i in a], FPGroupElem[])
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Parent object call overloads
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
function (G::FPGroup)()
|
function (G::FPGroup)()
|
||||||
id = FPGroupElem(FPSymbol("", 0))
|
id = FPGroupElem(FPSymbol("", 0))
|
||||||
id.parent = G
|
id.parent = G
|
||||||
@ -53,6 +73,11 @@ end
|
|||||||
|
|
||||||
(G::FPGroup)(s::FPSymbol) = G(FPGroupElem(s))
|
(G::FPGroup)(s::FPSymbol) = G(FPGroupElem(s))
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Basic manipulation
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
hash(s::FPSymbol, h::UInt) = hash(s.str, hash(s.pow, hash(FPSymbol, h)))
|
hash(s::FPSymbol, h::UInt) = hash(s.str, hash(s.pow, hash(FPSymbol, h)))
|
||||||
|
|
||||||
@ -64,6 +89,12 @@ length(s::FPSymbol) = abs(s.pow)
|
|||||||
|
|
||||||
generators(G::FPGroup) = [G(FPGroupElem(g)) for g in G.gens]
|
generators(G::FPGroup) = [G(FPGroupElem(g)) for g in G.gens]
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# String I/O
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
function show(io::IO, G::FPGroup)
|
function show(io::IO, G::FPGroup)
|
||||||
print(io, "Finitely presented group on $(length(G.gens)) gens and $(length(G.rels)) relations:\n")
|
print(io, "Finitely presented group on $(length(G.gens)) gens and $(length(G.rels)) relations:\n")
|
||||||
print(io, "gens:\t", join([g.gen for g in G.gens], ","),"\n")
|
print(io, "gens:\t", join([g.gen for g in G.gens], ","),"\n")
|
||||||
@ -80,6 +111,12 @@ function show(io::IO, s::FPSymbol)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Comparison
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
function (==)(s::FPSymbol, t::FPSymbol)
|
function (==)(s::FPSymbol, t::FPSymbol)
|
||||||
isone(s) && isone(t) && return true
|
isone(s) && isone(t) && return true
|
||||||
s.str == t.str || return false
|
s.str == t.str || return false
|
||||||
@ -87,9 +124,19 @@ function (==)(s::FPSymbol, t::FPSymbol)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Inversion
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
inv(s::FPSymbol) = change_pow(s, -s.pow)
|
inv(s::FPSymbol) = change_pow(s, -s.pow)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Misc
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
FreeGroup(n::Int, f::String=f) = FPGroup(["$f$i" for i in 1:n])
|
FreeGroup(n::Int, f::String=f) = FPGroup(["$f$i" for i in 1:n])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user