From 5b128cd146477aeb9762e699e3c9aa7d2a89e8f4 Mon Sep 17 00:00:00 2001 From: kalmar Date: Wed, 19 Jul 2017 22:48:17 +0200 Subject: [PATCH] brave new inner constructors for GroupRing --- src/GroupRings.jl | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/GroupRings.jl b/src/GroupRings.jl index 2c40b1d..4b3aefe 100644 --- a/src/GroupRings.jl +++ b/src/GroupRings.jl @@ -17,17 +17,30 @@ type GroupRing{Gr<:Group, T<:GroupElem} <: Ring basis_dict::Dict{T, Int} pm::Array{Int,2} - function GroupRing(G::Gr; initialise=true) - A = new(G) - if initialise - complete(A) + function GroupRing(G::Group, basis::Vector{T}; init::Bool=false) + RG = new(G, basis, reverse_dict(basis)) + if init + RG.pm = try + create_pm(RG.basis, RG.basis_dict) + catch err + isa(err, KeyError) && throw("Product is not supported on basis") + throw(err) + end + else + RG.pm = zeros(Int, length(basis), length(basis)) end - return A + return RG end function GroupRing(G::Gr, basis::Vector{T}, basis_dict::Dict{T,Int}, pm::Array{Int,2}) return new(G, basis, basis_dict, pm) end + + function GroupRing(G::Gr, pm::Array{Int,2}) + RG = new(G) + RG.pm = pm + return RG + end end GroupRing{Gr<:Group}(G::Gr;initialise=true) = GroupRing{Gr, elem_type(G)}(G, initialise=initialise)