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

Threaded version of reconstruct_sol

This commit is contained in:
kalmar 2017-08-03 11:35:34 +02:00
parent a460b71db9
commit 47a41ac9fe

View File

@ -117,16 +117,17 @@ end
function reconstruct_sol{T<:GroupElem, S<:AbstractArray}(mreps::Dict{T, S},
Us::Vector, Ps::Vector, dims::Vector)
n = size(Us[1],1)
recP = zeros(Float64, (n,n))
Ust = transpose.(Us)
for g in keys(mreps)
A, B = mreps[g], mreps[inv(g)]
for π in 1:length(Us)
recP .+= dims[π].* (A * Us[π]*Ps[π]*Ust[π] * B)
s = size(first(mreps).second)
recP = zeros(Float64, s)
tmp = [zeros(Float64, s) for _ in 1:length(Us)]
ks = [(g, inv(g)) for g in keys(mreps)]
Threads.@threads for π in 1:length(Us)
for (g, invg) in ks
tmp[π] += dims[π]*mreps[g]*Us[π]*Ps[π]*Us[π]'*mreps[invg]
end
end
recP .*= 1/length(keys(mreps))
recP += 1/length(keys(mreps)) .* sum(tmp)
recP[abs.(recP) .< eps(eltype(recP))] = zero(eltype(recP))
return recP
end