1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-22 16:05:27 +01:00

test the correctness of hpc sos computation

This commit is contained in:
kalmarek 2019-04-16 17:05:34 +02:00
parent 70c160411d
commit 2a84d04edc
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
3 changed files with 73 additions and 7 deletions

View File

@ -37,14 +37,18 @@ function compute_SOS(RG::GroupRing, Q::AbstractMatrix{<:Real})
return GroupRingElem(result, RG)
end
function compute_SOS_square(RG::GroupRing, Q::AbstractMatrix{<:Real})
result = zeros(eltype(Q), maximum(RG.pm));
function compute_SOS_square(pm::AbstractMatrix{<:Integer}, Q::AbstractMatrix{<:Real})
result = zeros(eltype(Q), maximum(pm));
for i in 1:size(Q,2)
GroupRings.fmac!(result, view(Q,:,i), view(Q,:,i), RG.pm)
GroupRings.fmac!(result, view(Q,:,i), view(Q,:,i), pm)
end
return GroupRingElem(result, RG)
return result
end
function compute_SOS_square(RG::GroupRing, Q::AbstractMatrix{<:Real})
return GroupRingElem(compute_SOS_square(RG.pm, Q), RG)
end
function augIdproj(Q::AbstractMatrix{T}) where {T<:Real}

61
test/SOS_correctness.jl Normal file
View File

@ -0,0 +1,61 @@
using PropertyT.GroupRings
@testset "Correctness of HPC SOS computation" begin
function prepare(G_name, λ, S_size)
pm = load("$G_name/delta.jld", "pm")
P = load("$G_name//solution.jld", "P")
@time Q = real(sqrt(P))
Δ_coeff = SparseVector(maximum(pm), collect(1:1+S_size), [S_size; ((-1.0) for i in 1:S_size)...])
Δ²_coeff = GroupRings.GRmul!(spzeros(length(Δ_coeff)), Δ_coeff, Δ_coeff, pm)
eoi = Δ²_coeff - λ*Δ_coeff
Q = PropertyT.augIdproj(Q)
return eoi, pm, Q
end
#########################################################
NAME = "SL(3,Z)"
eoi, pm, Q = prepare(NAME, 0.1, 3*2*2)
@time sos_sqr = PropertyT.compute_SOS_square(pm, Q)
@time sos_hpc = PropertyT.compute_SOS(pm, Q)
@test norm(sos_sqr - sos_hpc, 1) < 3e-12
@info "$NAME:\nDifference in l₁-norm between square and hpc sos decompositions:" norm(eoi-sos_sqr,1) norm(eoi-sos_hpc,1) norm(sos_sqr - sos_hpc, 1)
#########################################################
NAME = "oSL(3,Z)"
eoi, pm, Q = prepare(NAME, 0.27, 3*2*2)
@time sos_sqr = PropertyT.compute_SOS_square(pm, Q)
@time sos_hpc = PropertyT.compute_SOS(pm, Q)
@test norm(sos_sqr - sos_hpc, 1) < 3e-12
@info "$NAME:\nDifference in l₁-norm between square and hpc sos decompositions:" norm(eoi-sos_sqr,1) norm(eoi-sos_hpc,1) norm(sos_sqr - sos_hpc, 1)
#########################################################
NAME = "oSL(4,Z)"
eoi, pm, Q = prepare(NAME, 1.3, 4*3*2)
@time sos_sqr = PropertyT.compute_SOS_square(pm, Q)
@time sos_hpc = PropertyT.compute_SOS(pm, Q)
@test norm(sos_sqr - sos_hpc, 1) < 2e-10
@info "$NAME:\nDifference in l₁-norm between square and hpc sos decompositions:" norm(eoi-sos_sqr,1) norm(eoi-sos_hpc,1) norm(sos_sqr - sos_hpc, 1)
#########################################################
NAME = "oSAut(F3)"
eoi, pm, Q = prepare(NAME, 0.15, 4*3*2*2)
@time sos_sqr = PropertyT.compute_SOS_square(pm, Q)
@time sos_hpc = PropertyT.compute_SOS(pm, Q)
@test norm(sos_sqr - sos_hpc, 1) < 6e-11
@info "$NAME:\nDifference in l₁-norm between square and hpc sos decompositions:" norm(eoi-sos_sqr,1) norm(eoi-sos_hpc,1) norm(sos_sqr - sos_hpc, 1)
end

View File

@ -22,3 +22,4 @@ solver(iters; accel=1) =
include("1703.09680.jl")
include("1712.07167.jl")
include("SOS_correctness.jl")