From e424bdc575f63dca0b1bdd36890dc3b46a3bcc76 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Wed, 26 May 2021 12:06:40 +0200 Subject: [PATCH] optimize evaluation with tmp storage --- src/new_autgroups.jl | 3 ++- src/new_transvections.jl | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/new_autgroups.jl b/src/new_autgroups.jl index db49d80..92d745a 100644 --- a/src/new_autgroups.jl +++ b/src/new_autgroups.jl @@ -110,10 +110,11 @@ evaluate(f::FPGroupElement{<:AutomorphismGroup{<:FreeGroup}}) = evaluate!(domain 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))))::NTuple{N,T} + t = @inbounds evaluate!(t, A[idx], alphabet(object(parent(f))), tmp)::NTuple{N,T} end return t end diff --git a/src/new_transvections.jl b/src/new_transvections.jl index 2200b93..d8c8819 100644 --- a/src/new_transvections.jl +++ b/src/new_transvections.jl @@ -49,7 +49,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) +Base.@propagate_inbounds function evaluate!(v::Tuple, t::Transvection, A::Alphabet, tmp=one(first(v))) i, j = indices(t) @assert i ≤ length(v) && j ≤ length(v) @@ -80,6 +80,8 @@ Base.@propagate_inbounds function evaluate!(v::Tuple, t::Transvection, A::Alphab _setnormalform!(v[i], false) _setvalidhash!(v[i], false) end + normalform!(tmp, v[i]) + copyto!(v[i], tmp) return v end