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