mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-12-26 02:30:29 +01:00
add separate average over perms to perm_avg
This commit is contained in:
parent
fc496e29f5
commit
8331159baa
@ -132,26 +132,34 @@ function reconstruct(Ps::Vector{M},
|
|||||||
preps::Dict{GEl, P}, Uπs::Vector{U}, dims::Vector{Int}) where
|
preps::Dict{GEl, P}, Uπs::Vector{U}, dims::Vector{Int}) where
|
||||||
{M<:AbstractMatrix, GEl<:GroupElem, P<:perm, U<:AbstractMatrix}
|
{M<:AbstractMatrix, GEl<:GroupElem, P<:perm, U<:AbstractMatrix}
|
||||||
|
|
||||||
l = length(Uπs)
|
lU = length(Uπs)
|
||||||
transfP = [dims[π].*Uπs[π]*Ps[π]*Uπs[π]' for π in 1:l]
|
transfP = [dims[π].*Uπs[π]*Ps[π]*Uπs[π]' for π in 1:lU]
|
||||||
tmp = [zeros(Float64, size(first(transfP))) for _ in 1:l]
|
tmp = [zeros(Float64, size(first(transfP))) for _ in 1:lU]
|
||||||
perms = collect(keys(preps))
|
|
||||||
|
|
||||||
Threads.@threads for π in 1:l
|
|
||||||
for p in perms
|
@time Threads.@threads for π in 1:lU
|
||||||
BLAS.axpy!(1.0, view(transfP[π], preps[p].d, preps[p].d), tmp[π])
|
tmp[π] = perm_avg(tmp[π], transfP[π], values(preps))
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
recP = 1/length(perms) .* sum(tmp)
|
@time recP = sum(tmp)./length(preps)
|
||||||
# for i in eachindex(recP)
|
|
||||||
# if abs(recP[i]) .< eps(eltype(recP))*100
|
|
||||||
# recP[i] = zero(eltype(recP))
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
return recP
|
return recP
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function perm_avg(result, P, perms)
|
||||||
|
lp = length(first(perms).d)
|
||||||
|
for p in perms
|
||||||
|
# result .+= view(P, p.d, p.d)
|
||||||
|
@inbounds for j in 1:lp
|
||||||
|
k = p[j]
|
||||||
|
for i in 1:lp
|
||||||
|
result[i,j] += P[p[i], k]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
# Low-level solve
|
# Low-level solve
|
||||||
|
Loading…
Reference in New Issue
Block a user