getindex, setindex for (::GroupRingElem, n::Int/g::GroupElem)

This commit is contained in:
kalmar 2017-05-17 11:35:39 +02:00
parent 933c578b8f
commit 7cdaeea6e9
1 changed files with 19 additions and 0 deletions

View File

@ -113,6 +113,25 @@ function hash(X::GroupRingElem, h::UInt)
return hash(X.coeffs, hash(parent(X), h))
end
function getindex(X::GroupRingElem, n::Int)
return X.coeffs[n]
end
function getindex(X::GroupRingElem, g::GroupElem)
return X.coeffs[parent(X).basis_dict[g]]
end
function setindex!(X::GroupRingElem, k, n::Int)
X.coeffs[n] = k
end
function setindex!(X::GroupRingElem, k, g::GroupElem)
RG = parent(X)
typeof(g) == elem_type(RG.group) || throw("$g is not an element of $(RG.group)")
g = (RG.group)(g)
X.coeffs[RG.basis_dict[g]] = k
end
###############################################################################
#
# String I/O