From 2c7d968990d0096d584eeea20ae8f3ff3c0b2464 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Wed, 15 Aug 2018 19:28:14 +0200 Subject: [PATCH] embedding constructor of GroupRing produces sparse GroupRingElem --- src/GroupRings.jl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/GroupRings.jl b/src/GroupRings.jl index 49c28a2..6aa0056 100644 --- a/src/GroupRings.jl +++ b/src/GroupRings.jl @@ -151,6 +151,15 @@ function (RG::GroupRing{Gr,T})(V::Vector{T}, S::Type=Int) where {Gr<:Group, T<:G return res end +function (RG::GroupRing)(f::Function, X::GroupRingElem{T}) where T + isdefined(RG, :basis) || throw("Can not coerce without basis of GroupRing") + res = RG(T) + for g in supp(X) + res[f(g)] = X[g] + end + return res +end + # keep storage type function (RG::GroupRing)(x::AbstractVector{T}) where T<:Number @@ -163,16 +172,6 @@ function (RG::GroupRing)(X::GroupRingElem) return RG(X.coeffs) end -function (RG::GroupRing)(f::Function, X::GroupRingElem) - isdefined(RG, :basis) || throw("Can not coerce without basis of GroupRing") - res = RG(zeros(X.coeffs)) - - for g in RG.basis - res[f(g)] = X[g] - end - return res -end - ############################################################################### # # Basic manipulation && Array protocol