optimize evaluation with tmp storage

This commit is contained in:
Marek Kaluba 2021-05-26 12:06:40 +02:00
parent 812b2e15a1
commit e424bdc575
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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