mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-24 18:05:27 +01:00
IdSymbol, one, etc. are now replaced by overloading parent object
This commit is contained in:
parent
ba3ca8a0ba
commit
ae1dac76fc
@ -24,11 +24,6 @@ abstract GSymbol
|
|||||||
|
|
||||||
length(s::GSymbol) = (s.pow == 0 ? 0 : 1)
|
length(s::GSymbol) = (s.pow == 0 ? 0 : 1)
|
||||||
|
|
||||||
IdSymbol(T::Type{GSymbol}) = throw(ArgumentError("Define IdSymbol(::Type{$T}) which is the identity element for Your type!"))
|
|
||||||
|
|
||||||
one{T<:GSymbol}(::Type{T}) = IdSymbol(T)
|
|
||||||
one(s::GSymbol) = one(typeof(s))
|
|
||||||
|
|
||||||
(*){T<:GSymbol}(s::T, t::T) = return GWord{T}([s])*t
|
(*){T<:GSymbol}(s::T, t::T) = return GWord{T}([s])*t
|
||||||
|
|
||||||
change_pow(s::GSymbol, n::Int) = throw(ArgumentError("Define change_pow function for $(typeof(s))!"))
|
change_pow(s::GSymbol, n::Int) = throw(ArgumentError("Define change_pow function for $(typeof(s))!"))
|
||||||
@ -45,15 +40,11 @@ end
|
|||||||
GWord{T<:GSymbol}(s::T) = GWord{T}([s])
|
GWord{T<:GSymbol}(s::T) = GWord{T}([s])
|
||||||
convert{T<:GSymbol, W<:Word}(::Type{W}, s::T) = GWord{T}(s)
|
convert{T<:GSymbol, W<:Word}(::Type{W}, s::T) = GWord{T}(s)
|
||||||
|
|
||||||
IDWord{T<:GSymbol}(::Type{T}) = GWord(one(T))
|
|
||||||
IDWord{T<:GSymbol}(W::GWord{T}) = IDWord(T)
|
|
||||||
|
|
||||||
function length(W::GWord)
|
function length(W::GWord)
|
||||||
return sum([abs(s.pow) for s in W.symbols])
|
return sum([abs(s.pow) for s in W.symbols])
|
||||||
end
|
end
|
||||||
|
|
||||||
one{T}(::Type{GWord{T}}) = IDWord(T)
|
|
||||||
one{T}(w::GWord{T}) = one(GWord{T})
|
|
||||||
|
|
||||||
function inv{T}(W::GWord{T})
|
function inv{T}(W::GWord{T})
|
||||||
if length(W) == 0
|
if length(W) == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user