1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-12-26 10:35:29 +01:00

in reconstruct: accumulate to a single matrix

This commit is contained in:
Marek Kaluba 2024-02-19 18:39:01 +01:00
parent c7491f37f9
commit 3b9c75604c
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15

View File

@ -12,10 +12,9 @@ function reconstruct(
wbdec::SW.WedderburnDecomposition,
)
n = __outer_dim(wbdec)
res = sum(zip(Ms, SW.direct_summands(wbdec))) do (M, ds)
res = similar(M, n, n)
res = zeros(eltype(first(Ms)), n, n)
for (M, ds) in zip(Ms, SW.direct_summands(wbdec))
res = _reconstruct!(res, M, ds)
return res
end
res = average!(zero(res), res, __group_of(wbdec), wbdec.hom)
return res
@ -26,11 +25,10 @@ function _reconstruct!(
M::AbstractMatrix,
ds::SW.DirectSummand,
)
res .= zero(eltype(res))
if !iszero(M)
U = SW.image_basis(ds)
d = SW.degree(ds)
res = (U' * M * U) .* d
res .+= (U' * M * U) .* d
end
return res
end