From ed1e3f9709bcb777291262899ad4ecd35a035f8a Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Sun, 18 Jul 2021 18:36:07 +0200 Subject: [PATCH] store invperm in SMC to avoid allocation in evaluate --- src/groups/symplectic_twists.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/groups/symplectic_twists.jl b/src/groups/symplectic_twists.jl index d9f5929..306f6c1 100644 --- a/src/groups/symplectic_twists.jl +++ b/src/groups/symplectic_twists.jl @@ -105,6 +105,7 @@ struct SymplecticMappingClass{T, F} <: GSymbol inv::Bool autFn_word::T perm::Vector{Int} + invperm::Vector{Int} f::F end @@ -164,7 +165,7 @@ function SymplecticMappingClass( f = compiled(a) # f = t -> evaluate!(t, a) - res = SymplecticMappingClass(id, UInt(i), UInt(j), minus, inverse, a, perm, f) + res = SymplecticMappingClass(id, UInt(i), UInt(j), minus, inverse, a, perm, invperm(perm), f) return res end @@ -183,7 +184,7 @@ function Base.inv(m::SymplecticMappingClass) inv_w = inv(m.autFn_word) # f(t) = evaluate!(t, inv_w) f = compiled(inv_w) - return SymplecticMappingClass(m.id, m.i, m.j, m.minus, !m.inv, inv_w, m.perm, f) + return SymplecticMappingClass(m.id, m.i, m.j, m.minus, !m.inv, inv_w, m.perm, m.invperm, f) end function evaluate!( @@ -193,7 +194,7 @@ function evaluate!( tmp = one(first(t)), ) where {N,T} - t = smc.f(t[smc.perm])[invperm(smc.perm)] + t = smc.f(t[smc.perm])[smc.invperm] return t end