Group elements
GroupsCore
defines abstract types GroupElement <: MonoidElement
, which all implementations of group/monoid elements should subtype.
Obligatory methods
Base.parent
— Methodparent(g::MonoidElement)
Return the parent object of the group element.
Base.:==
— Method==(g::El, h::El) where {El <: MonoidElement}
Return the best effort equality for monoid elements.
If ==(g, h)
returns true
then the mathematical equality
g == hholds. However
==(g, h)may return
falseeven if
gand
h` represent mathematically equal group elements.
For example, in a finitely presented group, ==
may return the equality of words.
This function may not return due to unsolvable word problem.
GroupsCore.isfiniteorder
— Methodisfiniteorder(m::MonoidElement)
Return true
if m
is of finite order, possibly without computing it.
If finiteness of a group or monoid can be decided based on its type there is no need to extend isfiniteorder
for its elements.
As well as the two arithmetic operations:
Base.:(*)(::El, ::El) where {El <: MonoidElement}
Base.inv(::GroupElement)
A note on deepcopy
The elements which are not of isbitstype
should extend
Base.deepcopy_internal(g::MonoidElement, ::IdDict)
according to Base.deepcopy
docstring. Due to our assumption on parents of group/monoid elements (acting as local singleton objects), a monoid element and its deepcopy
should have identical (i.e. ===
) parents.
Implemented methods
Using the obligatory methods we implement the rest of the functions in GroupsCore
. For starters, the first of these are:
Base.one(::MonoidElement)
Base.:(/)(::El, ::El) where {El <: GroupElement}
and
GroupsCore.order
— Methodorder(m::MonoidElement)
order(::Type{T}, m::MonoidElement) where T
Return the order of m
as an instance of T
. If m
is of infinite order GroupsCore.InfiniteOrder
exception will be thrown.
Only arbitrary sized integers are required to return a mathematicaly correct answer.
Base.conj
— Functionconj(g::El, h::El) where {El <: GroupElement}
Return the conjugation of g
by h
, i.e. inv(h)*g*h
.
Base.:^
— Method^(g::El, h::El) where {El <: GroupElement}
Alias for conj
.
GroupsCore.commutator
— Functioncommutator(g::El, h::El, k::El...) where {El <: GroupElement}
Return the left associative iterated commutator $[[g, h], ...]$, where $[g, h] = g^{-1} h^{-1} g h$.
Moreover we provide basic implementation which could be altered for performance reasons:
Base.:(^)(g::MonoidElement, n::Integer)
Groups.Core.order([::Type{T}], g::MonoidElement) where T
Base.hash(::MonoidElement, ::UInt)
Mutable API
Work-in-progress. Mutable API is considered private and hence may change between versions without warning.
For the purpose of mutable arithmetic the following methods may be overloaded to provide more tailored versions for a given type and reduce the allocations. These functions should be used when writing libraries, in performance critical sections. However one should only use the returned value and there are no guarantees on in-place modifications actually happening.
All of these functions (possibly) alter only the first argument, and must unalias their arguments when necessary.
GroupsCore.one!
— Functionone!(m::MonoidElement)
Return one(m)
, possibly modifying m
.
GroupsCore.inv!
— Functioninv!(out::El, g::El) where {El <: GroupElement}
Return inv(g)
, possibly modifying out
. Aliasing of g
with out
is allowed.
GroupsCore.mul!
— Functionmul!(out::El, g::El, h::El) where {El <: MonoidElement}
Return g*h
, possibly modifying out
. Aliasing of g
or h
with out
is allowed.
GroupsCore.div_left!
— Functiondiv_left!(out::El, g::El, h::El) where {El <: GroupElement}
Return inv(h)*g
, possibly modifying out
. Aliasing of g
or h
with out
is allowed.
GroupsCore.div_right!
— Functiondiv_right!(out::El, g::El, h::El) where {El <: GroupElement}
Return g*inv(h)
, possibly modifying out
. Aliasing of g
or h
with out
is allowed.
GroupsCore.conj!
— Functionconj!(out::El, g::El, h::El) where {El <: GroupElement}
Return inv(h)*g*h
, possibly modifying out
. Aliasing of g
or h
with out
is allowed.
GroupsCore.commutator!
— Functioncommutator!(out::El, g::El, h::El) where {El <: GroupElement}
Return inv(g)*inv(h)*g*h
, possibly modifying out
. Aliasing of g
or h
with out
is allowed.