faster permutation actions on GroupElements

This commit is contained in:
kalmarek 2019-06-25 17:36:37 +02:00
parent 7a8b21db3c
commit 4cef591dfa
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
1 changed files with 33 additions and 6 deletions

View File

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