From eecba6c5d8752293860594f44b79620def101498 Mon Sep 17 00:00:00 2001 From: kalmar Date: Tue, 16 May 2017 18:35:20 +0200 Subject: [PATCH] GroupRing coercion (::GroupRing object overloads) --- src/GroupAlgebras.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/GroupAlgebras.jl b/src/GroupAlgebras.jl index 12b6035..bf63c47 100644 --- a/src/GroupAlgebras.jl +++ b/src/GroupAlgebras.jl @@ -63,6 +63,18 @@ function GroupRing(G::Group; complete=false) return A end + +function (A::GroupRing)(X::GroupRingElem) + length(X) == length(A.basis) || throw("Can not coerce to $A: lengths differ") + X.parent = A + return X +end + +function (A::GroupRing)(x::AbstractVector) + length(x) == length(A.basis) || throw("Can not coerce to $A: lengths differ") + return GroupRingElem(x, A) +end + function show(io::IO, A::GroupRing) print(io, "GroupRing of $(A.group)") end