From 5e821286e5310cfa7d6cfdde8cc01d845171f513 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Fri, 5 Jul 2019 18:55:25 +0200 Subject: [PATCH] define and use one(::Group) --- src/PropertyT.jl | 2 ++ src/RGprojections.jl | 8 ++++---- src/laplacians.jl | 20 +++++--------------- src/orbitdata.jl | 6 +++--- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/PropertyT.jl b/src/PropertyT.jl index 415d8a3..53199b3 100644 --- a/src/PropertyT.jl +++ b/src/PropertyT.jl @@ -17,6 +17,8 @@ import AbstractAlgebra: Group, NCRing, perm import MathProgBase.SolverInterface.AbstractMathProgSolver +AbstractAlgebra.one(G::Group) = G() + include("laplacians.jl") include("RGprojections.jl") include("orbitdata.jl") diff --git a/src/RGprojections.jl b/src/RGprojections.jl index 4a470ab..ffa3f11 100644 --- a/src/RGprojections.jl +++ b/src/RGprojections.jl @@ -70,7 +70,7 @@ end function central_projection(RG::GroupRing, chi::AbstractCharacter, T::Type=Rational{Int}) result = RG(zeros(T, length(RG.basis))) - dim = chi(RG.group()) + dim = chi(one(RG.group)) ord = Int(order(RG.group)) for g in RG.basis @@ -187,8 +187,8 @@ function rankOne_projections(RBn::GroupRing{G}, T::Type=Rational{Int}) where {G< r = collect(1:N) for i in 1:N-1 - first_emb = g->Bn(Generic.emb!(Bn.P(), g, view(r, 1:i))) - last_emb = g->Bn(Generic.emb!(Bn.P(), g, view(r, (i+1):N))) + first_emb = g->Bn(Generic.emb!(one(Bn.P), g, view(r, 1:i))) + last_emb = g->Bn(Generic.emb!(one(Bn.P), g, view(r, (i+1):N))) Sk_first = (RBn(first_emb, p) for p in Sn_rankOnePr[i]) Sk_last = (RBn(last_emb, p) for p in Sn_rankOnePr[N-i]) @@ -238,7 +238,7 @@ end > The identity element `Id` and binary operation function `op` can be supplied > to e.g. take advantage of additive group structure. """ -function generateGroup(gens::Vector{T}, r=2, Id::T=parent(first(gens))(), op=*) where {T<:GroupElem} +function generateGroup(gens::Vector{T}, r=2, Id::T=one(parent(first(gens))), op=*) where {T<:GroupElem} n = 0 R = 1 elts = gens diff --git a/src/laplacians.jl b/src/laplacians.jl index 5df4cb7..fbf6d8a 100644 --- a/src/laplacians.jl +++ b/src/laplacians.jl @@ -4,36 +4,26 @@ # ############################################################################### -function spLaplacian(RG::GroupRing, S::AbstractVector{El}, T::Type=Float64) where El +function spLaplacian(RG::GroupRing, S::AbstractVector, T::Type=Float64) result = RG(T) - id = (El <: AbstractAlgebra.NCRingElem ? one(RG.group) : RG.group()) - result[id] = T(length(S)) + result[one(RG.group)] = T(length(S)) for s in S result[s] -= one(T) end return result end -function Laplacian(S::AbstractVector{REl}, halfradius) where REl<:AbstractAlgebra.NCRingElem - R = parent(first(S)) - return Laplacian(S, one(R), halfradius) -end - -function Laplacian(S::AbstractVector{E}, halfradius) where E<:AbstractAlgebra.GroupElem +function Laplacian(S::AbstractVector{REl}, halfradius) where REl<:Union{NCRingElem, GroupElem} G = parent(first(S)) - return Laplacian(S, G(), halfradius) -end - -function Laplacian(S, Id, halfradius) @info "Generating metric ball of radius" radius=2halfradius - @time E_R, sizes = Groups.generate_balls(S, Id, radius=2halfradius) + @time E_R, sizes = Groups.generate_balls(S, one(G), radius=2halfradius) @info "Generated balls:" sizes @info "Creating product matrix..." rdict = GroupRings.reverse_dict(E_R) @time pm = GroupRings.create_pm(E_R, rdict, sizes[halfradius]; twisted=true) - RG = GroupRing(parent(Id), E_R, rdict, pm) + RG = GroupRing(G, E_R, rdict, pm) Δ = spLaplacian(RG, S) return Δ end diff --git a/src/orbitdata.jl b/src/orbitdata.jl index 6818c06..1e8c189 100644 --- a/src/orbitdata.jl +++ b/src/orbitdata.jl @@ -28,7 +28,7 @@ function OrbitData(RG::GroupRing, autS::Group, verbose=true) @time Uπs = [orthSVD(matrix_repr(p, mreps)) for p in autS_mps] multiplicities = size.(Uπs,2) - dimensions = [Int(p[autS()]*Int(order(autS))) for p in autS_mps] + dimensions = [Int(p[one(autS)]*Int(order(autS))) for p in autS_mps] if verbose info_strs = ["", lpad("multiplicities", 14) * " =" * join(lpad.(multiplicities, 4), ""), @@ -273,8 +273,8 @@ end function AutFG_emb(A::AutGroup, g::WreathProductElem) isa(A.objectGroup, FreeGroup) || throw("Not an Aut(Fₙ)") parent(g).P.n == length(A.objectGroup.gens) || throw("No natural embedding of $(parent(g)) into $A") - elt = A() - Id = parent(g.n.elts[1])() + elt = one(A) + Id = one(parent(g.n.elts[1])) flips = Groups.AutSymbol[Groups.flip_autsymbol(i) for i in 1:length(g.p.d) if g.n.elts[i] != Id] Groups.r_multiply!(elt, flips, reduced=false) Groups.r_multiply!(elt, [Groups.perm_autsymbol(g.p)])