From 666fac177515329022d47ae63769f38cf38ac3ef Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 4 Aug 2017 15:30:12 +0200 Subject: [PATCH] Threaded version of projection to the augmentation ideal --- src/CheckSolution.jl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/CheckSolution.jl b/src/CheckSolution.jl index fb928ff..7fd32cb 100644 --- a/src/CheckSolution.jl +++ b/src/CheckSolution.jl @@ -47,14 +47,15 @@ function compute_SOS(sqrt_matrix, elt) end function correct_to_augmentation_ideal{T<:Rational}(sqrt_matrix::Array{T,2}) - sqrt_corrected = similar(sqrt_matrix) - l = size(sqrt_matrix,2) - for i in 1:l - col = view(sqrt_matrix, :,i) - sqrt_corrected[:,i] .= col .- sum(col)//l - # @assert sum(sqrt_corrected[:,i]) == 0 - end - return sqrt_corrected + l = size(sqrt_matrix, 2) + sqrt_corrected = copy(sqrt_matrix) + Threads.@threads for j in 1:l + col = sum(view(sqrt_matrix, :,j))//l + for i in 1:l + sqrt_corrected[i,j] -= col + end + end + return sqrt_corrected end function distance_to_cone{T<:Rational}(λ::T, sqrt_matrix::Array{T,2}, Δ::GroupRingElem{T}, wlen)