From 3c0ae5baf0c1bbcd685f4d11f43fee62769c1ff7 Mon Sep 17 00:00:00 2001 From: kalmar Date: Thu, 8 Jun 2017 21:45:46 +0200 Subject: [PATCH] dispatch splaplacian on GroupRing{T} type with multiplicative unit for Rings --- src/PropertyT.jl | 2 +- src/sdps.jl | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/PropertyT.jl b/src/PropertyT.jl index a98a302..0140075 100644 --- a/src/PropertyT.jl +++ b/src/PropertyT.jl @@ -5,7 +5,7 @@ using GroupRings using Memento using Groups -import Nemo: Group, GroupElem +import Nemo: Ring, Group, GroupElem const logger = Memento.config("info", fmt="{msg}") const solver_logger = Memento.config("info", fmt="{msg}") diff --git a/src/sdps.jl b/src/sdps.jl index 6b26e74..27fa87e 100644 --- a/src/sdps.jl +++ b/src/sdps.jl @@ -13,10 +13,18 @@ function constraints_from_pm(pm, total_length=maximum(pm)) return constraints end -function splaplacian(RG::GroupRing, S, Id=RG.group(), - n=length(RG.basis), T::Type=Int) - result = RG(spzeros(n)) - result[Id] = float(length(S)) +function splaplacian{TT<:Group}(RG::GroupRing{TT}, S, Id=RG.group(), T::Type=Int) + result = RG(T) + result[Id] = T(length(S)) + for s in S + result[s] -= one(T) + end + return result +end + +function splaplacian{TT<:Ring}(RG::GroupRing{TT}, S, Id=one(RG.group), T::Type=Int) + result = RG(T) + result[Id] = T(length(S)) for s in S result[s] -= one(T) end