mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2025-01-01 03:40:29 +01:00
RG(::Vector{GroupElem}) method for constructing GroupRingElems
This commit is contained in:
parent
9e09317148
commit
8d1604863c
@ -136,7 +136,7 @@ function (RG::GroupRing)(g::GroupElem, T::Type=Int)
|
|||||||
return result
|
return result
|
||||||
end
|
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")
|
isdefined(RG, :basis) || throw("Can not coerce without basis of GroupRing")
|
||||||
length(x) == length(RG.basis) || throw("Can not coerce to $RG: lengths differ")
|
length(x) == length(RG.basis) || throw("Can not coerce to $RG: lengths differ")
|
||||||
result = RG(eltype(x))
|
result = RG(eltype(x))
|
||||||
@ -144,6 +144,16 @@ function (RG::GroupRing)(x::AbstractVector)
|
|||||||
return result
|
return result
|
||||||
end
|
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)
|
function (RG::GroupRing)(X::GroupRingElem)
|
||||||
RG == parent(X) || throw("Can not coerce!")
|
RG == parent(X) || throw("Can not coerce!")
|
||||||
return RG(X.coeffs)
|
return RG(X.coeffs)
|
||||||
|
Loading…
Reference in New Issue
Block a user