From 7cdaeea6e942059b3ac5803a6f021f398b787c6f Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 17 May 2017 11:35:39 +0200 Subject: [PATCH] getindex, setindex for (::GroupRingElem, n::Int/g::GroupElem) --- src/GroupRings.jl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/GroupRings.jl b/src/GroupRings.jl index 9c39e78..c6bfdc9 100644 --- a/src/GroupRings.jl +++ b/src/GroupRings.jl @@ -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