From 26abb88b3a4a0a48e712539c489a95afb14285da Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 17 May 2017 14:33:49 +0200 Subject: [PATCH] get parametrised type constructor finally right --- src/GroupRings.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/GroupRings.jl b/src/GroupRings.jl index e397606..df049b6 100644 --- a/src/GroupRings.jl +++ b/src/GroupRings.jl @@ -29,6 +29,13 @@ end type GroupRingElem{T<:Number} <: RingElem coeffs::AbstractVector{T} parent::GroupRing + + function GroupRingElem(c::AbstractVector{T}, RG::GroupRing) + isdefined(RG, :basis) || complete(RG) + length(c) == length(RG.basis) || throw("Can't create GroupRingElem -- lengths differ: length(c) = $(length(c)) != $(length(RG.basis)) = length(RG.basis)") + + return new(c,RG) + end end export GroupRing, GroupRingElem @@ -52,10 +59,7 @@ parent{T}(g::GroupRingElem{T}) = g.parent ############################################################################### function GroupRingElem{T<:Number}(c::AbstractVector{T}, RG::GroupRing) - isdefined(RG, :basis) || complete(RG) - length(c) == length(RG.basis) || throw("Can't create GroupRingElem -- lengths differ: length(c) = $(length(c)) != $(length(RG.basis)) = length(RG.basis)") - - GroupRingElem{T}(c,RG) + return GroupRingElem{T}(c, RG) end convert{T<:Number}(::Type{T}, X::GroupRingElem) =