From 2992244a24488882ec584b3f33c5aa2aa4d6f7db Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Mon, 7 Jun 2021 20:23:04 +0200 Subject: [PATCH] make evaluate[!] a general thing for AutomorphismGroups --- src/groups/sautFn.jl | 14 -------------- src/groups/transvections.jl | 2 +- src/new_autgroups.jl | 16 +++++++++++++++- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/groups/sautFn.jl b/src/groups/sautFn.jl index 17ba331..e6a22d9 100644 --- a/src/groups/sautFn.jl +++ b/src/groups/sautFn.jl @@ -18,17 +18,3 @@ function relations(G::AutomorphismGroup{<:FreeGroup}) n = length(KnuthBendix.alphabet(object(G))) ÷ 2 return last(gersten_relations(n, commutative = false)) end - -evaluate(f::FPGroupElement{<:AutomorphismGroup{<:FreeGroup}}) = evaluate!(domain(f), f) - -function evaluate!( - t::NTuple{N,T}, - f::FPGroupElement{<:AutomorphismGroup{<:FreeGroup}}, - tmp = one(first(t)), -) where {T<:FPGroupElement,N} - A = alphabet(f) - for idx in word(f) - t = @inbounds evaluate!(t, A[idx], alphabet(object(parent(f))), tmp)::NTuple{N,T} - end - return t -end diff --git a/src/groups/transvections.jl b/src/groups/transvections.jl index 06a3737..17b0d89 100644 --- a/src/groups/transvections.jl +++ b/src/groups/transvections.jl @@ -46,7 +46,7 @@ Base.:(==)(t::Transvection, s::Transvection) = t.id === s.id && t.ij == s.ij && t.inv == s.inv Base.hash(t::Transvection, h::UInt) = hash(t.id, hash(t.ij, hash(t.inv, h))) -Base.@propagate_inbounds function evaluate!(v::Tuple, t::Transvection, A::Alphabet, tmp=one(first(v))) +Base.@propagate_inbounds function evaluate!(v::NTuple{T, N}, t::Transvection, A::Alphabet, tmp=one(first(v))) where {T, N} i, j = indices(t) @assert i ≤ length(v) && j ≤ length(v) diff --git a/src/new_autgroups.jl b/src/new_autgroups.jl index 4122e58..ef09005 100644 --- a/src/new_autgroups.jl +++ b/src/new_autgroups.jl @@ -89,6 +89,20 @@ Base.show(io::IO, A::AutomorphismGroup) = print(io, "automorphism group of ", ob domain(f::FPGroupElement{<:AutomorphismGroup}) = deepcopy(parent(f).domain) # tuple(gens(object(parent(f)))...) -evaluate(f::FPGroupElement{<:AutomorphismGroup}) = throw("you need to implement `evaluate(::typeof(f))`") +evaluate(f::FPGroupElement{<:AutomorphismGroup}) = evaluate!(domain(f), f) +function evaluate!( + t::NTuple{N,T}, + f::FPGroupElement{<:AutomorphismGroup{<:Group}}, + tmp = one(first(t)), +) where {N, T} + A = alphabet(f) + AF = alphabet(object(parent(f))) + for idx in word(f) + t = @inbounds evaluate!(t, A[idx], AF, tmp)::NTuple{N,T} + end + return t end + +evaluate!(t::NTuple{N, T}, s::GSymbol, A, tmp=one(first(t))) where {N, T} = throw("you need to implement `evaluate!(::$(typeof(t)), ::$(typeof(s)), ::Alphabet, tmp=one(first(t)))`") +