1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-10-15 07:20:35 +02:00

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!( function evaluate!(
t::NTuple{N,T}, t::NTuple{N,T},
f::FPGroupElement{<:AutomorphismGroup{<:FreeGroup}}, f::FPGroupElement{<:AutomorphismGroup{<:FreeGroup}},
tmp = one(first(t)),
) where {T<:FPGroupElement,N} ) where {T<:FPGroupElement,N}
A = alphabet(f) A = alphabet(f)
for idx in word(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 end
return t return t
end end

View File

@ -49,7 +49,7 @@ Base.:(==)(t::Transvection, s::Transvection) =
t.id === s.id && t.ij == s.ij && t.inv == s.inv 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.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) i, j = indices(t)
@assert i length(v) && j length(v) @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) _setnormalform!(v[i], false)
_setvalidhash!(v[i], false) _setvalidhash!(v[i], false)
end end
normalform!(tmp, v[i])
copyto!(v[i], tmp)
return v return v
end end