1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-23 08:15:29 +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}, function reconstruct_sol{T<:GroupElem, S<:AbstractArray}(mreps::Dict{T, S},
Us::Vector, Ps::Vector, dims::Vector) Us::Vector, Ps::Vector, dims::Vector)
n = size(Us[1],1) s = size(first(mreps).second)
recP = zeros(Float64, (n,n)) recP = zeros(Float64, s)
Ust = transpose.(Us) tmp = [zeros(Float64, s) for _ in 1:length(Us)]
for g in keys(mreps) ks = [(g, inv(g)) for g in keys(mreps)]
A, B = mreps[g], mreps[inv(g)]
for π in 1:length(Us) Threads.@threads for π in 1:length(Us)
recP .+= dims[π].* (A * Us[π]*Ps[π]*Ust[π] * B) for (g, invg) in ks
tmp[π] += dims[π]*mreps[g]*Us[π]*Ps[π]*Us[π]'*mreps[invg]
end end
end end
recP .*= 1/length(keys(mreps)) recP += 1/length(keys(mreps)) .* sum(tmp)
recP[abs.(recP) .< eps(eltype(recP))] = zero(eltype(recP)) recP[abs.(recP) .< eps(eltype(recP))] = zero(eltype(recP))
return recP return recP
end end