mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-25 18:15:29 +01:00
store invperm in SMC to avoid allocation in evaluate
This commit is contained in:
parent
bcce338754
commit
ed1e3f9709
@ -105,6 +105,7 @@ struct SymplecticMappingClass{T, F} <: GSymbol
|
|||||||
inv::Bool
|
inv::Bool
|
||||||
autFn_word::T
|
autFn_word::T
|
||||||
perm::Vector{Int}
|
perm::Vector{Int}
|
||||||
|
invperm::Vector{Int}
|
||||||
f::F
|
f::F
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ function SymplecticMappingClass(
|
|||||||
f = compiled(a)
|
f = compiled(a)
|
||||||
# f = t -> evaluate!(t, 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
|
return res
|
||||||
end
|
end
|
||||||
@ -183,7 +184,7 @@ function Base.inv(m::SymplecticMappingClass)
|
|||||||
inv_w = inv(m.autFn_word)
|
inv_w = inv(m.autFn_word)
|
||||||
# f(t) = evaluate!(t, inv_w)
|
# f(t) = evaluate!(t, inv_w)
|
||||||
f = compiled(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
|
end
|
||||||
|
|
||||||
function evaluate!(
|
function evaluate!(
|
||||||
@ -193,7 +194,7 @@ function evaluate!(
|
|||||||
tmp = one(first(t)),
|
tmp = one(first(t)),
|
||||||
) where {N,T}
|
) where {N,T}
|
||||||
|
|
||||||
t = smc.f(t[smc.perm])[invperm(smc.perm)]
|
t = smc.f(t[smc.perm])[smc.invperm]
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user