From f478081d4e681ad3a9c33f4ef57d767d232ff762 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Tue, 2 Jan 2018 03:22:46 +0100 Subject: [PATCH] reduce code duplication --- src/Orbit-wise.jl | 27 +++------------------------ src/PropertyT.jl | 47 ++++++++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/Orbit-wise.jl b/src/Orbit-wise.jl index 3217272..f300cda 100644 --- a/src/Orbit-wise.jl +++ b/src/Orbit-wise.jl @@ -243,32 +243,11 @@ function check_property_T(sett::Settings) info(sett.logger, "maximum(P) = $(maximum(P))") info(sett.logger, "minimum(P) = $(minimum(P))") - if λ > 0 - pm_fname = filename(prepath(sett), :pm) - Δ_fname = filename(prepath(sett), :Δ) - RG = GroupRing(sett.G, load(pm_fname, "pm")) - Δ = GroupRingElem(load(Δ_fname, "Δ")[:, 1], RG) - - isapprox(eigvals(P), abs.(eigvals(P)), atol=sett.tol) || + isapprox(eigvals(P), abs.(eigvals(P)), atol=sett.tol) || warn("The solution matrix doesn't seem to be positive definite!") - # @assert P == Symmetric(P) - @logtime LOGGER Q = real(sqrtm(Symmetric(P))) - sgap = distance_to_positive_cone(Δ, λ, Q, 2*sett.radius, LOGGER) - if isa(sgap, Interval) - sgap = sgap.lo - end - if sgap > 0 - info(LOGGER, "λ ≥ $(Float64(trunc(sgap,12)))") - Kazhdan_κ = PropertyT.Kazhdan_from_sgap(sgap, length(sett.S)) - Kazhdan_κ = Float64(trunc(Kazhdan_κ, 12)) - info(LOGGER, "κ($(sett.name), S) ≥ $Kazhdan_κ: Group HAS property (T)!") - return true - else - sgap = Float64(trunc(sgap, 12)) - info(LOGGER, "λ($(sett.name), S) ≥ $sgap: Group may NOT HAVE property (T)!") - return false - end + if λ > 0 + return check_λ(sett.name, sett.S, λ, P, sett.radius, sett.logger) end info(sett.logger, "κ($(sett.name), S) ≥ $λ < 0: Tells us nothing about property (T)") return false diff --git a/src/PropertyT.jl b/src/PropertyT.jl index 1a02d64..5773e6c 100644 --- a/src/PropertyT.jl +++ b/src/PropertyT.jl @@ -171,6 +171,28 @@ end Kazhdan_from_sgap(λ,N) = sqrt(2*λ/N) +function check_λ(name, S, λ, P, radius, logger) + + RG = GroupRing(parent(first(S)), load(filename(name, :pm), "pm")) + Δ = GroupRingElem(load(filename(name, :Δ), "Δ")[:, 1], RG) + + @logtime logger Q = real(sqrtm(Symmetric(P))) + + sgap = check_distance_to_cone(Δ, λ, Q, 2*radius, logger) + + if sgap > 0 + info(logger, "λ ≥ $(Float64(trunc(sgap,12)))") + Kazhdan_κ = Kazhdan_from_sgap(sgap, length(S)) + Kazhdan_κ = Float64(trunc(Kazhdan_κ, 12)) + info(logger, "κ($name, S) ≥ $Kazhdan_κ: Group HAS property (T)!") + return true + else + sgap = Float64(trunc(sgap, 12)) + info(logger, "λ($name, S) ≥ $sgap: Group may NOT HAVE property (T)!") + return false + end +end + function check_property_T(name::String, S, Id, solver, upper_bound, tol, radius) isdir(name) || mkdir(name) @@ -203,28 +225,11 @@ function check_property_T(name::String, S, Id, solver, upper_bound, tol, radius) info(LOGGER, "maximum(P) = $(maximum(P))") info(LOGGER, "minimum(P) = $(minimum(P))") + isapprox(eigvals(P), abs.(eigvals(P)), atol=tol) || + warn("The solution matrix doesn't seem to be positive definite!") + if λ > 0 - - RG = GroupRing(parent(first(S)), load(filename(name, :pm), "pm")) - Δ = GroupRingElem(load(filename(name, :Δ), "Δ")[:, 1], RG) - - isapprox(eigvals(P), abs(eigvals(P)), atol=tol) || - warn("The solution matrix doesn't seem to be positive definite!") - @logtime LOGGER Q = real(sqrtm(Symmetric(P))) - - sgap = check_distance_to_cone(Δ, λ, Q, 2*radius, LOGGER) - - if sgap > 0 - info(LOGGER, "λ ≥ $(Float64(trunc(sgap,12)))") - Kazhdan_κ = Kazhdan_from_sgap(sgap, length(S)) - Kazhdan_κ = Float64(trunc(Kazhdan_κ, 12)) - info(LOGGER, "κ($name, S) ≥ $Kazhdan_κ: Group HAS property (T)!") - return true - else - sgap = Float64(trunc(sgap, 12)) - info(LOGGER, "λ($name, S) ≥ $sgap: Group may NOT HAVE property (T)!") - return false - end + return check_λ(name, S, λ, P, radius, logger) end info(LOGGER, "κ($name, S) ≥ $λ < 0: Tells us nothing about property (T)") return false