mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-11-19 15:25:29 +01:00
test the correctness of hpc sos computation
This commit is contained in:
parent
70c160411d
commit
2a84d04edc
@ -37,14 +37,18 @@ function compute_SOS(RG::GroupRing, Q::AbstractMatrix{<:Real})
|
|||||||
return GroupRingElem(result, RG)
|
return GroupRingElem(result, RG)
|
||||||
end
|
end
|
||||||
|
|
||||||
function compute_SOS_square(RG::GroupRing, Q::AbstractMatrix{<:Real})
|
function compute_SOS_square(pm::AbstractMatrix{<:Integer}, Q::AbstractMatrix{<:Real})
|
||||||
result = zeros(eltype(Q), maximum(RG.pm));
|
result = zeros(eltype(Q), maximum(pm));
|
||||||
|
|
||||||
for i in 1:size(Q,2)
|
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
|
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
|
end
|
||||||
|
|
||||||
function augIdproj(Q::AbstractMatrix{T}) where {T<:Real}
|
function augIdproj(Q::AbstractMatrix{T}) where {T<:Real}
|
||||||
|
61
test/SOS_correctness.jl
Normal file
61
test/SOS_correctness.jl
Normal 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
|
@ -22,3 +22,4 @@ solver(iters; accel=1) =
|
|||||||
|
|
||||||
include("1703.09680.jl")
|
include("1703.09680.jl")
|
||||||
include("1712.07167.jl")
|
include("1712.07167.jl")
|
||||||
|
include("SOS_correctness.jl")
|
||||||
|
Loading…
Reference in New Issue
Block a user