in setindex! perform coercion only when necessary

This commit is contained in:
kalmar 2017-06-05 21:38:03 +02:00
parent b2231c44e6
commit 1e75372068
1 changed files with 5 additions and 2 deletions

View File

@ -173,8 +173,11 @@ end
function setindex!(X::GroupRingElem, value, 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]] = value
if !(g in keys(RG.basis_dict))
g = (RG.group)(g)
else
X.coeffs[RG.basis_dict[g]] = value
end
end
eltype(X::GroupRingElem) = eltype(X.coeffs)