RG(::Vector{GroupElem}) method for constructing GroupRingElems

This commit is contained in:
kalmar 2017-07-27 22:09:48 +02:00
parent 9e09317148
commit 8d1604863c
1 changed files with 11 additions and 1 deletions

View File

@ -136,7 +136,7 @@ function (RG::GroupRing)(g::GroupElem, T::Type=Int)
return result
end
function (RG::GroupRing)(x::AbstractVector)
function (RG::GroupRing){T<:Number}(x::AbstractVector{T})
isdefined(RG, :basis) || throw("Can not coerce without basis of GroupRing")
length(x) == length(RG.basis) || throw("Can not coerce to $RG: lengths differ")
result = RG(eltype(x))
@ -144,6 +144,16 @@ function (RG::GroupRing)(x::AbstractVector)
return result
end
function (RG::GroupRing{Gr,T}){Gr<:Nemo.Group, T<:Nemo.GroupElem}(V::Vector{T},
S::Type=Rational{Int}; alt=false)
res = RG(S)
for g in V
c = (alt ? sign(g)*one(S) : one(S))
res[g] += c/length(V)
end
return res
end
function (RG::GroupRing)(X::GroupRingElem)
RG == parent(X) || throw("Can not coerce!")
return RG(X.coeffs)