From 4cef591dfa292ff9b410cd5140b54228cbdd0ecc Mon Sep 17 00:00:00 2001 From: kalmarek Date: Tue, 25 Jun 2019 17:36:37 +0200 Subject: [PATCH] faster permutation actions on GroupElements --- src/orbitdata.jl | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/orbitdata.jl b/src/orbitdata.jl index 8542ca7..6a85340 100644 --- a/src/orbitdata.jl +++ b/src/orbitdata.jl @@ -178,18 +178,45 @@ end # ############################################################################### -function (p::perm)(A::GroupRingElem) - RG = parent(A) - result = zero(RG, eltype(A.coeffs)) +function (g::perm)(y::GroupRingElem) + RG = parent(y) + result = zero(RG, eltype(y.coeffs)) - for (idx, c) in enumerate(A.coeffs) - if c!= zero(eltype(A.coeffs)) - result[p(RG.basis[idx])] = c + for (idx, c) in enumerate(y.coeffs) + if c!= zero(eltype(y.coeffs)) + result[g(RG.basis[idx])] = c end end return result end +function (g::perm)(y::GroupRingElem{T, <:SparseVector}) where T + RG = parent(y) + index = [RG.basis_dict[g(RG.basis[idx])] for idx in y.coeffs.nzind] + + result = GroupRingElem(sparsevec(index, y.coeffs.nzval, y.coeffs.n), RG) + + return result +end + +function (g::GroupRingElem)(y::GroupRingElem) + res = parent(y)() + for elt in GroupRings.supp(g) + res += g[elt]*elt(y) + end + return res +end + +function (p::perm)(A::MatElem) + length(p.d) == size(A, 1) == size(A,2) || throw("Can't act via $p on matrix of size $(size(A))") + result = similar(A) + @inbounds for i in 1:size(A, 1) + for j in 1:size(A, 2) + result[i, j] = A[p[i], p[j]] # action by permuting rows and colums/conjugation + end + return result +end + ############################################################################### # # Action of WreathProductElems on Nemo.MatElem