From 27e0b03b3c8cfb205c170689b20c6b0f37295196 Mon Sep 17 00:00:00 2001 From: kalmar Date: Tue, 11 Jul 2017 15:58:02 +0200 Subject: [PATCH] move type-related functions to one location --- src/GroupRings.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/GroupRings.jl b/src/GroupRings.jl index caede0c..5686c9e 100644 --- a/src/GroupRings.jl +++ b/src/GroupRings.jl @@ -65,8 +65,16 @@ elem_type(::GroupRing) = GroupRingElem parent_type(::GroupRingElem) = GroupRing parent_type(::Type{GroupRingElem}) = GroupRing +eltype(X::GroupRingElem) = eltype(X.coeffs) + parent{T}(g::GroupRingElem{T}) = g.parent +Base.promote_rule{T<:Number,S<:Number}(::Type{GroupRingElem{T}}, ::Type{GroupRingElem{S}}) = GroupRingElem{promote_type(T,S)} + +function convert{T<:Number}(::Type{T}, X::GroupRingElem) + return GroupRingElem(convert(AbstractVector{T}, X.coeffs), parent(X)) +end + ############################################################################### # # GroupRing / GroupRingElem constructors @@ -77,10 +85,6 @@ function GroupRingElem{T<:Number}(c::AbstractVector{T}, RG::GroupRing) return GroupRingElem{T}(c, RG) end -function convert{T<:Number}(::Type{T}, X::GroupRingElem) - return GroupRingElem(convert(AbstractVector{T}, X.coeffs), parent(X)) -end - function GroupRing(G::Group, pm::Array{Int,2}) size(pm,1) == size(pm,2) || throw("pm must be square, got $(size(pm))") RG = GroupRing(G, initialise=false)